A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
mac64-address.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
*/
8
#ifndef MAC64_ADDRESS_H
9
#define MAC64_ADDRESS_H
10
11
#include "
ipv4-address.h
"
12
#include "
ipv6-address.h
"
13
14
#include "ns3/attribute-helper.h"
15
#include "ns3/attribute.h"
16
17
#include <array>
18
#include <compare>
19
#include <ostream>
20
#include <stdint.h>
21
22
namespace
ns3
23
{
24
25
class
Address
;
26
27
/**
28
* @ingroup address
29
*
30
* @brief an EUI-64 address
31
*
32
* This class can contain 64 bit IEEE addresses.
33
*
34
* @see attribute_Mac64Address
35
*/
36
class
Mac64Address
37
{
38
public
:
39
/// Address length when converted to an Address [bytes].
40
static
constexpr
uint8_t
ADDRESS_LENGTH
= 8;
41
42
Mac64Address
() =
default
;
43
/**
44
* @param str a string representing the new Mac64Address
45
*
46
* The format of the string is "xx:xx:xx:xx:xx:xx:xx:xx"
47
*/
48
Mac64Address
(
const
char
* str);
49
50
/**
51
* @param addr The 64 bit unsigned integer used to create a Mac64Address object.
52
*
53
* Create a Mac64Address from an 64 bit unsigned integer.
54
*/
55
Mac64Address
(uint64_t addr);
56
57
/**
58
* @param buffer address in network order
59
*
60
* Copy the input address to our internal buffer.
61
*/
62
void
CopyFrom
(
const
uint8_t buffer[
ADDRESS_LENGTH
]);
63
/**
64
* @param buffer address in network order
65
*
66
* Copy the internal address to the input buffer.
67
*/
68
void
CopyTo
(uint8_t buffer[
ADDRESS_LENGTH
])
const
;
69
/**
70
* @returns a new Address instance
71
*
72
* Convert an instance of this class to a polymorphic Address instance.
73
*/
74
operator
Address
()
const
;
75
/**
76
* @param address a polymorphic address
77
* @returns a new Mac64Address from the polymorphic address
78
*
79
* This function performs a type check and asserts if the
80
* type of the input address is not compatible with an
81
* Mac64Address.
82
*/
83
static
Mac64Address
ConvertFrom
(
const
Address
& address);
84
/**
85
* @returns a new Address instance
86
*
87
* Convert an instance of this class to a polymorphic Address instance.
88
*/
89
Address
ConvertTo
()
const
;
90
91
/**
92
* @return the mac address in a 64 bit unsigned integer.
93
*
94
* Convert an instance of this class to a 64 bit unsigned integer.
95
*/
96
uint64_t
ConvertToInt
()
const
;
97
98
/**
99
* @param address address to test
100
* @returns true if the address matches, false otherwise.
101
*/
102
static
bool
IsMatchingType
(
const
Address
& address);
103
/**
104
* Allocate a new Mac64Address.
105
* @returns newly allocated mac64Address
106
*/
107
static
Mac64Address
Allocate
();
108
109
/**
110
* Reset the Mac64Address allocation index.
111
*
112
* This function resets (to zero) the global integer
113
* that is used for unique address allocation.
114
* It is automatically called whenever
115
* @code
116
* SimulatorDestroy ();
117
* @endcode
118
* is called. It may also be optionally called
119
* by user code if there is a need to force a reset
120
* of this allocation index.
121
*/
122
static
void
ResetAllocationIndex
();
123
124
/**
125
* Spaceship comparison operator. All the other comparison operators
126
* are automatically generated from this one.
127
*
128
* @param other address to compare to this one
129
* @returns The result of the comparison.
130
*/
131
constexpr
std::strong_ordering
operator<=>
(
const
Mac64Address
& other)
const
=
default
;
132
133
private
:
134
/**
135
* @brief Return the Type of address.
136
* @return type of address
137
*/
138
static
uint8_t
GetType
();
139
140
/**
141
* @brief Stream insertion operator.
142
*
143
* @param os the stream
144
* @param address the address
145
* @returns a reference to the stream
146
*/
147
friend
std::ostream&
operator<<
(std::ostream& os,
const
Mac64Address
& address);
148
149
/**
150
* @brief Stream extraction operator.
151
*
152
* @param is the stream
153
* @param address the address
154
* @returns a reference to the stream
155
*/
156
friend
std::istream&
operator>>
(std::istream& is,
Mac64Address
& address);
157
158
static
uint64_t
m_allocationIndex
;
//!< Address allocation index
159
std::array<uint8_t, ADDRESS_LENGTH>
m_address
{};
//!< Address value
160
};
161
162
/**
163
* @class ns3::Mac64AddressValue
164
* @brief hold objects of type ns3::Mac64Address
165
*/
166
167
ATTRIBUTE_HELPER_HEADER
(
Mac64Address
);
168
169
std::ostream&
operator<<
(std::ostream& os,
const
Mac64Address
& address);
170
std::istream&
operator>>
(std::istream& is,
Mac64Address
& address);
171
172
}
// namespace ns3
173
174
#endif
/* MAC64_ADDRESS_H */
ns3::Address
a polymophic address class
Definition
address.h:114
ns3::Mac64Address
an EUI-64 address
Definition
mac64-address.h:37
ns3::Mac64Address::operator>>
friend std::istream & operator>>(std::istream &is, Mac64Address &address)
Stream extraction operator.
Definition
mac64-address.cc:187
ns3::Mac64Address::operator<<
friend std::ostream & operator<<(std::ostream &os, const Mac64Address &address)
Stream insertion operator.
Definition
mac64-address.cc:165
ns3::Mac64Address::ConvertTo
Address ConvertTo() const
Definition
mac64-address.cc:103
ns3::Mac64Address::ADDRESS_LENGTH
static constexpr uint8_t ADDRESS_LENGTH
Address length when converted to an Address [bytes].
Definition
mac64-address.h:40
ns3::Mac64Address::ConvertToInt
uint64_t ConvertToInt() const
Definition
mac64-address.cc:110
ns3::Mac64Address::IsMatchingType
static bool IsMatchingType(const Address &address)
Definition
mac64-address.cc:80
ns3::Mac64Address::Allocate
static Mac64Address Allocate()
Allocate a new Mac64Address.
Definition
mac64-address.cc:127
ns3::Mac64Address::operator<=>
constexpr std::strong_ordering operator<=>(const Mac64Address &other) const =default
Spaceship comparison operator.
ns3::Mac64Address::m_address
std::array< uint8_t, ADDRESS_LENGTH > m_address
Address value.
Definition
mac64-address.h:159
ns3::Mac64Address::CopyFrom
void CopyFrom(const uint8_t buffer[ADDRESS_LENGTH])
Definition
mac64-address.cc:66
ns3::Mac64Address::ConvertFrom
static Mac64Address ConvertFrom(const Address &address)
Definition
mac64-address.cc:93
ns3::Mac64Address::ResetAllocationIndex
static void ResetAllocationIndex()
Reset the Mac64Address allocation index.
Definition
mac64-address.cc:150
ns3::Mac64Address::CopyTo
void CopyTo(uint8_t buffer[ADDRESS_LENGTH]) const
Definition
mac64-address.cc:73
ns3::Mac64Address::GetType
static uint8_t GetType()
Return the Type of address.
Definition
mac64-address.cc:157
ns3::Mac64Address::Mac64Address
Mac64Address()=default
ns3::Mac64Address::m_allocationIndex
static uint64_t m_allocationIndex
Address allocation index.
Definition
mac64-address.h:158
ATTRIBUTE_HELPER_HEADER
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type.
Definition
attribute-helper.h:398
ipv4-address.h
ipv6-address.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition
angles.cc:148
ns3::operator>>
std::istream & operator>>(std::istream &is, Angles &a)
Definition
angles.cc:172
src
network
utils
mac64-address.h
Generated on
for ns-3 by
1.16.1