author | Craig Dowell <craigdo@ee.washington.edu> |
Fri, 24 Aug 2007 17:38:49 -0700 | |
changeset 1441 | d6f8a7546e7f |
parent 1440 | c77745b2731c |
child 1442 | bb5cf98c0c64 |
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 |
// |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
// Copyright (c) 2006 Georgia Tech Research Corporation |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
// All rights reserved. |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
// |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
// 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
|
7 |
// 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
|
8 |
// published by the Free Software Foundation; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
// |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
// 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
|
11 |
// 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
|
12 |
// 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
|
13 |
// GNU General Public License for more details. |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
// |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
// 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
|
16 |
// 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
|
17 |
// 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
|
18 |
// |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
// Author: George F. Riley<riley@ece.gatech.edu> |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
// |
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 "ns3/packet.h" |
287
692ddac3794c
convert old TRACE code to use new NS_DEBUG macro
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
286
diff
changeset
|
23 |
#include "ns3/debug.h" |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
24 |
#include "ns3/composite-trace-resolver.h" |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
25 |
#include "ns3/array-trace-resolver.h" |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
26 |
#include "ns3/callback.h" |
524
082ffdd8fbd7
move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
514
diff
changeset
|
27 |
#include "ns3/ipv4-address.h" |
082ffdd8fbd7
move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
514
diff
changeset
|
28 |
#include "ns3/ipv4-route.h" |
729
b5e744285e92
rename i-node to node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
29 |
#include "ns3/node.h" |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
555
diff
changeset
|
30 |
#include "ns3/net-device.h" |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
31 |
|
733
fb1882e7d785
rename ipv4.h to ipv4-l3-protocol.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
32 |
#include "ipv4-l3-protocol.h" |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
#include "ipv4-l4-protocol.h" |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
34 |
#include "ipv4-header.h" |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
35 |
#include "ipv4-interface.h" |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
36 |
#include "ipv4-loopback-interface.h" |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
37 |
#include "arp-ipv4-interface.h" |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
38 |
#include "ipv4-l4-demux.h" |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
39 |
|
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
40 |
NS_DEBUG_COMPONENT_DEFINE ("Ipv4L3Protocol"); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
41 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
42 |
namespace ns3 { |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
43 |
|
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
983
diff
changeset
|
44 |
const InterfaceId Ipv4L3Protocol::iid = MakeInterfaceId ("Ipv4L3Protocol", Object::iid); |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
45 |
const uint16_t Ipv4L3Protocol::PROT_NUMBER = 0x0800; |
293
007bc9e735f3
remove Ipv4L3Protocol class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
287
diff
changeset
|
46 |
|
1229
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
47 |
Ipv4L3ProtocolTraceContextElement::Ipv4L3ProtocolTraceContextElement () |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
48 |
: m_type (TX) |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
49 |
{} |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
50 |
Ipv4L3ProtocolTraceContextElement::Ipv4L3ProtocolTraceContextElement (enum Type type) |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
51 |
: m_type (type) |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
52 |
{} |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
53 |
bool |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
54 |
Ipv4L3ProtocolTraceContextElement::IsTx (void) const |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
55 |
{ |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
56 |
return m_type == TX; |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
57 |
} |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
58 |
bool |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
59 |
Ipv4L3ProtocolTraceContextElement::IsRx (void) const |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
60 |
{ |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
61 |
return m_type == RX; |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
62 |
} |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
63 |
bool |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
64 |
Ipv4L3ProtocolTraceContextElement::IsDrop (void) const |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
65 |
{ |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
66 |
return m_type == DROP; |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
67 |
} |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
68 |
void |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
69 |
Ipv4L3ProtocolTraceContextElement::Print (std::ostream &os) const |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
70 |
{ |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
71 |
os << "ipv4="; |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
72 |
switch (m_type) |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
73 |
{ |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
74 |
case TX: |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
75 |
os << "tx"; |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
76 |
break; |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
77 |
case RX: |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
78 |
os << "rx"; |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
79 |
break; |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
80 |
case DROP: |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
81 |
os << "drop"; |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
82 |
break; |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
83 |
} |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
84 |
} |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
85 |
uint16_t |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
86 |
Ipv4L3ProtocolTraceContextElement::GetUid (void) |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
87 |
{ |
1235
dc52ea3507ff
TraceContextElement::Register -> TraceContextElement::AllocateUid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1229
diff
changeset
|
88 |
static uint16_t uid = AllocateUid<Ipv4L3ProtocolTraceContextElement> ("Ipv4L3ProtocolTraceContextElement"); |
1229
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
89 |
return uid; |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
90 |
} |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
91 |
|
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
92 |
|
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
93 |
Ipv4l3ProtocolInterfaceIndex::Ipv4l3ProtocolInterfaceIndex () |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
94 |
: m_index (0) |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
95 |
{} |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
96 |
Ipv4l3ProtocolInterfaceIndex::Ipv4l3ProtocolInterfaceIndex (uint32_t index) |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
97 |
: m_index (index) |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
98 |
{} |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
99 |
uint32_t |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
100 |
Ipv4l3ProtocolInterfaceIndex::Get (void) const |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
101 |
{ |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
102 |
return m_index; |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
103 |
} |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
104 |
void |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
105 |
Ipv4l3ProtocolInterfaceIndex::Print (std::ostream &os) const |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
106 |
{ |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
107 |
os << "ipv4-interface=" << m_index; |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
108 |
} |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
109 |
uint16_t |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
110 |
Ipv4l3ProtocolInterfaceIndex::GetUid (void) |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
111 |
{ |
1235
dc52ea3507ff
TraceContextElement::Register -> TraceContextElement::AllocateUid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1229
diff
changeset
|
112 |
static uint16_t uid = AllocateUid<Ipv4l3ProtocolInterfaceIndex> ("Ipv4l3ProtocolInterfaceIndex"); |
1229
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
113 |
return uid; |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
114 |
} |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
115 |
|
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
116 |
|
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
117 |
Ipv4L3Protocol::Ipv4L3Protocol(Ptr<Node> node) |
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
983
diff
changeset
|
118 |
: m_nInterfaces (0), |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
119 |
m_defaultTtl (64), |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
120 |
m_identification (0), |
241
9004ab4cfe17
add Ipv4 and Udp node capabilities, rework Copy methods to include an extra Node * argument
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
240
diff
changeset
|
121 |
m_node (node) |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
122 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
123 |
NS_DEBUG("Ipv4L3Protocol::Ipv4L3Protocol ()"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
124 |
|
1178
a40440a4b2fa
forgot to set the interface id
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1176
diff
changeset
|
125 |
SetInterfaceId (Ipv4L3Protocol::iid); |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
126 |
m_staticRouting = Create<Ipv4StaticRouting> (); |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
127 |
AddRoutingProtocol (m_staticRouting, 0); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
128 |
SetupLoopback (); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
129 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
130 |
|
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
131 |
Ipv4L3Protocol::~Ipv4L3Protocol () |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
132 |
{ |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
133 |
NS_DEBUG("Ipv4L3Protocol::~Ipv4L3Protocol ()"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
134 |
} |
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
135 |
|
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
136 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
137 |
Ipv4L3Protocol::DoDispose (void) |
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
138 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
139 |
NS_DEBUG("Ipv4L3Protocol::DoDispose ()"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
140 |
|
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
141 |
for (Ipv4InterfaceList::iterator i = m_interfaces.begin (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
142 |
i != m_interfaces.end (); i++) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
143 |
{ |
551
12ed30c77cab
revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
548
diff
changeset
|
144 |
delete (*i); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
145 |
} |
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
146 |
m_interfaces.clear (); |
555
4d3b2a77bc92
convert Node * to Ptr<Node>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
551
diff
changeset
|
147 |
m_node = 0; |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
148 |
m_staticRouting->Dispose (); |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
149 |
m_staticRouting = 0; |
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
983
diff
changeset
|
150 |
Object::DoDispose (); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
151 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
152 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
153 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
154 |
Ipv4L3Protocol::SetupLoopback (void) |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
155 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
156 |
NS_DEBUG("Ipv4L3Protocol::SetupLoopback ()"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
157 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
158 |
Ipv4LoopbackInterface * interface = new Ipv4LoopbackInterface (m_node); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
159 |
interface->SetAddress (Ipv4Address::GetLoopback ()); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
160 |
interface->SetNetworkMask (Ipv4Mask::GetLoopback ()); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
161 |
uint32_t index = AddIpv4Interface (interface); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
162 |
AddHostRouteTo (Ipv4Address::GetLoopback (), index); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
163 |
interface->SetUp (); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
164 |
} |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
165 |
|
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
166 |
TraceResolver * |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
167 |
Ipv4L3Protocol::CreateTraceResolver (TraceContext const &context) |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
168 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
169 |
NS_DEBUG("Ipv4L3Protocol::CreateTraceResolver ()"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
170 |
|
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
171 |
CompositeTraceResolver *resolver = new CompositeTraceResolver (context); |
1229
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
172 |
resolver->Add ("tx", m_txTrace, Ipv4L3ProtocolTraceContextElement(Ipv4L3ProtocolTraceContextElement::TX)); |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
173 |
resolver->Add ("rx", m_rxTrace, Ipv4L3ProtocolTraceContextElement(Ipv4L3ProtocolTraceContextElement::RX)); |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
174 |
resolver->Add ("drop", m_dropTrace, Ipv4L3ProtocolTraceContextElement (Ipv4L3ProtocolTraceContextElement::DROP)); |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
175 |
resolver->Add ("interfaces", |
1229
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
176 |
MakeCallback (&Ipv4L3Protocol::InterfacesCreateTraceResolver, this)); |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
177 |
return resolver; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
178 |
} |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
179 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
180 |
TraceResolver * |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
181 |
Ipv4L3Protocol::InterfacesCreateTraceResolver (TraceContext const &context) const |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
182 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
183 |
NS_DEBUG("Ipv4L3Protocol::InterfacesCreateTraceResolver ()"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
184 |
|
1229
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
185 |
ArrayTraceResolver<Ipv4Interface *, Ipv4l3ProtocolInterfaceIndex> *resolver = |
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
186 |
new ArrayTraceResolver<Ipv4Interface *,Ipv4l3ProtocolInterfaceIndex> |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
187 |
(context, |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
188 |
MakeCallback (&Ipv4L3Protocol::GetNInterfaces, this), |
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
189 |
MakeCallback (&Ipv4L3Protocol::GetInterface, this)); |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
190 |
return resolver; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
191 |
} |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
192 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
193 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
194 |
Ipv4L3Protocol::SetDefaultTtl (uint8_t ttl) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
195 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
196 |
NS_DEBUG("Ipv4L3Protocol::SetDefaultTtl ()"); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
197 |
m_defaultTtl = ttl; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
198 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
199 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
200 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
201 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
202 |
Ipv4L3Protocol::AddHostRouteTo (Ipv4Address dest, |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
203 |
Ipv4Address nextHop, |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
204 |
uint32_t interface) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
205 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
206 |
NS_DEBUG("Ipv4L3Protocol::AddHostRouteTo (" << dest << ", " << nextHop << |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
207 |
", " << interface << ")"); |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
208 |
m_staticRouting->AddHostRouteTo (dest, nextHop, interface); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
209 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
210 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
211 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
212 |
Ipv4L3Protocol::AddHostRouteTo (Ipv4Address dest, |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
213 |
uint32_t interface) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
214 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
215 |
NS_DEBUG("Ipv4L3Protocol::AddHostRouteTo (" << dest << ", " << |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
216 |
interface << ")"); |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
217 |
m_staticRouting->AddHostRouteTo (dest, interface); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
218 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
219 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
220 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
221 |
Ipv4L3Protocol::AddNetworkRouteTo (Ipv4Address network, |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
222 |
Ipv4Mask networkMask, |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
223 |
Ipv4Address nextHop, |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
224 |
uint32_t interface) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
225 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
226 |
NS_DEBUG("Ipv4L3Protocol::AddNetworkRouteTo (" << network << ", " << |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
227 |
networkMask << ", " << nextHop << ", " << interface << ")"); |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
228 |
m_staticRouting->AddNetworkRouteTo (network, networkMask, nextHop, interface); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
229 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
230 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
231 |
Ipv4L3Protocol::AddNetworkRouteTo (Ipv4Address network, |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
232 |
Ipv4Mask networkMask, |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
233 |
uint32_t interface) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
234 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
235 |
NS_DEBUG("Ipv4L3Protocol::AddNetworkRouteTo (" << network << ", " << |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
236 |
networkMask << ", " << interface << ")"); |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
237 |
m_staticRouting->AddNetworkRouteTo (network, networkMask, interface); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
238 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
239 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
240 |
Ipv4L3Protocol::SetDefaultRoute (Ipv4Address nextHop, |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
241 |
uint32_t interface) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
242 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
243 |
NS_DEBUG("Ipv4L3Protocol::SetDefaultRoute (" << nextHop << ", " << |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
244 |
interface << ")"); |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
245 |
m_staticRouting->SetDefaultRoute (nextHop, interface); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
246 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
247 |
|
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
248 |
void |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
249 |
Ipv4L3Protocol::Lookup ( |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
250 |
Ipv4Header const &ipHeader, |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
251 |
Packet packet, |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
252 |
Ipv4RoutingProtocol::RouteReplyCallback routeReply) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
253 |
{ |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
254 |
NS_DEBUG("Ipv4L3Protocol::Lookup (" << &ipHeader << |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
255 |
", " << &packet << &routeReply << ")"); |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
256 |
|
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
257 |
Lookup (Ipv4RoutingProtocol::IF_INDEX_ANY, ipHeader, packet, routeReply); |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
258 |
} |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
259 |
|
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
260 |
void |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
261 |
Ipv4L3Protocol::Lookup ( |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
262 |
uint32_t ifIndex, |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
263 |
Ipv4Header const &ipHeader, |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
264 |
Packet packet, |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
265 |
Ipv4RoutingProtocol::RouteReplyCallback routeReply) |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
266 |
{ |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
267 |
NS_DEBUG("Ipv4L3Protocol::Lookup (" << ifIndex << ", " << &ipHeader << |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
268 |
", " << &packet << &routeReply << ")"); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
269 |
|
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
270 |
for (Ipv4RoutingProtocolList::const_iterator rprotoIter = |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
271 |
m_routingProtocols.begin (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
272 |
rprotoIter != m_routingProtocols.end (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
273 |
rprotoIter++) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
274 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
275 |
NS_DEBUG("Ipv4L3Protocol::Lookup (): Requesting route"); |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
276 |
if ((*rprotoIter).second->RequestRoute (ifIndex, ipHeader, packet, |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
277 |
routeReply)) |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
278 |
return; |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
279 |
} |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
280 |
|
1440
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
281 |
if (ipHeader.GetDestination ().IsMulticast () && |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
282 |
ifIndex == Ipv4RoutingProtocol::IF_INDEX_ANY) |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
283 |
{ |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
284 |
NS_DEBUG ("Ipv4L3Protocol::Lookup (): " |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
285 |
"Multicast destination with local source"); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
286 |
// |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
287 |
// We have a multicast packet originating from the current node. We didn't |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
288 |
// want to force users to construct a route in order to get packets out of a |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
289 |
// node, so there will have been no route found and it is left to us to send |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
290 |
// the packet. What we'll do is to send the multicast out all of the |
1441
d6f8a7546e7f
semi-real multicast hardware addresses
Craig Dowell <craigdo@ee.washington.edu>
parents:
1440
diff
changeset
|
291 |
// interfaces on this node. Note that we start with interface 1 since we |
d6f8a7546e7f
semi-real multicast hardware addresses
Craig Dowell <craigdo@ee.washington.edu>
parents:
1440
diff
changeset
|
292 |
// don't particularly want to send the packet out the loopback. |
1440
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
293 |
// |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
294 |
NS_DEBUG ("Ipv4StaticRouting::Lookup (): " |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
295 |
"Local source. Flooding multicast packet"); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
296 |
|
1441
d6f8a7546e7f
semi-real multicast hardware addresses
Craig Dowell <craigdo@ee.washington.edu>
parents:
1440
diff
changeset
|
297 |
for (uint32_t i = 1; i < GetNInterfaces (); ++i) |
1440
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
298 |
{ |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
299 |
Packet p = packet; |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
300 |
Ipv4Header h = ipHeader; |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
301 |
Ipv4Route route = |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
302 |
Ipv4Route::CreateHostRouteTo(h.GetDestination (), i); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
303 |
NS_DEBUG ("Ipv4StaticRouting::Lookup (): " |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
304 |
"Send via interface " << i); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
305 |
routeReply (true, route, p, h); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
306 |
} |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
307 |
return; |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
308 |
} |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
309 |
// No route found |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
310 |
routeReply (false, Ipv4Route (), packet, ipHeader); |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
311 |
} |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
312 |
|
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
313 |
void |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
314 |
Ipv4L3Protocol::AddRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol, |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
315 |
int priority) |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
316 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
317 |
NS_DEBUG("Ipv4L3Protocol::AddRoutingProtocol (" << &routingProtocol << |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
318 |
", " << priority << ")"); |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
319 |
m_routingProtocols.push_back |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
320 |
(std::pair<int, Ptr<Ipv4RoutingProtocol> > (-priority, routingProtocol)); |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
321 |
m_routingProtocols.sort (); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
322 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
323 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
324 |
uint32_t |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
325 |
Ipv4L3Protocol::GetNRoutes (void) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
326 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
327 |
NS_DEBUG("Ipv4L3Protocol::GetNRoutes ()"); |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
328 |
return m_staticRouting->GetNRoutes (); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
329 |
} |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
330 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
331 |
Ipv4Route * |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
332 |
Ipv4L3Protocol::GetRoute (uint32_t index) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
333 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
334 |
NS_DEBUG("Ipv4L3Protocol::GetRoute ()"); |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
335 |
return m_staticRouting->GetRoute (index); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
336 |
} |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
337 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
338 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
339 |
Ipv4L3Protocol::RemoveRoute (uint32_t index) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
340 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
341 |
NS_DEBUG("Ipv4L3Protocol::RemoveRoute (" << index << ")"); |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
342 |
m_staticRouting->RemoveRoute (index); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
343 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
344 |
|
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
345 |
void |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
346 |
Ipv4L3Protocol::AddMulticastRoute (Ipv4Address origin, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
347 |
Ipv4Address group, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
348 |
uint32_t inputInterface, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
349 |
std::vector<uint32_t> outputInterfaces) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
350 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
351 |
NS_DEBUG("Ipv4L3Protocol::AddMulticastRoute (" << origin << ", " << |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
352 |
group << ", " << inputInterface << ", " << &outputInterfaces << ")"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
353 |
|
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
354 |
m_staticRouting->AddMulticastRoute (origin, group, inputInterface, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
355 |
outputInterfaces); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
356 |
} |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
357 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
358 |
uint32_t |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
359 |
Ipv4L3Protocol::GetNMulticastRoutes (void) const |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
360 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
361 |
NS_DEBUG("Ipv4L3Protocol::GetNMulticastRoutes ()"); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
362 |
return m_staticRouting->GetNMulticastRoutes (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
363 |
} |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
364 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
365 |
Ipv4MulticastRoute * |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
366 |
Ipv4L3Protocol::GetMulticastRoute (uint32_t index) const |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
367 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
368 |
NS_DEBUG("Ipv4L3Protocol::GetMulticastRoute (" << index << ")"); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
369 |
return m_staticRouting->GetMulticastRoute (index); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
370 |
} |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
371 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
372 |
void |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
373 |
Ipv4L3Protocol::RemoveMulticastRoute (Ipv4Address origin, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
374 |
Ipv4Address group, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
375 |
uint32_t inputInterface) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
376 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
377 |
NS_DEBUG("Ipv4L3Protocol::RemoveMulticastRoute (" << origin << ", " << |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
378 |
group << ", " << inputInterface << ")"); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
379 |
m_staticRouting->RemoveMulticastRoute (origin, group, inputInterface); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
380 |
} |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
381 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
382 |
void |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
383 |
Ipv4L3Protocol::RemoveMulticastRoute (uint32_t index) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
384 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
385 |
NS_DEBUG("Ipv4L3Protocol::RemoveMulticastRoute (" << index << ")"); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
386 |
m_staticRouting->RemoveMulticastRoute (index); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
387 |
} |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
388 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
389 |
uint32_t |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
390 |
Ipv4L3Protocol::AddInterface (Ptr<NetDevice> device) |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
391 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
392 |
NS_DEBUG("Ipv4L3Protocol::AddInterface (" << &device << ")"); |
551
12ed30c77cab
revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
548
diff
changeset
|
393 |
Ipv4Interface *interface = new ArpIpv4Interface (m_node, device); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
394 |
return AddIpv4Interface (interface); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
395 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
396 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
397 |
uint32_t |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
398 |
Ipv4L3Protocol::AddIpv4Interface (Ipv4Interface *interface) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
399 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
400 |
NS_DEBUG("Ipv4L3Protocol::AddIpv4Interface (" << interface << ")"); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
401 |
uint32_t index = m_nInterfaces; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
402 |
m_interfaces.push_back (interface); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
403 |
m_nInterfaces++; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
404 |
return index; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
405 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
406 |
|
551
12ed30c77cab
revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
548
diff
changeset
|
407 |
Ipv4Interface * |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
408 |
Ipv4L3Protocol::GetInterface (uint32_t index) const |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
409 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
410 |
NS_DEBUG("Ipv4L3Protocol::GetInterface (" << index << ")"); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
411 |
uint32_t tmp = 0; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
412 |
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
413 |
{ |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
414 |
if (index == tmp) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
415 |
{ |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
416 |
return *i; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
417 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
418 |
tmp++; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
419 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
420 |
return 0; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
421 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
422 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
423 |
uint32_t |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
424 |
Ipv4L3Protocol::GetNInterfaces (void) const |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
425 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
426 |
NS_DEBUG("Ipv4L3Protocol::GetNInterface ()"); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
427 |
return m_nInterfaces; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
428 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
429 |
|
1440
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
430 |
uint32_t |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
431 |
Ipv4L3Protocol::FindInterfaceForAddr (Ipv4Address addr) const |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
432 |
{ |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
433 |
NS_DEBUG("Ipv4L3Protocol::FindInterfaceForAddr (" << addr << ")"); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
434 |
|
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
435 |
uint32_t ifIndex = 0; |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
436 |
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
437 |
i != m_interfaces.end (); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
438 |
i++, ifIndex++) |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
439 |
{ |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
440 |
if ((*i)->GetAddress () == addr) |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
441 |
{ |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
442 |
return ifIndex; |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
443 |
} |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
444 |
} |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
445 |
|
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
446 |
NS_ASSERT_MSG(false, "Ipv4L3Protocol::FindInterfaceForAddr (): " |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
447 |
"Interface not found for IP address"); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
448 |
return 0; |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
449 |
} |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
450 |
|
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
451 |
uint32_t |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
452 |
Ipv4L3Protocol::FindInterfaceForAddr (Ipv4Address addr, Ipv4Mask mask) const |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
453 |
{ |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
454 |
NS_DEBUG("Ipv4L3Protocol::FindInterfaceForAddr (" << addr << ", " << |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
455 |
mask << ")"); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
456 |
|
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
457 |
uint32_t ifIndex = 0; |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
458 |
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
459 |
i != m_interfaces.end (); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
460 |
i++, ifIndex++) |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
461 |
{ |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
462 |
if ((*i)->GetAddress ().CombineMask (mask) == addr.CombineMask (mask)) |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
463 |
{ |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
464 |
return ifIndex; |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
465 |
} |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
466 |
} |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
467 |
|
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
468 |
NS_ASSERT_MSG(false, "Ipv4L3Protocol::FindInterfaceForAddr (): " |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
469 |
"Interface not found for masked IP address"); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
470 |
return 0; |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
471 |
} |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
472 |
|
551
12ed30c77cab
revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
548
diff
changeset
|
473 |
Ipv4Interface * |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
474 |
Ipv4L3Protocol::FindInterfaceForDevice (Ptr<const NetDevice> device) |
242
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
475 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
476 |
NS_DEBUG("Ipv4L3Protocol::FindInterfaceForDevice (" << &device << ")"); |
242
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
477 |
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++) |
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
478 |
{ |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
555
diff
changeset
|
479 |
if ((*i)->GetDevice () == device) |
242
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
480 |
{ |
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
481 |
return *i; |
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
482 |
} |
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
483 |
} |
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
484 |
return 0; |
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
485 |
} |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
486 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
487 |
void |
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1178
diff
changeset
|
488 |
Ipv4L3Protocol::Receive( Ptr<NetDevice> device, const Packet& p, uint16_t protocol, const Address &from) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
489 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
490 |
NS_DEBUG("Ipv4L3Protocol::Receive (" << &device << ", " << &p << ", " << |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
491 |
protocol << ", " << from << ")"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
492 |
|
457
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
493 |
uint32_t index = 0; |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
494 |
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
495 |
i != m_interfaces.end (); |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
496 |
i++) |
457
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
497 |
{ |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
555
diff
changeset
|
498 |
if ((*i)->GetDevice () == device) |
457
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
499 |
{ |
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
983
diff
changeset
|
500 |
m_rxTrace (p, index); |
457
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
501 |
break; |
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
502 |
} |
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
503 |
index++; |
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
504 |
} |
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
983
diff
changeset
|
505 |
Packet packet = p; |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
506 |
Ipv4Header ipHeader; |
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
461
diff
changeset
|
507 |
packet.RemoveHeader (ipHeader); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
508 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
509 |
if (!ipHeader.IsChecksumOk ()) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
510 |
{ |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
511 |
return; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
512 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
513 |
|
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
514 |
if (Forwarding (index, packet, ipHeader, device)) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
515 |
{ |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
516 |
return; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
517 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
518 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
519 |
ForwardUp (packet, ipHeader); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
520 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
521 |
|
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
522 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
523 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
524 |
Ipv4L3Protocol::Send (Packet const &packet, |
457
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
525 |
Ipv4Address source, |
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
526 |
Ipv4Address destination, |
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
527 |
uint8_t protocol) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
528 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
529 |
NS_DEBUG("Ipv4L3Protocol::Send (" << &packet << ", " << source << ", " << |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
530 |
", " << destination << ", " << protocol << ")"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
531 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
532 |
Ipv4Header ipHeader; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
533 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
534 |
ipHeader.SetSource (source); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
535 |
ipHeader.SetDestination (destination); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
536 |
ipHeader.SetProtocol (protocol); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
537 |
ipHeader.SetPayloadSize (packet.GetSize ()); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
538 |
ipHeader.SetTtl (m_defaultTtl); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
539 |
ipHeader.SetMayFragment (); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
540 |
ipHeader.SetIdentification (m_identification); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
541 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
542 |
m_identification ++; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
543 |
|
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
544 |
if (destination.IsBroadcast ()) |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
545 |
{ |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
546 |
uint32_t ifaceIndex = 0; |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
547 |
for (Ipv4InterfaceList::iterator ifaceIter = m_interfaces.begin (); |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
548 |
ifaceIter != m_interfaces.end (); ifaceIter++, ifaceIndex++) |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
549 |
{ |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
550 |
Ipv4Interface *outInterface = *ifaceIter; |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
551 |
Packet packetCopy = packet; |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
552 |
|
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
553 |
NS_ASSERT (packetCopy.GetSize () <= outInterface->GetMtu ()); |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
554 |
packetCopy.AddHeader (ipHeader); |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
555 |
m_txTrace (packetCopy, ifaceIndex); |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
556 |
outInterface->Send (packetCopy, destination); |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
557 |
} |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
558 |
} |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
559 |
else |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
560 |
{ |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
561 |
// XXX Note here that in most ipv4 stacks in the world, |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
562 |
// the route calculation for an outgoing packet is not |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
563 |
// done in the ip layer. It is done within the application |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
564 |
// socket when the first packet is sent to avoid this |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
565 |
// costly lookup on a per-packet basis. |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
566 |
// That would require us to get the route from the packet, |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
567 |
// most likely with a packet tag. The higher layers do not |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
568 |
// do this yet for us. |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
569 |
Lookup (ipHeader, packet, |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
570 |
MakeCallback (&Ipv4L3Protocol::SendRealOut, this)); |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
571 |
} |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
572 |
} |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
573 |
|
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
574 |
void |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
575 |
Ipv4L3Protocol::SendRealOut (bool found, |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
576 |
Ipv4Route const &route, |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
577 |
Packet packet, |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
578 |
Ipv4Header const &ipHeader) |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
579 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
580 |
NS_DEBUG("Ipv4L3Protocol::SendRealOut (" << found << ", " << &route << |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
581 |
", " << &packet << &ipHeader << ")"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
582 |
|
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
583 |
if (!found) |
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
584 |
{ |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
585 |
NS_DEBUG ("Ipv4L3Protocol::SendRealOut (): No route to host. Drop."); |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
586 |
m_dropTrace (packet); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
587 |
return; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
588 |
} |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
589 |
|
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
590 |
NS_DEBUG ("Ipv4L3Protocol::SendRealOut (): Send via interface " << |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
591 |
route.GetInterface ()); |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
592 |
|
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
593 |
packet.AddHeader (ipHeader); |
551
12ed30c77cab
revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
548
diff
changeset
|
594 |
Ipv4Interface *outInterface = GetInterface (route.GetInterface ()); |
286
57e6a2006962
convert use of <cassert> to "ns3/assert.h"
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
254
diff
changeset
|
595 |
NS_ASSERT (packet.GetSize () <= outInterface->GetMtu ()); |
457
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
596 |
m_txTrace (packet, route.GetInterface ()); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
597 |
if (route.IsGateway ()) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
598 |
{ |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
599 |
NS_DEBUG ("Ipv4L3Protocol::SendRealOut (): Send to gateway " << |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
600 |
route.GetGateway ()); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
601 |
outInterface->Send (packet, route.GetGateway ()); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
602 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
603 |
else |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
604 |
{ |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
605 |
NS_DEBUG ("Ipv4L3Protocol::SendRealOut (): Send to destination " << |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
606 |
ipHeader.GetDestination ()); |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
607 |
outInterface->Send (packet, ipHeader.GetDestination ()); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
608 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
609 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
610 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
611 |
bool |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
612 |
Ipv4L3Protocol::Forwarding ( |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
613 |
uint32_t ifIndex, |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
614 |
Packet const &packet, |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
615 |
Ipv4Header &ipHeader, |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
616 |
Ptr<NetDevice> device) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
617 |
{ |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
618 |
NS_DEBUG("Ipv4L3Protocol::Forwarding (" << ifIndex << ", " << &packet << |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
619 |
", " << &ipHeader << ", " << device << ")"); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
620 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
621 |
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
622 |
i != m_interfaces.end (); i++) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
623 |
{ |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
624 |
if ((*i)->GetAddress ().IsEqual (ipHeader.GetDestination ())) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
625 |
{ |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
626 |
NS_DEBUG("Ipv4L3Protocol::Forwarding (): " |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
627 |
"For me (destination match)"); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
628 |
return false; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
629 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
630 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
631 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
632 |
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
633 |
i != m_interfaces.end (); i++) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
634 |
{ |
551
12ed30c77cab
revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
548
diff
changeset
|
635 |
Ipv4Interface *interface = *i; |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
555
diff
changeset
|
636 |
if (interface->GetDevice () == device) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
637 |
{ |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
638 |
if (ipHeader.GetDestination ().IsEqual (interface->GetBroadcast ())) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
639 |
{ |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
640 |
NS_DEBUG("Ipv4L3Protocol::Forwarding (): " |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
641 |
"For me (interface broadcast address)"); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
642 |
return false; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
643 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
644 |
break; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
645 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
646 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
647 |
|
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
648 |
if (ipHeader.GetDestination ().IsBroadcast ()) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
649 |
{ |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
650 |
NS_DEBUG("Ipv4L3Protocol::Forwarding (): " |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
651 |
"For me (Ipv4Addr broadcast address)"); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
652 |
return false; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
653 |
} |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
654 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
655 |
if (ipHeader.GetDestination ().IsEqual (Ipv4Address::GetAny ())) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
656 |
{ |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
657 |
NS_DEBUG("Ipv4L3Protocol::Forwarding (): " |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
658 |
"For me (Ipv4Addr any address)"); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
659 |
return false; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
660 |
} |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
661 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
662 |
if (ipHeader.GetTtl () == 1) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
663 |
{ |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
664 |
// Should send ttl expired here |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
665 |
// XXX |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
666 |
NS_DEBUG("Ipv4L3Protocol::Forwarding (): " |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
667 |
"Not for me (TTL expired). Drop"); |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
293
diff
changeset
|
668 |
m_dropTrace (packet); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
669 |
return true; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
670 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
671 |
ipHeader.SetTtl (ipHeader.GetTtl () - 1); |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
672 |
|
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
673 |
NS_DEBUG("Ipv4L3Protocol::Forwarding (): Forwarding packet."); |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
674 |
Lookup (ifIndex, ipHeader, packet, |
983
47c42bd66fb7
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
979
diff
changeset
|
675 |
MakeCallback (&Ipv4L3Protocol::SendRealOut, this)); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
676 |
// |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
677 |
// If this is a to a multicast address and this node is a member of the |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
678 |
// indicated group we need to return false so the multicast is forwarded up. |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
679 |
// Note that we may have just forwarded this packet too. |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
680 |
// |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
681 |
for (Ipv4MulticastGroupList::const_iterator i = m_multicastGroups.begin (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
682 |
i != m_multicastGroups.end (); i++) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
683 |
{ |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
684 |
if ((*i).first.IsEqual (ipHeader.GetSource ()) && |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
685 |
(*i).second.IsEqual (ipHeader.GetDestination ())) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
686 |
{ |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
687 |
NS_DEBUG("Ipv4L3Protocol::Forwarding (): " |
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
688 |
"For me (Joined multicast group)"); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
689 |
return false; |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
690 |
} |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
691 |
} |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
692 |
|
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
693 |
NS_DEBUG("Ipv4L3Protocol::Forwarding (): Not for me."); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
694 |
return true; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
695 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
696 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
697 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
698 |
Ipv4L3Protocol::ForwardUp (Packet p, Ipv4Header const&ip) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
699 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
700 |
NS_DEBUG("Ipv4L3Protocol::ForwardUp (" << &p << ", " << &ip << ")"); |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
555
diff
changeset
|
701 |
Ptr<Ipv4L4Demux> demux = m_node->QueryInterface<Ipv4L4Demux> (Ipv4L4Demux::iid); |
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
555
diff
changeset
|
702 |
Ptr<Ipv4L4Protocol> protocol = demux->GetProtocol (ip.GetProtocol ()); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
703 |
protocol->Receive (p, ip.GetSource (), ip.GetDestination ()); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
704 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
705 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
706 |
void |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
707 |
Ipv4L3Protocol::JoinMulticastGroup (Ipv4Address origin, Ipv4Address group) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
708 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
709 |
NS_DEBUG("Ipv4L3Protocol::JoinMulticastGroup (" << origin << ", " << |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
710 |
group << ")"); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
711 |
m_multicastGroups.push_back( |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
712 |
std::pair<Ipv4Address, Ipv4Address> (origin, group)); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
713 |
} |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
714 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
715 |
void |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
716 |
Ipv4L3Protocol::LeaveMulticastGroup (Ipv4Address origin, Ipv4Address group) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
717 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
718 |
NS_DEBUG("Ipv4L3Protocol::LeaveMulticastGroup (" << origin << ", " << |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
719 |
group << ")"); |
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
720 |
|
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
721 |
for (Ipv4MulticastGroupList::iterator i = m_multicastGroups.begin (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
722 |
i != m_multicastGroups.end (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
723 |
i++) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
724 |
{ |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
725 |
if ((*i).first.IsEqual(origin) && (*i).second.IsEqual(group)) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
726 |
{ |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
727 |
m_multicastGroups.erase (i); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
728 |
return; |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
729 |
} |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
730 |
} |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
731 |
} |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
732 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
733 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
734 |
Ipv4L3Protocol::SetAddress (uint32_t i, Ipv4Address address) |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
735 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
736 |
NS_DEBUG("Ipv4L3Protocol::SetAddress (" << i << ", " << address << ")"); |
551
12ed30c77cab
revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
548
diff
changeset
|
737 |
Ipv4Interface *interface = GetInterface (i); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
738 |
interface->SetAddress (address); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
739 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
740 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
741 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
742 |
Ipv4L3Protocol::SetNetworkMask (uint32_t i, Ipv4Mask mask) |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
743 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
744 |
NS_DEBUG("Ipv4L3Protocol::SetNetworkMask (" << i << ", " << mask << ")"); |
551
12ed30c77cab
revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
548
diff
changeset
|
745 |
Ipv4Interface *interface = GetInterface (i); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
746 |
interface->SetNetworkMask (mask); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
747 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
748 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
749 |
Ipv4Mask |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
750 |
Ipv4L3Protocol::GetNetworkMask (uint32_t i) const |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
751 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
752 |
NS_DEBUG("Ipv4L3Protocol::GetNetworkMask (" << i << ")"); |
551
12ed30c77cab
revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
548
diff
changeset
|
753 |
Ipv4Interface *interface = GetInterface (i); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
754 |
return interface->GetNetworkMask (); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
755 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
756 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
757 |
Ipv4Address |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
758 |
Ipv4L3Protocol::GetAddress (uint32_t i) const |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
759 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
760 |
NS_DEBUG("Ipv4L3Protocol::GetAddress (" << i << ")"); |
551
12ed30c77cab
revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
548
diff
changeset
|
761 |
Ipv4Interface *interface = GetInterface (i); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
762 |
return interface->GetAddress (); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
763 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
764 |
|
1434
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
765 |
bool |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
766 |
Ipv4L3Protocol::GetIfIndexForDestination ( |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
767 |
Ipv4Address destination, uint32_t& ifIndex) const |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
768 |
{ |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
769 |
NS_DEBUG("Ipv4L3Protocol::GetIfIndexForDestination (" << destination << |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
770 |
", " << &ifIndex << ")"); |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
771 |
|
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
772 |
for (Ipv4RoutingProtocolList::const_iterator i = m_routingProtocols.begin (); |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
773 |
i != m_routingProtocols.end (); |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
774 |
i++) |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
775 |
{ |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
776 |
NS_DEBUG("Ipv4L3Protocol::Lookup (): Requesting Source Address"); |
1435
a70de165a25a
set source IP address in udp-socket packets
Craig Dowell <craigdo@ee.washington.edu>
parents:
1434
diff
changeset
|
777 |
uint32_t ifIndexTmp; |
1434
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
778 |
|
1435
a70de165a25a
set source IP address in udp-socket packets
Craig Dowell <craigdo@ee.washington.edu>
parents:
1434
diff
changeset
|
779 |
if ((*i).second->RequestIfIndex (destination, ifIndexTmp)) |
1434
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
780 |
{ |
1435
a70de165a25a
set source IP address in udp-socket packets
Craig Dowell <craigdo@ee.washington.edu>
parents:
1434
diff
changeset
|
781 |
NS_DEBUG("Ipv4L3Protocol::GetIfIndexForDestination (): " |
a70de165a25a
set source IP address in udp-socket packets
Craig Dowell <craigdo@ee.washington.edu>
parents:
1434
diff
changeset
|
782 |
"Found ifIndex " << ifIndexTmp); |
a70de165a25a
set source IP address in udp-socket packets
Craig Dowell <craigdo@ee.washington.edu>
parents:
1434
diff
changeset
|
783 |
ifIndex = ifIndexTmp; |
1434
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
784 |
return true; |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
785 |
} |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
786 |
} |
1440
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
787 |
// |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
788 |
// If there's no routing table entry telling us what single interface will be |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
789 |
// used to send a packet to this destination, we'll have to just pick one. |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
790 |
// If there's only one interface on this node, a good answer isn't very hard |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
791 |
// to come up with. Before jumping to any conclusions, remember that the |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
792 |
// zeroth interface is the loopback interface, so what we actually want is |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
793 |
// a situation where there are exactly two interfaces on the node, in which |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
794 |
// case interface one is the "single" interface. |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
795 |
// |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
796 |
if (GetNInterfaces () == 2) |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
797 |
{ |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
798 |
NS_DEBUG("Ipv4L3Protocol::GetIfIndexForDestination (): " |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
799 |
"One Interface. Using interface 1."); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
800 |
ifIndex = 1; |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
801 |
return true; |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
802 |
} |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
803 |
// |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
804 |
// If we fall through to here, we have a node with multiple interfaces and |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
805 |
// no routes to guide us in determining what interface to choose. The last |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
806 |
// choice is to use the one set in the default route. |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
807 |
// |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
808 |
NS_DEBUG("Ipv4L3Protocol::GetIfIndexForDestination (): " |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
809 |
"Using default route"); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
810 |
Ipv4Route *route = m_staticRouting->GetDefaultRoute (); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
811 |
|
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
812 |
NS_ASSERT_MSG(route, |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
813 |
"Ipv4L3Protocol::GetIfIndexForDestination (): " |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
814 |
"Unable to determine outbound interface. No default route set"); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
815 |
|
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
816 |
ifIndex = route->GetInterface (); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
817 |
|
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
818 |
NS_DEBUG("Ipv4L3Protocol::GetIfIndexForDestination (): " |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
819 |
"Default route specifies interface " << ifIndex); |
c77745b2731c
add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents:
1435
diff
changeset
|
820 |
return true; |
1434
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
821 |
} |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
822 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
823 |
uint16_t |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
824 |
Ipv4L3Protocol::GetMtu (uint32_t i) const |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
825 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
826 |
NS_DEBUG("Ipv4L3Protocol::GetMtu (" << i << ")"); |
551
12ed30c77cab
revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
548
diff
changeset
|
827 |
Ipv4Interface *interface = GetInterface (i); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
828 |
return interface->GetMtu (); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
829 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
830 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
831 |
bool |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
832 |
Ipv4L3Protocol::IsUp (uint32_t i) const |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
833 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
834 |
NS_DEBUG("Ipv4L3Protocol::IsUp (" << i << ")"); |
551
12ed30c77cab
revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
548
diff
changeset
|
835 |
Ipv4Interface *interface = GetInterface (i); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
836 |
return interface->IsUp (); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
837 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
838 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
839 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
840 |
Ipv4L3Protocol::SetUp (uint32_t i) |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
841 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
842 |
NS_DEBUG("Ipv4L3Protocol::SetUp (" << i << ")"); |
551
12ed30c77cab
revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
548
diff
changeset
|
843 |
Ipv4Interface *interface = GetInterface (i); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
844 |
interface->SetUp (); |
979
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
845 |
|
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
846 |
// If interface address and network mask have been set, add a route |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
847 |
// to the network of the interface (like e.g. ifconfig does on a |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
848 |
// Linux box) |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
849 |
if ((interface->GetAddress ()) != (Ipv4Address ()) |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
850 |
&& (interface->GetNetworkMask ()) != (Ipv4Mask ())) |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
851 |
{ |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
852 |
AddNetworkRouteTo (interface->GetAddress ().CombineMask (interface->GetNetworkMask ()), |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
853 |
interface->GetNetworkMask (), i); |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
854 |
} |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
855 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
856 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
857 |
void |
979
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
858 |
Ipv4L3Protocol::SetDown (uint32_t ifaceIndex) |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
859 |
{ |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
860 |
NS_DEBUG("Ipv4L3Protocol::SetDown (" << ifaceIndex << ")"); |
979
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
861 |
Ipv4Interface *interface = GetInterface (ifaceIndex); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
862 |
interface->SetDown (); |
979
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
863 |
|
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
864 |
// Remove all routes that are going through this interface |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
865 |
bool modified = true; |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
866 |
while (modified) |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
867 |
{ |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
868 |
modified = false; |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
869 |
for (uint32_t i = 0; i < GetNRoutes (); i++) |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
870 |
{ |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
871 |
Ipv4Route *route = GetRoute (i); |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
872 |
if (route->GetInterface () == ifaceIndex) |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
873 |
{ |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
874 |
RemoveRoute (i); |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
875 |
modified = true; |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
876 |
break; |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
877 |
} |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
878 |
} |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
879 |
} |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
880 |
} |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
881 |
|
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
882 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
883 |
}//namespace ns3 |