A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
rip-header.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2016 Universita' di Firenze, Italy
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
7
*/
8
9
#ifndef RIP_HEADER_H
10
#define RIP_HEADER_H
11
12
#include "
ipv4-header.h
"
13
14
#include "ns3/header.h"
15
#include "ns3/ipv4-address.h"
16
#include "ns3/packet.h"
17
18
#include <list>
19
20
namespace
ns3
21
{
22
23
/**
24
* @ingroup rip
25
* @brief Rip v2 Routing Table Entry (RTE) - see \RFC{2453}.
26
*/
27
class
RipRte
:
public
Header
28
{
29
public
:
30
RipRte
();
31
32
/**
33
* @brief Get the type ID.
34
* @return The object TypeId.
35
*/
36
static
TypeId
GetTypeId
();
37
38
/**
39
* @brief Return the instance type identifier.
40
* @return Instance type ID.
41
*/
42
TypeId
GetInstanceTypeId
()
const override
;
43
44
void
Print
(std::ostream& os)
const override
;
45
46
/**
47
* @brief Get the serialized size of the packet.
48
* @return Size.
49
*/
50
uint32_t
GetSerializedSize
()
const override
;
51
52
/**
53
* @brief Serialize the packet.
54
* @param start Buffer iterator.
55
*/
56
void
Serialize
(
Buffer::Iterator
start)
const override
;
57
58
/**
59
* @brief Deserialize the packet.
60
* @param start Buffer iterator.
61
* @return Size of the packet.
62
*/
63
uint32_t
Deserialize
(
Buffer::Iterator
start)
override
;
64
65
/**
66
* @brief Set the prefix.
67
* @param prefix The prefix.
68
*/
69
void
SetPrefix
(
Ipv4Address
prefix);
70
71
/**
72
* @brief Get the prefix.
73
* @returns The prefix.
74
*/
75
Ipv4Address
GetPrefix
()
const
;
76
77
/**
78
* @brief Set the subnet mask.
79
* @param subnetMask The subnet mask.
80
*/
81
void
SetSubnetMask
(
Ipv4Mask
subnetMask);
82
83
/**
84
* @brief Get the subnet mask.
85
* @returns The subnet mask.
86
*/
87
Ipv4Mask
GetSubnetMask
()
const
;
88
89
/**
90
* @brief Set the route tag.
91
* @param routeTag The route tag.
92
*/
93
void
SetRouteTag
(uint16_t routeTag);
94
95
/**
96
* @brief Get the route tag.
97
* @returns The route tag.
98
*/
99
uint16_t
GetRouteTag
()
const
;
100
101
/**
102
* @brief Set the route metric.
103
* @param routeMetric The route metric.
104
*/
105
void
SetRouteMetric
(
uint32_t
routeMetric);
106
107
/**
108
* @brief Get the route metric.
109
* @returns The route metric.
110
*/
111
uint32_t
GetRouteMetric
()
const
;
112
113
/**
114
* @brief Set the next hop.
115
* @param nextHop The next hop.
116
*/
117
void
SetNextHop
(
Ipv4Address
nextHop);
118
119
/**
120
* @brief Get the next hop.
121
* @returns The next hop.
122
*/
123
Ipv4Address
GetNextHop
()
const
;
124
125
private
:
126
uint16_t
m_tag
;
//!< Route tag.
127
Ipv4Address
m_prefix
;
//!< Advertised prefix.
128
Ipv4Mask
m_subnetMask
;
//!< Subnet mask.
129
Ipv4Address
m_nextHop
;
//!< Next hop.
130
uint32_t
m_metric
;
//!< Route metric.
131
};
132
133
/**
134
* @brief Stream insertion operator.
135
*
136
* @param os the reference to the output stream
137
* @param h the Routing Table Entry
138
* @returns the reference to the output stream
139
*/
140
std::ostream&
operator<<
(std::ostream& os,
const
RipRte
& h);
141
142
/**
143
* @ingroup rip
144
* @brief RipHeader - see \RFC{2453}
145
*/
146
class
RipHeader
:
public
Header
147
{
148
public
:
149
RipHeader
();
150
151
/**
152
* @brief Get the type ID.
153
* @return the object TypeId
154
*/
155
static
TypeId
GetTypeId
();
156
157
/**
158
* @brief Return the instance type identifier.
159
* @return instance type ID
160
*/
161
TypeId
GetInstanceTypeId
()
const override
;
162
163
void
Print
(std::ostream& os)
const override
;
164
165
/**
166
* @brief Get the serialized size of the packet.
167
* @return size
168
*/
169
uint32_t
GetSerializedSize
()
const override
;
170
171
/**
172
* @brief Serialize the packet.
173
* @param start Buffer iterator
174
*/
175
void
Serialize
(
Buffer::Iterator
start)
const override
;
176
177
/**
178
* @brief Deserialize the packet.
179
* @param start Buffer iterator
180
* @return size of the packet
181
*/
182
uint32_t
Deserialize
(
Buffer::Iterator
start)
override
;
183
184
/**
185
* Commands to be used in Rip headers
186
*/
187
enum
Command_e
188
{
189
REQUEST
= 0x1,
190
RESPONSE
= 0x2,
191
};
192
193
/**
194
* @brief Set the command
195
* @param command the command
196
*/
197
void
SetCommand
(
Command_e
command);
198
199
/**
200
* @brief Get the command
201
* @returns the command
202
*/
203
Command_e
GetCommand
()
const
;
204
205
/**
206
* @brief Add a RTE to the message
207
* @param rte the RTE
208
*/
209
void
AddRte
(
RipRte
rte);
210
211
/**
212
* @brief Clear all the RTEs from the header
213
*/
214
void
ClearRtes
();
215
216
/**
217
* @brief Get the number of RTE included in the message
218
* @returns the number of RTE in the message
219
*/
220
uint16_t
GetRteNumber
()
const
;
221
222
/**
223
* @brief Get the list of the RTEs included in the message
224
* @returns the list of the RTEs in the message
225
*/
226
std::list<RipRte>
GetRteList
()
const
;
227
228
private
:
229
uint8_t
m_command
;
//!< command type
230
std::list<RipRte>
m_rteList
;
//!< list of the RTEs in the message
231
};
232
233
/**
234
* @brief Stream insertion operator.
235
*
236
* @param os the reference to the output stream
237
* @param h the Rip header
238
* @returns the reference to the output stream
239
*/
240
std::ostream&
operator<<
(std::ostream& os,
const
RipHeader
& h);
241
242
}
// namespace ns3
243
244
#endif
/* Rip_HEADER_H */
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:31
ns3::Ipv4Mask
a class to represent an Ipv4 address mask
Definition
ipv4-address.h:246
ns3::RipHeader
RipHeader - see RFC 2453
Definition
rip-header.h:147
ns3::RipHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Definition
rip-header.cc:204
ns3::RipHeader::Print
void Print(std::ostream &os) const override
Definition
rip-header.cc:186
ns3::RipHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Return the instance type identifier.
Definition
rip-header.cc:180
ns3::RipHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
Definition
rip-header.cc:220
ns3::RipHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Definition
rip-header.cc:197
ns3::RipHeader::GetRteNumber
uint16_t GetRteNumber() const
Get the number of RTE included in the message.
Definition
rip-header.cc:283
ns3::RipHeader::AddRte
void AddRte(RipRte rte)
Add a RTE to the message.
Definition
rip-header.cc:271
ns3::RipHeader::m_rteList
std::list< RipRte > m_rteList
list of the RTEs in the message
Definition
rip-header.h:230
ns3::RipHeader::SetCommand
void SetCommand(Command_e command)
Set the command.
Definition
rip-header.cc:259
ns3::RipHeader::Command_e
Command_e
Commands to be used in Rip headers.
Definition
rip-header.h:188
ns3::RipHeader::RESPONSE
@ RESPONSE
Definition
rip-header.h:190
ns3::RipHeader::REQUEST
@ REQUEST
Definition
rip-header.h:189
ns3::RipHeader::m_command
uint8_t m_command
command type
Definition
rip-header.h:229
ns3::RipHeader::ClearRtes
void ClearRtes()
Clear all the RTEs from the header.
Definition
rip-header.cc:277
ns3::RipHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
rip-header.cc:170
ns3::RipHeader::RipHeader
RipHeader()
Definition
rip-header.cc:164
ns3::RipHeader::GetRteList
std::list< RipRte > GetRteList() const
Get the list of the RTEs included in the message.
Definition
rip-header.cc:289
ns3::RipHeader::GetCommand
Command_e GetCommand() const
Get the command.
Definition
rip-header.cc:265
ns3::RipRte
Rip v2 Routing Table Entry (RTE) - see RFC 2453 .
Definition
rip-header.h:28
ns3::RipRte::GetSubnetMask
Ipv4Mask GetSubnetMask() const
Get the subnet mask.
Definition
rip-header.cc:110
ns3::RipRte::Serialize
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Definition
rip-header.cc:59
ns3::RipRte::SetSubnetMask
void SetSubnetMask(Ipv4Mask subnetMask)
Set the subnet mask.
Definition
rip-header.cc:104
ns3::RipRte::m_prefix
Ipv4Address m_prefix
Advertised prefix.
Definition
rip-header.h:127
ns3::RipRte::GetSerializedSize
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Definition
rip-header.cc:53
ns3::RipRte::m_metric
uint32_t m_metric
Route metric.
Definition
rip-header.h:130
ns3::RipRte::m_subnetMask
Ipv4Mask m_subnetMask
Subnet mask.
Definition
rip-header.h:128
ns3::RipRte::SetRouteMetric
void SetRouteMetric(uint32_t routeMetric)
Set the route metric.
Definition
rip-header.cc:128
ns3::RipRte::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
Definition
rip-header.cc:71
ns3::RipRte::m_tag
uint16_t m_tag
Route tag.
Definition
rip-header.h:126
ns3::RipRte::SetPrefix
void SetPrefix(Ipv4Address prefix)
Set the prefix.
Definition
rip-header.cc:92
ns3::RipRte::GetNextHop
Ipv4Address GetNextHop() const
Get the next hop.
Definition
rip-header.cc:146
ns3::RipRte::Print
void Print(std::ostream &os) const override
Definition
rip-header.cc:45
ns3::RipRte::GetRouteMetric
uint32_t GetRouteMetric() const
Get the route metric.
Definition
rip-header.cc:134
ns3::RipRte::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
rip-header.cc:31
ns3::RipRte::GetPrefix
Ipv4Address GetPrefix() const
Get the prefix.
Definition
rip-header.cc:98
ns3::RipRte::GetRouteTag
uint16_t GetRouteTag() const
Get the route tag.
Definition
rip-header.cc:122
ns3::RipRte::m_nextHop
Ipv4Address m_nextHop
Next hop.
Definition
rip-header.h:129
ns3::RipRte::SetRouteTag
void SetRouteTag(uint16_t routeTag)
Set the route tag.
Definition
rip-header.cc:116
ns3::RipRte::SetNextHop
void SetNextHop(Ipv4Address nextHop)
Set the next hop.
Definition
rip-header.cc:140
ns3::RipRte::RipRte
RipRte()
Definition
rip-header.cc:21
ns3::RipRte::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Return the instance type identifier.
Definition
rip-header.cc:39
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
uint32_t
ipv4-header.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition
angles.cc:148
src
internet
model
rip-header.h
Generated on Fri Dec 13 2024 18:20:41 for ns-3 by
1.11.0