Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

/home/gilberto/prog/tesi2.31/TelepatiUdp/UDPConnection.h

Go to the documentation of this file.
00001 
00002 #ifndef UDPConnection_h_DEFINED
00003 #define UDPConnection_h_DEFINED
00004 
00005 #include <ant.h>
00006 #include <IPAddress.h>
00007 #include <OPENR/OSyslog.h>
00008 
00010 enum ConnectionState {
00011   CONNECTION_INVALID =0,    
00012   CONNECTION_CLOSED =1,     
00013   CONNECTION_BINDED =2,     
00014   CONNECTION_WAITING =3,    
00015   CONNECTION_LISTENING =4,  
00016   CONNECTION_SENDING =5,    
00017   CONNECTION_RECEIVING =6,  
00018   CONNECTION_CLOSING =7,    
00019   CONNECTION_WAITING_ACK =8 
00020 };
00021 
00024 class UDPConnection {
00025  public:
00028   UDPConnection() {state = CONNECTION_INVALID;};
00032   UDPConnection(antStackRef ipStack) {ipstackRef=ipStack; state = CONNECTION_CLOSED;  };
00033 
00035   virtual ~UDPConnection() {};
00036 
00039   inline antModuleRef& getEndpoint() {return endpoint;};
00042   inline void setState(ConnectionState st) {state = st;};
00045   inline ConnectionState getState() {return state;};
00046   
00051   virtual OStatus initConnection() = 0;
00057   virtual OStatus stop() = 0;  
00058   
00059  protected:
00060   antModuleRef endpoint;      
00061   antStackRef ipstackRef;     
00063   ConnectionState state;      
00065 };
00066 
00069 class UDPRecvConnection : public UDPConnection { 
00070  public:
00072   UDPRecvConnection() {};  
00077   UDPRecvConnection(antStackRef ipStack, int bs, Port port); 
00078 
00080   ~UDPRecvConnection();
00081   
00085   OStatus initConnection(); 
00091   OStatus stop();
00092 
00095   inline byte* getRecvData() { return recvData;};
00098   inline int getRecvSize() { return recvSize;}
00099   
00100  private:
00101 
00102   antSharedBuffer recvBuffer; /* Buffer di ricezione*/
00103   byte* recvData;             /* Puntatore ai dati contenunti nel buffer di ricezione*/
00104   int recvSize;               /* Dimensione buffer di Ricezione*/
00105 
00106   Port recvPort;              /* Porta di ricezione*/
00107 
00108   OStatus initBuffer();       /* Inizializza il buffer*/          
00109   OStatus initUdpEndpoint();  /* Crea l'Endpoint*/                
00110   OStatus initBind();         /* Effettua il Bind dell'Endpoint*/
00111 };
00112 
00113 
00116 class UDPSendConnection : public UDPConnection {
00117  public:
00119   UDPSendConnection() {}; 
00123   UDPSendConnection(antStackRef ipStack, int bs);
00124 
00126   ~UDPSendConnection();
00127 
00131   OStatus initConnection();
00137   OStatus stop();
00138   
00142   byte* getSendData() {return sendData;};
00146   inline int getSendSize() { return sendSize;}
00150   inline void setSendSize(int size) { sendSize=size;}
00151 
00152  private:
00153 
00154   antSharedBuffer sendBuffer; /* Buffer di spedizione*/
00155   byte* sendData;             /* Puntatore ai dati contenunti nel buffer di spedizione*/
00156   int bufferSize;             /* Dimensione del buffer*/
00157   int sendSize;               /* Dimensione dei dati spediti*/
00158 
00159   OStatus initBuffer();       /*Inizializza il buffer*/   
00160   OStatus initUdpEndpoint();  /*Crea l'Endpoint*/                 
00161   OStatus initBind();         /*Effettua il Bind dell'Endpoint*/
00162 };
00163 
00164 #endif // UDPConnection_h_DEFINED

Generated on Tue Mar 1 16:20:22 2005 for TelepatiUdp by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002