A Discrete-Event Network Simulator
API
mac8-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 MAC8_ADDRESS_H
22 #define MAC8_ADDRESS_H
23 
24 #include "ns3/address.h"
25 #include <iostream>
26 
27 namespace ns3 {
28 
29 class Address;
30 
43 {
44 public:
46  Mac8Address ();
52  Mac8Address (uint8_t addr);
54  virtual ~Mac8Address ();
55 
62  static Mac8Address ConvertFrom (const Address &address);
63 
70  static bool IsMatchingType (const Address &address);
71 
77  operator Address () const;
78 
84  void CopyFrom (const uint8_t *pBuffer);
85 
91  void CopyTo (uint8_t *pBuffer) const;
92 
98  static Mac8Address GetBroadcast (void);
99 
108  static Mac8Address Allocate ();
109 
110 
111 private:
112  uint8_t m_address;
113 
119  static uint8_t GetType (void);
125  Address ConvertTo (void) const;
126 
127  friend bool operator < (const Mac8Address &a, const Mac8Address &b);
128  friend bool operator == (const Mac8Address &a, const Mac8Address &b);
129  friend bool operator != (const Mac8Address &a, const Mac8Address &b);
130  friend std::ostream& operator<< (std::ostream& os, const Mac8Address & address);
131  friend std::istream& operator>> (std::istream& is, Mac8Address & address);
132 
133 }; // class Mac8Address
134 
135 
143 bool operator < (const Mac8Address &a, const Mac8Address &b);
144 
152 bool operator == (const Mac8Address &a, const Mac8Address &b);
153 
161 bool operator != (const Mac8Address &a, const Mac8Address &b);
162 
170 std::ostream& operator<< (std::ostream& os, const Mac8Address & address);
171 
179 std::istream& operator>> (std::istream& is, Mac8Address & address);
180 
181 } // namespace ns3
182 
183 #endif /* MAC8_ADDRESS_H */
a polymophic address class
Definition: address.h:91
A class used for addressing MAC8 MAC's.
Definition: mac8-address.h:43
static Mac8Address GetBroadcast(void)
Get the broadcast address (255).
Definition: mac8-address.cc:87
friend bool operator<(const Mac8Address &a, const Mac8Address &b)
Address comparison, less than.
Address ConvertTo(void) const
Convert to a generic Address.
Definition: mac8-address.cc:48
static Mac8Address ConvertFrom(const Address &address)
Convert a generic address to a Mac8Address.
Definition: mac8-address.cc:54
static bool IsMatchingType(const Address &address)
Check that a generic Address is compatible with Mac8Address.
Definition: mac8-address.cc:63
uint8_t m_address
The address.
Definition: mac8-address.h:112
static uint8_t GetType(void)
Get the Mac8Address type.
Definition: mac8-address.cc:41
void CopyTo(uint8_t *pBuffer) const
Writes address to buffer parameter.
Definition: mac8-address.cc:80
static Mac8Address Allocate()
Allocates Mac8Address from 0-254.
Definition: mac8-address.cc:92
friend bool operator==(const Mac8Address &a, const Mac8Address &b)
Address comparison, equalit.
friend bool operator!=(const Mac8Address &a, const Mac8Address &b)
Address comparison, unequal.
friend std::istream & operator>>(std::istream &is, Mac8Address &address)
Read address from stream is as 8 bit integer.
friend std::ostream & operator<<(std::ostream &os, const Mac8Address &address)
Write address to stream os as 8 bit integer.
void CopyFrom(const uint8_t *pBuffer)
Sets address to address stored in parameter.
Definition: mac8-address.cc:74
virtual ~Mac8Address()
Destructor.
Definition: mac8-address.cc:36
Mac8Address()
Constructor.
Definition: mac8-address.cc:26
address
Definition: first.py:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:158
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:176
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:1612
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:162
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:139