A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv4-route.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 University of Washington
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7#ifndef IPV4_ROUTE_H
8#define IPV4_ROUTE_H
9
10#include "ns3/ipv4-address.h"
11#include "ns3/simple-ref-count.h"
12
13#include <list>
14#include <map>
15#include <ostream>
16
17namespace ns3
18{
19
20class NetDevice;
21
22/**
23 * \ingroup ipv4Routing
24 *
25 * \brief IPv4 route cache entry (similar to Linux struct rtable)
26 *
27 * This is a reference counted object. In the future, we will add other
28 * entries from struct dst_entry, struct rtable, and struct dst_ops as needed.
29 */
30class Ipv4Route : public SimpleRefCount<Ipv4Route>
31{
32 public:
33 Ipv4Route();
34
35 /**
36 * \param dest Destination Ipv4Address
37 */
38 void SetDestination(Ipv4Address dest);
39 /**
40 * \return Destination Ipv4Address of the route
41 */
43
44 /**
45 * \param src Source Ipv4Address
46 */
47 void SetSource(Ipv4Address src);
48 /**
49 * \return Source Ipv4Address of the route
50 */
51 Ipv4Address GetSource() const;
52
53 /**
54 * \param gw Gateway (next hop) Ipv4Address
55 */
56 void SetGateway(Ipv4Address gw);
57 /**
58 * \return Ipv4Address of the gateway (next hop)
59 */
60 Ipv4Address GetGateway() const;
61
62 /**
63 * Equivalent in Linux to dst_entry.dev
64 *
65 * \param outputDevice pointer to NetDevice for outgoing packets
66 */
67 void SetOutputDevice(Ptr<NetDevice> outputDevice);
68 /**
69 * \return pointer to NetDevice for outgoing packets
70 */
72
73#ifdef NOTYET
74 // rtable.idev
75 void SetInputIfIndex(uint32_t iif);
76 uint32_t GetInputIfIndex() const;
77#endif
78
79 private:
80 Ipv4Address m_dest; //!< Destination address.
81 Ipv4Address m_source; //!< Source address.
82 Ipv4Address m_gateway; //!< Gateway address.
83 Ptr<NetDevice> m_outputDevice; //!< Output device.
84#ifdef NOTYET
85 uint32_t m_inputIfIndex;
86#endif
87};
88
89/**
90 * \brief Stream insertion operator.
91 *
92 * \param os the reference to the output stream
93 * \param route the Ipv4 route
94 * \returns the reference to the output stream
95 */
96std::ostream& operator<<(std::ostream& os, const Ipv4Route& route);
97
98/**
99 * \ingroup ipv4Routing
100 *
101 * \brief Ipv4 multicast route cache entry (similar to Linux struct mfc_cache)
102 */
103class Ipv4MulticastRoute : public SimpleRefCount<Ipv4MulticastRoute>
104{
105 public:
107
108 /**
109 * \param group Ipv4Address of the multicast group
110 */
111 void SetGroup(const Ipv4Address group);
112 /**
113 * \return Ipv4Address of the multicast group
114 */
115 Ipv4Address GetGroup() const;
116
117 /**
118 * \param origin Ipv4Address of the origin address
119 */
120 void SetOrigin(const Ipv4Address origin);
121 /**
122 * \return Ipv4Address of the origin address
123 */
124 Ipv4Address GetOrigin() const;
125
126 /**
127 * \param iif Parent (input interface) for this route
128 */
129 void SetParent(uint32_t iif);
130 /**
131 * \return Parent (input interface) for this route
132 */
133 uint32_t GetParent() const;
134
135 /**
136 * \param oif Outgoing interface index
137 * \param ttl time-to-live for this route
138 */
139 void SetOutputTtl(uint32_t oif, uint32_t ttl);
140
141 /**
142 * \return map of output interface Ids and TTLs for this route
143 */
144 std::map<uint32_t, uint32_t> GetOutputTtlMap() const;
145
147 16; //!< Maximum number of multicast interfaces on a router
148 static const uint32_t MAX_TTL = 255; //!< Maximum time-to-live (TTL)
149
150 private:
152 Ipv4Address m_origin; //!< Source of packet
153 uint32_t m_parent; //!< Source interface
154 std::map<uint32_t, uint32_t> m_ttls; //!< Time to Live container
155};
156
157} // namespace ns3
158
159#endif /* IPV4_ROUTE_H */
Ipv4 addresses are stored in host order in this class.
Ipv4 multicast route cache entry (similar to Linux struct mfc_cache)
Definition ipv4-route.h:104
uint32_t GetParent() const
Ipv4Address m_group
Group.
Definition ipv4-route.h:151
Ipv4Address GetGroup() const
std::map< uint32_t, uint32_t > GetOutputTtlMap() const
Ipv4Address GetOrigin() const
void SetOrigin(const Ipv4Address origin)
Ipv4Address m_origin
Source of packet.
Definition ipv4-route.h:152
void SetOutputTtl(uint32_t oif, uint32_t ttl)
void SetGroup(const Ipv4Address group)
Definition ipv4-route.cc:95
static const uint32_t MAX_INTERFACES
Maximum number of multicast interfaces on a router.
Definition ipv4-route.h:146
uint32_t m_parent
Source interface.
Definition ipv4-route.h:153
static const uint32_t MAX_TTL
Maximum time-to-live (TTL)
Definition ipv4-route.h:148
std::map< uint32_t, uint32_t > m_ttls
Time to Live container.
Definition ipv4-route.h:154
void SetParent(uint32_t iif)
IPv4 route cache entry (similar to Linux struct rtable)
Definition ipv4-route.h:31
Ipv4Address m_source
Source address.
Definition ipv4-route.h:81
void SetGateway(Ipv4Address gw)
Definition ipv4-route.cc:53
Ptr< NetDevice > GetOutputDevice() const
Definition ipv4-route.cc:74
Ipv4Address GetGateway() const
Definition ipv4-route.cc:60
void SetDestination(Ipv4Address dest)
Definition ipv4-route.cc:25
void SetSource(Ipv4Address src)
Definition ipv4-route.cc:39
Ipv4Address GetSource() const
Definition ipv4-route.cc:46
Ipv4Address m_gateway
Gateway address.
Definition ipv4-route.h:82
void SetOutputDevice(Ptr< NetDevice > outputDevice)
Equivalent in Linux to dst_entry.dev.
Definition ipv4-route.cc:67
Ipv4Address GetDestination() const
Definition ipv4-route.cc:32
Ptr< NetDevice > m_outputDevice
Output device.
Definition ipv4-route.h:83
Ipv4Address m_dest
Destination address.
Definition ipv4-route.h:80
Smart pointer class similar to boost::intrusive_ptr.
A template-based reference counting class.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148