A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv4-routing-table-entry.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19#ifndef IPV4_ROUTING_TABLE_ENTRY_H
20#define IPV4_ROUTING_TABLE_ENTRY_H
21
22#include "ns3/ipv4-address.h"
23
24#include <list>
25#include <ostream>
26#include <vector>
27
28namespace ns3
29{
30
31/**
32 * \ingroup ipv4Routing
33 *
34 * A record of an IPv4 routing table entry for Ipv4GlobalRouting and
35 * Ipv4StaticRouting. This is not a reference counted object.
36 */
38{
39 public:
40 /**
41 * \brief This constructor does nothing
42 */
44 /**
45 * \brief Copy Constructor
46 * \param route The route to copy
47 */
49 /**
50 * \brief Copy Constructor
51 * \param route The route to copy
52 */
54 /**
55 * \return True if this route is a host route (mask of all ones); false otherwise
56 */
57 bool IsHost() const;
58 /**
59 * \return True if this route is not a host route (mask is not all ones); false otherwise
60 *
61 * This method is implemented as !IsHost ().
62 */
63 bool IsNetwork() const;
64 /**
65 * \return True if this route is a default route; false otherwise
66 */
67 bool IsDefault() const;
68 /**
69 * \return True if this route is a gateway route; false otherwise
70 */
71 bool IsGateway() const;
72 /**
73 * \return address of the gateway stored in this entry
74 */
75 Ipv4Address GetGateway() const;
76 /**
77 * \return The IPv4 address of the destination of this route
78 */
79 Ipv4Address GetDest() const;
80 /**
81 * \return The IPv4 network number of the destination of this route
82 */
84 /**
85 * \return The IPv4 network mask of the destination of this route
86 */
88 /**
89 * \return The Ipv4 interface number used for sending outgoing packets
90 */
91 uint32_t GetInterface() const;
92 /**
93 * \return An Ipv4RoutingTableEntry object corresponding to the input parameters.
94 * \param dest Ipv4Address of the destination
95 * \param nextHop Ipv4Address of the next hop
96 * \param interface Outgoing interface
97 */
99 Ipv4Address nextHop,
100 uint32_t interface);
101 /**
102 * \return An Ipv4RoutingTableEntry object corresponding to the input parameters.
103 * \param dest Ipv4Address of the destination
104 * \param interface Outgoing interface
105 */
107 /**
108 * \return An Ipv4RoutingTableEntry object corresponding to the input parameters.
109 * \param network Ipv4Address of the destination network
110 * \param networkMask Ipv4Mask of the destination network mask
111 * \param nextHop Ipv4Address of the next hop
112 * \param interface Outgoing interface
113 */
115 Ipv4Mask networkMask,
116 Ipv4Address nextHop,
117 uint32_t interface);
118 /**
119 * \return An Ipv4RoutingTableEntry object corresponding to the input parameters.
120 * \param network Ipv4Address of the destination network
121 * \param networkMask Ipv4Mask of the destination network mask
122 * \param interface Outgoing interface
123 */
125 Ipv4Mask networkMask,
126 uint32_t interface);
127 /**
128 * \return An Ipv4RoutingTableEntry object corresponding to the input
129 * parameters. This route is distinguished; it will match any
130 * destination for which a more specific route does not exist.
131 * \param nextHop Ipv4Address of the next hop
132 * \param interface Outgoing interface
133 */
135
136 private:
137 /**
138 * \brief Constructor.
139 * \param network network address
140 * \param mask network mask
141 * \param gateway the gateway
142 * \param interface the interface index
143 */
145 Ipv4Mask mask,
146 Ipv4Address gateway,
147 uint32_t interface);
148 /**
149 * \brief Constructor.
150 * \param dest destination address
151 * \param mask network mask
152 * \param interface the interface index
153 */
154 Ipv4RoutingTableEntry(Ipv4Address dest, Ipv4Mask mask, uint32_t interface);
155 /**
156 * \brief Constructor.
157 * \param dest destination address
158 * \param gateway the gateway
159 * \param interface the interface index
160 */
161 Ipv4RoutingTableEntry(Ipv4Address dest, Ipv4Address gateway, uint32_t interface);
162 /**
163 * \brief Constructor.
164 * \param dest destination address
165 * \param interface the interface index
166 */
168
169 Ipv4Address m_dest; //!< destination address
170 Ipv4Mask m_destNetworkMask; //!< destination network mask
171 Ipv4Address m_gateway; //!< gateway
172 uint32_t m_interface; //!< output interface
173};
174
175/**
176 * \brief Stream insertion operator.
177 *
178 * \param os the reference to the output stream
179 * \param route the Ipv4 routing table entry
180 * \returns the reference to the output stream
181 */
182std::ostream& operator<<(std::ostream& os, const Ipv4RoutingTableEntry& route);
183
184/**
185 * \brief Equality operator.
186 *
187 * \param a lhs
188 * \param b rhs
189 * \returns true if operands are equal, false otherwise
190 */
192
193/**
194 * \ingroup ipv4Routing
195 *
196 * \brief A record of an IPv4 multicast route for Ipv4GlobalRouting and Ipv4StaticRouting
197 */
199{
200 public:
201 /**
202 * \brief This constructor does nothing
203 */
205
206 /**
207 * \brief Copy Constructor
208 * \param route The route to copy
209 */
211 /**
212 * \brief Copy Constructor
213 * \param route The route to copy
214 */
216 /**
217 * \return The IPv4 address of the source of this route
218 */
219 Ipv4Address GetOrigin() const;
220 /**
221 * \return The IPv4 address of the multicast group of this route
222 */
223 Ipv4Address GetGroup() const;
224 /**
225 * \return The IPv4 address of the input interface of this route
226 */
228 /**
229 * \return The number of output interfaces of this route
230 */
232 /**
233 * \param n interface index
234 * \return A specified output interface.
235 */
237 /**
238 * \return A vector of all of the output interfaces of this route.
239 */
240 std::vector<uint32_t> GetOutputInterfaces() const;
241 /**
242 * \return Ipv4MulticastRoutingTableEntry corresponding to the input parameters.
243 * \param origin Source address for the multicast route
244 * \param group Group destination address for the multicast route
245 * \param inputInterface Input interface that multicast datagram must be received on
246 * \param outputInterfaces vector of output interfaces to copy and forward the datagram to
247 */
249 Ipv4Address origin,
250 Ipv4Address group,
251 uint32_t inputInterface,
252 std::vector<uint32_t> outputInterfaces);
253
254 private:
255 /**
256 * \brief Constructor.
257 * \param origin source address
258 * \param group destination address
259 * \param inputInterface input interface
260 * \param outputInterfaces output interfaces
261 */
263 Ipv4Address group,
264 uint32_t inputInterface,
265 std::vector<uint32_t> outputInterfaces);
266
267 Ipv4Address m_origin; //!< source address
268 Ipv4Address m_group; //!< destination address
269 uint32_t m_inputInterface; //!< input interface
270 std::vector<uint32_t> m_outputInterfaces; //!< output interfaces
271};
272
273/**
274 * \brief Stream insertion operator.
275 *
276 * \param os the reference to the output stream
277 * \param route the Ipv4 multicast routing table entry
278 * \returns the reference to the output stream
279 */
280std::ostream& operator<<(std::ostream& os, const Ipv4MulticastRoutingTableEntry& route);
281
282/**
283 * \brief Equality operator.
284 *
285 * \param a lhs
286 * \param b rhs
287 * \returns true if operands are equal, false otherwise
288 */
290
291} // namespace ns3
292
293#endif /* IPV4_ROUTING_TABLE_ENTRY_H */
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
A record of an IPv4 multicast route for Ipv4GlobalRouting and Ipv4StaticRouting.
Ipv4Address m_origin
source address
Ipv4Address GetGroup() const
Ipv4Address GetOrigin() const
std::vector< uint32_t > m_outputInterfaces
output interfaces
std::vector< uint32_t > GetOutputInterfaces() const
Ipv4Address m_group
destination address
uint32_t GetOutputInterface(uint32_t n) const
Ipv4MulticastRoutingTableEntry()
This constructor does nothing.
static Ipv4MulticastRoutingTableEntry CreateMulticastRoute(Ipv4Address origin, Ipv4Address group, uint32_t inputInterface, std::vector< uint32_t > outputInterfaces)
uint32_t GetNOutputInterfaces() const
uint32_t GetInputInterface() const
uint32_t m_inputInterface
input interface
A record of an IPv4 routing table entry for Ipv4GlobalRouting and Ipv4StaticRouting.
Ipv4Address GetDest() const
Ipv4Address GetGateway() const
static Ipv4RoutingTableEntry CreateDefaultRoute(Ipv4Address nextHop, uint32_t interface)
bool IsHost() const
Ipv4Address m_dest
destination address
Ipv4RoutingTableEntry()
This constructor does nothing.
bool IsNetwork() const
uint32_t m_interface
output interface
bool IsGateway() const
Ipv4Mask m_destNetworkMask
destination network mask
Ipv4Address GetDestNetwork() const
uint32_t GetInterface() const
Ipv4Address m_gateway
gateway
static Ipv4RoutingTableEntry CreateNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface)
static Ipv4RoutingTableEntry CreateHostRouteTo(Ipv4Address dest, Ipv4Address nextHop, uint32_t interface)
bool IsDefault() const
Ipv4Mask GetDestNetworkMask() const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:157
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159