A Discrete-Event Network Simulator
API
ripng-header.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Universita' di Firenze, Italy
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
19  */
20 
21 #ifndef RIPNG_HEADER_H
22 #define RIPNG_HEADER_H
23 
24 #include <list>
25 #include "ns3/header.h"
26 #include "ns3/ipv6-address.h"
27 #include "ns3/packet.h"
28 #include "ns3/ipv6-header.h"
29 
30 
31 namespace ns3 {
32 
38 class RipNgRte : public Header
39 {
40 public:
41  RipNgRte (void);
42 
47  static TypeId GetTypeId (void);
48 
53  virtual TypeId GetInstanceTypeId (void) const;
54 
55  virtual void Print (std::ostream& os) const;
56 
61  virtual uint32_t GetSerializedSize (void) const;
62 
67  virtual void Serialize (Buffer::Iterator start) const;
68 
74  virtual uint32_t Deserialize (Buffer::Iterator start);
75 
80  void SetPrefix (Ipv6Address prefix);
81 
86  Ipv6Address GetPrefix (void) const;
87 
92  void SetPrefixLen (uint8_t prefixLen);
93 
98  uint8_t GetPrefixLen (void) const;
99 
104  void SetRouteTag (uint16_t routeTag);
105 
110  uint16_t GetRouteTag (void) const;
111 
116  void SetRouteMetric (uint8_t routeMetric);
117 
122  uint8_t GetRouteMetric (void) const;
123 
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 (void);
150 
155  static TypeId GetTypeId (void);
156 
161  virtual TypeId GetInstanceTypeId (void) const;
162 
163  virtual void Print (std::ostream& os) const;
164 
169  virtual uint32_t GetSerializedSize (void) const;
170 
175  virtual void Serialize (Buffer::Iterator start) const;
176 
182  virtual uint32_t Deserialize (Buffer::Iterator start);
183 
188  {
189  REQUEST = 0x1,
190  RESPONSE = 0x2,
191  };
192 
197  void SetCommand (Command_e command);
198 
203  Command_e GetCommand (void) const;
204 
209  void AddRte (RipNgRte rte);
210 
214  void ClearRtes ();
215 
220  uint16_t GetRteNumber (void) const;
221 
226  std::list<RipNgRte> GetRteList (void) 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 }
243 
244 #endif /* RIPNG_HEADER_H */
245 
Protocol header serialization and deserialization.
Definition: header.h:42
virtual void Print(std::ostream &os) const
Command_e
Commands to be used in RipNg headers.
Definition: ripng-header.h:187
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
Definition: ripng-header.cc:72
def start()
Definition: core.py:1844
void SetPrefix(Ipv6Address prefix)
Set the prefix.
Definition: ripng-header.cc:85
uint8_t m_prefixLen
prefix length
Definition: ripng-header.h:128
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
Definition: ripng-header.cc:45
uint8_t GetRouteMetric(void) const
Get the route metric.
iterator in a Buffer instance
Definition: buffer.h:98
Ipv6Address m_prefix
prefix
Definition: ripng-header.h:126
uint16_t GetRteNumber(void) const
Get the number of RTE included in the message.
void AddRte(RipNgRte rte)
Add a RTE to the message.
uint8_t m_command
command type
Definition: ripng-header.h:229
Ipv6Address GetPrefix(void) const
Get the prefix.
Definition: ripng-header.cc:90
uint8_t m_metric
route metric
Definition: ripng-header.h:129
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
void SetRouteTag(uint16_t routeTag)
Set the route tag.
static TypeId GetTypeId(void)
Get the type ID.
Definition: ripng-header.cc:36
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
RipNgHeader - see RFC 2080
Definition: ripng-header.h:146
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
void SetRouteMetric(uint8_t routeMetric)
Set the route metric.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::list< RipNgRte > m_rteList
list of the RTEs in the message
Definition: ripng-header.h:230
Command_e GetCommand(void) const
Get the command.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Definition: ripng-header.cc:60
uint16_t m_tag
route tag
Definition: ripng-header.h:127
Describes an IPv6 address.
Definition: ipv6-address.h:49
uint8_t GetPrefixLen(void) const
Get the prefix length.
static TypeId GetTypeId(void)
Get the type ID.
virtual void Print(std::ostream &os) const
Definition: ripng-header.cc:50
std::list< RipNgRte > GetRteList(void) const
Get the list of the RTEs included in the message.
void SetCommand(Command_e command)
Set the command.
uint16_t GetRouteTag(void) const
Get the route tag.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
Definition: ripng-header.cc:55
void ClearRtes()
Clear all the RTEs from the header.
RipNg Routing Table Entry (RTE) - see RFC 2080
Definition: ripng-header.h:38
a unique identifier for an interface.
Definition: type-id.h:58
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
void SetPrefixLen(uint8_t prefixLen)
Set the prefix length.
Definition: ripng-header.cc:95