|
|
| 76 |
/** |
76 |
/** |
| 77 |
* \brief Request that a packet be routed. |
77 |
* \brief Request that a packet be routed. |
| 78 |
* |
78 |
* |
| 79 |
* \param ifIndex The interface index on which the packet was received. |
79 |
* \param interfaceIndex The Ipv4 interface on which the packet was received. |
| 80 |
* \param ipHeader IP header of the packet |
80 |
* \param ipHeader IP header of the packet |
| 81 |
* \param packet packet that is being sent or forwarded |
81 |
* \param packet packet that is being sent or forwarded |
| 82 |
* \param routeReply callback that will receive the route reply |
82 |
* \param routeReply callback that will receive the route reply |
|
|
| 111 |
* destination will be serviced by cloning the packet and calling the |
111 |
* destination will be serviced by cloning the packet and calling the |
| 112 |
* route reply callback once for each outgoing interface in the route. |
112 |
* route reply callback once for each outgoing interface in the route. |
| 113 |
*/ |
113 |
*/ |
| 114 |
virtual bool RequestRoute (uint32_t ifIndex, |
114 |
virtual bool RequestRoute (uint32_t interfaceIndex, |
| 115 |
const Ipv4Header &ipHeader, |
115 |
const Ipv4Header &ipHeader, |
| 116 |
Ptr<Packet> packet, |
116 |
Ptr<Packet> packet, |
| 117 |
RouteReplyCallback routeReply) = 0; |
117 |
RouteReplyCallback routeReply) = 0; |
|
|
| 129 |
* routing protocols for what they would do if presented with a packet of the |
129 |
* routing protocols for what they would do if presented with a packet of the |
| 130 |
* given destination. |
130 |
* given destination. |
| 131 |
* |
131 |
* |
| 132 |
* Note that the a single interface index is returned. This means that if |
132 |
* Note that the a single interface index is returned, corresponding to an |
|
|
133 |
* Ipv4Interface index. This means that if |
| 133 |
* the destination address is a multicast, and an explicit route is present |
134 |
* the destination address is a multicast, and an explicit route is present |
| 134 |
* that includeds multiple output interfaces, that route cannot be used. |
135 |
* that includeds multiple output interfaces, that route cannot be used. |
| 135 |
* |
136 |
* |
|
|
| 139 |
* |
140 |
* |
| 140 |
* \param destination The Ipv4Address if the destination of a hypothetical |
141 |
* \param destination The Ipv4Address if the destination of a hypothetical |
| 141 |
* packet. This may be a multicast group address. |
142 |
* packet. This may be a multicast group address. |
| 142 |
* \param ifIndex A reference to the interface index over which a packet |
143 |
* \param interfaceIndex A reference to the interface index over which a packet |
| 143 |
* sent to this destination would be sent. |
144 |
* sent to this destination would be sent. |
| 144 |
* \return Returns true if a route is found to the destination that involves |
145 |
* \return Returns true if a route is found to the destination that involves |
| 145 |
* a single output interface index, otherwise false. |
146 |
* a single output interface index, otherwise false. |
|
|
| 149 |
* \see Ipv4L3Protocol |
150 |
* \see Ipv4L3Protocol |
| 150 |
*/ |
151 |
*/ |
| 151 |
virtual bool RequestIfIndex (Ipv4Address destination, |
152 |
virtual bool RequestIfIndex (Ipv4Address destination, |
| 152 |
uint32_t& ifIndex) = 0; |
153 |
uint32_t& interfaceIndex) = 0; |
| 153 |
|
154 |
|
| 154 |
static const uint32_t IF_INDEX_ANY = 0xffffffff; |
155 |
static const uint32_t IF_INDEX_ANY = 0xffffffff; |
| 155 |
}; |
156 |
}; |
| 156 |
|
157 |
|
| 157 |
/** |
158 |
/** |
| 158 |
* \brief Access to the Ipv4 forwarding table and to the ipv4 interfaces |
159 |
* \brief Access to the Ipv4 forwarding table and to the Ipv4 interfaces |
| 159 |
* |
160 |
* |
| 160 |
* This class allows you to create ipv4 interfaces based on a NetDevice. |
161 |
* This class allows you to create Ipv4 interfaces based on a NetDevice. |
| 161 |
* Multiple interfaces can be created for a single NetDevice, hence |
162 |
* An Ipv4Interface holds an Ipv4 address for the NetDevice (which |
| 162 |
* achieving multihoming. |
163 |
* does not know about IP). The interface indices at this layer |
| 163 |
* |
164 |
* may be different from the NetDevice ifIndex values, to allow for the |
| 164 |
* This class also allows you to control the content of the ipv4 |
165 |
* possibility of having more than one Ipv4Interface map to a NetDevice, |
|
|
166 |
* although presently only one Ipv4Interface may map to a NetDevice. |
| 167 |
* |
| 168 |
* This class also allows you to control the content of the Ipv4 |
| 165 |
* forwarding table. |
169 |
* forwarding table. |
| 166 |
*/ |
170 |
*/ |
| 167 |
class Ipv4 : public Object |
171 |
class Ipv4 : public Object |
|
|
| 187 |
/** |
191 |
/** |
| 188 |
* \param dest destination address |
192 |
* \param dest destination address |
| 189 |
* \param nextHop address of next hop. |
193 |
* \param nextHop address of next hop. |
| 190 |
* \param interface interface of next hop. |
194 |
* \param interfaceIndex interface of next hop. |
| 191 |
* |
195 |
* |
| 192 |
* Add route to host dest through host nextHop |
196 |
* Add route to host dest through host nextHop |
| 193 |
* on interface. |
197 |
* on interface. |
| 194 |
*/ |
198 |
*/ |
| 195 |
virtual void AddHostRouteTo (Ipv4Address dest, |
199 |
virtual void AddHostRouteTo (Ipv4Address dest, |
| 196 |
Ipv4Address nextHop, |
200 |
Ipv4Address nextHop, |
| 197 |
uint32_t interface) = 0; |
201 |
uint32_t interfaceIndex) = 0; |
| 198 |
/** |
202 |
/** |
| 199 |
* \param dest destination address |
203 |
* \param dest destination address |
| 200 |
* \param interface of next hop |
204 |
* \param interfaceIndex interface of next hop |
| 201 |
* |
205 |
* |
| 202 |
* add route to host dest on interface. |
206 |
* add route to host dest on interface. |
| 203 |
*/ |
207 |
*/ |
| 204 |
virtual void AddHostRouteTo (Ipv4Address dest, |
208 |
virtual void AddHostRouteTo (Ipv4Address dest, |
| 205 |
uint32_t interface) = 0; |
209 |
uint32_t interfaceIndex) = 0; |
| 206 |
|
210 |
|
| 207 |
/** |
211 |
/** |
| 208 |
* \param network destination network |
212 |
* \param network destination network |
| 209 |
* \param networkMask netmask of destination network |
213 |
* \param networkMask netmask of destination network |
| 210 |
* \param nextHop address of next hop |
214 |
* \param nextHop address of next hop |
| 211 |
* \param interface interface of next hop |
215 |
* \param interfaceIndex interface of next hop |
| 212 |
* |
216 |
* |
| 213 |
* add route to network dest with netmask |
217 |
* add route to network dest with netmask |
| 214 |
* through host nextHop on interface |
218 |
* through host nextHop on interface |
|
|
| 216 |
virtual void AddNetworkRouteTo (Ipv4Address network, |
220 |
virtual void AddNetworkRouteTo (Ipv4Address network, |
| 217 |
Ipv4Mask networkMask, |
221 |
Ipv4Mask networkMask, |
| 218 |
Ipv4Address nextHop, |
222 |
Ipv4Address nextHop, |
| 219 |
uint32_t interface) = 0; |
223 |
uint32_t interfaceIndex) = 0; |
| 220 |
|
224 |
|
| 221 |
/** |
225 |
/** |
| 222 |
* \param network destination network |
226 |
* \param network destination network |
| 223 |
* \param networkMask netmask of destination network |
227 |
* \param networkMask netmask of destination network |
| 224 |
* \param interface interface of next hop |
228 |
* \param interfaceIndex interface of next hop |
| 225 |
* |
229 |
* |
| 226 |
* add route to network dest with netmask |
230 |
* add route to network dest with netmask |
| 227 |
* on interface |
231 |
* on interface |
| 228 |
*/ |
232 |
*/ |
| 229 |
virtual void AddNetworkRouteTo (Ipv4Address network, |
233 |
virtual void AddNetworkRouteTo (Ipv4Address network, |
| 230 |
Ipv4Mask networkMask, |
234 |
Ipv4Mask networkMask, |
| 231 |
uint32_t interface) = 0; |
235 |
uint32_t interfaceIndex) = 0; |
| 232 |
/** |
236 |
/** |
| 233 |
* \param nextHop address of default next hop |
237 |
* \param nextHop address of default next hop |
| 234 |
* \param interface interface of default next hop. |
238 |
* \param interfaceIndex interface of default next hop. |
| 235 |
* |
239 |
* |
| 236 |
* set the default route to host nextHop on |
240 |
* set the default route to host nextHop on |
| 237 |
* interface. |
241 |
* interface. |
| 238 |
*/ |
242 |
*/ |
| 239 |
virtual void SetDefaultRoute (Ipv4Address nextHop, |
243 |
virtual void SetDefaultRoute (Ipv4Address nextHop, |
| 240 |
uint32_t interface) = 0; |
244 |
uint32_t interfaceIndex) = 0; |
| 241 |
|
245 |
|
| 242 |
/** |
246 |
/** |
| 243 |
* \returns the number of entries in the routing table. |
247 |
* \returns the number of entries in the routing table. |
|
|
| 306 |
virtual void RemoveMulticastRoute (uint32_t i) = 0; |
310 |
virtual void RemoveMulticastRoute (uint32_t i) = 0; |
| 307 |
|
311 |
|
| 308 |
/** |
312 |
/** |
| 309 |
* \param device device to add to the list of ipv4 interfaces |
313 |
* \param device device to add to the list of Ipv4 interfaces |
| 310 |
* which can be used as output interfaces during packet forwarding. |
314 |
* which can be used as output interfaces during packet forwarding. |
| 311 |
* \returns the index of the ipv4 interface added. |
315 |
* \returns the index of the Ipv4 interface added. |
| 312 |
* |
316 |
* |
| 313 |
* Once a device has been added, it can never be removed: if you want |
317 |
* Once a device has been added, it can never be removed: if you want |
| 314 |
* to disable it, you can invoke Ipv4::SetDown which will |
318 |
* to disable it, you can invoke Ipv4::SetDown which will |
|
|
| 322 |
virtual uint32_t GetNInterfaces (void) = 0; |
326 |
virtual uint32_t GetNInterfaces (void) = 0; |
| 323 |
|
327 |
|
| 324 |
/** |
328 |
/** |
| 325 |
* \brief Find and return the interface ID of the interface that has been |
329 |
* \brief Find and return the interface index of the interface that has been |
| 326 |
* assigned the specified IP address. |
330 |
* assigned the specified IP address. |
| 327 |
* \param addr The IP address assigned to the interface of interest. |
331 |
* \param addr The IP address assigned to the interface of interest. |
| 328 |
* \returns The index of the ipv4 interface with the given address. |
332 |
* \returns The index of the Ipv4 interface with the given address. |
| 329 |
* |
333 |
* |
| 330 |
* Each IP interface has an IP address associated with it. It is often |
334 |
* Each IP interface has an IP address associated with it. It is often |
| 331 |
* useful to search the list of interfaces for one that corresponds to |
335 |
* useful to search the list of interfaces for one that corresponds to |
|
|
| 336 |
virtual uint32_t FindInterfaceForAddr (Ipv4Address addr) const = 0; |
340 |
virtual uint32_t FindInterfaceForAddr (Ipv4Address addr) const = 0; |
| 337 |
|
341 |
|
| 338 |
/** |
342 |
/** |
| 339 |
* \brief Find and return the interface ID of the interface that has been |
343 |
* \brief Find and return the interface index of the interface that has been |
| 340 |
* assigned the specified (masked) IP address. |
344 |
* assigned the specified (masked) IP address. |
| 341 |
* \param addr The IP address assigned to the interface of interest. |
345 |
* \param addr The IP address assigned to the interface of interest. |
| 342 |
* \param mask The address mask to be used in address matching. |
346 |
* \param mask The address mask to be used in address matching. |
|
|
| 352 |
Ipv4Mask mask) const = 0; |
356 |
Ipv4Mask mask) const = 0; |
| 353 |
|
357 |
|
| 354 |
/** |
358 |
/** |
| 355 |
* \brief Find and return the interface ID of the interface that has been |
359 |
* \brief Find and return the interface index of the interface that has been |
| 356 |
* associated with the specified (masked) NetDevice |
360 |
* associated with the specified (masked) NetDevice |
| 357 |
* \param nd The net device of the interface of interest. |
361 |
* \param nd The net device of the interface of interest. |
| 358 |
* \returns The index of the ipv4 interface associated with the given net |
362 |
* \returns The index of the ipv4 interface associated with the given net |
|
|
| 367 |
virtual int32_t FindInterfaceForDevice(Ptr<NetDevice> nd) const = 0; |
371 |
virtual int32_t FindInterfaceForDevice(Ptr<NetDevice> nd) const = 0; |
| 368 |
|
372 |
|
| 369 |
/** |
373 |
/** |
| 370 |
* \param i index of ipv4 interface |
374 |
* \param i index of Ipv4 interface |
| 371 |
* \returns the NetDevice associated with the ipv4 interface index |
375 |
* \returns the NetDevice associated with the Ipv4 interface index |
| 372 |
*/ |
376 |
*/ |
| 373 |
virtual Ptr<NetDevice> GetNetDevice (uint32_t i) = 0; |
377 |
virtual Ptr<NetDevice> GetNetDevice (uint32_t i) = 0; |
| 374 |
|
378 |
|
|
|
| 437 |
|
441 |
|
| 438 |
/** |
442 |
/** |
| 439 |
* \param dest The IP address of a hypothetical destination. |
443 |
* \param dest The IP address of a hypothetical destination. |
| 440 |
* \param ifIndex filled in with the interface index that will be used to |
444 |
* \param interfaceIndex filled in with the interface index that will be used to |
| 441 |
* send a packet to the hypothetical destination. |
445 |
* send a packet to the hypothetical destination. |
| 442 |
* \returns true if a single interface can be identified, false otherwise. |
446 |
* \returns true if a single interface can be identified, false otherwise. |
| 443 |
*/ |
447 |
*/ |
| 444 |
virtual bool GetIfIndexForDestination (Ipv4Address dest, |
448 |
virtual bool GetIfIndexForDestination (Ipv4Address dest, |
| 445 |
uint32_t &ifIndex) const = 0; |
449 |
uint32_t &interfaceIndex) const = 0; |
| 446 |
|
450 |
|
| 447 |
/** |
451 |
/** |
| 448 |
* \param i index of ipv4 interface |
452 |
* \param i index of ipv4 interface |
|
|
| 475 |
virtual void SetDown (uint32_t i) = 0; |
479 |
virtual void SetDown (uint32_t i) = 0; |
| 476 |
|
480 |
|
| 477 |
/** |
481 |
/** |
| 478 |
* \brief Convenience function to return the ifIndex corresponding |
482 |
* \brief Convenience function to return the interfaceIndex corresponding |
| 479 |
* to the Ipv4Address provided |
483 |
* to the Ipv4Address provided |
| 480 |
* |
484 |
* |
| 481 |
* \param addr Ipv4Address |
485 |
* \param addr Ipv4Address |
| 482 |
* \param mask corresponding Ipv4Mask |
486 |
* \param mask corresponding Ipv4Mask |
| 483 |
* \returns ifIndex corresponding to a/amask |
487 |
* \returns interfaceIndex corresponding to a/amask |
| 484 |
*/ |
488 |
*/ |
| 485 |
virtual uint32_t GetIfIndexByAddress (Ipv4Address addr, |
489 |
virtual uint32_t GetIfIndexByAddress (Ipv4Address addr, |
| 486 |
Ipv4Mask mask = Ipv4Mask("255.255.255.255")); |
490 |
Ipv4Mask mask = Ipv4Mask("255.255.255.255")); |