A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
37 class RipNgRte : public Header
38 {
39 public:
40  RipNgRte (void);
41 
46  static TypeId GetTypeId (void);
47 
52  virtual TypeId GetInstanceTypeId (void) const;
53 
54  virtual void Print (std::ostream& os) const;
55 
60  virtual uint32_t GetSerializedSize (void) const;
61 
66  virtual void Serialize (Buffer::Iterator start) const;
67 
73  virtual uint32_t Deserialize (Buffer::Iterator start);
74 
79  void SetPrefix (Ipv6Address prefix);
80 
85  Ipv6Address GetPrefix (void) const;
86 
91  void SetPrefixLen (uint8_t prefixLen);
92 
97  uint8_t GetPrefixLen (void) const;
98 
103  void SetRouteTag (uint16_t routeTag);
104 
109  uint16_t GetRouteTag (void) const;
110 
115  void SetRouteMetric (uint8_t routeMetric);
116 
121  uint8_t GetRouteMetric (void) const;
122 
123 
124 private:
126  uint16_t m_tag;
127  uint8_t m_prefixLen;
128  uint8_t m_metric;
129 };
130 
138 std::ostream & operator << (std::ostream & os, const RipNgRte & h);
139 
144 class RipNgHeader : public Header
145 {
146 public:
147  RipNgHeader (void);
148 
153  static TypeId GetTypeId (void);
154 
159  virtual TypeId GetInstanceTypeId (void) const;
160 
161  virtual void Print (std::ostream& os) const;
162 
167  virtual uint32_t GetSerializedSize (void) const;
168 
173  virtual void Serialize (Buffer::Iterator start) const;
174 
180  virtual uint32_t Deserialize (Buffer::Iterator start);
181 
186  {
187  REQUEST = 0x1,
188  RESPONSE = 0x2,
189  };
190 
195  void SetCommand (Command_e command);
196 
201  Command_e GetCommand (void) const;
202 
207  void AddRte (RipNgRte rte);
208 
212  void ClearRtes ();
213 
218  uint16_t GetRteNumber (void) const;
219 
224  std::list<RipNgRte> GetRteList (void) const;
225 
226 private:
227  uint8_t m_command;
228  std::list<RipNgRte> m_rteList;
229 };
230 
238 std::ostream & operator << (std::ostream & os, const RipNgHeader & h);
239 
240 }
241 
242 #endif /* RIPNG_HEADER_H */
243 
Protocol header serialization and deserialization.
Definition: header.h:42
uint16_t GetRteNumber(void) const
Get the number of RTE included in the message.
std::list< RipNgRte > GetRteList(void) const
Get the list of the RTEs included in the message.
Command_e
Commands to be used in RipNg headers.
Definition: ripng-header.h:185
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
Definition: ripng-header.cc:42
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
Definition: ripng-header.cc:69
void SetPrefix(Ipv6Address prefix)
Set the prefix.
Definition: ripng-header.cc:82
uint8_t m_prefixLen
prefix length
Definition: ripng-header.h:127
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
iterator in a Buffer instance
Definition: buffer.h:98
Ipv6Address m_prefix
prefix
Definition: ripng-header.h:125
void AddRte(RipNgRte rte)
Add a RTE to the message.
uint8_t m_command
command type
Definition: ripng-header.h:227
uint8_t m_metric
route metric
Definition: ripng-header.h:128
Ipv6Address GetPrefix(void) const
Get the prefix.
Definition: ripng-header.cc:87
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
void SetRouteTag(uint16_t routeTag)
Set the route tag.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
static TypeId GetTypeId(void)
Get the type ID.
Definition: ripng-header.cc:36
RipNgHeader - see RFC 2080
Definition: ripng-header.h:144
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Definition: ripng-header.cc:57
uint16_t GetRouteTag(void) const
Get the route tag.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:43
void SetRouteMetric(uint8_t routeMetric)
Set the route metric.
std::list< RipNgRte > m_rteList
list of the RTEs in the message
Definition: ripng-header.h:228
virtual void Print(std::ostream &os) const
Definition: ripng-header.cc:47
virtual void Print(std::ostream &os) const
uint16_t m_tag
route tag
Definition: ripng-header.h:126
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
uint8_t GetPrefixLen(void) const
Get the prefix length.
Definition: ripng-header.cc:97
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
Definition: ripng-header.cc:52
Describes an IPv6 address.
Definition: ipv6-address.h:46
static TypeId GetTypeId(void)
Get the type ID.
uint8_t GetRouteMetric(void) const
Get the route metric.
void SetCommand(Command_e command)
Set the command.
Command_e GetCommand(void) const
Get the command.
void ClearRtes()
Clear all the RTEs from the header.
RipNg Routing Table Entry (RTE) - see RFC 2080
Definition: ripng-header.h:37
a unique identifier for an interface.
Definition: type-id.h:49
void SetPrefixLen(uint8_t prefixLen)
Set the prefix length.
Definition: ripng-header.cc:92