root / otg / trunk / src / cpp / port.h

Revision 547, 2.6 kB (checked in by zhibinwu, 3 years ago)

Fix all warning messages, clean build

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1
2#include "packet.h"
3#include "address.h"
4//#include "stream.h"
5#include "generator.h"
6#include "popt.h"
7
8#ifndef PORT_H
9#define PORT_H
10
11#define MAX_STREAM_NUM_PER_PORT 16  // but we only allow 1
12
13#define DEFAULT_SEND_PORT 3000
14#define DEFAULT_RECV_PORT 4000
15
16
17
18/**
19 * Port is an abstract class for the interface to send (send only) a packet, whether UDP, TCP Socket, or IP raw socket.
20 * The common funcitons for a port are defiend here:
21 * - Send Packet.
22 *
23 *
24 *  In general, port is a duplex entity, but we limit port for sender-only.
25    Port is also associated with a pair of address. One Port send to one Address only,
26    no matter the address is unicast or broadcast.
27*/
28
29class Port
30{
31public:
32  Port();
33  virtual ~Port(){}
34   /**
35    * Function to initialize the port
36    */
37  virtual void init()=0;
38   /**
39    * Function to send a packet.
40    * The default socket file descriptor will always be used for send()
41    * No matter how many streams will be served by this port, only a sockfd used by the port.
42    * For TCP, multiple streams are not allowed.
43    */
44  virtual void sendPacket(Packet *pkt)=0;
45   /**
46    * Function to close a port
47    */
48  virtual void closePort()=0;
49   /**
50    * Function to get the next packet delivery time for a sender port
51    */
52   //virtual double nextDeliverTime()=0;
53 
54   /**
55    * Function to get Command line Options
56    *
57    */
58   virtual const struct poptOption* getOptions()=0;
59 
60   //void pickPacket();
61   //bool readyCheck();
62   //void addStream(Generator *gen);
63   //bool deleteStream(Stream *strm);
64   //bool deleteStream(short id);
65   //Stream *searchStreambyID(short id);
66   //short getStreamNum();
67
68   Address *getDstAddr();
69
70protected:
71 
72   /**This pointer points to the packet.
73    * This packet is  to be send next time in OTG or is just received in OTR
74    *
75    */
76   //Packet * pkt_;   
77
78   //   Stream* slhead_;   ///< This points to the head of Outgoing Stream List
79   //   Stream* sltail_;   ///< This points to the tail of Outgoing Stream List
80   //   Stream* slcurr_;    ///<  This points to the outgoing stream which feeds last(curr) packet   
81
82   /** An enum.
83    * Indication of port state */
84   //enum port_state {
85   //              uninitialized, /*!< Enum value UnInit. */ 
86   //              running, /*!< Enum value Normal running. */ 
87   //              paused  /*!< Enum value Paused by user's command. */ 
88   //}
89     //! Enum variable.
90     /*! Indicating the state of port */
91   //  state_; 
92   
93   Address myaddr_;  ///< The default address of mine
94   Address itsaddr_; ///< The default address of the other end of communication link (Source,Destination, depends on role)
95};
96
97#endif
98
Note: See TracBrowser for help on using the browser.