21 #include "ns3/address.h"
22 #include "ns3/assert.h"
34 #define ASCII_a (0x41)
35 #define ASCII_z (0x5a)
36 #define ASCII_A (0x61)
37 #define ASCII_Z (0x7a)
38 #define ASCII_COLON (0x3a)
39 #define ASCII_ZERO (0x30)
69 while (*str != 0 && i < 6)
131 address.
CopyTo (retval.m_address);
138 static uint64_t
id = 0;
141 address.
m_address[0] = (
id >> 40) & 0xff;
142 address.
m_address[1] = (
id >> 32) & 0xff;
143 address.
m_address[2] = (
id >> 24) & 0xff;
144 address.
m_address[3] = (
id >> 16) & 0xff;
200 uint8_t etherBuffer[6];
201 etherAddr.
CopyTo (etherBuffer);
215 etherBuffer[3] |= ipBuffer[1] & 0x7f;
216 etherBuffer[4] = ipBuffer[2];
217 etherBuffer[5] = ipBuffer[3];
231 uint8_t etherBuffer[6];
232 uint8_t ipBuffer[16];
236 etherAddr.
CopyTo (etherBuffer);
239 etherBuffer[2] = ipBuffer[12];
240 etherBuffer[3] = ipBuffer[13];
241 etherBuffer[4] = ipBuffer[14];
242 etherBuffer[5] = ipBuffer[15];
254 os.setf (std::ios::hex, std::ios::basefield);
256 for (uint8_t i=0; i < 5; i++)
258 os << std::setw (2) << (uint32_t)ad[i] <<
":";
261 os << std::setw (2) << (uint32_t)ad[5];
262 os.setf (std::ios::dec, std::ios::basefield);
272 std::string::size_type col = 0;
273 for (uint8_t i = 0; i < 6; ++i)
276 std::string::size_type next;
277 next = v.find (
":", col);
278 if (next == std::string::npos)
280 tmp = v.substr (col, v.size ()-col);
281 address.
m_address[i] = strtoul (tmp.c_str(), 0, 16);
286 tmp = v.substr (col, next-col);
287 address.
m_address[i] = strtoul (tmp.c_str(), 0, 16);
uint8_t m_address[6]
address value
static bool IsMatchingType(const Address &address)
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
static Mac48Address GetMulticastPrefix(void)
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
bool IsBroadcast(void) const
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
a polymophic address class
bool CheckCompatible(uint8_t type, uint8_t len) const
static char AsciiToLowCase(char c)
Converts a char to lower case.
void CopyTo(uint8_t buffer[6]) const
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
static Mac48Address GetMulticast(Ipv4Address address)
static Mac48Address GetBroadcast(void)
void Serialize(uint8_t buf[4]) const
Serialize this address to a 4-byte buffer.
static Mac48Address ConvertFrom(const Address &address)
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
static uint8_t GetType(void)
Return the Type of address.
void CopyFrom(const uint8_t buffer[6])
Describes an IPv6 address.
Ipv4 addresses are stored in host order in this class.
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
Copy the address bytes into a buffer.
ATTRIBUTE_HELPER_CPP(ObjectFactory)
static Mac48Address GetMulticast6Prefix(void)
Get the multicast prefix for IPv6 (33:33:00:00:00:00).
Address ConvertTo(void) const
static uint8_t Register(void)
Allocate a new type id for a new type of address.
void Serialize(uint8_t buf[16]) const
Serialize this address to a 16-byte buffer.