src/internet/model/ipv4-end-point-demux.h
changeset 10440 1e48ff9185f1
parent 7441 bf446d9feecc
child 11470 0b3d6135a28b
equal deleted inserted replaced
10439:73bc9e55f9bd 10440:1e48ff9185f1
    40  * sits between ns3's layer four and the socket layer
    40  * sits between ns3's layer four and the socket layer
    41  */
    41  */
    42 
    42 
    43 class Ipv4EndPointDemux {
    43 class Ipv4EndPointDemux {
    44 public:
    44 public:
       
    45   /**
       
    46    * \brief Container of the IPv4 endpoints.
       
    47    */
    45   typedef std::list<Ipv4EndPoint *> EndPoints;
    48   typedef std::list<Ipv4EndPoint *> EndPoints;
       
    49 
       
    50   /**
       
    51    * \brief Iterator to the container of the IPv4 endpoints.
       
    52    */
    46   typedef std::list<Ipv4EndPoint *>::iterator EndPointsI;
    53   typedef std::list<Ipv4EndPoint *>::iterator EndPointsI;
    47 
    54 
    48   Ipv4EndPointDemux ();
    55   Ipv4EndPointDemux ();
    49   ~Ipv4EndPointDemux ();
    56   ~Ipv4EndPointDemux ();
    50 
    57 
       
    58   /**
       
    59    * \brief Get the entire list of end points registered.
       
    60    * \return list of Ipv4EndPoint
       
    61    */
    51   EndPoints GetAllEndPoints (void);
    62   EndPoints GetAllEndPoints (void);
       
    63 
       
    64   /**
       
    65    * \brief Lookup for port local.
       
    66    * \param port port to test
       
    67    * \return true if a port local is in EndPoints, false otherwise
       
    68    */
    52   bool LookupPortLocal (uint16_t port);
    69   bool LookupPortLocal (uint16_t port);
       
    70 
       
    71   /**
       
    72    * \brief Lookup for address and port.
       
    73    * \param addr address to test
       
    74    * \param port port to test
       
    75    * \return true if there is a match in EndPoints, false otherwise
       
    76    */
    53   bool LookupLocal (Ipv4Address addr, uint16_t port);
    77   bool LookupLocal (Ipv4Address addr, uint16_t port);
       
    78 
       
    79   /**
       
    80    * \brief lookup for a match with all the parameters.
       
    81    * \param daddr destination address to test
       
    82    * \param dport destination port to test
       
    83    * \param saddr source address to test
       
    84    * \param sport source port to test
       
    85    * \param incomingInterface the incoming interface
       
    86    * \return list of IPv4EndPoints (could be 0 element)
       
    87    */
    54   EndPoints Lookup (Ipv4Address daddr, 
    88   EndPoints Lookup (Ipv4Address daddr, 
    55                     uint16_t dport, 
    89                     uint16_t dport, 
    56                     Ipv4Address saddr, 
    90                     Ipv4Address saddr, 
    57                     uint16_t sport,
    91                     uint16_t sport,
    58                     Ptr<Ipv4Interface> incomingInterface);
    92                     Ptr<Ipv4Interface> incomingInterface);
    59 
    93 
       
    94   /**
       
    95    * \brief simple lookup for a match with all the parameters.
       
    96    * \param daddr destination address to test
       
    97    * \param dport destination port to test
       
    98    * \param saddr source address to test
       
    99    * \param sport source port to test
       
   100    * \return IPv4EndPoint (0 if not found)
       
   101    */
    60   Ipv4EndPoint *SimpleLookup (Ipv4Address daddr, 
   102   Ipv4EndPoint *SimpleLookup (Ipv4Address daddr, 
    61                               uint16_t dport, 
   103                               uint16_t dport, 
    62                               Ipv4Address saddr, 
   104                               Ipv4Address saddr, 
    63                               uint16_t sport);
   105                               uint16_t sport);
    64 
   106 
       
   107   /**
       
   108    * \brief Allocate a Ipv4EndPoint.
       
   109    * \return an empty Ipv4EndPoint instance
       
   110    */
    65   Ipv4EndPoint *Allocate (void);
   111   Ipv4EndPoint *Allocate (void);
       
   112 
       
   113   /**
       
   114    * \brief Allocate a Ipv4EndPoint.
       
   115    * \param address IPv4 address
       
   116    * \return an Ipv4EndPoint instance
       
   117    */
    66   Ipv4EndPoint *Allocate (Ipv4Address address);
   118   Ipv4EndPoint *Allocate (Ipv4Address address);
       
   119 
       
   120   /**
       
   121    * \brief Allocate a Ipv4EndPoint.
       
   122    * \param port local port
       
   123    * \return an Ipv4EndPoint instance
       
   124    */
    67   Ipv4EndPoint *Allocate (uint16_t port);
   125   Ipv4EndPoint *Allocate (uint16_t port);
       
   126 
       
   127   /**
       
   128    * \brief Allocate a Ipv4EndPoint.
       
   129    * \param address local address
       
   130    * \param port local port
       
   131    * \return an Ipv4EndPoint instance
       
   132    */
    68   Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port);
   133   Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port);
       
   134 
       
   135   /**
       
   136    * \brief Allocate a Ipv4EndPoint.
       
   137    * \param localAddress local address
       
   138    * \param localPort local port
       
   139    * \param peerAddress peer address
       
   140    * \param peerPort peer port
       
   141    * \return an Ipv4EndPoint instance
       
   142    */
    69   Ipv4EndPoint *Allocate (Ipv4Address localAddress, 
   143   Ipv4EndPoint *Allocate (Ipv4Address localAddress, 
    70                           uint16_t localPort,
   144                           uint16_t localPort,
    71                           Ipv4Address peerAddress, 
   145                           Ipv4Address peerAddress, 
    72                           uint16_t peerPort);
   146                           uint16_t peerPort);
    73 
   147 
       
   148   /**
       
   149    * \brief Remove a end point.
       
   150    * \param endPoint the end point to remove
       
   151    */
    74   void DeAllocate (Ipv4EndPoint *endPoint);
   152   void DeAllocate (Ipv4EndPoint *endPoint);
    75 
   153 
    76 private:
   154 private:
       
   155 
       
   156   /**
       
   157    * \brief Allocate an ephemeral port.
       
   158    * \returns the ephemeral port
       
   159    */
    77   uint16_t AllocateEphemeralPort (void);
   160   uint16_t AllocateEphemeralPort (void);
    78 
   161 
       
   162   /**
       
   163    * \brief The ephemeral port.
       
   164    */
    79   uint16_t m_ephemeral;
   165   uint16_t m_ephemeral;
       
   166 
       
   167   /**
       
   168    * \brief The last ephemeral port.
       
   169    */
    80   uint16_t m_portLast;
   170   uint16_t m_portLast;
       
   171 
       
   172   /**
       
   173    * \brief The first ephemeral port.
       
   174    */
    81   uint16_t m_portFirst;
   175   uint16_t m_portFirst;
       
   176 
       
   177   /**
       
   178    * \brief A list of IPv4 end points.
       
   179    */
    82   EndPoints m_endPoints;
   180   EndPoints m_endPoints;
    83 };
   181 };
    84 
   182 
    85 } // namespace ns3
   183 } // namespace ns3
    86 
   184