A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
non-inheritance.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Universita' degli Studi di Napoli Federico II
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Stefano Avallone <stavallo@unina.it>
7 */
8
9#include "non-inheritance.h"
10
11#include <algorithm>
12#include <iterator>
13
14namespace ns3
15{
16
19{
20 return IE_EXTENSION;
21}
22
28
29void
30NonInheritance::Print(std::ostream& os) const
31{
32 os << "NonInheritance=[";
33 std::copy(m_elemIdList.cbegin(), m_elemIdList.cend(), std::ostream_iterator<uint16_t>(os, " "));
34 os << "][";
35 std::copy(m_elemIdExtList.cbegin(),
36 m_elemIdExtList.cend(),
37 std::ostream_iterator<uint16_t>(os, " "));
38 os << "]";
39}
40
41uint16_t
43{
44 uint16_t size = 1; // Element ID Extension
45 size += 1 /* Length */ + m_elemIdList.size();
46 size += 1 /* Length */ + m_elemIdExtList.size();
47 return size;
48}
49
50void
52{
53 start.WriteU8(m_elemIdList.size());
54 for (const auto id : m_elemIdList)
55 {
56 start.WriteU8(id);
57 }
58 start.WriteU8(m_elemIdExtList.size());
59 for (const auto id : m_elemIdExtList)
60 {
61 start.WriteU8(id);
62 }
63}
64
65uint16_t
67{
68 auto i = start;
69 auto count = i.ReadU8();
70 for (uint8_t j = 0; j < count; j++)
71 {
72 m_elemIdList.emplace(i.ReadU8());
73 }
74 count = i.ReadU8();
75 for (uint8_t j = 0; j < count; j++)
76 {
77 m_elemIdExtList.emplace(i.ReadU8());
78 }
79 return i.GetDistanceFrom(start);
80}
81
82void
83NonInheritance::Add(uint8_t elemId, uint8_t elemIdExt)
84{
85 elemId != IE_EXTENSION ? m_elemIdList.insert(elemId) : m_elemIdExtList.insert(elemIdExt);
86}
87
88bool
89NonInheritance::IsPresent(uint8_t elemId, uint8_t elemIdExt) const
90{
91 return elemId != IE_EXTENSION ? m_elemIdList.count(elemId) == 1
92 : m_elemIdExtList.count(elemIdExt) == 1;
93}
94
95} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:89
uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
std::set< uint8_t > m_elemIdList
list of unique Element ID values (in increasing order)
bool IsPresent(uint8_t elemId, uint8_t elemIdExt=0) const
void Add(uint8_t elemId, uint8_t elemIdExt=0)
Add the Information Element specified by the given Element ID and Element ID Extension.
void Print(std::ostream &os) const override
Generate human-readable form of IE.
uint16_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
void SerializeInformationField(Buffer::Iterator start) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
WifiInformationElementId ElementIdExt() const override
Get the wifi information element ID extension.
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
std::set< uint8_t > m_elemIdExtList
list of unique Element ID Extension values
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
#define IE_EXTENSION
#define IE_EXT_NON_INHERITANCE