Socket/Protocols: Replace uint64 with EUI64 in address classes
[senf.git] / Socket / Protocols / INet / INet6Address.hh
index 98fb726..a80e0ad 100644 (file)
@@ -37,6 +37,8 @@
 #include "../../../Utils/Tags.hh"
 #include "INet4Address.hh"
 #include "../AddressExceptions.hh"
+#include "../Raw/MACAddress.hh"
+#include "../Raw/EUI64.hh"
 
 //#include "INet6Address.mpp"
 #include "INet6Address.ih"
@@ -44,6 +46,8 @@
 
 namespace senf {
 
+    class INet6Network;
+
     /** \brief INet6 network address
 
         This implementation of an INet6 address is based strictly on
@@ -193,7 +197,7 @@ namespace senf {
                                              data as accessed by the iterator. The data must be in
                                              network byte order. */
 
-        static INet6Address from_inet4address(INet4Address addr);
+        static INet6Address from_inet4address(INet4Address const & addr);
                                         ///< Construct an INet6-mapped INet4 address
                                         /**< This will construct an address of the form
                                              <tt>::FFFF::w.x.y.z</tt> where <tt>w.x.y.z</tt> is
@@ -203,20 +207,26 @@ namespace senf {
                                              \par
                                              INet4 compatible INet6 addresses are not directly
                                              supported, they are deprecated in the RFC. */
-        std::string toString() const;
-                                        ///< get the string representation of this INet6Address
-        in6_addr  toin6_addr() const;
-                                        ///< get the linux in6_addr struct (convinience only)
-
+        static INet6Address from_mac(senf::MACAddress const & mac);
+                                        ///< Construct a link-local INet6 address
+                                        /**< This will construct a link local address of the form
+                                             <tt>fe80::xxxx:xxff:fexx:xxxx</tt>. */
+
+        static INet6Address from_eui64(senf::EUI64 const & eui);
+                                        ///< Construct link-local INet6 address
+                                        /**< This will construct a link local address of the form
+                                             <tt>fe80::xxxx:xxxx:xxxx:xxxx</tt>. */
+        
+        in6_addr toin6_addr() const;    ///< get the linux in6_addr struct (convinience only)
 
         ///@}
         ///////////////////////////////////////////////////////////////////////////
         ///\name Accessors
         ///@{
 
-        boost::uint64_t network() const; ///< Return 64bit network part
-        bool hasEuid64() const;         ///< \c true, if address is based on an EUID-64
-        boost::uint64_t id() const;     ///< Return interface id (EUID-64)
+        INet6Network network() const; ///< Return <tt>/64</tt> Network of this address
+        bool hasEUI64() const;          ///< \c true, if address is based on an EUID-64
+        EUI64 id() const;               ///< Return interface id (EUID-64)
         bool universalId() const;       ///< \c true, if the id() is universally assigned
         bool groupId() const;           ///< \c true, if the id()'s \a group bit is set
 
@@ -283,6 +293,12 @@ namespace senf {
         \related INet6Address
      */
     std::ostream & operator<<(std::ostream & os, INet6Address const & addr);
+    /** \brief Try to initialize INet6Address instance from a string representation
+        sets std::ios::failbit on the stream if an error occurred
+        \see INet6Address from_string()
+        \related INet6Address
+     */
+    std::istream & operator>>(std::istream & is, INet6Address & addr);
 
     /** \brief Check INet6Address against a fixed network prefix
 
@@ -333,9 +349,9 @@ namespace senf {
         ///@{
 
         INet6Network();                 ///< Construct empty (::/0) network
-        INet6Network(INet6Address address, unsigned prefix_len);
+        INet6Network(INet6Address const & address, unsigned prefix_len);
                                         ///< Construct network from given address and prefix length
-        explicit INet6Network(std::string s); ///< Construct network from CIDR notation
+        explicit INet6Network(std::string const & s); ///< Construct network from CIDR notation
 
         ///@}
         ///////////////////////////////////////////////////////////////////////////
@@ -347,8 +363,8 @@ namespace senf {
         bool operator==(INet6Network const & other) const;
                                         ///< Compare two networks for equality
 
-        bool match(INet6Address addr) const; ///< \c true, if the network includes \a addr
-        bool match(INet6Network net) const; ///< \c true, if the network includes \a net
+        bool match(INet6Address const & addr) const; ///< \c true, if the network includes \a addr
+        bool match(INet6Network const & net) const; ///< \c true, if the network includes \a net
                                         /**< The is true, if \a net is sub-network (or the same as)
                                              \c this. */
         INet6Address host(boost::uint64_t id); ///< Return the host with the given id
@@ -387,7 +403,7 @@ namespace senf {
 #include "INet6Address.cti"
 #endif
 
-\f
+
 // Local Variables:
 // mode: c++
 // fill-column: 100