A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
address.h
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);
115  Address &operator = (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 Address& operator + (Address &a, const int b);
215  friend std::ostream& operator<< (std::ostream& os, const Address & address);
216  friend std::istream& operator>> (std::istream& is, Address & address);
217 
218  uint8_t m_type;
219  uint8_t m_len;
220  uint8_t m_data[MAX_SIZE];
221 };
222 
228 ATTRIBUTE_HELPER_HEADER (Address);
229 
230 bool operator == (const Address &a, const Address &b);
231 bool operator != (const Address &a, const Address &b);
232 bool operator < (const Address &a, const Address &b);
233 Address& operator + (Address &a, const int b);
234 std::ostream& operator<< (std::ostream& os, const Address & address);
235 std::istream& operator>> (std::istream& is, Address & address);
236 
237 
238 } // namespace ns3
239 
240 #endif /* ADDRESS_H */
bool IsInvalid(void) const
Definition: address.cc:68
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:49
bool IsMatchingType(uint8_t type) const
Definition: address.cc:130
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
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:162
uint32_t GetSerializedSize(void) const
Definition: address.cc:146
#define ATTRIBUTE_HELPER_HEADER(type)
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:43
uint32_t CopyFrom(const uint8_t *buffer, uint8_t len)
Definition: address.cc:101
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
Definition: address.cc:153
static uint8_t Register(void)
Definition: address.cc:137