A Discrete-Event Network Simulator
API
cid.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007,2008,2009 INRIA, UDcast
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  * Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
18  * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19  * <amine.ismail@UDcast.com>
20  */
21 
22 #include "cid.h"
23 
24 // 0 will match IR CID, -1 will match broadcast CID 0xFFFF, hence 60000
25 #define CID_UNINITIALIZED 60000
26 
27 namespace ns3
28 {
29 
31 {
33 }
34 
35 Cid::Cid(uint16_t identifier)
36 {
37  m_identifier = identifier;
38 }
39 
41 {
42 }
43 
44 uint16_t
46 {
47  return m_identifier;
48 }
49 
50 bool
52 {
53  return m_identifier >= 0xff00 && m_identifier <= 0xfffd;
54 }
55 
56 bool
58 {
59  return *this == Broadcast();
60 }
61 
62 bool
64 {
65  return *this == Padding();
66 }
67 
68 bool
70 {
71  return *this == InitialRanging();
72 }
73 
74 Cid
76 {
77  return 0xffff;
78 }
79 
80 Cid
82 {
83  return 0xfffe;
84 }
85 
86 Cid
88 {
89  return 0;
90 }
91 
98 bool
99 operator==(const Cid& lhs, const Cid& rhs)
100 {
101  return lhs.m_identifier == rhs.m_identifier;
102 }
103 
110 bool
111 operator!=(const Cid& lhs, const Cid& rhs)
112 {
113  return !(lhs == rhs);
114 }
115 
122 std::ostream&
123 operator<<(std::ostream& os, const Cid& cid)
124 {
125  os << cid.GetIdentifier();
126  return os;
127 }
128 
129 } // namespace ns3
#define CID_UNINITIALIZED
Definition: cid.cc:25
Cid class.
Definition: cid.h:37
uint16_t GetIdentifier() const
Definition: cid.cc:45
bool IsInitialRanging() const
Definition: cid.cc:69
~Cid()
Definition: cid.cc:40
Cid()
Create a cid of unknown type.
Definition: cid.cc:30
static Cid InitialRanging()
Definition: cid.cc:87
bool IsPadding() const
Definition: cid.cc:63
static Cid Padding()
Definition: cid.cc:81
bool IsMulticast() const
Definition: cid.cc:51
bool IsBroadcast() const
Definition: cid.cc:57
static Cid Broadcast()
Definition: cid.cc:75
uint16_t m_identifier
identiifier
Definition: cid.h:98
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:678
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:159