A Discrete-Event Network Simulator
API
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:
107 {
108 MAX_SIZE = 20
109 };
110
114 Address();
128 Address(uint8_t type, const uint8_t* buffer, uint8_t len);
133 Address(const Address& address);
140
148 bool IsInvalid() const;
153 uint8_t GetLength() const;
159 uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const;
170 uint32_t CopyAllTo(uint8_t* buffer, uint8_t len) const;
181 uint32_t CopyFrom(const uint8_t* buffer, uint8_t len);
192 uint32_t CopyAllFrom(const uint8_t* buffer, uint8_t len);
200 bool CheckCompatible(uint8_t type, uint8_t len) const;
211 bool IsMatchingType(uint8_t type) const;
216 static uint8_t Register();
229 void Serialize(TagBuffer buffer) const;
235 void Deserialize(TagBuffer buffer);
236
237 private:
245 friend bool operator==(const Address& a, const Address& b);
246
254 friend bool operator!=(const Address& a, const Address& b);
255
263 friend bool operator<(const Address& a, const Address& b);
264
272 friend std::ostream& operator<<(std::ostream& os, const Address& address);
273
281 friend std::istream& operator>>(std::istream& is, Address& address);
282
283 uint8_t m_type;
284 uint8_t m_len;
285 uint8_t m_data[MAX_SIZE];
286};
287
289
290bool operator==(const Address& a, const Address& b);
291bool operator!=(const Address& a, const Address& b);
292bool operator<(const Address& a, const Address& b);
293std::ostream& operator<<(std::ostream& os, const Address& address);
294std::istream& operator>>(std::istream& is, Address& address);
295
296} // namespace ns3
297
298#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
bool IsInvalid() const
Definition: address.cc:71
uint8_t m_len
Length of the address.
Definition: address.h:284
MaxSize_e
The maximum size of a byte buffer which can be stored in an Address instance.
Definition: address.h:107
uint8_t m_data[MAX_SIZE]
The address value.
Definition: address.h:285
uint8_t m_type
Type of the address.
Definition: address.h:283
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
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