A Discrete-Event Network Simulator
API
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 void CopyFrom(const uint8_t buffer[8]);
67 void CopyTo(uint8_t buffer[8]) const;
73 operator Address() const;
88 Address ConvertTo() const;
89
94 static bool IsMatchingType(const Address& address);
99 static Mac64Address Allocate();
100
114 static void ResetAllocationIndex();
115
116 private:
121 static uint8_t GetType();
122
130 friend bool operator==(const Mac64Address& a, const Mac64Address& b);
131
139 friend bool operator!=(const Mac64Address& a, const Mac64Address& b);
140
148 friend bool operator<(const Mac64Address& a, const Mac64Address& b);
149
157 friend std::ostream& operator<<(std::ostream& os, const Mac64Address& address);
158
166 friend std::istream& operator>>(std::istream& is, Mac64Address& address);
167
168 static uint64_t m_allocationIndex;
169 uint8_t m_address[8];
170};
171
178
179inline bool
181{
182 return memcmp(a.m_address, b.m_address, 8) == 0;
183}
184
185inline bool
187{
188 return memcmp(a.m_address, b.m_address, 8) != 0;
189}
190
191inline bool
192operator<(const Mac64Address& a, const Mac64Address& b)
193{
194 return memcmp(a.m_address, b.m_address, 8) < 0;
195}
196
197std::ostream& operator<<(std::ostream& os, const Mac64Address& address);
198std::istream& operator>>(std::istream& is, Mac64Address& address);
199
200} // namespace ns3
201
202#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
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.
address
Definition: first.py:40
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:681
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:157
ATTRIBUTE_HELPER_HEADER(ValueClassTest)
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