A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
cid-factory.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-factory.h"
12
13#include "ns3/uinteger.h"
14
15#include <stdint.h>
16
17namespace ns3
18{
19
21 : m_m(0x5500),
22 // this is an arbitrary default
23 m_basicIdentifier(1),
24 m_primaryIdentifier(m_m + 1),
25 m_transportOrSecondaryIdentifier(2 * m_m + 1),
26 m_multicastPollingIdentifier(0xff00)
27{
28}
29
30Cid
37
38Cid
45
46Cid
53
54Cid
61
62Cid
64{
65 switch (type)
66 {
67 case Cid::BROADCAST:
68 return Cid::Broadcast();
70 return Cid::InitialRanging();
71 case Cid::BASIC:
72 return AllocateBasic();
73 case Cid::PRIMARY:
74 return AllocatePrimary();
75 case Cid::TRANSPORT:
77 case Cid::MULTICAST:
78 return AllocateMulticast();
79 case Cid::PADDING:
80 return Cid::Padding();
81 default:
82 NS_FATAL_ERROR("Cannot be reached");
83 return 0; // quiet compiler
84 }
85}
86
87bool
89{
90 int id = cid.m_identifier;
91 return (id - 2 * m_m > 0) && (id <= 0xfefe);
92}
93
94bool
96{
97 int id = cid.m_identifier;
98 return (id - m_m > 0) && (id <= 2 * m_m);
99}
100
101bool
103{
104 uint16_t id = cid.m_identifier;
105 return id >= 1 && id <= m_m;
106}
107
108void
110{
111 /// \todo We need to update the cid bitmap properly here.
113 "TODO: Update the cid bitmap properly here-- please implement and contribute a patch");
114}
115
116} // namespace ns3
uint16_t m_m
m
Definition cid-factory.h:95
Cid Allocate(Cid::Type type)
This function returns the next CID for the specified type.
uint16_t m_basicIdentifier
basic identifier
Definition cid-factory.h:97
bool IsBasic(Cid cid) const
This function determines if the CID is basic.
uint16_t m_transportOrSecondaryIdentifier
transport or secondary identifier
Definition cid-factory.h:99
Cid AllocatePrimary()
This function returns the next primary basic CID.
Cid AllocateTransportOrSecondary()
This function returns the next Transport (or Secondary) CID.
uint16_t m_multicastPollingIdentifier
multicast polling identifier
bool IsPrimary(Cid cid) const
This function determines if the CID is primary.
Cid AllocateBasic()
This function returns the next basic CID.
bool IsTransport(Cid cid) const
This function determines if the CID is a transport.
uint16_t m_primaryIdentifier
primary identifier
Definition cid-factory.h:98
Cid AllocateMulticast()
This function returns the next Multicast CID.
CidFactory()
Create a cid factory with a default value for m of 0x5500.
void FreeCid(Cid cid)
Notify the factory that the connection associated to this cid has been killed and that this cid can b...
Cid class.
Definition cid.h:26
Type
Type enumeration.
Definition cid.h:30
@ PRIMARY
Definition cid.h:34
@ BROADCAST
Definition cid.h:31
@ TRANSPORT
Definition cid.h:35
@ MULTICAST
Definition cid.h:36
@ BASIC
Definition cid.h:33
@ PADDING
Definition cid.h:37
@ INITIAL_RANGING
Definition cid.h:32
static Cid InitialRanging()
Definition cid.cc:76
static Cid Padding()
Definition cid.cc:70
static Cid Broadcast()
Definition cid.cc:64
uint16_t m_identifier
identiifier
Definition cid.h:87
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Every class exported by the ns3 library is enclosed in the ns3 namespace.