A Discrete-Event Network Simulator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
21 #ifndef ADDRESS_H
22 #define ADDRESS_H
24 #include <stdint.h>
25 #include <ostream>
26 #include "ns3/attribute.h"
27 #include "ns3/attribute-helper.h"
28 #include "ns3/tag-buffer.h"
30 namespace ns3 {
86 class Address
87 {
88 public:
93  enum MaxSize_e {
94  MAX_SIZE = 20
95  };
100  Address ();
114  Address (uint8_t type, const uint8_t *buffer, uint8_t len);
119  Address (const Address & address);
134  bool IsInvalid (void) const;
139  uint8_t GetLength (void) const;
145  uint32_t CopyTo (uint8_t buffer[MAX_SIZE]) const;
156  uint32_t CopyAllTo (uint8_t *buffer, uint8_t len) const;
167  uint32_t CopyFrom (const uint8_t *buffer, uint8_t len);
178  uint32_t CopyAllFrom (const uint8_t *buffer, uint8_t len);
186  bool CheckCompatible (uint8_t type, uint8_t len) const;
197  bool IsMatchingType (uint8_t type) const;
202  static uint8_t Register (void);
209  uint32_t GetSerializedSize (void) const;
215  void Serialize (TagBuffer buffer) const;
221  void Deserialize (TagBuffer buffer);
223 private:
231  friend bool operator == (const Address &a, const Address &b);
240  friend bool operator != (const Address &a, const Address &b);
249  friend bool operator < (const Address &a, const Address &b);
258  friend std::ostream& operator<< (std::ostream& os, const Address & address);
267  friend std::istream& operator>> (std::istream& is, Address & address);
269  uint8_t m_type;
270  uint8_t m_len;
271  uint8_t m_data[MAX_SIZE];
272 };
281 bool operator == (const Address &a, const Address &b);
282 bool operator != (const Address &a, const Address &b);
283 bool operator < (const Address &a, const Address &b);
284 std::ostream& operator<< (std::ostream& os, const Address & address);
285 std::istream& operator>> (std::istream& is, Address & address);
288 } // namespace ns3
290 #endif /* ADDRESS_H */
bool IsInvalid(void) const
Definition: address.cc:68
uint8_t m_len
Length of the address.
Definition: address.h:270
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Definition: angles.cc:49
friend std::ostream & operator<<(std::ostream &os, const Address &address)
Stream insertion operator.
Definition: address.cc:235
bool IsMatchingType(uint8_t type) const
Definition: address.cc:131
Create an invalid address.
Definition: address.cc:32
friend bool operator<(const Address &a, const Address &b)
Less than operator.
Definition: address.cc:202
a polymophic address class
Definition: address.h:86
bool CheckCompatible(uint8_t type, uint8_t len) const
Definition: address.cc:122
uint32_t CopyAllTo(uint8_t *buffer, uint8_t len) const
Definition: address.cc:90
Address & operator=(const Address &address)
Basic assignment operator.
Definition: address.cc:57
uint8_t m_type
Type of the address.
Definition: address.h:269
uint8_t GetLength(void) const
Get the length of the underlying address.
Definition: address.cc:75
uint32_t CopyAllFrom(const uint8_t *buffer, uint8_t len)
Definition: address.cc:110
void Deserialize(TagBuffer buffer)
Definition: address.cc:163
bool operator<(const int64x64_t &lhs, const int64x64_t &rhs)
Less than operator.
Definition: int64x64-128.h:327
uint32_t GetSerializedSize(void) const
Get the number of bytes needed to serialize the underlying Address Typically, this is GetLength () + ...
Definition: address.cc:147
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:43
bool operator!=(Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > a, Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > b)
Inequality test.
Definition: callback.h:1217
uint32_t CopyFrom(const uint8_t *buffer, uint8_t len)
Definition: address.cc:101
uint8_t m_data[MAX_SIZE]
The address value.
Definition: address.h:271
read and write tag data
Definition: tag-buffer.h:51
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
Copy the address bytes into a buffer.
Definition: address.cc:82
void Serialize(TagBuffer buffer) const
Serialize this address in host byte order to a byte buffer.
Definition: address.cc:154
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.cc:89
friend bool operator!=(const Address &a, const Address &b)
Not equal to operator.
Definition: address.cc:198
friend bool operator==(const Address &a, const Address &b)
Equal to operator.
Definition: address.cc:175
tuple address
Definition: first.py:37
static uint8_t Register(void)
Allocate a new type id for a new type of address.
Definition: address.cc:138
friend std::istream & operator>>(std::istream &is, Address &address)
Stream extraction operator.
Definition: address.cc:251
The maximum size of a byte buffer which can be stored in an Address instance.
Definition: address.h:93