A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
mac48-address.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19#ifndef MAC48_ADDRESS_H
20#define MAC48_ADDRESS_H
21
22#include "ipv4-address.h"
23#include "ipv6-address.h"
24
25#include "ns3/attribute-helper.h"
26#include "ns3/attribute.h"
27
28#include <ostream>
29#include <stdint.h>
30
31namespace ns3
32{
33
34class Address;
35
46{
47 public:
54 Mac48Address(const char* str);
55
61 void CopyFrom(const uint8_t buffer[6]);
67 void CopyTo(uint8_t buffer[6]) const;
68
74 operator Address() const;
83 static Mac48Address ConvertFrom(const Address& address);
89 Address ConvertTo() const;
90
95 static bool IsMatchingType(const Address& address);
100 static Mac48Address Allocate();
101
115 static void ResetAllocationIndex();
116
120 bool IsBroadcast() const;
121
125 bool IsGroup() const;
126
130 static Mac48Address GetBroadcast();
131
136 static Mac48Address GetMulticast(Ipv4Address address);
137
143 static Mac48Address GetMulticast(Ipv6Address address);
144
149
155
161 typedef void (*TracedCallback)(Mac48Address value);
162
163 private:
168 static uint8_t GetType();
169
177 friend bool operator==(const Mac48Address& a, const Mac48Address& b);
178
186 friend bool operator!=(const Mac48Address& a, const Mac48Address& b);
187
195 friend bool operator<(const Mac48Address& a, const Mac48Address& b);
196
204 friend std::ostream& operator<<(std::ostream& os, const Mac48Address& address);
205
213 friend std::istream& operator>>(std::istream& is, Mac48Address& address);
214
215 static uint64_t m_allocationIndex;
216 uint8_t m_address[6];
217};
218
220
221inline bool
223{
224 return memcmp(a.m_address, b.m_address, 6) == 0;
225}
226
227inline bool
229{
230 return memcmp(a.m_address, b.m_address, 6) != 0;
231}
232
233inline bool
234operator<(const Mac48Address& a, const Mac48Address& b)
235{
236 return memcmp(a.m_address, b.m_address, 6) < 0;
237}
238
239std::ostream& operator<<(std::ostream& os, const Mac48Address& address);
240std::istream& operator>>(std::istream& is, Mac48Address& address);
241
242} // namespace ns3
243
244#endif /* MAC48_ADDRESS_H */
a polymophic address class
Definition: address.h:100
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Describes an IPv6 address.
Definition: ipv6-address.h:49
an EUI-48 address
Definition: mac48-address.h:46
static Mac48Address GetMulticast(Ipv4Address address)
friend std::ostream & operator<<(std::ostream &os, const Mac48Address &address)
Stream insertion operator.
static void ResetAllocationIndex()
Reset the Mac48Address allocation index.
bool IsGroup() const
static bool IsMatchingType(const Address &address)
void CopyFrom(const uint8_t buffer[6])
friend bool operator<(const Mac48Address &a, const Mac48Address &b)
Less than operator.
friend bool operator!=(const Mac48Address &a, const Mac48Address &b)
Not equal to operator.
static uint8_t GetType()
Return the Type of address.
static Mac48Address ConvertFrom(const Address &address)
uint8_t m_address[6]
address value
static Mac48Address GetBroadcast()
static Mac48Address Allocate()
Allocate a new Mac48Address.
static Mac48Address GetMulticast6Prefix()
Get the multicast prefix for IPv6 (33:33:00:00:00:00).
friend bool operator==(const Mac48Address &a, const Mac48Address &b)
Equal to operator.
void CopyTo(uint8_t buffer[6]) const
static Mac48Address GetMulticastPrefix()
static uint64_t m_allocationIndex
Address allocation index.
friend std::istream & operator>>(std::istream &is, Mac48Address &address)
Stream extraction operator.
Address ConvertTo() const
bool IsBroadcast() const
Forward calls to a chain of Callback.
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool operator!=(Callback< R, Args... > a, Callback< R, Args... > b)
Inequality test.
Definition: callback.h:676
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:157
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:129
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:153
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:170