author | Adrian S Tam <adrian.sw.tam@gmail.com> |
Wed, 07 Dec 2011 11:22:10 -0500 | |
changeset 7619 | b4dee6307aa7 |
parent 7386 | 2310ed220a61 |
child 9871 | 90c92578f680 |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7256
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
3 |
* Copyright (c) 2009 University of Washington |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
*/ |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
#ifndef IPV4_ROUTE_H |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
#define IPV4_ROUTE_H |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
#include <list> |
7161
7cc4506fb853
bug 1047: Multicast routes on nodes with >16 interfaces
Ken Renard <kenneth.renard@arl.army.mil>
parents:
6834
diff
changeset
|
23 |
#include <map> |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
#include <ostream> |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
|
5505
c0ac392289c3
replace RefCountBase with SimpleRefCount<> to avoid duplicate refcounting implementations.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4526
diff
changeset
|
26 |
#include "ns3/simple-ref-count.h" |
6823
a27f86fb4e55
Merge node and common modules into new network module
Tom Henderson <tomh@tomh.org>
parents:
5505
diff
changeset
|
27 |
#include "ns3/ipv4-address.h" |
7161
7cc4506fb853
bug 1047: Multicast routes on nodes with >16 interfaces
Ken Renard <kenneth.renard@arl.army.mil>
parents:
6834
diff
changeset
|
28 |
#include "ns3/deprecated.h" |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
namespace ns3 { |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
31 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
32 |
class NetDevice; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
33 |
|
633
ecedbcb39fb7
Some dox additions/fixes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
236
diff
changeset
|
34 |
/** |
4526 | 35 |
* \ingroup ipv4Routing |
4482 | 36 |
* |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
37 |
*\brief Ipv4 route cache entry (similar to Linux struct rtable) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
38 |
* |
4482 | 39 |
* This is a reference counted object. In the future, we will add other |
40 |
* entries from struct dst_entry, struct rtable, and struct dst_ops as needed. |
|
633
ecedbcb39fb7
Some dox additions/fixes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
236
diff
changeset
|
41 |
*/ |
5505
c0ac392289c3
replace RefCountBase with SimpleRefCount<> to avoid duplicate refcounting implementations.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4526
diff
changeset
|
42 |
class Ipv4Route : public SimpleRefCount<Ipv4Route> |
c0ac392289c3
replace RefCountBase with SimpleRefCount<> to avoid duplicate refcounting implementations.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4526
diff
changeset
|
43 |
{ |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
44 |
public: |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
45 |
Ipv4Route (); |
1445
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
46 |
|
4482 | 47 |
/** |
48 |
* \param dest Destination Ipv4Address |
|
49 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
50 |
void SetDestination (Ipv4Address dest); |
4482 | 51 |
/** |
52 |
* \return Destination Ipv4Address of the route |
|
53 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
54 |
Ipv4Address GetDestination (void) const; |
1445
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
55 |
|
4482 | 56 |
/** |
57 |
* \param src Source Ipv4Address |
|
58 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
59 |
void SetSource (Ipv4Address src); |
4482 | 60 |
/** |
61 |
* \return Source Ipv4Address of the route |
|
62 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
63 |
Ipv4Address GetSource (void) const; |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
64 |
|
4482 | 65 |
/** |
66 |
* \param gw Gateway (next hop) Ipv4Address |
|
67 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
68 |
void SetGateway (Ipv4Address gw); |
4482 | 69 |
/** |
70 |
* \return Ipv4Address of the gateway (next hop) |
|
71 |
*/ |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
72 |
Ipv4Address GetGateway (void) const; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
73 |
|
4482 | 74 |
/** |
75 |
* Equivalent in Linux to dst_entry.dev |
|
76 |
* |
|
77 |
* \param outputDevice pointer to NetDevice for outgoing packets |
|
78 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
79 |
void SetOutputDevice (Ptr<NetDevice> outputDevice); |
4482 | 80 |
/** |
81 |
* \return pointer to NetDevice for outgoing packets |
|
82 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
83 |
Ptr<NetDevice> GetOutputDevice (void) const; |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
84 |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
85 |
#ifdef NOTYET |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
86 |
// rtable.idev |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
87 |
void SetInputIfIndex (uint32_t iif); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
88 |
uint32_t GetInputIfIndex (void) const; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
89 |
#endif |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
90 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
91 |
private: |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
92 |
Ipv4Address m_dest; |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
93 |
Ipv4Address m_source; |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
94 |
Ipv4Address m_gateway; |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
95 |
Ptr<NetDevice> m_outputDevice; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
96 |
#ifdef NOTYET |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
97 |
uint32_t m_inputIfIndex; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
98 |
#endif |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
99 |
}; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
100 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
101 |
std::ostream& operator<< (std::ostream& os, Ipv4Route const& route); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
102 |
|
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
103 |
/** |
4526 | 104 |
* \ingroup ipv4Routing |
4482 | 105 |
* |
106 |
* \brief Ipv4 multicast route cache entry (similar to Linux struct mfc_cache) |
|
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
107 |
*/ |
5505
c0ac392289c3
replace RefCountBase with SimpleRefCount<> to avoid duplicate refcounting implementations.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4526
diff
changeset
|
108 |
class Ipv4MulticastRoute : public SimpleRefCount<Ipv4MulticastRoute> |
c0ac392289c3
replace RefCountBase with SimpleRefCount<> to avoid duplicate refcounting implementations.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4526
diff
changeset
|
109 |
{ |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
110 |
public: |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
111 |
Ipv4MulticastRoute (); |
1445
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
112 |
|
4482 | 113 |
/** |
114 |
* \param group Ipv4Address of the multicast group |
|
115 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
116 |
void SetGroup (const Ipv4Address group); |
4482 | 117 |
/** |
118 |
* \return Ipv4Address of the multicast group |
|
119 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
120 |
Ipv4Address GetGroup (void) const; |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
121 |
|
4482 | 122 |
/** |
123 |
* \param origin Ipv4Address of the origin address |
|
124 |
*/ |
|
125 |
void SetOrigin (const Ipv4Address origin); |
|
126 |
/** |
|
127 |
* \return Ipv4Address of the origin address |
|
128 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
129 |
Ipv4Address GetOrigin (void) const; |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7161
diff
changeset
|
130 |
|
4482 | 131 |
/** |
132 |
* \param iif Parent (input interface) for this route |
|
133 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
134 |
void SetParent (uint32_t iif); |
4482 | 135 |
/** |
136 |
* \return Parent (input interface) for this route |
|
137 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
138 |
uint32_t GetParent (void) const; |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
139 |
|
4482 | 140 |
/** |
141 |
* \param oif Outgoing interface index |
|
142 |
* \param ttl time-to-live for this route |
|
143 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
144 |
void SetOutputTtl (uint32_t oif, uint32_t ttl); |
4482 | 145 |
/** |
146 |
* \param oif outgoing interface |
|
147 |
* \return TTL for this route |
|
148 |
*/ |
|
7161
7cc4506fb853
bug 1047: Multicast routes on nodes with >16 interfaces
Ken Renard <kenneth.renard@arl.army.mil>
parents:
6834
diff
changeset
|
149 |
uint32_t GetOutputTtl (uint32_t oif) NS_DEPRECATED; |
7cc4506fb853
bug 1047: Multicast routes on nodes with >16 interfaces
Ken Renard <kenneth.renard@arl.army.mil>
parents:
6834
diff
changeset
|
150 |
|
7cc4506fb853
bug 1047: Multicast routes on nodes with >16 interfaces
Ken Renard <kenneth.renard@arl.army.mil>
parents:
6834
diff
changeset
|
151 |
/** |
7cc4506fb853
bug 1047: Multicast routes on nodes with >16 interfaces
Ken Renard <kenneth.renard@arl.army.mil>
parents:
6834
diff
changeset
|
152 |
* \return map of output interface Ids and TTLs for this route |
7cc4506fb853
bug 1047: Multicast routes on nodes with >16 interfaces
Ken Renard <kenneth.renard@arl.army.mil>
parents:
6834
diff
changeset
|
153 |
*/ |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
154 |
std::map<uint32_t, uint32_t> GetOutputTtlMap () const; |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7161
diff
changeset
|
155 |
|
4482 | 156 |
static const uint32_t MAX_INTERFACES = 16; // Maximum number of multicast interfaces on a router |
157 |
static const uint32_t MAX_TTL = 255; // Maximum time-to-live (TTL) |
|
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
158 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
159 |
private: |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
160 |
Ipv4Address m_group; // Group |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
161 |
Ipv4Address m_origin; // Source of packet |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
162 |
uint32_t m_parent; // Source interface |
7161
7cc4506fb853
bug 1047: Multicast routes on nodes with >16 interfaces
Ken Renard <kenneth.renard@arl.army.mil>
parents:
6834
diff
changeset
|
163 |
std::map<uint32_t, uint32_t> m_ttls; |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
164 |
}; |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
165 |
|
7386
2310ed220a61
standardize ns-3 namespace declaration format
Vedran Miletić <rivanvx@gmail.com>
parents:
7385
diff
changeset
|
166 |
} // namespace ns3 |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
167 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
168 |
#endif /* IPV4_ROUTE_H */ |