A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
mac8-address.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 University of Washington
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Leonard Tracy <lentracy@gmail.com>
18 */
19
20#ifndef MAC8_ADDRESS_H
21#define MAC8_ADDRESS_H
22
23#include "ns3/address.h"
24
25#include <iostream>
26
27namespace ns3
28{
29
30class Address;
31
44{
45 public:
53 Mac8Address(uint8_t addr);
55 virtual ~Mac8Address();
56
63 static Mac8Address ConvertFrom(const Address& address);
64
70 Address ConvertTo() const;
71
78 static bool IsMatchingType(const Address& address);
79
85 operator Address() const;
86
92 void CopyFrom(const uint8_t* pBuffer);
93
99 void CopyTo(uint8_t* pBuffer) const;
100
106 static Mac8Address GetBroadcast();
107
116 static Mac8Address Allocate();
117
131 static void ResetAllocationIndex();
132
133 private:
134 static uint8_t m_allocationIndex;
135 uint8_t m_address;
136
142 static uint8_t GetType();
143
144 friend bool operator<(const Mac8Address& a, const Mac8Address& b);
145 friend bool operator==(const Mac8Address& a, const Mac8Address& b);
146 friend bool operator!=(const Mac8Address& a, const Mac8Address& b);
147 friend std::ostream& operator<<(std::ostream& os, const Mac8Address& address);
148 friend std::istream& operator>>(std::istream& is, Mac8Address& address);
149
150}; // class Mac8Address
151
159bool operator<(const Mac8Address& a, const Mac8Address& b);
160
168bool operator==(const Mac8Address& a, const Mac8Address& b);
169
177bool operator!=(const Mac8Address& a, const Mac8Address& b);
178
186std::ostream& operator<<(std::ostream& os, const Mac8Address& address);
187
195std::istream& operator>>(std::istream& is, Mac8Address& address);
196
197} // namespace ns3
198
199#endif /* MAC8_ADDRESS_H */
a polymophic address class
Definition: address.h:100
A class used for addressing MAC8 MAC's.
Definition: mac8-address.h:44
friend bool operator<(const Mac8Address &a, const Mac8Address &b)
Address comparison, less than.
static Mac8Address GetBroadcast()
Get the broadcast address (255).
Definition: mac8-address.cc:93
static Mac8Address ConvertFrom(const Address &address)
Convert a generic address to a Mac8Address.
Definition: mac8-address.cc:61
friend std::ostream & operator<<(std::ostream &os, const Mac8Address &address)
Write address to stream os as 8 bit integer.
static void ResetAllocationIndex()
Reset the Mac8Address allocation index.
Address ConvertTo() const
Convert to a generic Address.
Definition: mac8-address.cc:55
static bool IsMatchingType(const Address &address)
Check that a generic Address is compatible with Mac8Address.
Definition: mac8-address.cc:70
static uint8_t GetType()
Get the Mac8Address type.
Definition: mac8-address.cc:48
uint8_t m_address
The address.
Definition: mac8-address.h:135
static uint8_t m_allocationIndex
Address allocation index.
Definition: mac8-address.h:134
friend std::istream & operator>>(std::istream &is, Mac8Address &address)
Read address from stream is as 8 bit integer.
void CopyTo(uint8_t *pBuffer) const
Writes address to buffer parameter.
Definition: mac8-address.cc:87
static Mac8Address Allocate()
Allocates Mac8Address from 0-254.
Definition: mac8-address.cc:99
friend bool operator==(const Mac8Address &a, const Mac8Address &b)
Address comparison, equality.
friend bool operator!=(const Mac8Address &a, const Mac8Address &b)
Address comparison, unequal.
void CopyFrom(const uint8_t *pBuffer)
Sets address to address stored in parameter.
Definition: mac8-address.cc:81
virtual ~Mac8Address()
Destructor.
Definition: mac8-address.cc:43
Mac8Address()
Constructor.
Definition: mac8-address.cc:33
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool operator!=(Callback< R, Args... > a, Callback< R, Args... > b)
Inequality test.
Definition: callback.h:676
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:157
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:129
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:153
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:170