Socket: Renamed all protocol classes and files to end in SocketProtocol
[senf.git] / Socket / Protocols / Raw / MACAddress.hh
index 4f91297..f8739be 100644 (file)
@@ -1,6 +1,8 @@
-// Copyright (C) 2007 
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
 //     Stefan Bund <g0dil@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
@@ -30,7 +32,9 @@
 #include <boost/array.hpp>
 #include <boost/utility.hpp>
 #include <boost/type_traits.hpp>
-#include "Utils/SafeBool.hh"
+#include "../../../Utils/safe_bool.hh"
+#include "../../../Utils/Tags.hh"
+#include "../AddressExceptions.hh"
 
 //#include "MACAddress.mpp"
 ///////////////////////////////hh.p////////////////////////////////////////
@@ -46,22 +50,27 @@ namespace senf {
             doubles as string literal and as arbitrary data iterator. The iterator constructor can
             therefore not be distinguished from initialization with a string literal. Therefore we
             need to disambiguate using the named constructors.
+
+        \ingroup addr_group
      */
     struct MACAddress
         : public boost::array<boost::uint8_t,6>, 
-          public ComparableSafeBool<MACAddress>
+          public comparable_safe_bool<MACAddress>
     {
-        enum NoInit_t { noinit };
-        
+        static MACAddress const Broadcast; ///< The broadcast address
+        static MACAddress const None;   ///< The empty (0) address
+
         MACAddress();                   ///< Construct zero-initialized address
-        MACAddress(NoInit_t);           ///< Construct uninitialized (!) address
+        MACAddress(senf::NoInit_t);     ///< Construct uninitialized (!) address
+        explicit MACAddress(boost::uint64_t v); ///< Construct MACAddress constants
 
         static MACAddress from_string(std::string const & s);
                                         ///< Construct address from string representation
                                         /**< The string representation must exactly match the form
                                              <tt>dd:dd:dd:dd:dd:dd</tt> where <tt>d</tt> is any
                                              hexadecimal digit. In place of ':', '-' is also
-                                             accepted as a delimiter. */
+                                             accepted as a delimiter.
+                                             \throws AddressSyntaxException */
 
         template <class InputIterator> 
         static MACAddress from_data(InputIterator i);
@@ -76,11 +85,11 @@ namespace senf {
                                              to a MAC address. This conversion is only possible, if
                                              the EUI-64 is MAC compatible: the 4th/5th byte (in
                                              transmission order) must be 0xFFFE.
-                                             \throws SyntaxException if \a v is not a MAC compatible
-                                                 EUI-64. */
+                                             \throws AddressSyntaxException if \a v is not a MAC
+                                                 compatible EUI-64. */
 
         bool local() const;             ///< \c true, if address is locally administered
-        bool group() const;             ///< \c true, if address is a group/multicast address
+        bool multicast() const;             ///< \c true, if address is a group/multicast address
         bool broadcast() const;         ///< \c true, if address is the broadcast address
         bool boolean_test() const;      ///< \c true, if address is the zero address
 
@@ -89,9 +98,6 @@ namespace senf {
         
         boost::uint64_t eui64() const;  ///< Build EUI-64 from the MAC address
 
-        /** \brief Bad MAC address syntax or conversion */
-        struct SyntaxException : public std::exception
-        { virtual char const * what() const throw() { return "invalid MAC address syntax"; } };
     };
 
     /** \brief Write MAC address