A Discrete-Event Network Simulator
API
cid.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007,2008,2009 INRIA, UDcast
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  * Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
19  * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
20  * <amine.ismail@UDcast.com>
21  */
22 
23 #include "cid.h"
24 
25 // 0 will match IR CID, -1 will match broadcast CID 0xFFFF, hence 60000
26 #define CID_UNINITIALIZED 60000
27 
28 namespace ns3 {
29 
30 Cid::Cid (void)
31 {
33 }
34 
35 Cid::Cid (uint16_t identifier)
36 {
37  m_identifier = identifier;
38 }
39 
40 Cid::~Cid (void)
41 {
42 }
43 
44 uint16_t
45 Cid::GetIdentifier (void) const
46 {
47  return m_identifier;
48 }
49 
50 bool
51 Cid::IsMulticast (void) const
52 {
53  return m_identifier >= 0xff00 && m_identifier <= 0xfffd;
54 }
55 bool
56 Cid::IsBroadcast (void) const
57 {
58  return *this == Broadcast ();
59 }
60 bool
61 Cid::IsPadding (void) const
62 {
63  return *this == Padding ();
64 }
65 bool
67 {
68  return *this == InitialRanging ();
69 }
70 
71 Cid
73 {
74  return 0xffff;
75 }
76 Cid
78 {
79  return 0xfffe;
80 }
81 Cid
83 {
84  return 0;
85 }
86 
93 bool operator == (const Cid &lhs,
94  const Cid &rhs)
95 {
96  return lhs.m_identifier == rhs.m_identifier;
97 }
98 
105 bool operator != (const Cid &lhs,
106  const Cid &rhs)
107 {
108  return !(lhs == rhs);
109 }
110 
117 std::ostream & operator << (std::ostream &os, const Cid &cid)
118 {
119  os << cid.GetIdentifier ();
120  return os;
121 }
122 
123 } // namespace ns3
#define CID_UNINITIALIZED
Definition: cid.cc:26
Cid class.
Definition: cid.h:38
uint16_t GetIdentifier(void) const
Definition: cid.cc:45
~Cid(void)
Definition: cid.cc:40
static Cid InitialRanging(void)
Definition: cid.cc:82
bool IsInitialRanging(void) const
Definition: cid.cc:66
bool IsPadding(void) const
Definition: cid.cc:61
bool IsMulticast(void) const
Definition: cid.cc:51
Cid(void)
Create a cid of unknown type.
Definition: cid.cc:30
static Cid Padding(void)
Definition: cid.cc:77
static Cid Broadcast(void)
Definition: cid.cc:72
bool IsBroadcast(void) const
Definition: cid.cc:56
uint16_t m_identifier
identiifier
Definition: cid.h:99
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!=(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::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:139