A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
cid.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008,2009 INRIA, UDcast
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
7 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
8 * <amine.ismail@UDcast.com>
9 */
10
11#include "cid.h"
12
13// 0 will match IR CID, -1 will match broadcast CID 0xFFFF, hence 60000
14#define CID_UNINITIALIZED 60000
15
16namespace ns3
17{
18
23
24Cid::Cid(uint16_t identifier)
25{
26 m_identifier = identifier;
27}
28
30{
31}
32
33uint16_t
35{
36 return m_identifier;
37}
38
39bool
41{
42 return m_identifier >= 0xff00 && m_identifier <= 0xfffd;
43}
44
45bool
47{
48 return *this == Broadcast();
49}
50
51bool
53{
54 return *this == Padding();
55}
56
57bool
59{
60 return *this == InitialRanging();
61}
62
63Cid
65{
66 return 0xffff;
67}
68
69Cid
71{
72 return 0xfffe;
73}
74
75Cid
77{
78 return 0;
79}
80
81/**
82 * @brief equality operator
83 * @param lhs left hand side
84 * @param rhs right hand side
85 * @returns true if equal
86 */
87bool
88operator==(const Cid& lhs, const Cid& rhs)
89{
90 return lhs.m_identifier == rhs.m_identifier;
91}
92
93/**
94 * @brief inequality operator
95 * @param lhs left hand side
96 * @param rhs right hand side
97 * @returns true if not equal
98 */
99bool
100operator!=(const Cid& lhs, const Cid& rhs)
101{
102 return !(lhs == rhs);
103}
104
105/**
106 * @brief output stream output operator
107 * @param os output stream
108 * @param cid CID
109 * @returns output stream
110 */
111std::ostream&
112operator<<(std::ostream& os, const Cid& cid)
113{
114 os << cid.GetIdentifier();
115 return os;
116}
117
118} // namespace ns3
#define CID_UNINITIALIZED
Definition cid.cc:14
Cid class.
Definition cid.h:26
uint16_t GetIdentifier() const
Definition cid.cc:34
bool IsInitialRanging() const
Definition cid.cc:58
~Cid()
Definition cid.cc:29
Cid()
Create a cid of unknown type.
Definition cid.cc:19
static Cid InitialRanging()
Definition cid.cc:76
bool IsPadding() const
Definition cid.cc:52
static Cid Padding()
Definition cid.cc:70
bool IsMulticast() const
Definition cid.cc:40
bool IsBroadcast() const
Definition cid.cc:46
static Cid Broadcast()
Definition cid.cc:64
uint16_t m_identifier
identiifier
Definition cid.h:87
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:658
bool operator==(const EventId &a, const EventId &b)
Definition event-id.h:155
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148