src/network/utils/ipv6-address.h
changeset 10405 45c8fceae24e
parent 9946 df4a7e93c13d
child 10416 b22e9f50a0da
equal deleted inserted replaced
10404:eb6495608840 10405:45c8fceae24e
   348   /**
   348   /**
   349    * \brief The address representation on 128 bits (16 bytes).
   349    * \brief The address representation on 128 bits (16 bytes).
   350    */
   350    */
   351   uint8_t m_address[16];
   351   uint8_t m_address[16];
   352 
   352 
       
   353   /**
       
   354    * \brief Equal to operator.
       
   355    *
       
   356    * \param a the first operand
       
   357    * \param b the first operand
       
   358    * \returns true if the operands are equal
       
   359    */
   353   friend bool operator == (Ipv6Address const &a, Ipv6Address const &b);
   360   friend bool operator == (Ipv6Address const &a, Ipv6Address const &b);
       
   361 
       
   362   /**
       
   363    * \brief Not equal to operator.
       
   364    *
       
   365    * \param a the first operand
       
   366    * \param b the first operand
       
   367    * \returns true if the operands are not equal
       
   368    */
   354   friend bool operator != (Ipv6Address const &a, Ipv6Address const &b);
   369   friend bool operator != (Ipv6Address const &a, Ipv6Address const &b);
       
   370 
       
   371   /**
       
   372    * \brief Less than to operator.
       
   373    *
       
   374    * \param a the first operand
       
   375    * \param b the first operand
       
   376    * \returns true if the first operand is less than the second
       
   377    */
   355   friend bool operator < (Ipv6Address const &a, Ipv6Address const &b);
   378   friend bool operator < (Ipv6Address const &a, Ipv6Address const &b);
   356 };
   379 };
   357 
   380 
   358 /**
   381 /**
   359  * \ingroup address
   382  * \ingroup address
   461 private:
   484 private:
   462   /**
   485   /**
   463    * \brief The prefix representation.
   486    * \brief The prefix representation.
   464    */
   487    */
   465   uint8_t m_prefix[16];
   488   uint8_t m_prefix[16];
       
   489 
       
   490   /**
       
   491    * \brief Equal to operator.
       
   492    *
       
   493    * \param a the first operand
       
   494    * \param b the first operand
       
   495    * \returns true if the operands are equal
       
   496    */
       
   497   friend bool operator == (Ipv6Prefix const &a, Ipv6Prefix const &b);
       
   498 
       
   499   /**
       
   500    * \brief Not equal to operator.
       
   501    *
       
   502    * \param a the first operand
       
   503    * \param b the first operand
       
   504    * \returns true if the operands are not equal
       
   505    */
       
   506   friend bool operator != (Ipv6Prefix const &a, Ipv6Prefix const &b);
   466 };
   507 };
   467 
   508 
   468 /**
   509 /**
   469  * \class ns3::Ipv6AddressValue
   510  * \class ns3::Ipv6AddressValue
   470  * \brief Hold objects of type ns3::Ipv6Address
   511  * \brief Hold objects of type ns3::Ipv6Address
   475  * \class ns3::Ipv6PrefixValue
   516  * \class ns3::Ipv6PrefixValue
   476  * \brief Hold objects of type ns3::Ipv6Prefix
   517  * \brief Hold objects of type ns3::Ipv6Prefix
   477  */
   518  */
   478 ATTRIBUTE_HELPER_HEADER (Ipv6Prefix);
   519 ATTRIBUTE_HELPER_HEADER (Ipv6Prefix);
   479 
   520 
   480 std::ostream& operator << (std::ostream& os, Ipv6Address const& address);
   521 /**
   481 std::ostream& operator<< (std::ostream& os, Ipv6Prefix const& prefix);
   522  * \brief Stream insertion operator.
       
   523  *
       
   524  * \param os the reference to the output stream
       
   525  * \param address the Ipv6Address
       
   526  * \returns the reference to the output stream
       
   527  */
       
   528 std::ostream & operator << (std::ostream& os, Ipv6Address const& address);
       
   529 
       
   530 /**
       
   531  * \brief Stream insertion operator.
       
   532  *
       
   533  * \param os the reference to the output stream
       
   534  * \param prefix the Ipv6Prefix
       
   535  * \returns the reference to the output stream
       
   536  */
       
   537 std::ostream & operator << (std::ostream& os, Ipv6Prefix const& prefix);
       
   538 
       
   539 /**
       
   540  * \brief Stream extraction operator.
       
   541  *
       
   542  * \param is the reference to the input stream
       
   543  * \param address the Ipv6Address
       
   544  * \returns the reference to the input stream
       
   545  */
   482 std::istream & operator >> (std::istream &is, Ipv6Address &address);
   546 std::istream & operator >> (std::istream &is, Ipv6Address &address);
       
   547 
       
   548 /**
       
   549  * \brief Stream extraction operator.
       
   550  *
       
   551  * \param is the reference to the input stream
       
   552  * \param prefix the Ipv6Preofix
       
   553  * \returns the reference to the input stream
       
   554  */
   483 std::istream & operator >> (std::istream &is, Ipv6Prefix &prefix);
   555 std::istream & operator >> (std::istream &is, Ipv6Prefix &prefix);
   484 
   556 
   485 inline bool operator == (const Ipv6Address& a, const Ipv6Address& b)
   557 inline bool operator == (const Ipv6Address& a, const Ipv6Address& b)
   486 {
   558 {
   487   return (!std::memcmp (a.m_address, b.m_address, 16));
   559   return (!std::memcmp (a.m_address, b.m_address, 16));
   495 inline bool operator < (const Ipv6Address& a, const Ipv6Address& b)
   567 inline bool operator < (const Ipv6Address& a, const Ipv6Address& b)
   496 {
   568 {
   497   return (std::memcmp (a.m_address, b.m_address, 16) < 0);
   569   return (std::memcmp (a.m_address, b.m_address, 16) < 0);
   498 }
   570 }
   499 
   571 
       
   572 inline bool operator == (const Ipv6Prefix& a, const Ipv6Prefix& b)
       
   573 {
       
   574   return (!std::memcmp (a.m_prefix, b.m_prefix, 16));
       
   575 }
       
   576 
       
   577 inline bool operator != (const Ipv6Prefix& a, const Ipv6Prefix& b)
       
   578 {
       
   579   return std::memcmp (a.m_prefix, b.m_prefix, 16);
       
   580 }
       
   581 
   500 /**
   582 /**
   501  * \class Ipv6AddressHash
   583  * \class Ipv6AddressHash
   502  * \brief Hash function class for IPv6 addresses.
   584  * \brief Hash function class for IPv6 addresses.
   503  */
   585  */
   504 class Ipv6AddressHash : public std::unary_function<Ipv6Address, size_t>
   586 class Ipv6AddressHash : public std::unary_function<Ipv6Address, size_t>
   505 {
   587 {
   506 public:
   588 public:
   507   /**
   589   /**
   508    * \brief Unary operator to hash IPv6 address.
   590    * \brief Unary operator to hash IPv6 address.
   509    * \param x IPv6 address to hash
   591    * \param x IPv6 address to hash
       
   592    * \returns the hash of the address
   510    */
   593    */
   511   size_t operator () (Ipv6Address const &x) const;
   594   size_t operator () (Ipv6Address const &x) const;
   512 };
   595 };
   513 
   596 
   514 bool operator == (Ipv6Prefix const &a, Ipv6Prefix const &b);
       
   515 bool operator != (Ipv6Prefix const &a, Ipv6Prefix const &b);
       
   516 
       
   517 } /* namespace ns3 */
   597 } /* namespace ns3 */
   518 
   598 
   519 #endif /* IPV6_ADDRESS_H */
   599 #endif /* IPV6_ADDRESS_H */
   520 
   600