00001 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2007 INRIA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 00019 */ 00020 #ifndef MAC64_ADDRESS_H 00021 #define MAC64_ADDRESS_H 00022 00023 #include <stdint.h> 00024 #include <ostream> 00025 00026 namespace ns3 { 00027 00028 class Address; 00029 00030 /** 00031 * \ingroup address 00032 * 00033 * \brief an EUI-64 address 00034 * 00035 * This class can contain 64 bit IEEE addresses. 00036 */ 00037 class Mac64Address 00038 { 00039 public: 00040 Mac64Address (); 00041 /** 00042 * \param str a string representing the new Mac64Address 00043 * 00044 * The format of the string is "xx:xx:xx:xx:xx:xx" 00045 */ 00046 Mac64Address (const char *str); 00047 00048 /** 00049 * \param buffer address in network order 00050 * 00051 * Copy the input address to our internal buffer. 00052 */ 00053 void CopyFrom (const uint8_t buffer[8]); 00054 /** 00055 * \param buffer address in network order 00056 * 00057 * Copy the internal address to the input buffer. 00058 */ 00059 void CopyTo (uint8_t buffer[8]) const; 00060 /** 00061 * \returns a new Address instance 00062 * 00063 * Convert an instance of this class to a polymorphic Address instance. 00064 */ 00065 operator Address () const; 00066 /** 00067 * \param address a polymorphic address 00068 * \returns a new Mac64Address from the polymorphic address 00069 * 00070 * This function performs a type check and asserts if the 00071 * type of the input address is not compatible with an 00072 * Mac64Address. 00073 */ 00074 static Mac64Address ConvertFrom (const Address &address); 00075 /** 00076 * \returns true if the address matches, false otherwise. 00077 */ 00078 static bool IsMatchingType (const Address &address); 00079 /** 00080 * Allocate a new Mac64Address. 00081 */ 00082 static Mac64Address Allocate (void); 00083 private: 00084 /** 00085 * \returns a new Address instance 00086 * 00087 * Convert an instance of this class to a polymorphic Address instance. 00088 */ 00089 Address ConvertTo (void) const; 00090 static uint8_t GetType (void); 00091 uint8_t m_address[8]; 00092 }; 00093 00094 bool operator == (const Mac64Address &a, const Mac64Address &b); 00095 bool operator != (const Mac64Address &a, const Mac64Address &b); 00096 std::ostream& operator<< (std::ostream& os, const Mac64Address & address); 00097 00098 } // namespace ns3 00099 00100 #endif /* MAC64_ADDRESS_H */