src/network/model/socket.h
changeset 10405 45c8fceae24e
parent 9145 5752b425cdf5
child 10440 1e48ff9185f1
equal deleted inserted replaced
10404:eb6495608840 10405:45c8fceae24e
    64  * More details are provided in the ns-3 tutorial.
    64  * More details are provided in the ns-3 tutorial.
    65  */
    65  */
    66 class Socket : public Object
    66 class Socket : public Object
    67 {
    67 {
    68 public:
    68 public:
       
    69   /**
       
    70    * \brief Get the type ID.
       
    71    * \return the object TypeId
       
    72    */
    69   static TypeId GetTypeId (void);
    73   static TypeId GetTypeId (void);
    70 
    74 
    71   Socket (void);
    75   Socket (void);
    72   virtual ~Socket (void);
    76   virtual ~Socket (void);
    73 
    77 
       
    78   /**
       
    79    * \enum SocketErrno
       
    80    * \brief Enumeration of the possible errors returned by a socket.
       
    81    */
    74   enum SocketErrno {
    82   enum SocketErrno {
    75     ERROR_NOTERROR,
    83     ERROR_NOTERROR,
    76     ERROR_ISCONN,
    84     ERROR_ISCONN,
    77     ERROR_NOTCONN,
    85     ERROR_NOTCONN,
    78     ERROR_MSGSIZE,
    86     ERROR_MSGSIZE,
    87     ERROR_ADDRNOTAVAIL,
    95     ERROR_ADDRNOTAVAIL,
    88     ERROR_ADDRINUSE,
    96     ERROR_ADDRINUSE,
    89     SOCKET_ERRNO_LAST
    97     SOCKET_ERRNO_LAST
    90   };
    98   };
    91 
    99 
       
   100   /**
       
   101    * \enum SocketType
       
   102    * \brief Enumeration of the possible socket types.
       
   103    */
    92   enum SocketType {
   104   enum SocketType {
    93     NS3_SOCK_STREAM,
   105     NS3_SOCK_STREAM,
    94     NS3_SOCK_SEQPACKET,
   106     NS3_SOCK_SEQPACKET,
    95     NS3_SOCK_DGRAM,
   107     NS3_SOCK_DGRAM,
    96     NS3_SOCK_RAW
   108     NS3_SOCK_RAW
   251   virtual int ShutdownRecv (void) = 0;
   263   virtual int ShutdownRecv (void) = 0;
   252 
   264 
   253   /**
   265   /**
   254    * \brief Initiate a connection to a remote host
   266    * \brief Initiate a connection to a remote host
   255    * \param address Address of remote.
   267    * \param address Address of remote.
       
   268    * \returns 0 on success, -1 on error (in which case errno is set).
   256    */
   269    */
   257   virtual int Connect (const Address &address) = 0;
   270   virtual int Connect (const Address &address) = 0;
   258 
   271 
   259   /**
   272   /**
   260    * \brief Listen for incoming connections.
   273    * \brief Listen for incoming connections.
   269    * For datagram sockets, this returns the number of bytes that
   282    * For datagram sockets, this returns the number of bytes that
   270    * can be passed atomically through the underlying protocol.
   283    * can be passed atomically through the underlying protocol.
   271    *
   284    *
   272    * For stream sockets, this returns the available space in bytes
   285    * For stream sockets, this returns the available space in bytes
   273    * left in the transmit buffer.
   286    * left in the transmit buffer.
       
   287    *
       
   288    * \returns The number of bytes which can be sent in a single Send call.
   274    */
   289    */
   275   virtual uint32_t GetTxAvailable (void) const = 0;
   290   virtual uint32_t GetTxAvailable (void) const = 0;
   276  
   291  
   277   /**
   292   /**
   278    * \brief Send data (or dummy data) to the remote host
   293    * \brief Send data (or dummy data) to the remote host
   339 
   354 
   340   /**
   355   /**
   341    * Return number of bytes which can be returned from one or 
   356    * Return number of bytes which can be returned from one or 
   342    * multiple calls to Recv.
   357    * multiple calls to Recv.
   343    * Must be possible to call this method from the Recv callback.
   358    * Must be possible to call this method from the Recv callback.
       
   359    *
       
   360    * \returns the number of bytes which can be returned from one or
       
   361    *          multiple Recv calls.
   344    */
   362    */
   345   virtual uint32_t GetRxAvailable (void) const = 0;
   363   virtual uint32_t GetRxAvailable (void) const = 0;
   346 
   364 
   347   /**
   365   /**
   348    * \brief Read data from the socket
   366    * \brief Read data from the socket
   444    * \param buf A pointer to a raw byte buffer of some data to send.  If 
   462    * \param buf A pointer to a raw byte buffer of some data to send.  If 
   445    * this buffer is 0, we send dummy data whose size is specified by the 
   463    * this buffer is 0, we send dummy data whose size is specified by the 
   446    * second parameter
   464    * second parameter
   447    * \param size the number of bytes to copy from the buffer
   465    * \param size the number of bytes to copy from the buffer
   448    * \param flags Socket control flags
   466    * \param flags Socket control flags
       
   467    * \returns the number of bytes accepted for transmission if no error
       
   468    *          occurs, and -1 otherwise.
   449    */
   469    */
   450   int Send (const uint8_t* buf, uint32_t size, uint32_t flags);
   470   int Send (const uint8_t* buf, uint32_t size, uint32_t flags);
   451 
   471 
   452 
   472 
   453   /**
   473   /**
   611    *
   631    *
   612    * \returns True if packet information should be sent to socket
   632    * \returns True if packet information should be sent to socket
   613    */
   633    */
   614   bool IsRecvPktInfo () const;
   634   bool IsRecvPktInfo () const;
   615 
   635 
   616   /*
   636   /**
   617    * \brief Manually set IP Type of Service field
   637    * \brief Manually set IP Type of Service field
   618    * 
   638    * 
   619    * This method corresponds to using setsockopt () IP_TOS of
   639    * This method corresponds to using setsockopt () IP_TOS of
   620    * real network or BSD sockets. This option is for IPv4 only.
   640    * real network or BSD sockets. This option is for IPv4 only.
   621    * Setting the IP TOS should also change the socket queueing
   641    * Setting the IP TOS should also change the socket queueing
   624    *
   644    *
   625    * \param ipTos The desired TOS value for IP headers
   645    * \param ipTos The desired TOS value for IP headers
   626    */
   646    */
   627   void SetIpTos (uint8_t ipTos);
   647   void SetIpTos (uint8_t ipTos);
   628 
   648 
   629   /*
   649   /**
   630    * \brief Query the value of IP Type of Service of this socket
   650    * \brief Query the value of IP Type of Service of this socket
   631    *
   651    *
   632    * This method corresponds to using getsockopt () IP_TOS of real network
   652    * This method corresponds to using getsockopt () IP_TOS of real network
   633    * or BSD sockets.
   653    * or BSD sockets.
   634    *
   654    *
   653    * \brief Ask if the socket is currently passing information about IP Type of Service up the stack
   673    * \brief Ask if the socket is currently passing information about IP Type of Service up the stack
   654    *
   674    *
   655    * This method corresponds to using getsockopt () IP_RECVTOS of real
   675    * This method corresponds to using getsockopt () IP_RECVTOS of real
   656    * network or BSD sockets.
   676    * network or BSD sockets.
   657    *
   677    *
   658    * \return Wheter the IP_RECVTOS is set
   678    * \return Whether the IP_RECVTOS is set
   659    */
   679    */
   660   bool IsIpRecvTos (void) const;
   680   bool IsIpRecvTos (void) const;
   661 
   681 
   662   /*
   682   /**
   663    * \brief Manually set IPv6 Traffic Class field
   683    * \brief Manually set IPv6 Traffic Class field
   664    * 
   684    * 
   665    * This method corresponds to using setsockopt () IPV6_TCLASS of
   685    * This method corresponds to using setsockopt () IPV6_TCLASS of
   666    * real network or BSD sockets. This option is for IPv6 only.
   686    * real network or BSD sockets. This option is for IPv6 only.
   667    * Setting the IPV6_TCLASSS to -1 clears the option and let the socket
   687    * Setting the IPV6_TCLASSS to -1 clears the option and let the socket
   669    *
   689    *
   670    * \param ipTclass The desired TCLASS value for IPv6 headers
   690    * \param ipTclass The desired TCLASS value for IPv6 headers
   671    */
   691    */
   672   void SetIpv6Tclass (int ipTclass);
   692   void SetIpv6Tclass (int ipTclass);
   673 
   693 
   674   /*
   694   /**
   675    * \brief Query the value of IPv6 Traffic Class field of this socket
   695    * \brief Query the value of IPv6 Traffic Class field of this socket
   676    *
   696    *
   677    * This method corresponds to using getsockopt () IPV6_TCLASS of real network
   697    * This method corresponds to using getsockopt () IPV6_TCLASS of real network
   678    * or BSD sockets.
   698    * or BSD sockets.
   679    *
   699    *
   698    * \brief Ask if the socket is currently passing information about IPv6 Traffic Class up the stack
   718    * \brief Ask if the socket is currently passing information about IPv6 Traffic Class up the stack
   699    *
   719    *
   700    * This method corresponds to using getsockopt () IPV6_RECVTCLASS of real
   720    * This method corresponds to using getsockopt () IPV6_RECVTCLASS of real
   701    * network or BSD sockets.
   721    * network or BSD sockets.
   702    *
   722    *
   703    * \return Wheter the IPV6_RECVTCLASS is set
   723    * \return Whether the IPV6_RECVTCLASS is set
   704    */
   724    */
   705   bool IsIpv6RecvTclass (void) const;
   725   bool IsIpv6RecvTclass (void) const;
   706 
   726 
   707   /*
   727   /**
   708    * \brief Manually set IP Time to Live field
   728    * \brief Manually set IP Time to Live field
   709    * 
   729    * 
   710    * This method corresponds to using setsockopt () IP_TTL of
   730    * This method corresponds to using setsockopt () IP_TTL of
   711    * real network or BSD sockets.
   731    * real network or BSD sockets.
   712    *
   732    *
   713    * \param ipTtl The desired TTL value for IP headers
   733    * \param ipTtl The desired TTL value for IP headers
   714    */
   734    */
   715   virtual void SetIpTtl (uint8_t ipTtl);
   735   virtual void SetIpTtl (uint8_t ipTtl);
   716 
   736 
   717   /*
   737   /**
   718    * \brief Query the value of IP Time to Live field of this socket
   738    * \brief Query the value of IP Time to Live field of this socket
   719    *
   739    *
   720    * This method corresponds to using getsockopt () IP_TTL of real network
   740    * This method corresponds to using getsockopt () IP_TTL of real network
   721    * or BSD sockets.
   741    * or BSD sockets.
   722    *
   742    *
   741    * \brief Ask if the socket is currently passing information about IP_TTL up the stack
   761    * \brief Ask if the socket is currently passing information about IP_TTL up the stack
   742    *
   762    *
   743    * This method corresponds to using getsockopt () IP_RECVTTL of real
   763    * This method corresponds to using getsockopt () IP_RECVTTL of real
   744    * network or BSD sockets.
   764    * network or BSD sockets.
   745    *
   765    *
   746    * \return Wheter the IP_RECVTTL is set
   766    * \return Whether the IP_RECVTTL is set
   747    */
   767    */
   748   bool IsIpRecvTtl (void) const;
   768   bool IsIpRecvTtl (void) const;
   749 
   769 
   750   /*
   770   /**
   751    * \brief Manually set IPv6 Hop Limit
   771    * \brief Manually set IPv6 Hop Limit
   752    * 
   772    * 
   753    * This method corresponds to using setsockopt () IPV6_HOPLIMIT of
   773    * This method corresponds to using setsockopt () IPV6_HOPLIMIT of
   754    * real network or BSD sockets.
   774    * real network or BSD sockets.
   755    *
   775    *
   756    * \param ipHopLimit The desired Hop Limit value for IPv6 headers
   776    * \param ipHopLimit The desired Hop Limit value for IPv6 headers
   757    */
   777    */
   758   virtual void SetIpv6HopLimit (uint8_t ipHopLimit);
   778   virtual void SetIpv6HopLimit (uint8_t ipHopLimit);
   759 
   779 
   760   /*
   780   /**
   761    * \brief Query the value of IP Hop Limit field of this socket
   781    * \brief Query the value of IP Hop Limit field of this socket
   762    *
   782    *
   763    * This method corresponds to using getsockopt () IPV6_HOPLIMIT of real network
   783    * This method corresponds to using getsockopt () IPV6_HOPLIMIT of real network
   764    * or BSD sockets.
   784    * or BSD sockets.
   765    *
   785    *
   784    * \brief Ask if the socket is currently passing information about IPv6 Hop Limit up the stack
   804    * \brief Ask if the socket is currently passing information about IPv6 Hop Limit up the stack
   785    *
   805    *
   786    * This method corresponds to using getsockopt () IPV6_RECVHOPLIMIT of real
   806    * This method corresponds to using getsockopt () IPV6_RECVHOPLIMIT of real
   787    * network or BSD sockets.
   807    * network or BSD sockets.
   788    *
   808    *
   789    * \return Wheter the IPV6_RECVHOPLIMIT is set
   809    * \return Whether the IPV6_RECVHOPLIMIT is set
   790    */
   810    */
   791   bool IsIpv6RecvHopLimit (void) const;
   811   bool IsIpv6RecvHopLimit (void) const;
   792  
   812  
   793 protected:
   813 protected:
       
   814   /**
       
   815    * \brief Notify through the callback (if set) that the connection has been
       
   816    *        established.
       
   817    */
   794   void NotifyConnectionSucceeded (void);
   818   void NotifyConnectionSucceeded (void);
       
   819 
       
   820   /**
       
   821    * \brief Notify through the callback (if set) that the connection has not been
       
   822    *        established due to an error.
       
   823    */
   795   void NotifyConnectionFailed (void);
   824   void NotifyConnectionFailed (void);
       
   825 
       
   826   /**
       
   827    * \brief Notify through the callback (if set) that the connection has been
       
   828    *        closed.
       
   829    */
   796   void NotifyNormalClose (void);
   830   void NotifyNormalClose (void);
       
   831 
       
   832   /**
       
   833    * \brief Notify through the callback (if set) that the connection has been
       
   834    *        closed due to an error.
       
   835    */
   797   void NotifyErrorClose (void);
   836   void NotifyErrorClose (void);
       
   837 
       
   838   /**
       
   839    * \brief Notify through the callback (if set) that an incoming connection
       
   840    *        is being requested by a remote host.
       
   841    *
       
   842    * This function returns true by default (i.e., accept all the incoming connections).
       
   843    * The callback (if set) might restrict this behaviour by returning zero for a
       
   844    * connection that should be refused.
       
   845    *
       
   846    * \param from the address the connection is incoming from
       
   847    * \returns true if the connection must be accepted, false otherwise.
       
   848    */
   798   bool NotifyConnectionRequest (const Address &from);
   849   bool NotifyConnectionRequest (const Address &from);
       
   850 
       
   851   /**
       
   852    * \brief Notify through the callback (if set) that a new connection has been
       
   853    *        created.
       
   854    */
   799   void NotifyNewConnectionCreated (Ptr<Socket> socket, const Address &from);
   855   void NotifyNewConnectionCreated (Ptr<Socket> socket, const Address &from);
       
   856 
       
   857   /**
       
   858    * \brief Notify through the callback (if set) that some data have been sent.
       
   859    *
       
   860    * \param size number of sent bytes.
       
   861    */
   800   void NotifyDataSent (uint32_t size);
   862   void NotifyDataSent (uint32_t size);
       
   863 
       
   864   /**
       
   865    * \brief Notify through the callback (if set) that some data have been sent.
       
   866    *
       
   867    * \param spaceAvailable the number of bytes available in the transmission buffer.
       
   868    */
   801   void NotifySend (uint32_t spaceAvailable);
   869   void NotifySend (uint32_t spaceAvailable);
       
   870 
       
   871   /**
       
   872    * \brief Notify through the callback (if set) that some data have been received.
       
   873    */
   802   void NotifyDataRecv (void);
   874   void NotifyDataRecv (void);
       
   875 
       
   876   // inherited function, no doc necessary
   803   virtual void DoDispose (void);
   877   virtual void DoDispose (void);
   804 
   878 
       
   879   /**
       
   880    * \brief Checks if the socket has a specific IPv4 ToS set
       
   881    *
       
   882    * \returns true if the socket has a IPv4 ToS set, false otherwise.
       
   883    */
   805   bool IsManualIpTos (void) const;
   884   bool IsManualIpTos (void) const;
       
   885 
       
   886   /**
       
   887    * \brief Checks if the socket has a specific IPv6 Tclass set
       
   888    *
       
   889    * \returns true if the socket has a IPv6 Tclass set, false otherwise.
       
   890    */
   806   bool IsManualIpv6Tclass (void) const;
   891   bool IsManualIpv6Tclass (void) const;
       
   892 
       
   893   /**
       
   894    * \brief Checks if the socket has a specific IPv4 TTL set
       
   895    *
       
   896    * \returns true if the socket has a IPv4 TTL set, false otherwise.
       
   897    */
   807   bool IsManualIpTtl (void) const;
   898   bool IsManualIpTtl (void) const;
       
   899 
       
   900   /**
       
   901    * \brief Checks if the socket has a specific IPv6 Hop Limit set
       
   902    *
       
   903    * \returns true if the socket has a IPv6 Hop Limit set, false otherwise.
       
   904    */
   808   bool IsManualIpv6HopLimit (void) const;
   905   bool IsManualIpv6HopLimit (void) const;
   809 
   906 
   810   Ptr<NetDevice> m_boundnetdevice;
   907   Ptr<NetDevice> m_boundnetdevice; //!< the device this socket is bound to (might be null).
   811   bool m_recvPktInfo;
   908   bool m_recvPktInfo; //!< if the socket should add packet info tags to the packet forwarded to L4.
   812 
   909 
   813 private:
   910 private:
   814   Callback<void, Ptr<Socket> >                   m_connectionSucceeded;
   911   Callback<void, Ptr<Socket> >                   m_connectionSucceeded;  //!< connection succeeded callback
   815   Callback<void, Ptr<Socket> >                   m_connectionFailed;
   912   Callback<void, Ptr<Socket> >                   m_connectionFailed;     //!< connection failed callback
   816   Callback<void, Ptr<Socket> >                   m_normalClose;
   913   Callback<void, Ptr<Socket> >                   m_normalClose;          //!< connection closed callback
   817   Callback<void, Ptr<Socket> >                   m_errorClose;
   914   Callback<void, Ptr<Socket> >                   m_errorClose;           //!< connection closed due to errors callback
   818   Callback<bool, Ptr<Socket>, const Address &>   m_connectionRequest;
   915   Callback<bool, Ptr<Socket>, const Address &>   m_connectionRequest;    //!< connection request callback
   819   Callback<void, Ptr<Socket>, const Address&>    m_newConnectionCreated;
   916   Callback<void, Ptr<Socket>, const Address&>    m_newConnectionCreated; //!< connection created callback
   820   Callback<void, Ptr<Socket>, uint32_t>          m_dataSent;
   917   Callback<void, Ptr<Socket>, uint32_t>          m_dataSent;             //!< data sent callback
   821   Callback<void, Ptr<Socket>, uint32_t >         m_sendCb;
   918   Callback<void, Ptr<Socket>, uint32_t >         m_sendCb;               //!< packet sent callback
   822   Callback<void, Ptr<Socket> >                   m_receivedData;
   919   Callback<void, Ptr<Socket> >                   m_receivedData;         //!< data received callback
   823 
   920 
   824   //IPv4 options
   921   //IPv4 options
   825   bool m_manualIpTos;
   922   bool m_manualIpTos; //!< socket has IPv4 TOS set
   826   bool m_manualIpTtl;
   923   bool m_manualIpTtl; //!< socket has IPv4 TTL set
   827   bool m_ipRecvTos;
   924   bool m_ipRecvTos;   //!< socket forwards IPv4 TOS tag to L4
   828   bool m_ipRecvTtl;
   925   bool m_ipRecvTtl;   //!< socket forwards IPv4 TTL tag to L4
   829 
   926 
   830   uint8_t m_ipTos;
   927   uint8_t m_ipTos; //!< the socket IPv4 TOS
   831   uint8_t m_ipTtl;
   928   uint8_t m_ipTtl; //!< the socket IPv4 TTL
   832 
   929 
   833   //IPv6 options
   930   //IPv6 options
   834   bool m_manualIpv6Tclass;
   931   bool m_manualIpv6Tclass;    //!< socket has IPv6 Tclass set
   835   bool m_manualIpv6HopLimit;
   932   bool m_manualIpv6HopLimit;  //!< socket has IPv6 Hop Limit set
   836   bool m_ipv6RecvTclass;
   933   bool m_ipv6RecvTclass;      //!< socket forwards IPv6 Tclass tag to L4
   837   bool m_ipv6RecvHopLimit;
   934   bool m_ipv6RecvHopLimit;    //!< socket forwards IPv6 Hop Limit tag to L4
   838 
   935 
   839   uint8_t m_ipv6Tclass;
   936   uint8_t m_ipv6Tclass;     //!< the socket IPv6 Tclass
   840   uint8_t m_ipv6HopLimit;
   937   uint8_t m_ipv6HopLimit;   //!< the socket IPv6 Hop Limit
   841 };
   938 };
   842 
   939 
   843 /**
   940 /**
   844  * \brief This class implements a tag that carries an address
   941  * \brief This class implements a tag that carries an address
   845  * of a packet across the socket interface.
   942  * of a packet across the socket interface.
   846  */
   943  */
   847 class SocketAddressTag : public Tag
   944 class SocketAddressTag : public Tag
   848 {
   945 {
   849 public:
   946 public:
   850   SocketAddressTag ();
   947   SocketAddressTag ();
       
   948 
       
   949   /**
       
   950    * \brief Set the tag's address
       
   951    *
       
   952    * \param addr the address
       
   953    */
   851   void SetAddress (Address addr);
   954   void SetAddress (Address addr);
       
   955 
       
   956   /**
       
   957    * \brief Get the tag's address
       
   958    *
       
   959    * \returns the address
       
   960    */
   852   Address GetAddress (void) const;
   961   Address GetAddress (void) const;
   853 
   962 
       
   963   /**
       
   964    * \brief Get the type ID.
       
   965    * \return the object TypeId
       
   966    */
   854   static TypeId GetTypeId (void);
   967   static TypeId GetTypeId (void);
       
   968 
       
   969   // inherited function, no need to doc.
   855   virtual TypeId GetInstanceTypeId (void) const;
   970   virtual TypeId GetInstanceTypeId (void) const;
       
   971 
       
   972   // inherited function, no need to doc.
   856   virtual uint32_t GetSerializedSize (void) const;
   973   virtual uint32_t GetSerializedSize (void) const;
       
   974 
       
   975   // inherited function, no need to doc.
   857   virtual void Serialize (TagBuffer i) const;
   976   virtual void Serialize (TagBuffer i) const;
       
   977 
       
   978   // inherited function, no need to doc.
   858   virtual void Deserialize (TagBuffer i);
   979   virtual void Deserialize (TagBuffer i);
       
   980 
       
   981   // inherited function, no need to doc.
   859   virtual void Print (std::ostream &os) const;
   982   virtual void Print (std::ostream &os) const;
   860 
   983 
   861 private:
   984 private:
   862   Address m_address;
   985   Address m_address; //!< the address carried by the tag
   863 };
   986 };
   864 
   987 
   865 /**
   988 /**
   866  * \brief This class implements a tag that carries the socket-specific
   989  * \brief This class implements a tag that carries the socket-specific
   867  * TTL of a packet to the IP layer
   990  * TTL of a packet to the IP layer
   868  */
   991  */
   869 class SocketIpTtlTag : public Tag
   992 class SocketIpTtlTag : public Tag
   870 {
   993 {
   871 public:
   994 public:
   872   SocketIpTtlTag ();
   995   SocketIpTtlTag ();
       
   996 
       
   997   /**
       
   998    * \brief Set the tag's TTL
       
   999    *
       
  1000    * \param ttl the TTL
       
  1001    */
   873   void SetTtl (uint8_t ttl);
  1002   void SetTtl (uint8_t ttl);
       
  1003 
       
  1004   /**
       
  1005    * \brief Get the tag's TTL
       
  1006    *
       
  1007    * \returns the TTL
       
  1008    */
   874   uint8_t GetTtl (void) const;
  1009   uint8_t GetTtl (void) const;
   875 
  1010 
       
  1011   /**
       
  1012    * \brief Get the type ID.
       
  1013    * \return the object TypeId
       
  1014    */
   876   static TypeId GetTypeId (void);
  1015   static TypeId GetTypeId (void);
       
  1016 
       
  1017   // inherited function, no need to doc.
   877   virtual TypeId GetInstanceTypeId (void) const;
  1018   virtual TypeId GetInstanceTypeId (void) const;
       
  1019 
       
  1020   // inherited function, no need to doc.
   878   virtual uint32_t GetSerializedSize (void) const;
  1021   virtual uint32_t GetSerializedSize (void) const;
       
  1022 
       
  1023   // inherited function, no need to doc.
   879   virtual void Serialize (TagBuffer i) const;
  1024   virtual void Serialize (TagBuffer i) const;
       
  1025 
       
  1026   // inherited function, no need to doc.
   880   virtual void Deserialize (TagBuffer i);
  1027   virtual void Deserialize (TagBuffer i);
       
  1028 
       
  1029   // inherited function, no need to doc.
   881   virtual void Print (std::ostream &os) const;
  1030   virtual void Print (std::ostream &os) const;
   882 
  1031 
   883 private:
  1032 private:
   884   uint8_t m_ttl;
  1033   uint8_t m_ttl; //!< the ttl carried by the tag
   885 };
  1034 };
   886 
  1035 
   887 /**
  1036 /**
   888  * \brief This class implements a tag that carries the socket-specific
  1037  * \brief This class implements a tag that carries the socket-specific
   889  * HOPLIMIT of a packet to the IPv6 layer
  1038  * HOPLIMIT of a packet to the IPv6 layer
   890  */
  1039  */
   891 class SocketIpv6HopLimitTag : public Tag
  1040 class SocketIpv6HopLimitTag : public Tag
   892 {
  1041 {
   893 public:
  1042 public:
   894   SocketIpv6HopLimitTag ();
  1043   SocketIpv6HopLimitTag ();
       
  1044 
       
  1045   /**
       
  1046    * \brief Set the tag's Hop Limit
       
  1047    *
       
  1048    * \param hopLimit the Hop Limit
       
  1049    */
   895   void SetHopLimit (uint8_t hopLimit);
  1050   void SetHopLimit (uint8_t hopLimit);
       
  1051 
       
  1052   /**
       
  1053    * \brief Get the tag's Hop Limit
       
  1054    *
       
  1055    * \returns the Hop Limit
       
  1056    */
   896   uint8_t GetHopLimit (void) const;
  1057   uint8_t GetHopLimit (void) const;
   897 
  1058 
       
  1059   /**
       
  1060    * \brief Get the type ID.
       
  1061    * \return the object TypeId
       
  1062    */
   898   static TypeId GetTypeId (void);
  1063   static TypeId GetTypeId (void);
       
  1064 
       
  1065   // inherited function, no need to doc.
   899   virtual TypeId GetInstanceTypeId (void) const;
  1066   virtual TypeId GetInstanceTypeId (void) const;
       
  1067 
       
  1068   // inherited function, no need to doc.
   900   virtual uint32_t GetSerializedSize (void) const;
  1069   virtual uint32_t GetSerializedSize (void) const;
       
  1070 
       
  1071   // inherited function, no need to doc.
   901   virtual void Serialize (TagBuffer i) const;
  1072   virtual void Serialize (TagBuffer i) const;
       
  1073 
       
  1074   // inherited function, no need to doc.
   902   virtual void Deserialize (TagBuffer i);
  1075   virtual void Deserialize (TagBuffer i);
       
  1076 
       
  1077   // inherited function, no need to doc.
   903   virtual void Print (std::ostream &os) const;
  1078   virtual void Print (std::ostream &os) const;
   904 
  1079 
   905 private:
  1080 private:
   906   uint8_t m_hopLimit;
  1081   uint8_t m_hopLimit; //!< the Hop Limit carried by the tag
   907 };
  1082 };
   908 
  1083 
   909 /**
  1084 /**
   910  * \brief indicated whether packets should be sent out with
  1085  * \brief indicates whether packets should be sent out with
   911  * the DF flag set.
  1086  * the DF (Don't Fragment) flag set.
   912  */
  1087  */
   913 class SocketSetDontFragmentTag : public Tag
  1088 class SocketSetDontFragmentTag : public Tag
   914 {
  1089 {
   915 public:
  1090 public:
   916   SocketSetDontFragmentTag ();
  1091   SocketSetDontFragmentTag ();
       
  1092 
       
  1093   /**
       
  1094    * \brief Enables the DF (Don't Fragment) flag
       
  1095    */
   917   void Enable (void);
  1096   void Enable (void);
       
  1097 
       
  1098   /**
       
  1099    * \brief Disables the DF (Don't Fragment) flag
       
  1100    */
   918   void Disable (void);
  1101   void Disable (void);
       
  1102 
       
  1103   /**
       
  1104    * \brief Checks if the DF (Don't Fragment) flag is set
       
  1105    *
       
  1106    * \returns true if DF is set.
       
  1107    */
   919   bool IsEnabled (void) const;
  1108   bool IsEnabled (void) const;
   920 
  1109 
       
  1110   /**
       
  1111    * \brief Get the type ID.
       
  1112    * \return the object TypeId
       
  1113    */
   921   static TypeId GetTypeId (void);
  1114   static TypeId GetTypeId (void);
       
  1115 
       
  1116   // inherited function, no need to doc.
   922   virtual TypeId GetInstanceTypeId (void) const;
  1117   virtual TypeId GetInstanceTypeId (void) const;
       
  1118 
       
  1119   // inherited function, no need to doc.
   923   virtual uint32_t GetSerializedSize (void) const;
  1120   virtual uint32_t GetSerializedSize (void) const;
       
  1121 
       
  1122   // inherited function, no need to doc.
   924   virtual void Serialize (TagBuffer i) const;
  1123   virtual void Serialize (TagBuffer i) const;
       
  1124 
       
  1125   // inherited function, no need to doc.
   925   virtual void Deserialize (TagBuffer i);
  1126   virtual void Deserialize (TagBuffer i);
       
  1127 
       
  1128   // inherited function, no need to doc.
   926   virtual void Print (std::ostream &os) const;
  1129   virtual void Print (std::ostream &os) const;
   927 private:
  1130 private:
   928   bool m_dontFragment;
  1131   bool m_dontFragment; //!< DF bit value for outgoing packets.
   929 };
  1132 };
   930 
  1133 
   931 /*
  1134 /**
   932  * \brief indicated whether the socket has IP_TOS set.
  1135  * \brief indicates whether the socket has IP_TOS set.
   933  * This tag is for IPv4 socket.
  1136  * This tag is for IPv4 socket.
   934  */
  1137  */
   935 class SocketIpTosTag : public Tag
  1138 class SocketIpTosTag : public Tag
   936 {
  1139 {
   937 public:
  1140 public:
   938   SocketIpTosTag ();
  1141   SocketIpTosTag ();
       
  1142 
       
  1143   /**
       
  1144    * \brief Set the tag's TOS
       
  1145    *
       
  1146    * \param tos the TOS
       
  1147    */
   939   void SetTos (uint8_t tos);
  1148   void SetTos (uint8_t tos);
       
  1149 
       
  1150   /**
       
  1151    * \brief Get the tag's TOS
       
  1152    *
       
  1153    * \returns the TOS
       
  1154    */
   940   uint8_t GetTos (void) const;
  1155   uint8_t GetTos (void) const;
   941   
  1156   
       
  1157   /**
       
  1158    * \brief Get the type ID.
       
  1159    * \return the object TypeId
       
  1160    */
   942   static TypeId GetTypeId (void);
  1161   static TypeId GetTypeId (void);
       
  1162 
       
  1163   // inherited function, no need to doc.
   943   virtual TypeId GetInstanceTypeId (void) const;
  1164   virtual TypeId GetInstanceTypeId (void) const;
       
  1165 
       
  1166   // inherited function, no need to doc.
   944   virtual uint32_t GetSerializedSize (void) const;
  1167   virtual uint32_t GetSerializedSize (void) const;
       
  1168 
       
  1169   // inherited function, no need to doc.
   945   virtual void Serialize (TagBuffer i) const;
  1170   virtual void Serialize (TagBuffer i) const;
       
  1171 
       
  1172   // inherited function, no need to doc.
   946   virtual void Deserialize (TagBuffer i);
  1173   virtual void Deserialize (TagBuffer i);
       
  1174 
       
  1175   // inherited function, no need to doc.
   947   virtual void Print (std::ostream &os) const;
  1176   virtual void Print (std::ostream &os) const;
   948 private:
  1177 private:
   949   uint8_t m_ipTos;
  1178   uint8_t m_ipTos;  //!< the TOS carried by the tag
   950 };
  1179 };
   951 
  1180 
   952 /*
  1181 /**
   953  * \brief indicated whether the socket has IPV6_TCLASS set.
  1182  * \brief indicates whether the socket has IPV6_TCLASS set.
   954  * This tag is for IPv6 socket.
  1183  * This tag is for IPv6 socket.
   955  */
  1184  */
   956 class SocketIpv6TclassTag : public Tag
  1185 class SocketIpv6TclassTag : public Tag
   957 {
  1186 {
   958 public:
  1187 public:
   959   SocketIpv6TclassTag ();
  1188   SocketIpv6TclassTag ();
       
  1189 
       
  1190   /**
       
  1191    * \brief Set the tag's Tclass
       
  1192    *
       
  1193    * \param tclass the Tclass
       
  1194    */
   960   void SetTclass (uint8_t tclass);
  1195   void SetTclass (uint8_t tclass);
       
  1196 
       
  1197   /**
       
  1198    * \brief Get the tag's Tclass
       
  1199    *
       
  1200    * \returns the Tclass
       
  1201    */
   961   uint8_t GetTclass (void) const;
  1202   uint8_t GetTclass (void) const;
   962   
  1203   
       
  1204   /**
       
  1205    * \brief Get the type ID.
       
  1206    * \return the object TypeId
       
  1207    */
   963   static TypeId GetTypeId (void);
  1208   static TypeId GetTypeId (void);
       
  1209 
       
  1210   // inherited function, no need to doc.
   964   virtual TypeId GetInstanceTypeId (void) const;
  1211   virtual TypeId GetInstanceTypeId (void) const;
       
  1212 
       
  1213   // inherited function, no need to doc.
   965   virtual uint32_t GetSerializedSize (void) const;
  1214   virtual uint32_t GetSerializedSize (void) const;
       
  1215 
       
  1216   // inherited function, no need to doc.
   966   virtual void Serialize (TagBuffer i) const;
  1217   virtual void Serialize (TagBuffer i) const;
       
  1218 
       
  1219   // inherited function, no need to doc.
   967   virtual void Deserialize (TagBuffer i);
  1220   virtual void Deserialize (TagBuffer i);
       
  1221 
       
  1222   // inherited function, no need to doc.
   968   virtual void Print (std::ostream &os) const;
  1223   virtual void Print (std::ostream &os) const;
   969 private:
  1224 private:
   970   uint8_t m_ipv6Tclass;
  1225   uint8_t m_ipv6Tclass; //!< the Tclass carried by the tag
   971 };
  1226 };
   972 
  1227 
   973 } // namespace ns3
  1228 } // namespace ns3
   974 
  1229 
   975 #endif /* NS3_SOCKET_H */
  1230 #endif /* NS3_SOCKET_H */