A Discrete-Event Network Simulator
API
ripng-header.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 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 RIPNG_HEADER_H
21 #define RIPNG_HEADER_H
22 
23 #include "ipv6-header.h"
24 
25 #include "ns3/header.h"
26 #include "ns3/ipv6-address.h"
27 #include "ns3/packet.h"
28 
29 #include <list>
30 
31 namespace ns3
32 {
33 
39 class RipNgRte : public Header
40 {
41  public:
42  RipNgRte();
43 
48  static TypeId GetTypeId();
49 
54  TypeId GetInstanceTypeId() const override;
55 
56  void Print(std::ostream& os) const override;
57 
62  uint32_t GetSerializedSize() const override;
63 
68  void Serialize(Buffer::Iterator start) const override;
69 
75  uint32_t Deserialize(Buffer::Iterator start) override;
76 
81  void SetPrefix(Ipv6Address prefix);
82 
87  Ipv6Address GetPrefix() const;
88 
93  void SetPrefixLen(uint8_t prefixLen);
94 
99  uint8_t GetPrefixLen() const;
100 
105  void SetRouteTag(uint16_t routeTag);
106 
111  uint16_t GetRouteTag() const;
112 
117  void SetRouteMetric(uint8_t routeMetric);
118 
123  uint8_t GetRouteMetric() const;
124 
125  private:
127  uint16_t m_tag;
128  uint8_t m_prefixLen;
129  uint8_t m_metric;
130 };
131 
139 std::ostream& operator<<(std::ostream& os, const RipNgRte& h);
140 
146 class RipNgHeader : public Header
147 {
148  public:
149  RipNgHeader();
150 
155  static TypeId GetTypeId();
156 
161  TypeId GetInstanceTypeId() const override;
162 
163  void Print(std::ostream& os) const override;
164 
169  uint32_t GetSerializedSize() const override;
170 
175  void Serialize(Buffer::Iterator start) const override;
176 
182  uint32_t Deserialize(Buffer::Iterator start) override;
183 
188  {
189  REQUEST = 0x1,
190  RESPONSE = 0x2,
191  };
192 
197  void SetCommand(Command_e command);
198 
203  Command_e GetCommand() const;
204 
209  void AddRte(RipNgRte rte);
210 
214  void ClearRtes();
215 
220  uint16_t GetRteNumber() const;
221 
226  std::list<RipNgRte> GetRteList() const;
227 
228  private:
229  uint8_t m_command;
230  std::list<RipNgRte> m_rteList;
231 };
232 
240 std::ostream& operator<<(std::ostream& os, const RipNgHeader& h);
241 
242 } // namespace ns3
243 
244 #endif /* RIPNG_HEADER_H */
iterator in a Buffer instance
Definition: buffer.h:100
Protocol header serialization and deserialization.
Definition: header.h:44
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
Describes an IPv6 address.
Definition: ipv6-address.h:49
RipNgHeader - see RFC 2080
Definition: ripng-header.h:147
uint8_t m_command
command type
Definition: ripng-header.h:229
void SetCommand(Command_e command)
Set the command.
void ClearRtes()
Clear all the RTEs from the header.
uint16_t GetRteNumber() const
Get the number of RTE included in the message.
static TypeId GetTypeId()
Get the type ID.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
TypeId GetInstanceTypeId() const override
Return the instance type identifier.
std::list< RipNgRte > m_rteList
list of the RTEs in the message
Definition: ripng-header.h:230
void Print(std::ostream &os) const override
Command_e
Commands to be used in RipNg headers.
Definition: ripng-header.h:188
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Command_e GetCommand() const
Get the command.
std::list< RipNgRte > GetRteList() const
Get the list of the RTEs included in the message.
void AddRte(RipNgRte rte)
Add a RTE to the message.
RipNg Routing Table Entry (RTE) - see RFC 2080
Definition: ripng-header.h:40
uint16_t m_tag
route tag
Definition: ripng-header.h:127
static TypeId GetTypeId()
Get the type ID.
Definition: ripng-header.cc:41
uint8_t m_metric
route metric
Definition: ripng-header.h:129
Ipv6Address m_prefix
prefix
Definition: ripng-header.h:126
Ipv6Address GetPrefix() const
Get the prefix.
uint8_t GetRouteMetric() const
Get the route metric.
uint8_t GetPrefixLen() const
Get the prefix length.
uint16_t GetRouteTag() const
Get the route tag.
uint8_t m_prefixLen
prefix length
Definition: ripng-header.h:128
void SetPrefix(Ipv6Address prefix)
Set the prefix.
Definition: ripng-header.cc:97
void Print(std::ostream &os) const override
Definition: ripng-header.cc:57
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Definition: ripng-header.cc:70
void SetPrefixLen(uint8_t prefixLen)
Set the prefix length.
void SetRouteMetric(uint8_t routeMetric)
Set the route metric.
TypeId GetInstanceTypeId() const override
Return the instance type identifier.
Definition: ripng-header.cc:51
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Definition: ripng-header.cc:64
void SetRouteTag(uint16_t routeTag)
Set the route tag.
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:159