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
Mac64Address
() =
default
;
40
/**
41
* @param str a string representing the new Mac64Address
42
*
43
* The format of the string is "xx:xx:xx:xx:xx:xx:xx:xx"
44
*/
45
Mac64Address
(
const
char
* str);
46
47
/**
48
* @param addr The 64 bit unsigned integer used to create a Mac64Address object.
49
*
50
* Create a Mac64Address from an 64 bit unsigned integer.
51
*/
52
Mac64Address
(uint64_t addr);
53
54
/**
55
* @param buffer address in network order
56
*
57
* Copy the input address to our internal buffer.
58
*/
59
void
CopyFrom
(
const
uint8_t buffer[8]);
60
/**
61
* @param buffer address in network order
62
*
63
* Copy the internal address to the input buffer.
64
*/
65
void
CopyTo
(uint8_t buffer[8])
const
;
66
/**
67
* @returns a new Address instance
68
*
69
* Convert an instance of this class to a polymorphic Address instance.
70
*/
71
operator
Address
()
const
;
72
/**
73
* @param address a polymorphic address
74
* @returns a new Mac64Address from the polymorphic address
75
*
76
* This function performs a type check and asserts if the
77
* type of the input address is not compatible with an
78
* Mac64Address.
79
*/
80
static
Mac64Address
ConvertFrom
(
const
Address
& address);
81
/**
82
* @returns a new Address instance
83
*
84
* Convert an instance of this class to a polymorphic Address instance.
85
*/
86
Address
ConvertTo
()
const
;
87
88
/**
89
* @return the mac address in a 64 bit unsigned integer.
90
*
91
* Convert an instance of this class to a 64 bit unsigned integer.
92
*/
93
uint64_t
ConvertToInt
()
const
;
94
95
/**
96
* @param address address to test
97
* @returns true if the address matches, false otherwise.
98
*/
99
static
bool
IsMatchingType
(
const
Address
& address);
100
/**
101
* Allocate a new Mac64Address.
102
* @returns newly allocated mac64Address
103
*/
104
static
Mac64Address
Allocate
();
105
106
/**
107
* Reset the Mac64Address allocation index.
108
*
109
* This function resets (to zero) the global integer
110
* that is used for unique address allocation.
111
* It is automatically called whenever
112
* @code
113
* SimulatorDestroy ();
114
* @endcode
115
* is called. It may also be optionally called
116
* by user code if there is a need to force a reset
117
* of this allocation index.
118
*/
119
static
void
ResetAllocationIndex
();
120
121
/**
122
* Spaceship comparison operator. All the other comparison operators
123
* are automatically generated from this one.
124
*
125
* @param other address to compare to this one
126
* @returns The result of the comparison.
127
*/
128
constexpr
std::strong_ordering
operator<=>
(
const
Mac64Address
& other)
const
=
default
;
129
130
private
:
131
/**
132
* @brief Return the Type of address.
133
* @return type of address
134
*/
135
static
uint8_t
GetType
();
136
137
/**
138
* @brief Stream insertion operator.
139
*
140
* @param os the stream
141
* @param address the address
142
* @returns a reference to the stream
143
*/
144
friend
std::ostream&
operator<<
(std::ostream& os,
const
Mac64Address
& address);
145
146
/**
147
* @brief Stream extraction operator.
148
*
149
* @param is the stream
150
* @param address the address
151
* @returns a reference to the stream
152
*/
153
friend
std::istream&
operator>>
(std::istream& is,
Mac64Address
& address);
154
155
static
uint64_t
m_allocationIndex
;
//!< Address allocation index
156
std::array<uint8_t, 8>
m_address
{};
//!< Address value
157
};
158
159
/**
160
* @class ns3::Mac64AddressValue
161
* @brief hold objects of type ns3::Mac64Address
162
*/
163
164
ATTRIBUTE_HELPER_HEADER
(
Mac64Address
);
165
166
std::ostream&
operator<<
(std::ostream& os,
const
Mac64Address
& address);
167
std::istream&
operator>>
(std::istream& is,
Mac64Address
& address);
168
169
}
// namespace ns3
170
171
#endif
/* MAC64_ADDRESS_H */
ns3::Address
a polymophic address class
Definition
address.h:111
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::m_address
std::array< uint8_t, 8 > m_address
Address value.
Definition
mac64-address.h:156
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::CopyFrom
void CopyFrom(const uint8_t buffer[8])
Definition
mac64-address.cc:66
ns3::Mac64Address::operator<=>
constexpr std::strong_ordering operator<=>(const Mac64Address &other) const =default
Spaceship comparison operator.
ns3::Mac64Address::CopyTo
void CopyTo(uint8_t buffer[8]) const
Definition
mac64-address.cc:73
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::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:155
ATTRIBUTE_HELPER_HEADER
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type.
Definition
attribute-helper.h:395
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.15.0