OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2007 INRIA | 3 * Copyright (c) 2007 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> | 18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
19 */ | 19 */ |
20 #ifndef IPV4_H | 20 #ifndef IPV4_H |
21 #define IPV4_H | 21 #define IPV4_H |
22 | 22 |
23 #include <stdint.h> | 23 #include <stdint.h> |
24 #include "ns3/ipv4-address.h" | |
25 #include "ns3/ipv4-interface-address.h" | |
26 #include "ns3/object.h" | 24 #include "ns3/object.h" |
| 25 #include "ns3/socket.h" |
27 #include "ns3/callback.h" | 26 #include "ns3/callback.h" |
28 #include "ipv4-route.h" | 27 #include "ipv4-routing-protocol.h" |
| 28 #include "ipv4-address.h" |
| 29 #include "ipv4-interface-address.h" |
29 | 30 |
30 namespace ns3 { | 31 namespace ns3 { |
31 | 32 |
32 class Node; | 33 class Node; |
33 class NetDevice; | 34 class NetDevice; |
34 class Packet; | 35 class Packet; |
35 class Ipv4Route; | |
36 class Ipv4Header; | |
37 | 36 |
38 /** | 37 /** |
39 * \ingroup node | 38 * \ingroup node |
40 * \defgroup ipv4 Ipv4 | 39 * \defgroup ipv4 Ipv4 |
41 */ | 40 */ |
42 | 41 |
43 /** | 42 /** |
44 * \ingroup ipv4 | 43 * \brief Access to the Ipv4 forwarding table, interfaces, and configuration |
45 * | 44 * |
46 * \brief Base class for IPv4 routing protocols. | 45 * This class defines the API to manipulate the following aspects of |
| 46 * the Ipv4 implementation:·· |
| 47 * -# set/get an Ipv4RoutingProtocol· |
| 48 * -# register a NetDevice for use by the Ipv4 layer (basically, to |
| 49 * create Ipv4-related state such as addressing and neighbor cache that· |
| 50 * is associated with a NetDevice) |
| 51 * -# manipulate the status of the NetDevice from the Ipv4 perspective,· |
| 52 * such as marking it as Up or Down,· |
| 53 * -# adding, deleting, and getting addresses associated to the Ipv4· |
| 54 * interfaces. |
| 55 * -# exporting Ipv4 configuration attributes |
| 56 *· |
| 57 * Each NetDevice has conceptually a single Ipv4 interface associated |
| 58 * with it (the corresponding structure in the Linux Ipv4 implementation |
| 59 * is struct in_device). Each interface may have one or more Ipv4 |
| 60 * addresses associated with it. Each Ipv4 address may have different |
| 61 * subnet mask, scope, etc., so all of this per-address information· |
| 62 * is stored in an Ipv4InterfaceAddress class (the corresponding· |
| 63 * structure in Linux is struct in_ifaddr) |
47 * | 64 * |
48 * This class represents the interface between the IPv4 routing core | 65 * Ipv4 attributes such as whether IP forwarding is enabled and disabled |
49 * and a specific IPv4 routing protocol. The interface is | 66 * are also stored in this class |
50 * asynchronous (callback based) in order to support reactive routing | |
51 * protocols (e.g. AODV). | |
52 */ | |
53 class Ipv4RoutingProtocol : public Object | |
54 { | |
55 public: | |
56 // void (*RouteReply) (bool found, Ipv4Route route, Packet packet, Ipv4Header
const &ipHeader); | |
57 | |
58 | |
59 /** | |
60 * \brief Callback to be invoked when route discovery is completed | |
61 * | |
62 * \param bool flag indicating whether a route was actually found; | |
63 * when this is false, the Ipv4Route parameter is ignored | |
64 * | |
65 * \param Ipv4Route the route found | |
66 * | |
67 * \param Packet the packet for which a route was requested; can be | |
68 * modified by the routing protocol | |
69 * | |
70 * \param Ipv4Header the IP header supplied to the route request | |
71 * method (possibly modified in case a new routing header is | |
72 * inserted and consequently the protocol type has to change). | |
73 * | |
74 */ | |
75 typedef Callback<void, bool, const Ipv4Route&, Ptr<Packet>, const Ipv4Header&>
RouteReplyCallback; | |
76 | |
77 /** | |
78 * \brief Request that a packet be routed. | |
79 * | |
80 * \param interface The interface index on which the packet was received. | |
81 * \param ipHeader IP header of the packet | |
82 * \param packet packet that is being sent or forwarded | |
83 * \param routeReply callback that will receive the route reply | |
84 * | |
85 * \returns true if the routing protocol should be able to get the | |
86 * route, false otherwise. | |
87 * | |
88 * This method is called whenever a node's IPv4 forwarding engine | |
89 * needs to lookup a route for a given packet and IP header. | |
90 * | |
91 * The routing protocol implementation may determine immediately it | |
92 * should not be handling this particular the route request. For | |
93 * instance, a routing protocol may decline to search for routes for | |
94 * certain classes of addresses, like link-local. In this case, | |
95 * RequestRoute() should return false and the routeReply callback | |
96 * must not be invoked. | |
97 * | |
98 * If the routing protocol implementation assumes that it can provide | |
99 * the requested route, then it should return true, and the | |
100 * routeReply callback must be invoked, either immediately before | |
101 * returning true (synchronously), or in the future (asynchronous). | |
102 * The routing protocol may use any information available in the IP | |
103 * header and packet as routing key, although most routing protocols | |
104 * use only the destination address (as given by | |
105 * ipHeader.GetDestination ()). The routing protocol is also | |
106 * allowed to add a new header to the packet, which will appear | |
107 * immediately after the IP header, although most routing do not | |
108 * insert any extra header. | |
109 * | |
110 * Multicast routing is expected to be supported in this method. If a | |
111 * multicast route is encountered, all routes to a given multicast | |
112 * destination will be serviced by cloning the packet and calling the· | |
113 * route reply callback once for each outgoing interface in the route. | |
114 */ | |
115 virtual bool RequestRoute (uint32_t interface, | |
116 const Ipv4Header &ipHeader, | |
117 Ptr<Packet> packet, | |
118 RouteReplyCallback routeReply) = 0; | |
119 | |
120 /** | |
121 * \brief Synchronously check to see if we can determine the interface index· | |
122 * that will be used if a packet is sent to this destination. | |
123 * | 67 * |
124 * This method addresses a problem in the IP stack where a destination address | 68 * TO DO: Add API to allow access to the Ipv4 neighbor table |
125 * must be present and checksummed into the IP header before the actual· | |
126 * interface over which the packet is sent can be determined. The answer is | |
127 * to implement a known and intentional cross-layer violation. This is the | |
128 * endpoint of a call chain that started up quite high in the stack (sockets) | |
129 * and has found its way down to the Ipv4L3Protocol which is consulting the | |
130 * routing protocols for what they would do if presented with a packet of the | |
131 * given destination. | |
132 * | 69 * |
133 * Note that the a single interface index is returned. This means that if | |
134 * the destination address is a multicast, and an explicit route is present | |
135 * that includeds multiple output interfaces, that route cannot be used. | |
136 *· | |
137 * If there are multiple paths out of the node, the resolution is performed | |
138 * by Ipv4L3Protocol::GetInterfaceforDestination which has access to more· | |
139 * contextual information that is useful for making a determination. | |
140 * | |
141 * \param destination The Ipv4Address if the destination of a hypothetical· | |
142 * packet. This may be a multicast group address. | |
143 * \param interface A reference to the interface index over which a packet | |
144 * sent to this destination would be sent. | |
145 * \return Returns true if a route is found to the destination that involves | |
146 * a single output interface index, otherwise false. | |
147 * | |
148 * \see Ipv4StaticRouting | |
149 * \see Ipv4RoutingProtocol | 70 * \see Ipv4RoutingProtocol |
150 * \see Ipv4L3Protocol | 71 * \see Ipv4InterfaceAddress |
151 */ | |
152 virtual bool RequestInterface (Ipv4Address destination,· | |
153 uint32_t& interface) = 0; | |
154 | |
155 static const uint32_t INTERFACE_ANY = 0xffffffff; | |
156 }; | |
157 | |
158 /** | |
159 * \brief Access to the Ipv4 forwarding table and to the ipv4 interfaces | |
160 * | |
161 * This class allows you to create ipv4 interfaces based on a NetDevice. | |
162 * Multiple interfaces can be created for a single NetDevice, hence | |
163 * achieving multihoming. | |
164 * | |
165 * This class also allows you to control the content of the ipv4· | |
166 * forwarding table. | |
167 */ | 72 */ |
168 class Ipv4 : public Object | 73 class Ipv4 : public Object |
169 { | 74 { |
170 public: | 75 public: |
171 static TypeId GetTypeId (void); | 76 static TypeId GetTypeId (void); |
172 Ipv4 (); | 77 Ipv4 (); |
173 virtual ~Ipv4 (); | 78 virtual ~Ipv4 (); |
174 | 79 |
175 /** | 80 /** |
176 * \brief Register a new routing protocol to be used in this IPv4 stack | 81 * \brief Register a new routing protocol to be used by this Ipv4 stack |
| 82 *··· |
| 83 * This call will replace any routing protocol that has been previously· |
| 84 * registered. If you want to add multiple routing protocols, you must |
| 85 * add them to a Ipv4ListRoutingProtocol directly. |
177 *· | 86 *· |
178 * \param routingProtocol new routing protocol implementation object | 87 * \param routing smart pointer to Ipv4RoutingProtocol object |
179 * \param priority priority to give to this routing protocol. | |
180 * Values may range between -32768 and +32767. The priority 0 | |
181 * corresponds to static routing table lookups, higher values have | |
182 * more priority. The order by which routing protocols with the | |
183 * same priority value are consulted is undefined. | |
184 */ | 88 */ |
185 virtual void AddRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol, | 89 virtual void SetRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol) = 0
; |
186 int16_t priority) = 0; | |
187 ·· | |
188 /** | |
189 * \param dest destination address | |
190 * \param nextHop address of next hop. | |
191 * \param interface interface of next hop. | |
192 * | |
193 * Add route to host dest through host nextHop· | |
194 * on interface. | |
195 */ | |
196 virtual void AddHostRouteTo (Ipv4Address dest,· | |
197 » » » Ipv4Address nextHop,· | |
198 » » » uint32_t interface) = 0; | |
199 /** | |
200 * \param dest destination address | |
201 * \param interface of next hop | |
202 * | |
203 * add route to host dest on interface. | |
204 */ | |
205 virtual void AddHostRouteTo (Ipv4Address dest,· | |
206 » » » uint32_t interface) = 0; | |
207 | 90 |
208 /** | 91 /** |
209 * \param network destination network | 92 * \brief Get the routing protocol to be used by this Ipv4 stack |
210 * \param networkMask netmask of destination network | |
211 * \param nextHop address of next hop | |
212 * \param interface interface of next hop | |
213 *· | 93 *· |
214 * add route to network dest with netmask· | 94 * \returns smart pointer to Ipv4RoutingProtocol object, or null pointer if no
ne |
215 * through host nextHop on interface | |
216 */ | 95 */ |
217 virtual void AddNetworkRouteTo (Ipv4Address network,· | 96 virtual Ptr<Ipv4RoutingProtocol> GetRoutingProtocol (void) const = 0; |
218 » » » » Ipv4Mask networkMask,· | |
219 » » » » Ipv4Address nextHop,· | |
220 » » » » uint32_t interface) = 0; | |
221 | 97 |
222 /** | 98 /** |
223 * \param network destination network | 99 * \param device device to add to the list of Ipv4 interfaces |
224 * \param networkMask netmask of destination network | |
225 * \param interface interface of next hop | |
226 * | |
227 * add route to network dest with netmask· | |
228 * on interface | |
229 */ | |
230 virtual void AddNetworkRouteTo (Ipv4Address network,· | |
231 » » » » Ipv4Mask networkMask,· | |
232 » » » » uint32_t interface) = 0; | |
233 /** | |
234 * \param nextHop address of default next hop | |
235 * \param interface interface of default next hop. | |
236 *· | |
237 * set the default route to host nextHop on | |
238 * interface.· | |
239 */ | |
240 virtual void SetDefaultRoute (Ipv4Address nextHop,· | |
241 » » » » uint32_t interface) = 0; | |
242 | |
243 /** | |
244 * \returns the number of entries in the routing table. | |
245 */ | |
246 virtual uint32_t GetNRoutes (void) = 0; | |
247 | |
248 /** | |
249 * \param i index of route to return | |
250 * \returns the route whose index is i | |
251 */ | |
252 virtual Ipv4Route GetRoute (uint32_t i) = 0; | |
253 | |
254 /** | |
255 * \param i index of route to remove from routing table. | |
256 */ | |
257 virtual void RemoveRoute (uint32_t i) = 0; | |
258 | |
259 /** | |
260 * \brief Add a static multicast route for a given multicast source and· | |
261 * group. | |
262 * | |
263 * \param origin The Ipv4 address of the multicast source. | |
264 * \param group The multicast group address. | |
265 * \param inputInterface The interface index over which the packet arrived. | |
266 * \param outputInterfaces The list of output interface indices over which· | |
267 * the packet should be sent (excluding the inputInterface). | |
268 */ | |
269 virtual void AddMulticastRoute (Ipv4Address origin, | |
270 Ipv4Address group, | |
271 uint32_t inputInterface, | |
272 std::vector<uint32_t> outputInterfaces) = 0; | |
273 /** | |
274 * \brief Remove a static multicast route for a given multicast source and | |
275 * group. | |
276 * | |
277 * \param origin The Ipv4 address of the multicast source. | |
278 * \param group The multicast group address. | |
279 * \param inputInterface The interface index over which the packet arrived. | |
280 */ | |
281 virtual void RemoveMulticastRoute (Ipv4Address origin, | |
282 Ipv4Address group, | |
283 uint32_t inputInterface) = 0; | |
284 ·· | |
285 /** | |
286 * \brief Set the default static multicast route. | |
287 * | |
288 * \param outputInterface The network output interface index over which· | |
289 * packets without specific routes should be sent. | |
290 */ | |
291 virtual void SetDefaultMulticastRoute (uint32_t outputInterface) = 0; | |
292 | |
293 /** | |
294 * \returns the number of entries in the multicast routing table. | |
295 */ | |
296 virtual uint32_t GetNMulticastRoutes (void) const = 0; | |
297 | |
298 /** | |
299 * \param i index of route to return | |
300 * \returns the route whose index is i | |
301 */ | |
302 virtual Ipv4MulticastRoute GetMulticastRoute (uint32_t i) const = 0; | |
303 | |
304 /** | |
305 * \param i index of route to remove from routing table. | |
306 */ | |
307 virtual void RemoveMulticastRoute (uint32_t i) = 0; | |
308 | |
309 /** | |
310 * \param device device to add to the list of ipv4 interfaces | |
311 * which can be used as output interfaces during packet forwarding. | 100 * which can be used as output interfaces during packet forwarding. |
312 * \returns the index of the ipv4 interface added. | 101 * \returns the index of the Ipv4 interface added. |
313 * | 102 * |
314 * Once a device has been added, it can never be removed: if you want | 103 * Once a device has been added, it can never be removed: if you want |
315 * to disable it, you can invoke Ipv4::SetDown which will | 104 * to disable it, you can invoke Ipv4::SetDown which will |
316 * make sure that it is never used during packet forwarding. | 105 * make sure that it is never used during packet forwarding. |
317 */ | 106 */ |
318 virtual uint32_t AddInterface (Ptr<NetDevice> device) = 0; | 107 virtual uint32_t AddInterface (Ptr<NetDevice> device) = 0; |
319 | 108 |
320 /** | 109 /** |
321 * \returns the number of interfaces added by the user. | 110 * \returns the number of interfaces added by the user. |
322 */ | 111 */ |
323 virtual uint32_t GetNInterfaces (void) const = 0;·· | 112 virtual uint32_t GetNInterfaces (void) const = 0;·· |
324 | 113 |
325 /** | 114 /** |
326 * \brief Find and return the interface ID of the interface that has been | 115 * \brief Return the interface number of the interface that has been |
327 * assigned the specified IP address. | 116 * assigned the specified IP address. |
328 * \param addr The IP address assigned to the interface of interest. | |
329 * \returns The index of the ipv4 interface with the given address. | |
330 * | 117 * |
331 * Each IP interface has an IP address associated with it. It is often· | 118 * \param address The IP address being searched for |
332 * useful to search the list of interfaces for one that corresponds to· | 119 * \returns The interface number of the Ipv4 interface with the given· |
333 * a known IP Address. This call takes an IP address as a parameter and | 120 * address or -1 if not found. |
334 * returns the interface index of the first interface that has been assigned | 121 * |
335 * that address. If the address is not found, this function asserts. | 122 * Each IP interface has one or more IP addresses associated with it.·· |
| 123 * This method searches the list of interfaces for one that holds a |
| 124 * particular address. This call takes an IP address as a parameter and |
| 125 * returns the interface number of the first interface that has been assigned |
| 126 * that address, or -1 if not found. There must be an exact match. |
336 */ | 127 */ |
337 virtual uint32_t FindInterfaceForAddr (Ipv4Address addr) const = 0; | 128 virtual int32_t GetInterfaceForAddress (Ipv4Address address) const = 0; |
338 | 129 |
339 /** | 130 /** |
340 * \brief Find and return the interface ID of the interface that has been | 131 * \brief Return the interface number of first interface found that· |
341 * assigned the specified (masked) IP address. | 132 * has an Ipv4 address within the prefix specified by the input |
| 133 * address and mask parameters |
| 134 * |
342 * \param addr The IP address assigned to the interface of interest. | 135 * \param addr The IP address assigned to the interface of interest. |
343 * \param mask The address mask to be used in address matching. | 136 * \returns The interface number of the Ipv4 interface with the given· |
344 * \returns The index of the ipv4 interface with the given address. | 137 * address or -1 if not found. |
345 * | 138 * |
346 * Each IP interface has an IP address associated with it. It is often· | 139 * Each IP interface has one or more IP addresses associated with it.·· |
347 * useful to search the list of interfaces for one that corresponds to· | 140 * This method searches the list of interfaces for the first one found |
348 * a known IP Address. This call takes an IP address and an IP address | 141 * that holds an address that is included within the prefix· |
349 * mask as parameters and returns the interface index of the first interface | 142 * formed by the input address and mask parameters. The value -1 is |
350 * that matches the masked IP address. | 143 * returned if no match is found. |
351 */ | 144 */ |
352 virtual uint32_t FindInterfaceForAddr (Ipv4Address addr, | 145 virtual int32_t GetInterfaceForPrefix (Ipv4Address address, |
353 Ipv4Mask mask) const = 0; | 146 Ipv4Mask mask) const = 0; |
354 | 147 |
355 /** | 148 /** |
356 * \brief Find and return the interface ID of the interface that has been | 149 * \param interface The interface number of an Ipv4 interface. |
357 * associated with the specified (masked) NetDevice | 150 * \returns The NetDevice associated with the Ipv4 interface number. |
358 * \param nd The net device of the interface of interest. | |
359 * \returns The index of the ipv4 interface associated with the given net· | |
360 * device or -1 if not found. | |
361 * | |
362 * Each IP interface is associated with a net device. It is often· | |
363 * useful to search the list of interfaces for one that corresponds to· | |
364 * a known net device. This call takes an smart pointer to a net device | |
365 * and returns the interface index of the first interface that matches the | |
366 * net device. | |
367 */ | 151 */ |
368 virtual int32_t FindInterfaceForDevice(Ptr<NetDevice> nd) const = 0; | 152 virtual Ptr<NetDevice> GetNetDevice (uint32_t interface) = 0; |
369 | 153 |
370 /** | 154 /** |
371 * \param i index of ipv4 interface | 155 * \param device The NetDevice for an Ipv4Interface |
372 * \returns the NetDevice associated with the ipv4 interface index | 156 * \returns The interface number of an Ipv4 interface or -1 if not found. |
373 */ | 157 */ |
374 virtual Ptr<NetDevice> GetNetDevice (uint32_t i) = 0; | 158 virtual int32_t GetInterfaceForDevice (Ptr<const NetDevice> device) const = 0; |
375 | |
376 /** | |
377 * \brief Join a multicast group for a given multicast source and· | |
378 * group. | |
379 * | |
380 * \param origin The Ipv4 address of the multicast source. | |
381 * \param group The multicast group address. | |
382 */ | |
383 virtual void JoinMulticastGroup (Ipv4Address origin, Ipv4Address group) = 0; | |
384 | |
385 /** | |
386 * \brief Leave a multicast group for a given multicast source and· | |
387 * group. | |
388 * | |
389 * \param origin The Ipv4 address of the multicast source. | |
390 * \param group The multicast group address. | |
391 */ | |
392 virtual void LeaveMulticastGroup (Ipv4Address origin, Ipv4Address group) = 0; | |
393 | 159 |
394 /** | 160 /** |
395 * \param interface Interface number of an Ipv4 interface | 161 * \param interface Interface number of an Ipv4 interface |
396 * \param address Ipv4InterfaceAddress address to associate with the underlyin
g Ipv4 interface | 162 * \param address Ipv4InterfaceAddress address to associate with the underlyin
g Ipv4 interface |
397 * \returns The address index of the newly-added address | 163 * \returns The address index of the newly-added address |
398 */ | 164 */ |
399 virtual uint32_t AddAddress (uint32_t interface, Ipv4InterfaceAddress address)
= 0; | 165 virtual uint32_t AddAddress (uint32_t interface, Ipv4InterfaceAddress address)
= 0; |
400 | 166 |
401 /** | 167 /** |
402 * \param interface Interface number of an Ipv4 interface | 168 * \param interface Interface number of an Ipv4 interface |
403 * \returns the number of Ipv4InterfaceAddress entries for the interface. | 169 * \returns the number of Ipv4InterfaceAddress entries for the interface. |
404 */ | 170 */ |
405 virtual uint32_t GetNAddresses (uint32_t interface) const = 0; | 171 virtual uint32_t GetNAddresses (uint32_t interface) const = 0; |
406 | 172 |
407 /** | 173 /** |
408 * \param interface Interface number of an Ipv4 interface | 174 * \param interface Interface number of an Ipv4 interface |
409 * \param addressIndex index of Ipv4InterfaceAddress | 175 * \param addressIndex index of Ipv4InterfaceAddress |
410 * \returns the Ipv4InterfaceAddress associated to the interface and addresInd
ex | 176 * \returns the Ipv4InterfaceAddress associated to the interface and addresInd
ex |
411 */ | 177 */ |
412 virtual Ipv4InterfaceAddress GetAddress (uint32_t interface, uint32_t addressI
ndex) const = 0; | 178 virtual Ipv4InterfaceAddress GetAddress (uint32_t interface, uint32_t addressI
ndex) const = 0; |
413 | 179 |
414 /** | 180 /** |
415 * \param i index of ipv4 interface | 181 * \param interface The interface number of an Ipv4 interface |
416 * \param metric routing metric (cost) associated to the underlying· | 182 * \param metric routing metric (cost) associated to the underlying· |
417 * ipv4 interface | 183 * Ipv4 interface |
418 */ | 184 */ |
419 virtual void SetMetric (uint32_t i, uint16_t metric) = 0; | 185 virtual void SetMetric (uint32_t interface, uint16_t metric) = 0; |
420 | 186 |
421 /** | 187 /** |
422 * \param i index of ipv4 interface | 188 * \param interface The interface number of an Ipv4 interface |
423 * \returns routing metric (cost) associated to the underlying· | 189 * \returns routing metric (cost) associated to the underlying· |
424 * ipv4 interface | 190 * Ipv4 interface |
425 */ | 191 */ |
426 virtual uint16_t GetMetric (uint32_t i) const = 0; | 192 virtual uint16_t GetMetric (uint32_t interface) const = 0; |
427 | 193 |
428 /** | 194 /** |
429 * \param destination The IP address of a hypothetical destination. | 195 * \param interface Interface number of Ipv4 interface |
430 * \returns The IP address assigned to the interface that will be used | 196 * \returns the Maximum Transmission Unit (in bytes) associated |
431 * if we were to send a packet to destination. | 197 * to the underlying Ipv4 interface |
432 * | |
433 * Note that the broadcast address for this interface may be fetched | |
434 * from the Ipv4Address object returned here using | |
435 * Ipv4Address::GetSubnetDirectedBroadcast(mask), where the mask for | |
436 * the interface may be retrived using Ipv4::GetNetworkMask(i). | |
437 */ | 198 */ |
438 virtual Ipv4Address GetSourceAddress (Ipv4Address destination) const = 0; | 199 virtual uint16_t GetMtu (uint32_t interface) const = 0; |
439 | 200 |
440 /** | 201 /** |
441 * \param dest The IP address of a hypothetical destination. | 202 * \param interface Interface number of Ipv4 interface |
442 * \param interface filled in with the interface index that will be used to | |
443 * send a packet to the hypothetical destination. | |
444 * \returns true if a single interface can be identified, false otherwise. | |
445 */ | |
446 virtual bool GetInterfaceForDestination (Ipv4Address dest, | |
447 uint32_t &interface) const = 0; | |
448 | |
449 /** | |
450 * \param i index of ipv4 interface | |
451 * \returns the Maximum Transmission Unit (in bytes) associated | |
452 * to the underlying ipv4 interface | |
453 */ | |
454 virtual uint16_t GetMtu (uint32_t i) const = 0; | |
455 | |
456 /** | |
457 * \param i index of ipv4 interface | |
458 * \returns true if the underlying interface is in the "up" state, | 203 * \returns true if the underlying interface is in the "up" state, |
459 * false otherwise. | 204 * false otherwise. |
460 */ | 205 */ |
461 virtual bool IsUp (uint32_t i) const = 0; | 206 virtual bool IsUp (uint32_t interface) const = 0; |
462 | 207 |
463 /** | 208 /** |
464 * \param i index of ipv4 interface | 209 * \param i interface Interface number of Ipv4 interface |
465 *· | 210 *· |
466 * Set the interface into the "up" state. In this state, it is | 211 * Set the interface into the "up" state. In this state, it is |
467 * considered valid during ipv4 forwarding. | 212 * considered valid during Ipv4 forwarding. |
468 */ | 213 */ |
469 virtual void SetUp (uint32_t i) = 0; | 214 virtual void SetUp (uint32_t interface) = 0; |
470 | 215 |
471 /** | 216 /** |
472 * \param i index of ipv4 interface | 217 * \param interface Interface number of Ipv4 interface |
473 * | 218 * |
474 * Set the interface into the "down" state. In this state, it is | 219 * Set the interface into the "down" state. In this state, it is |
475 * ignored during ipv4 forwarding. | 220 * ignored during Ipv4 forwarding. |
476 */ | 221 */ |
477 virtual void SetDown (uint32_t i) = 0; | 222 virtual void SetDown (uint32_t interface) = 0; |
478 | 223 |
479 /** | 224 static const uint32_t IF_ANY = 0xffffffff; |
480 * \brief Convenience function to return the interface corresponding | 225 |
481 * to the Ipv4Address provided | 226 private: |
482 * | 227 // Indirect the Ipv4 attributes through private pure virtual methods |
483 * \param addr Ipv4Address | 228 virtual void SetIpForward (bool forward) = 0; |
484 * \param mask corresponding Ipv4Mask | 229 virtual bool GetIpForward (void) const = 0; |
485 * \returns interface corresponding to a/amask | |
486 */ | |
487 virtual uint32_t GetInterfaceByAddress (Ipv4Address addr,· | |
488 Ipv4Mask mask = Ipv4Mask("255.255.255.255")); | |
489 }; | 230 }; |
490 | 231 |
491 } // namespace ns3· | 232 } // namespace ns3· |
492 | 233 |
493 #endif /* IPV4_H */ | 234 #endif /* IPV4_H */ |
OLD | NEW |