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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8#ifndef IPV4_ROUTING_TABLE_ENTRY_H
9#define IPV4_ROUTING_TABLE_ENTRY_H
10
11#include "ns3/ipv4-address.h"
12
13#include <list>
14#include <ostream>
15#include <vector>
16
17namespace ns3
18{
19
20/**
21 * \ingroup ipv4Routing
22 *
23 * A record of an IPv4 routing table entry for Ipv4GlobalRouting and
24 * Ipv4StaticRouting. This is not a reference counted object.
25 */
27{
28 public:
29 /**
30 * \brief This constructor does nothing
31 */
33 /**
34 * \brief Copy Constructor
35 * \param route The route to copy
36 */
38 /**
39 * \brief Copy Constructor
40 * \param route The route to copy
41 */
43 /**
44 * \return True if this route is a host route (mask of all ones); false otherwise
45 */
46 bool IsHost() const;
47 /**
48 * \return True if this route is not a host route (mask is not all ones); false otherwise
49 *
50 * This method is implemented as !IsHost ().
51 */
52 bool IsNetwork() const;
53 /**
54 * \return True if this route is a default route; false otherwise
55 */
56 bool IsDefault() const;
57 /**
58 * \return True if this route is a gateway route; false otherwise
59 */
60 bool IsGateway() const;
61 /**
62 * \return address of the gateway stored in this entry
63 */
64 Ipv4Address GetGateway() const;
65 /**
66 * \return The IPv4 address of the destination of this route
67 */
68 Ipv4Address GetDest() const;
69 /**
70 * \return The IPv4 network number of the destination of this route
71 */
73 /**
74 * \return The IPv4 network mask of the destination of this route
75 */
77 /**
78 * \return The Ipv4 interface number used for sending outgoing packets
79 */
80 uint32_t GetInterface() const;
81 /**
82 * \return An Ipv4RoutingTableEntry object corresponding to the input parameters.
83 * \param dest Ipv4Address of the destination
84 * \param nextHop Ipv4Address of the next hop
85 * \param interface Outgoing interface
86 */
88 Ipv4Address nextHop,
89 uint32_t interface);
90 /**
91 * \return An Ipv4RoutingTableEntry object corresponding to the input parameters.
92 * \param dest Ipv4Address of the destination
93 * \param interface Outgoing interface
94 */
96 /**
97 * \return An Ipv4RoutingTableEntry object corresponding to the input parameters.
98 * \param network Ipv4Address of the destination network
99 * \param networkMask Ipv4Mask of the destination network mask
100 * \param nextHop Ipv4Address of the next hop
101 * \param interface Outgoing interface
102 */
104 Ipv4Mask networkMask,
105 Ipv4Address nextHop,
106 uint32_t interface);
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 interface Outgoing interface
112 */
114 Ipv4Mask networkMask,
115 uint32_t interface);
116 /**
117 * \return An Ipv4RoutingTableEntry object corresponding to the input
118 * parameters. This route is distinguished; it will match any
119 * destination for which a more specific route does not exist.
120 * \param nextHop Ipv4Address of the next hop
121 * \param interface Outgoing interface
122 */
124
125 private:
126 /**
127 * \brief Constructor.
128 * \param network network address
129 * \param mask network mask
130 * \param gateway the gateway
131 * \param interface the interface index
132 */
134 Ipv4Mask mask,
135 Ipv4Address gateway,
136 uint32_t interface);
137 /**
138 * \brief Constructor.
139 * \param dest destination address
140 * \param mask network mask
141 * \param interface the interface index
142 */
143 Ipv4RoutingTableEntry(Ipv4Address dest, Ipv4Mask mask, uint32_t interface);
144 /**
145 * \brief Constructor.
146 * \param dest destination address
147 * \param gateway the gateway
148 * \param interface the interface index
149 */
150 Ipv4RoutingTableEntry(Ipv4Address dest, Ipv4Address gateway, uint32_t interface);
151 /**
152 * \brief Constructor.
153 * \param dest destination address
154 * \param interface the interface index
155 */
157
158 Ipv4Address m_dest; //!< destination address
159 Ipv4Mask m_destNetworkMask; //!< destination network mask
160 Ipv4Address m_gateway; //!< gateway
161 uint32_t m_interface; //!< output interface
162};
163
164/**
165 * \brief Stream insertion operator.
166 *
167 * \param os the reference to the output stream
168 * \param route the Ipv4 routing table entry
169 * \returns the reference to the output stream
170 */
171std::ostream& operator<<(std::ostream& os, const Ipv4RoutingTableEntry& route);
172
173/**
174 * \brief Equality operator.
175 *
176 * \param a lhs
177 * \param b rhs
178 * \returns true if operands are equal, false otherwise
179 */
181
182/**
183 * \ingroup ipv4Routing
184 *
185 * \brief A record of an IPv4 multicast route for Ipv4GlobalRouting and Ipv4StaticRouting
186 */
188{
189 public:
190 /**
191 * \brief This constructor does nothing
192 */
194
195 /**
196 * \brief Copy Constructor
197 * \param route The route to copy
198 */
200 /**
201 * \brief Copy Constructor
202 * \param route The route to copy
203 */
205 /**
206 * \return The IPv4 address of the source of this route
207 */
208 Ipv4Address GetOrigin() const;
209 /**
210 * \return The IPv4 address of the multicast group of this route
211 */
212 Ipv4Address GetGroup() const;
213 /**
214 * \return The IPv4 address of the input interface of this route
215 */
217 /**
218 * \return The number of output interfaces of this route
219 */
221 /**
222 * \param n interface index
223 * \return A specified output interface.
224 */
226 /**
227 * \return A vector of all of the output interfaces of this route.
228 */
229 std::vector<uint32_t> GetOutputInterfaces() const;
230 /**
231 * \return Ipv4MulticastRoutingTableEntry corresponding to the input parameters.
232 * \param origin Source address for the multicast route
233 * \param group Group destination address for the multicast route
234 * \param inputInterface Input interface that multicast datagram must be received on
235 * \param outputInterfaces vector of output interfaces to copy and forward the datagram to
236 */
238 Ipv4Address origin,
239 Ipv4Address group,
240 uint32_t inputInterface,
241 std::vector<uint32_t> outputInterfaces);
242
243 private:
244 /**
245 * \brief Constructor.
246 * \param origin source address
247 * \param group destination address
248 * \param inputInterface input interface
249 * \param outputInterfaces output interfaces
250 */
252 Ipv4Address group,
253 uint32_t inputInterface,
254 std::vector<uint32_t> outputInterfaces);
255
256 Ipv4Address m_origin; //!< source address
257 Ipv4Address m_group; //!< destination address
258 uint32_t m_inputInterface; //!< input interface
259 std::vector<uint32_t> m_outputInterfaces; //!< output interfaces
260};
261
262/**
263 * \brief Stream insertion operator.
264 *
265 * \param os the reference to the output stream
266 * \param route the Ipv4 multicast routing table entry
267 * \returns the reference to the output stream
268 */
269std::ostream& operator<<(std::ostream& os, const Ipv4MulticastRoutingTableEntry& route);
270
271/**
272 * \brief Equality operator.
273 *
274 * \param a lhs
275 * \param b rhs
276 * \returns true if operands are equal, false otherwise
277 */
279
280} // namespace ns3
281
282#endif /* IPV4_ROUTING_TABLE_ENTRY_H */
Ipv4 addresses are stored in host order in this class.
a class to represent an Ipv4 address mask
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:155
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148