A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
20#ifndef ADDRESS_H
21#define ADDRESS_H
22
23#include "ns3/attribute-helper.h"
24#include "ns3/attribute.h"
25#include "ns3/tag-buffer.h"
26
27#include <ostream>
28#include <stdint.h>
29
30namespace ns3
31{
32
100{
101 public:
106 static constexpr uint32_t MAX_SIZE{20};
107
111 Address();
125 Address(uint8_t type, const uint8_t* buffer, uint8_t len);
130 Address(const Address& address);
136 Address& operator=(const Address& address);
137
145 bool IsInvalid() const;
150 uint8_t GetLength() const;
156 uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const;
167 uint32_t CopyAllTo(uint8_t* buffer, uint8_t len) const;
178 uint32_t CopyFrom(const uint8_t* buffer, uint8_t len);
189 uint32_t CopyAllFrom(const uint8_t* buffer, uint8_t len);
197 bool CheckCompatible(uint8_t type, uint8_t len) const;
208 bool IsMatchingType(uint8_t type) const;
213 static uint8_t Register();
226 void Serialize(TagBuffer buffer) const;
232 void Deserialize(TagBuffer buffer);
233
234 private:
242 friend bool operator==(const Address& a, const Address& b);
243
251 friend bool operator!=(const Address& a, const Address& b);
252
260 friend bool operator<(const Address& a, const Address& b);
261
269 friend std::ostream& operator<<(std::ostream& os, const Address& address);
270
278 friend std::istream& operator>>(std::istream& is, Address& address);
279
280 uint8_t m_type;
281 uint8_t m_len;
282 uint8_t m_data[MAX_SIZE];
283};
284
286
287bool operator==(const Address& a, const Address& b);
288bool operator!=(const Address& a, const Address& b);
289bool operator<(const Address& a, const Address& b);
290std::ostream& operator<<(std::ostream& os, const Address& address);
291std::istream& operator>>(std::istream& is, Address& address);
292
293} // namespace ns3
294
295#endif /* ADDRESS_H */
a polymophic address class
Definition: address.h:100
friend std::istream & operator>>(std::istream &is, Address &address)
Stream extraction operator.
Definition: address.cc:264
uint32_t GetSerializedSize() const
Get the number of bytes needed to serialize the underlying Address Typically, this is GetLength () + ...
Definition: address.cc:155
void Serialize(TagBuffer buffer) const
Serialize this address in host byte order to a byte buffer.
Definition: address.cc:162
uint32_t CopyFrom(const uint8_t *buffer, uint8_t len)
Definition: address.cc:106
friend std::ostream & operator<<(std::ostream &os, const Address &address)
Stream insertion operator.
Definition: address.cc:246
static constexpr uint32_t MAX_SIZE
The maximum size of a byte buffer which can be stored in an Address instance.
Definition: address.h:106
bool IsInvalid() const
Definition: address.cc:71
uint8_t m_len
Length of the address.
Definition: address.h:281
uint8_t m_data[MAX_SIZE]
The address value.
Definition: address.h:282
uint8_t m_type
Type of the address.
Definition: address.h:280
Address & operator=(const Address &address)
Basic assignment operator.
Definition: address.cc:60
Address()
Create an invalid address.
Definition: address.cc:34
friend bool operator!=(const Address &a, const Address &b)
Not equal to operator.
Definition: address.cc:206
uint32_t CopyAllFrom(const uint8_t *buffer, uint8_t len)
Definition: address.cc:116
bool CheckCompatible(uint8_t type, uint8_t len) const
Definition: address.cc:129
static uint8_t Register()
Allocate a new type id for a new type of address.
Definition: address.cc:146
uint8_t GetLength() const
Get the length of the underlying address.
Definition: address.cc:78
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
Copy the address bytes into a buffer.
Definition: address.cc:86
void Deserialize(TagBuffer buffer)
Definition: address.cc:171
friend bool operator<(const Address &a, const Address &b)
Less than operator.
Definition: address.cc:212
bool IsMatchingType(uint8_t type) const
Definition: address.cc:139
friend bool operator==(const Address &a, const Address &b)
Equal to operator.
Definition: address.cc:183
uint32_t CopyAllTo(uint8_t *buffer, uint8_t len) const
Definition: address.cc:95
read and write tag data
Definition: tag-buffer.h:52
#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