A Discrete-Event Network Simulator
API
uan-address.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 University of Washington
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: Leonard Tracy <lentracy@gmail.com>
19  */
20 
21 #ifndef UAN_ADDRESS_H
22 #define UAN_ADDRESS_H
23 
24 #include "ns3/address.h"
25 #include <iostream>
26 
27 namespace ns3 {
28 
41 {
42 public:
44  UanAddress ();
50  UanAddress (uint8_t addr);
52  virtual ~UanAddress ();
53 
60  static UanAddress ConvertFrom (const Address &address);
61 
68  static bool IsMatchingType (const Address &address);
69 
75  operator Address () const;
76 
82  void CopyFrom (const uint8_t *pBuffer);
83 
89  void CopyTo (uint8_t *pBuffer);
90 
96  uint8_t GetAsInt (void) const;
97 
103  static UanAddress GetBroadcast (void);
104 
113  static UanAddress Allocate ();
114 
115 
116 private:
117  uint8_t m_address;
118 
124  static uint8_t GetType (void);
130  Address ConvertTo (void) const;
131 
132  friend bool operator < (const UanAddress &a, const UanAddress &b);
133  friend bool operator == (const UanAddress &a, const UanAddress &b);
134  friend bool operator != (const UanAddress &a, const UanAddress &b);
135  friend std::ostream& operator<< (std::ostream& os, const UanAddress & address);
136  friend std::istream& operator>> (std::istream& is, UanAddress & address);
137 
138 }; // class UanAddress
139 
140 
148 bool operator < (const UanAddress &a, const UanAddress &b);
149 
157 bool operator == (const UanAddress &a, const UanAddress &b);
158 
166 bool operator != (const UanAddress &a, const UanAddress &b);
167 
175 std::ostream& operator<< (std::ostream& os, const UanAddress & address);
176 
184 std::istream& operator>> (std::istream& is, UanAddress & address);
185 
186 } // namespace ns3
187 
188 #endif /* UAN_ADDRESS_H */
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Definition: angles.cc:48
static bool IsMatchingType(const Address &address)
Check that a generic Address is compatible with UanAddress.
Definition: uan-address.cc:68
void CopyFrom(const uint8_t *pBuffer)
Sets address to address stored in parameter.
Definition: uan-address.cc:79
friend bool operator<(const UanAddress &a, const UanAddress &b)
Address comparison, less than.
Definition: uan-address.cc:111
a polymophic address class
Definition: address.h:90
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:153
friend std::ostream & operator<<(std::ostream &os, const UanAddress &address)
Write address to stream os as 8 bit integer.
Definition: uan-address.cc:129
A class used for addressing UAN MAC's.
Definition: uan-address.h:40
static uint8_t GetType(void)
Get the UanAddress type.
Definition: uan-address.cc:41
static UanAddress ConvertFrom(const Address &address)
Convert a generic address to a UanAddress.
Definition: uan-address.cc:54
friend bool operator!=(const UanAddress &a, const UanAddress &b)
Address comparison, unequal.
Definition: uan-address.cc:123
virtual ~UanAddress()
Destructor.
Definition: uan-address.cc:36
static UanAddress GetBroadcast(void)
Get the broadcast address (255).
Definition: uan-address.cc:92
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
Address ConvertTo(void) const
Convert to a generic Address.
Definition: uan-address.cc:48
uint8_t GetAsInt(void) const
Convert to integer.
Definition: uan-address.cc:63
friend bool operator==(const UanAddress &a, const UanAddress &b)
Address comparison, equalit.
Definition: uan-address.cc:117
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:1471
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void CopyTo(uint8_t *pBuffer)
Writes address to buffer parameter.
Definition: uan-address.cc:85
static UanAddress Allocate()
Allocates UanAddress from 0-254.
Definition: uan-address.cc:97
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:135
tuple address
Definition: first.py:37
friend std::istream & operator>>(std::istream &is, UanAddress &address)
Read address from stream is as 8 bit integer.
Definition: uan-address.cc:135
UanAddress()
Constructor.
Definition: uan-address.cc:26
uint8_t m_address
The address.
Definition: uan-address.h:117