A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
address.h
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
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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  */
20 
21 #ifndef ADDRESS_H
22 #define ADDRESS_H
23 
24 #include <stdint.h>
25 #include <ostream>
26 #include "ns3/attribute.h"
27 #include "ns3/attribute-helper.h"
28 #include "ns3/tag-buffer.h"
29 
30 namespace ns3 {
31 
86 class Address
87 {
88 public:
93  enum MaxSize_e {
94  MAX_SIZE = 20
95  };
96 
100  Address ();
113  Address (uint8_t type, const uint8_t *buffer, uint8_t len);
114  Address (const Address & address);
116 
124  bool IsInvalid (void) const;
128  uint8_t GetLength (void) const;
133  uint32_t CopyTo (uint8_t buffer[MAX_SIZE]) const;
144  uint32_t CopyAllTo (uint8_t *buffer, uint8_t len) const;
155  uint32_t CopyFrom (const uint8_t *buffer, uint8_t len);
166  uint32_t CopyAllFrom (const uint8_t *buffer, uint8_t len);
174  bool CheckCompatible (uint8_t type, uint8_t len) const;
185  bool IsMatchingType (uint8_t type) const;
190  static uint8_t Register (void);
197  uint32_t GetSerializedSize (void) const;
203  void Serialize (TagBuffer buffer) const;
209  void Deserialize (TagBuffer buffer);
210 
211 private:
212  friend bool operator == (const Address &a, const Address &b);
213  friend bool operator < (const Address &a, const Address &b);
214  friend std::ostream& operator<< (std::ostream& os, const Address & address);
215  friend std::istream& operator>> (std::istream& is, Address & address);
216 
217  uint8_t m_type;
218  uint8_t m_len;
219  uint8_t m_data[MAX_SIZE];
220 };
221 
228 
229 bool operator == (const Address &a, const Address &b);
230 bool operator != (const Address &a, const Address &b);
231 bool operator < (const Address &a, const Address &b);
232 std::ostream& operator<< (std::ostream& os, const Address & address);
233 std::istream& operator>> (std::istream& is, Address & address);
234 
235 
236 } // namespace ns3
237 
238 #endif /* ADDRESS_H */
bool IsInvalid(void) const
Definition: address.cc:68
uint8_t m_len
Definition: address.h:218
ATTRIBUTE_HELPER_HEADER(ObjectFactory)
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)
Definition: address.cc:235
bool IsMatchingType(uint8_t type) const
Definition: address.cc:131
bool operator<(const Room &a, const Room &b)
Address()
Create an invalid address.
Definition: address.cc:32
friend bool operator<(const Address &a, const Address &b)
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)
Definition: address.cc:57
uint8_t m_type
Definition: address.h:217
uint8_t GetLength(void) const
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
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:1213
uint32_t CopyFrom(const uint8_t *buffer, uint8_t len)
Definition: address.cc:101
uint8_t m_data[MAX_SIZE]
Definition: address.h:219
read and write tag data
Definition: tag-buffer.h:51
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
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)
Macro to make help make class an ns-3 attribute.
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)
Definition: address.cc:262
MaxSize_e
The maximum size of a byte buffer which can be stored in an Address instance.
Definition: address.h:93