author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Sat, 04 Jul 2009 08:15:48 +0200 | |
changeset 4654 | 2eaebe77d66b |
parent 4526 | 4d3213e6eecd |
permissions | -rw-r--r-- |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
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> |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
23 |
#include <vector> |
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 |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
26 |
#include "ns3/ref-count-base.h" |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
#include "ipv4-address.h" |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
namespace ns3 { |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
30 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
31 |
class NetDevice; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
32 |
|
633
ecedbcb39fb7
Some dox additions/fixes
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
236
diff
changeset
|
33 |
/** |
4526 | 34 |
* \ingroup ipv4Routing |
4482 | 35 |
* |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
36 |
*\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
|
37 |
* |
4482 | 38 |
* This is a reference counted object. In the future, we will add other |
39 |
* 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
|
40 |
*/ |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
41 |
class Ipv4Route : public RefCountBase { |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
42 |
public: |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
43 |
Ipv4Route (); |
1445
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
44 |
|
4482 | 45 |
/** |
46 |
* \param dest Destination Ipv4Address |
|
47 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
48 |
void SetDestination (Ipv4Address dest); |
4482 | 49 |
/** |
50 |
* \return Destination Ipv4Address of the route |
|
51 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
52 |
Ipv4Address GetDestination (void) const; |
1445
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
53 |
|
4482 | 54 |
/** |
55 |
* \param src Source Ipv4Address |
|
56 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
57 |
void SetSource (Ipv4Address src); |
4482 | 58 |
/** |
59 |
* \return Source Ipv4Address of the route |
|
60 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
61 |
Ipv4Address GetSource (void) const; |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
62 |
|
4482 | 63 |
/** |
64 |
* \param gw Gateway (next hop) Ipv4Address |
|
65 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
66 |
void SetGateway (Ipv4Address gw); |
4482 | 67 |
/** |
68 |
* \return Ipv4Address of the gateway (next hop) |
|
69 |
*/ |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
70 |
Ipv4Address GetGateway (void) const; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
71 |
|
4482 | 72 |
/** |
73 |
* Equivalent in Linux to dst_entry.dev |
|
74 |
* |
|
75 |
* \param outputDevice pointer to NetDevice for outgoing packets |
|
76 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
77 |
void SetOutputDevice (Ptr<NetDevice> outputDevice); |
4482 | 78 |
/** |
79 |
* \return pointer to NetDevice for outgoing packets |
|
80 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
81 |
Ptr<NetDevice> GetOutputDevice (void) const; |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
82 |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
83 |
#ifdef NOTYET |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
84 |
// rtable.idev |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
85 |
void SetInputIfIndex (uint32_t iif); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
86 |
uint32_t GetInputIfIndex (void) const; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
87 |
#endif |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
88 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
89 |
private: |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
90 |
Ipv4Address m_dest; |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
91 |
Ipv4Address m_source; |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
92 |
Ipv4Address m_gateway; |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
93 |
Ptr<NetDevice> m_outputDevice; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
94 |
#ifdef NOTYET |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
95 |
uint32_t m_inputIfIndex; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
96 |
#endif |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
97 |
}; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
98 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
99 |
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
|
100 |
|
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
101 |
/** |
4526 | 102 |
* \ingroup ipv4Routing |
4482 | 103 |
* |
104 |
* \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
|
105 |
*/ |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
106 |
class Ipv4MulticastRoute : public RefCountBase { |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
107 |
public: |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
108 |
Ipv4MulticastRoute (); |
1445
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
109 |
|
4482 | 110 |
/** |
111 |
* \param group Ipv4Address of the multicast group |
|
112 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
113 |
void SetGroup (const Ipv4Address group); |
4482 | 114 |
/** |
115 |
* \return Ipv4Address of the multicast group |
|
116 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
117 |
Ipv4Address GetGroup (void) const; |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
118 |
|
4482 | 119 |
/** |
120 |
* \param origin Ipv4Address of the origin address |
|
121 |
*/ |
|
122 |
void SetOrigin (const Ipv4Address origin); |
|
123 |
/** |
|
124 |
* \return Ipv4Address of the origin address |
|
125 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
126 |
Ipv4Address GetOrigin (void) const; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
127 |
|
4482 | 128 |
/** |
129 |
* \param iif Parent (input interface) for this route |
|
130 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
131 |
void SetParent (uint32_t iif); |
4482 | 132 |
/** |
133 |
* \return Parent (input interface) for this route |
|
134 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
135 |
uint32_t GetParent (void) const; |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
136 |
|
4482 | 137 |
/** |
138 |
* \param oif Outgoing interface index |
|
139 |
* \param ttl time-to-live for this route |
|
140 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
141 |
void SetOutputTtl (uint32_t oif, uint32_t ttl); |
4482 | 142 |
/** |
143 |
* \param oif outgoing interface |
|
144 |
* \return TTL for this route |
|
145 |
*/ |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
146 |
uint32_t GetOutputTtl (uint32_t oif) const; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
147 |
|
4482 | 148 |
static const uint32_t MAX_INTERFACES = 16; // Maximum number of multicast interfaces on a router |
149 |
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
|
150 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
151 |
private: |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
152 |
Ipv4Address m_group; // Group |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
153 |
Ipv4Address m_origin; // Source of packet |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
154 |
uint32_t m_parent; // Source interface |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
3183
diff
changeset
|
155 |
std::vector<uint32_t> m_ttls; |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
156 |
}; |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
633
diff
changeset
|
157 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
158 |
}//namespace ns3 |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
159 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
160 |
#endif /* IPV4_ROUTE_H */ |