A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
mac64-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 MAC64_ADDRESS_H
20#define MAC64_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 Mac64Address(const char* str);
55
61 Mac64Address(uint64_t addr);
62
68 void CopyFrom(const uint8_t buffer[8]);
74 void CopyTo(uint8_t buffer[8]) const;
80 operator Address() const;
89 static Mac64Address ConvertFrom(const Address& address);
95 Address ConvertTo() const;
96
102 uint64_t ConvertToInt() const;
103
108 static bool IsMatchingType(const Address& address);
113 static Mac64Address Allocate();
114
128 static void ResetAllocationIndex();
129
130 private:
135 static uint8_t GetType();
136
144 friend bool operator==(const Mac64Address& a, const Mac64Address& b);
145
153 friend bool operator!=(const Mac64Address& a, const Mac64Address& b);
154
162 friend bool operator<(const Mac64Address& a, const Mac64Address& b);
163
171 friend std::ostream& operator<<(std::ostream& os, const Mac64Address& address);
172
180 friend std::istream& operator>>(std::istream& is, Mac64Address& address);
181
182 static uint64_t m_allocationIndex;
183 uint8_t m_address[8];
184};
185
192
193inline bool
195{
196 return memcmp(a.m_address, b.m_address, 8) == 0;
197}
198
199inline bool
201{
202 return memcmp(a.m_address, b.m_address, 8) != 0;
203}
204
205inline bool
206operator<(const Mac64Address& a, const Mac64Address& b)
207{
208 return memcmp(a.m_address, b.m_address, 8) < 0;
209}
210
211std::ostream& operator<<(std::ostream& os, const Mac64Address& address);
212std::istream& operator>>(std::istream& is, Mac64Address& address);
213
214} // namespace ns3
215
216#endif /* MAC64_ADDRESS_H */
a polymophic address class
Definition: address.h:100
an EUI-64 address
Definition: mac64-address.h:46
friend std::istream & operator>>(std::istream &is, Mac64Address &address)
Stream extraction operator.
uint8_t m_address[8]
address value
friend std::ostream & operator<<(std::ostream &os, const Mac64Address &address)
Stream insertion operator.
Address ConvertTo() const
uint64_t ConvertToInt() const
static bool IsMatchingType(const Address &address)
static Mac64Address Allocate()
Allocate a new Mac64Address.
void CopyFrom(const uint8_t buffer[8])
friend bool operator!=(const Mac64Address &a, const Mac64Address &b)
Not equal to operator.
friend bool operator==(const Mac64Address &a, const Mac64Address &b)
Equal to operator.
void CopyTo(uint8_t buffer[8]) const
static Mac64Address ConvertFrom(const Address &address)
static void ResetAllocationIndex()
Reset the Mac64Address allocation index.
static uint8_t GetType()
Return the Type of address.
friend bool operator<(const Mac64Address &a, const Mac64Address &b)
Less than operator.
static uint64_t m_allocationIndex
Address allocation index.
#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