A Discrete-Event Network Simulator
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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
18 */
19
20#ifndef RIP_HEADER_H
21#define RIP_HEADER_H
22
23#include "ns3/header.h"
24#include "ns3/ipv4-address.h"
25#include "ns3/ipv4-header.h"
26#include "ns3/packet.h"
27
28#include <list>
29
30namespace ns3
31{
32
37class RipRte : public Header
38{
39 public:
40 RipRte();
41
46 static TypeId GetTypeId();
47
52 TypeId GetInstanceTypeId() const override;
53
54 void Print(std::ostream& os) const override;
55
60 uint32_t GetSerializedSize() const override;
61
66 void Serialize(Buffer::Iterator start) const override;
67
74
79 void SetPrefix(Ipv4Address prefix);
80
85 Ipv4Address GetPrefix() const;
86
91 void SetSubnetMask(Ipv4Mask subnetMask);
92
97 Ipv4Mask GetSubnetMask() const;
98
103 void SetRouteTag(uint16_t routeTag);
104
109 uint16_t GetRouteTag() const;
110
115 void SetRouteMetric(uint32_t routeMetric);
116
121 uint32_t GetRouteMetric() const;
122
127 void SetNextHop(Ipv4Address nextHop);
128
133 Ipv4Address GetNextHop() const;
134
135 private:
136 uint16_t m_tag;
141};
142
150std::ostream& operator<<(std::ostream& os, const RipRte& h);
151
156class RipHeader : public Header
157{
158 public:
159 RipHeader();
160
165 static TypeId GetTypeId();
166
171 TypeId GetInstanceTypeId() const override;
172
173 void Print(std::ostream& os) const override;
174
179 uint32_t GetSerializedSize() const override;
180
185 void Serialize(Buffer::Iterator start) const override;
186
192 uint32_t Deserialize(Buffer::Iterator start) override;
193
198 {
199 REQUEST = 0x1,
200 RESPONSE = 0x2,
201 };
202
207 void SetCommand(Command_e command);
208
213 Command_e GetCommand() const;
214
219 void AddRte(RipRte rte);
220
224 void ClearRtes();
225
230 uint16_t GetRteNumber() const;
231
236 std::list<RipRte> GetRteList() const;
237
238 private:
239 uint8_t m_command;
240 std::list<RipRte> m_rteList;
241};
242
250std::ostream& operator<<(std::ostream& os, const RipHeader& h);
251
252} // namespace ns3
253
254#endif /* Rip_HEADER_H */
iterator in a Buffer instance
Definition: buffer.h:100
Protocol header serialization and deserialization.
Definition: header.h:44
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
RipHeader - see RFC 2453
Definition: rip-header.h:157
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Definition: rip-header.cc:216
void Print(std::ostream &os) const override
Definition: rip-header.cc:197
TypeId GetInstanceTypeId() const override
Return the instance type identifier.
Definition: rip-header.cc:191
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
Definition: rip-header.cc:233
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Definition: rip-header.cc:209
uint16_t GetRteNumber() const
Get the number of RTE included in the message.
Definition: rip-header.cc:296
void AddRte(RipRte rte)
Add a RTE to the message.
Definition: rip-header.cc:284
std::list< RipRte > m_rteList
list of the RTEs in the message
Definition: rip-header.h:240
void SetCommand(Command_e command)
Set the command.
Definition: rip-header.cc:272
Command_e
Commands to be used in Rip headers.
Definition: rip-header.h:198
uint8_t m_command
command type
Definition: rip-header.h:239
void ClearRtes()
Clear all the RTEs from the header.
Definition: rip-header.cc:290
static TypeId GetTypeId()
Get the type ID.
Definition: rip-header.cc:181
std::list< RipRte > GetRteList() const
Get the list of the RTEs included in the message.
Definition: rip-header.cc:302
Command_e GetCommand() const
Get the command.
Definition: rip-header.cc:278
Rip v2 Routing Table Entry (RTE) - see RFC 2453.
Definition: rip-header.h:38
Ipv4Mask GetSubnetMask() const
Get the subnet mask.
Definition: rip-header.cc:121
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Definition: rip-header.cc:70
void SetSubnetMask(Ipv4Mask subnetMask)
Set the subnet mask.
Definition: rip-header.cc:115
Ipv4Address m_prefix
Advertised prefix.
Definition: rip-header.h:137
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Definition: rip-header.cc:64
uint32_t m_metric
Route metric.
Definition: rip-header.h:140
Ipv4Mask m_subnetMask
Subnet mask.
Definition: rip-header.h:138
void SetRouteMetric(uint32_t routeMetric)
Set the route metric.
Definition: rip-header.cc:139
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
Definition: rip-header.cc:82
uint16_t m_tag
Route tag.
Definition: rip-header.h:136
void SetPrefix(Ipv4Address prefix)
Set the prefix.
Definition: rip-header.cc:103
Ipv4Address GetNextHop() const
Get the next hop.
Definition: rip-header.cc:157
void Print(std::ostream &os) const override
Definition: rip-header.cc:56
uint32_t GetRouteMetric() const
Get the route metric.
Definition: rip-header.cc:145
static TypeId GetTypeId()
Get the type ID.
Definition: rip-header.cc:42
Ipv4Address GetPrefix() const
Get the prefix.
Definition: rip-header.cc:109
uint16_t GetRouteTag() const
Get the route tag.
Definition: rip-header.cc:133
Ipv4Address m_nextHop
Next hop.
Definition: rip-header.h:139
void SetRouteTag(uint16_t routeTag)
Set the route tag.
Definition: rip-header.cc:127
void SetNextHop(Ipv4Address nextHop)
Set the next hop.
Definition: rip-header.cc:151
TypeId GetInstanceTypeId() const override
Return the instance type identifier.
Definition: rip-header.cc:50
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:129