A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
mac16-address.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 INRIA
3 * Copyright (c) 2011 The Boeing Company
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 */
19#ifndef MAC16_ADDRESS_H
20#define MAC16_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
44{
45 public:
51 Mac16Address(const char* str);
52
58 Mac16Address(uint16_t addr);
59
65 void CopyFrom(const uint8_t buffer[2]);
66
72 void CopyTo(uint8_t buffer[2]) const;
73
79 operator Address() const;
80
89 static Mac16Address ConvertFrom(const Address& address);
90
96 Address ConvertTo() const;
97
103 uint16_t ConvertToInt() const;
104
109 static bool IsMatchingType(const Address& address);
110
115 static Mac16Address Allocate();
116
130 static void ResetAllocationIndex();
131
135 static Mac16Address GetBroadcast();
136
160 static Mac16Address GetMulticast(Ipv6Address address);
161
168 bool IsBroadcast() const;
169
176 bool IsMulticast() const;
177
178 private:
183 static uint8_t GetType();
184
192 friend bool operator==(const Mac16Address& a, const Mac16Address& b);
193
201 friend bool operator!=(const Mac16Address& a, const Mac16Address& b);
202
210 friend bool operator<(const Mac16Address& a, const Mac16Address& b);
211
219 friend std::ostream& operator<<(std::ostream& os, const Mac16Address& address);
220
228 friend std::istream& operator>>(std::istream& is, Mac16Address& address);
229
230 static uint64_t m_allocationIndex;
231 uint8_t m_address[2];
232};
233
235
236inline bool
238{
239 return memcmp(a.m_address, b.m_address, 2) == 0;
240}
241
242inline bool
244{
245 return memcmp(a.m_address, b.m_address, 2) != 0;
246}
247
248inline bool
249operator<(const Mac16Address& a, const Mac16Address& b)
250{
251 return memcmp(a.m_address, b.m_address, 2) < 0;
252}
253
254std::ostream& operator<<(std::ostream& os, const Mac16Address& address);
255std::istream& operator>>(std::istream& is, Mac16Address& address);
256
257} // namespace ns3
258
259#endif /* MAC16_ADDRESS_H */
a polymophic address class
Definition: address.h:100
Describes an IPv6 address.
Definition: ipv6-address.h:49
This class can contain 16 bit addresses.
Definition: mac16-address.h:44
friend bool operator<(const Mac16Address &a, const Mac16Address &b)
Less than operator.
static Mac16Address GetMulticast(Ipv6Address address)
Returns the multicast address associated with an IPv6 address according to RFC 4944 Section 9.
static bool IsMatchingType(const Address &address)
static uint64_t m_allocationIndex
Address allocation index.
friend bool operator!=(const Mac16Address &a, const Mac16Address &b)
Not equal to operator.
static Mac16Address ConvertFrom(const Address &address)
friend std::istream & operator>>(std::istream &is, Mac16Address &address)
Stream extraction operator.
uint16_t ConvertToInt() const
void CopyTo(uint8_t buffer[2]) const
friend bool operator==(const Mac16Address &a, const Mac16Address &b)
Equal to operator.
static Mac16Address Allocate()
Allocate a new Mac16Address.
Address ConvertTo() const
void CopyFrom(const uint8_t buffer[2])
bool IsMulticast() const
Checks if the address is a multicast address according to RFC 4944 Section 9 (i.e....
uint8_t m_address[2]
address value
static void ResetAllocationIndex()
Reset the Mac16Address allocation index.
static Mac16Address GetBroadcast()
bool IsBroadcast() const
Checks if the address is a broadcast address according to 802.15.4 scheme (i.e., 0xFFFF).
static uint8_t GetType()
Return the Type of address.
friend std::ostream & operator<<(std::ostream &os, const Mac16Address &address)
Stream insertion operator.
#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