author | Craig Dowell <craigdo@ee.washington.edu> |
Wed, 29 Oct 2008 11:18:39 -0700 | |
changeset 3820 | c04ecfdce1ef |
parent 3744 | bb6876ea0851 |
child 3877 | 5091e3a14b26 |
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 |
// |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
// This program is free software; you can redistribute it and/or modify |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
// it under the terms of the GNU General Public License version 2 as |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
// published by the Free Software Foundation; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
// |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
// This program is distributed in the hope that it will be useful, |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
// GNU General Public License for more details. |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
// |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
// You should have received a copy of the GNU General Public License |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
// along with this program; if not, write to the Free Software |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
// |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
// Author: George F. Riley<riley@ece.gatech.edu> |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
// |
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 |
#include "ns3/packet.h" |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
22 |
#include "ns3/log.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
|
23 |
#include "ns3/callback.h" |
524
082ffdd8fbd7
move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
514
diff
changeset
|
24 |
#include "ns3/ipv4-address.h" |
082ffdd8fbd7
move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
514
diff
changeset
|
25 |
#include "ns3/ipv4-route.h" |
729
b5e744285e92
rename i-node to node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
26 |
#include "ns3/node.h" |
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
27 |
#include "ns3/socket.h" |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
555
diff
changeset
|
28 |
#include "ns3/net-device.h" |
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
29 |
#include "ns3/uinteger.h" |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
30 |
#include "ns3/trace-source-accessor.h" |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
31 |
#include "ns3/object-vector.h" |
3216
b36bb98d766e
bug 207: ipv4-header.h needed in src/node module.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3172
diff
changeset
|
32 |
#include "ns3/ipv4-header.h" |
3235
c2f34dac1b9e
add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3216
diff
changeset
|
33 |
#include "ns3/boolean.h" |
3172
e661e08c3211
Don't register IPv4 protocol handler for all interfaces, only for IPv4-enabled interfaces.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3153
diff
changeset
|
34 |
#include "arp-l3-protocol.h" |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
35 |
|
733
fb1882e7d785
rename ipv4.h to ipv4-l3-protocol.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
36 |
#include "ipv4-l3-protocol.h" |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
37 |
#include "ipv4-l4-protocol.h" |
3820 | 38 |
#include "icmpv4-l4-protocol.h" |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
39 |
#include "ipv4-interface.h" |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
40 |
#include "ipv4-loopback-interface.h" |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
41 |
#include "arp-ipv4-interface.h" |
3820 | 42 |
#include "ipv4-raw-socket-impl.h" |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
43 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
44 |
NS_LOG_COMPONENT_DEFINE ("Ipv4L3Protocol"); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
45 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
46 |
namespace ns3 { |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
47 |
|
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
48 |
const uint16_t Ipv4L3Protocol::PROT_NUMBER = 0x0800; |
293
007bc9e735f3
remove Ipv4L3Protocol class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
287
diff
changeset
|
49 |
|
2249
3a1da26d61dc
replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2238
diff
changeset
|
50 |
NS_OBJECT_ENSURE_REGISTERED (Ipv4L3Protocol); |
3a1da26d61dc
replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2238
diff
changeset
|
51 |
|
2250
18f432098389
InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2249
diff
changeset
|
52 |
TypeId |
2251
04963d8cca51
iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2250
diff
changeset
|
53 |
Ipv4L3Protocol::GetTypeId (void) |
2232
9abd038ee588
replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2231
diff
changeset
|
54 |
{ |
2602
d9262bff6df2
add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2592
diff
changeset
|
55 |
static TypeId tid = TypeId ("ns3::Ipv4L3Protocol") |
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
56 |
.SetParent<Object> () |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
57 |
.AddConstructor<Ipv4L3Protocol> () |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
58 |
.AddAttribute ("DefaultTtl", "The TTL value set by default on all outgoing packets generated on this node.", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2933
diff
changeset
|
59 |
UintegerValue (64), |
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
60 |
MakeUintegerAccessor (&Ipv4L3Protocol::m_defaultTtl), |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
61 |
MakeUintegerChecker<uint8_t> ()) |
3235
c2f34dac1b9e
add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3216
diff
changeset
|
62 |
.AddAttribute ("CalcChecksum", "If true, we calculate the checksum of outgoing packets" |
c2f34dac1b9e
add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3216
diff
changeset
|
63 |
" and verify the checksum of incoming packets.", |
c2f34dac1b9e
add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3216
diff
changeset
|
64 |
BooleanValue (false), |
c2f34dac1b9e
add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3216
diff
changeset
|
65 |
MakeBooleanAccessor (&Ipv4L3Protocol::m_calcChecksum), |
c2f34dac1b9e
add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3216
diff
changeset
|
66 |
MakeBooleanChecker ()) |
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
67 |
.AddTraceSource ("Tx", "Send ipv4 packet to outgoing interface.", |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
68 |
MakeTraceSourceAccessor (&Ipv4L3Protocol::m_txTrace)) |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
69 |
.AddTraceSource ("Rx", "Receive ipv4 packet from incoming interface.", |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
70 |
MakeTraceSourceAccessor (&Ipv4L3Protocol::m_rxTrace)) |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
71 |
.AddTraceSource ("Drop", "Drop ipv4 packet", |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
72 |
MakeTraceSourceAccessor (&Ipv4L3Protocol::m_dropTrace)) |
2537
c937f3317a1f
be consistant in how lists of objects are named.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
73 |
.AddAttribute ("InterfaceList", "The set of Ipv4 interfaces associated to this Ipv4 stack.", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2933
diff
changeset
|
74 |
ObjectVectorValue (), |
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
75 |
MakeObjectVectorAccessor (&Ipv4L3Protocol::m_interfaces), |
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
76 |
MakeObjectVectorChecker<Ipv4Interface> ()) |
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
77 |
; |
2252
80595448707a
iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2251
diff
changeset
|
78 |
return tid; |
2232
9abd038ee588
replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2231
diff
changeset
|
79 |
} |
9abd038ee588
replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2231
diff
changeset
|
80 |
|
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
81 |
Ipv4L3Protocol::Ipv4L3Protocol() |
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
983
diff
changeset
|
82 |
: m_nInterfaces (0), |
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
83 |
m_identification (0) |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
84 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
85 |
NS_LOG_FUNCTION_NOARGS (); |
2230
9f13ac3291e0
add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1870
diff
changeset
|
86 |
m_staticRouting = CreateObject<Ipv4StaticRouting> (); |
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
|
87 |
AddRoutingProtocol (m_staticRouting, 0); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
88 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
89 |
|
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
90 |
Ipv4L3Protocol::~Ipv4L3Protocol () |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
91 |
{ |
3150
7350a68e5856
more logging. Make sure we do dispose attached Ipv4Interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2989
diff
changeset
|
92 |
NS_LOG_FUNCTION (this); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
93 |
} |
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
94 |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2537
diff
changeset
|
95 |
void |
3588
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
96 |
Ipv4L3Protocol::Insert(Ptr<Ipv4L4Protocol> protocol) |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
97 |
{ |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
98 |
m_protocols.push_back (protocol); |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
99 |
} |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
100 |
Ptr<Ipv4L4Protocol> |
3744 | 101 |
Ipv4L3Protocol::GetProtocol(int protocolNumber) const |
3588
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
102 |
{ |
3744 | 103 |
for (L4List_t::const_iterator i = m_protocols.begin(); i != m_protocols.end(); ++i) |
3588
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
104 |
{ |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
105 |
if ((*i)->GetProtocolNumber () == protocolNumber) |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
106 |
{ |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
107 |
return *i; |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
108 |
} |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
109 |
} |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
110 |
return 0; |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
111 |
} |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
112 |
void |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
113 |
Ipv4L3Protocol::Remove (Ptr<Ipv4L4Protocol> protocol) |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
114 |
{ |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
115 |
m_protocols.remove (protocol); |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
116 |
} |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
117 |
|
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
118 |
void |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2537
diff
changeset
|
119 |
Ipv4L3Protocol::SetNode (Ptr<Node> node) |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2537
diff
changeset
|
120 |
{ |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2537
diff
changeset
|
121 |
m_node = node; |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2537
diff
changeset
|
122 |
SetupLoopback (); |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2537
diff
changeset
|
123 |
} |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2537
diff
changeset
|
124 |
|
3820 | 125 |
Ptr<Socket> |
126 |
Ipv4L3Protocol::CreateRawSocket (void) |
|
127 |
{ |
|
128 |
NS_LOG_FUNCTION (this); |
|
129 |
Ptr<Ipv4RawSocketImpl> socket = CreateObject<Ipv4RawSocketImpl> (); |
|
130 |
socket->SetNode (m_node); |
|
131 |
m_sockets.push_back (socket); |
|
132 |
return socket; |
|
133 |
} |
|
134 |
void |
|
135 |
Ipv4L3Protocol::DeleteRawSocket (Ptr<Socket> socket) |
|
136 |
{ |
|
137 |
NS_LOG_FUNCTION (this << socket); |
|
138 |
for (SocketList::iterator i = m_sockets.begin (); i != m_sockets.end (); ++i) |
|
139 |
{ |
|
140 |
if ((*i) == socket) |
|
141 |
{ |
|
142 |
m_sockets.erase (i); |
|
143 |
return; |
|
144 |
} |
|
145 |
} |
|
146 |
return; |
|
147 |
} |
|
148 |
||
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
149 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
150 |
Ipv4L3Protocol::DoDispose (void) |
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
151 |
{ |
3150
7350a68e5856
more logging. Make sure we do dispose attached Ipv4Interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2989
diff
changeset
|
152 |
NS_LOG_FUNCTION (this); |
3588
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
153 |
for (L4List_t::iterator i = m_protocols.begin(); i != m_protocols.end(); ++i) |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
154 |
{ |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
155 |
(*i)->Dispose (); |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
156 |
*i = 0; |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
157 |
} |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
158 |
m_protocols.clear (); |
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
159 |
|
3150
7350a68e5856
more logging. Make sure we do dispose attached Ipv4Interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2989
diff
changeset
|
160 |
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); ++i) |
7350a68e5856
more logging. Make sure we do dispose attached Ipv4Interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2989
diff
changeset
|
161 |
{ |
7350a68e5856
more logging. Make sure we do dispose attached Ipv4Interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2989
diff
changeset
|
162 |
Ptr<Ipv4Interface> interface = *i; |
7350a68e5856
more logging. Make sure we do dispose attached Ipv4Interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2989
diff
changeset
|
163 |
interface->Dispose (); |
7350a68e5856
more logging. Make sure we do dispose attached Ipv4Interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2989
diff
changeset
|
164 |
} |
496
894c8380d57b
use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
487
diff
changeset
|
165 |
m_interfaces.clear (); |
555
4d3b2a77bc92
convert Node * to Ptr<Node>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
551
diff
changeset
|
166 |
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
|
167 |
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
|
168 |
m_staticRouting = 0; |
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
983
diff
changeset
|
169 |
Object::DoDispose (); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
170 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
171 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
172 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
173 |
Ipv4L3Protocol::SetupLoopback (void) |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
174 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
175 |
NS_LOG_FUNCTION_NOARGS (); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
176 |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2537
diff
changeset
|
177 |
Ptr<Ipv4LoopbackInterface> interface = CreateObject<Ipv4LoopbackInterface> (); |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2537
diff
changeset
|
178 |
interface->SetNode (m_node); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
179 |
interface->SetAddress (Ipv4Address::GetLoopback ()); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
180 |
interface->SetNetworkMask (Ipv4Mask::GetLoopback ()); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
181 |
uint32_t index = AddIpv4Interface (interface); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
182 |
AddHostRouteTo (Ipv4Address::GetLoopback (), index); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
183 |
interface->SetUp (); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
184 |
} |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
185 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
186 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
187 |
Ipv4L3Protocol::SetDefaultTtl (uint8_t ttl) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
188 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
189 |
NS_LOG_FUNCTION_NOARGS (); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
190 |
m_defaultTtl = ttl; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
191 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
192 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
193 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
194 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
195 |
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
|
196 |
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
|
197 |
uint32_t interface) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
198 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
199 |
NS_LOG_FUNCTION (this << dest << 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
|
200 |
m_staticRouting->AddHostRouteTo (dest, nextHop, interface); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
201 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
202 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
203 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
204 |
Ipv4L3Protocol::AddHostRouteTo (Ipv4Address dest, |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
205 |
uint32_t interface) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
206 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
207 |
NS_LOG_FUNCTION (this << dest << 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, 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::AddNetworkRouteTo (Ipv4Address network, |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
213 |
Ipv4Mask networkMask, |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
214 |
Ipv4Address nextHop, |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
215 |
uint32_t interface) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
216 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
217 |
NS_LOG_FUNCTION (this << network << 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
|
218 |
m_staticRouting->AddNetworkRouteTo (network, networkMask, nextHop, interface); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
219 |
} |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
220 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
221 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
222 |
Ipv4L3Protocol::AddNetworkRouteTo (Ipv4Address network, |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
223 |
Ipv4Mask networkMask, |
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 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
226 |
NS_LOG_FUNCTION (this << network << 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
|
227 |
m_staticRouting->AddNetworkRouteTo (network, networkMask, interface); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
228 |
} |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
229 |
|
236
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::SetDefaultRoute (Ipv4Address nextHop, |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
232 |
uint32_t interface) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
233 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
234 |
NS_LOG_FUNCTION (this << 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
|
235 |
m_staticRouting->SetDefaultRoute (nextHop, interface); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
236 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
237 |
|
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
|
238 |
void |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
239 |
Ipv4L3Protocol::Lookup ( |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
240 |
Ipv4Header const &ipHeader, |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
241 |
Ptr<Packet> packet, |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
242 |
Ipv4RoutingProtocol::RouteReplyCallback routeReply) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
243 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
244 |
NS_LOG_FUNCTION (this << &ipHeader << packet << &routeReply); |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
245 |
|
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
246 |
Lookup (Ipv4RoutingProtocol::IF_INDEX_ANY, ipHeader, packet, routeReply); |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
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 |
|
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
|
249 |
void |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
250 |
Ipv4L3Protocol::Lookup ( |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
251 |
uint32_t ifIndex, |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
252 |
Ipv4Header const &ipHeader, |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
253 |
Ptr<Packet> packet, |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
254 |
Ipv4RoutingProtocol::RouteReplyCallback routeReply) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
255 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
256 |
NS_LOG_FUNCTION (this << ifIndex << &ipHeader << packet << &routeReply); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
257 |
|
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
258 |
for (Ipv4RoutingProtocolList::const_iterator rprotoIter = |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
259 |
m_routingProtocols.begin (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
260 |
rprotoIter != m_routingProtocols.end (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
261 |
rprotoIter++) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
262 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
263 |
NS_LOG_LOGIC ("Requesting route"); |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
264 |
if ((*rprotoIter).second->RequestRoute (ifIndex, ipHeader, packet, |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
265 |
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
|
266 |
return; |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
267 |
} |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
268 |
|
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
|
269 |
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
|
270 |
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
|
271 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
272 |
NS_LOG_LOGIC ("Multicast destination with local source"); |
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
|
273 |
// |
1445
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1444
diff
changeset
|
274 |
// We have a multicast packet originating from the current node and were not |
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1444
diff
changeset
|
275 |
// able to send it using the usual RequestRoute process. Since the usual |
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1444
diff
changeset
|
276 |
// process includes trying to use a default multicast route, this means that |
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1444
diff
changeset
|
277 |
// there was no specific route out of the node found, and there was no default |
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1444
diff
changeset
|
278 |
// multicast route set. |
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
|
279 |
// |
1445
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1444
diff
changeset
|
280 |
// The fallback position is to look for a default unicast route and use that |
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1444
diff
changeset
|
281 |
// to get the packet off the node if we have one. |
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1444
diff
changeset
|
282 |
// |
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1444
diff
changeset
|
283 |
Ipv4Route *route = m_staticRouting->GetDefaultRoute (); |
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
|
284 |
|
1445
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1444
diff
changeset
|
285 |
if (route) |
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
|
286 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
287 |
NS_LOG_LOGIC ("Local source. Using unicast default route for " |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
288 |
"multicast packet"); |
1445
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1444
diff
changeset
|
289 |
|
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1444
diff
changeset
|
290 |
routeReply (true, *route, packet, ipHeader); |
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1444
diff
changeset
|
291 |
return; |
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
|
292 |
} |
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 |
} |
1445
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1444
diff
changeset
|
294 |
// |
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1444
diff
changeset
|
295 |
// No route found |
3fba36666488
Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents:
1444
diff
changeset
|
296 |
// |
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
|
297 |
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
|
298 |
} |
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
|
299 |
|
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
|
300 |
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
|
301 |
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
|
302 |
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
|
303 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
304 |
NS_LOG_FUNCTION (this << &routingProtocol << 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
|
305 |
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
|
306 |
(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
|
307 |
m_routingProtocols.sort (); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
308 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
309 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
310 |
uint32_t |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
311 |
Ipv4L3Protocol::GetNRoutes (void) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
312 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
313 |
NS_LOG_FUNCTION_NOARGS (); |
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
|
314 |
return m_staticRouting->GetNRoutes (); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
315 |
} |
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
|
316 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
317 |
Ipv4Route * |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
318 |
Ipv4L3Protocol::GetRoute (uint32_t index) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
319 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
320 |
NS_LOG_FUNCTION_NOARGS (); |
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
|
321 |
return m_staticRouting->GetRoute (index); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
322 |
} |
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
|
323 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
324 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
325 |
Ipv4L3Protocol::RemoveRoute (uint32_t index) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
326 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
327 |
NS_LOG_FUNCTION (this << 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
|
328 |
m_staticRouting->RemoveRoute (index); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
329 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
330 |
|
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
331 |
void |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
332 |
Ipv4L3Protocol::AddMulticastRoute (Ipv4Address origin, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
333 |
Ipv4Address group, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
334 |
uint32_t inputInterface, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
335 |
std::vector<uint32_t> outputInterfaces) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
336 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
337 |
NS_LOG_FUNCTION (this << origin << group << inputInterface << &outputInterfaces); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
338 |
|
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
339 |
m_staticRouting->AddMulticastRoute (origin, group, inputInterface, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
340 |
outputInterfaces); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
341 |
} |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
342 |
|
1442
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
343 |
void |
1444
7c81b4e2617d
piles of doxygen, changes to SetDefaultMulticastRoute plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1443
diff
changeset
|
344 |
Ipv4L3Protocol::SetDefaultMulticastRoute (uint32_t outputInterface) |
1442
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
345 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
346 |
NS_LOG_FUNCTION (this << outputInterface); |
1442
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
347 |
|
1444
7c81b4e2617d
piles of doxygen, changes to SetDefaultMulticastRoute plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1443
diff
changeset
|
348 |
m_staticRouting->SetDefaultMulticastRoute (outputInterface); |
1442
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
349 |
} |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
350 |
|
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
351 |
uint32_t |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
352 |
Ipv4L3Protocol::GetNMulticastRoutes (void) const |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
353 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
354 |
NS_LOG_FUNCTION_NOARGS (); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
355 |
return m_staticRouting->GetNMulticastRoutes (); |
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 |
Ipv4MulticastRoute * |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
359 |
Ipv4L3Protocol::GetMulticastRoute (uint32_t index) const |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
360 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
361 |
NS_LOG_FUNCTION (this << index); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
362 |
return m_staticRouting->GetMulticastRoute (index); |
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 |
void |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
366 |
Ipv4L3Protocol::RemoveMulticastRoute (Ipv4Address origin, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
367 |
Ipv4Address group, |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
368 |
uint32_t inputInterface) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
369 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
370 |
NS_LOG_FUNCTION (this << origin << group << inputInterface); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
371 |
m_staticRouting->RemoveMulticastRoute (origin, group, inputInterface); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
372 |
} |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
373 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
374 |
void |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
375 |
Ipv4L3Protocol::RemoveMulticastRoute (uint32_t index) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
376 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
377 |
NS_LOG_FUNCTION (this << index); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
378 |
m_staticRouting->RemoveMulticastRoute (index); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
379 |
} |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
380 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
381 |
uint32_t |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
382 |
Ipv4L3Protocol::AddInterface (Ptr<NetDevice> device) |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
383 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
384 |
NS_LOG_FUNCTION (this << &device); |
3172
e661e08c3211
Don't register IPv4 protocol handler for all interfaces, only for IPv4-enabled interfaces.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3153
diff
changeset
|
385 |
|
e661e08c3211
Don't register IPv4 protocol handler for all interfaces, only for IPv4-enabled interfaces.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3153
diff
changeset
|
386 |
Ptr<Node> node = GetObject<Node> (); |
e661e08c3211
Don't register IPv4 protocol handler for all interfaces, only for IPv4-enabled interfaces.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3153
diff
changeset
|
387 |
node->RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, this), |
e661e08c3211
Don't register IPv4 protocol handler for all interfaces, only for IPv4-enabled interfaces.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3153
diff
changeset
|
388 |
Ipv4L3Protocol::PROT_NUMBER, device); |
e661e08c3211
Don't register IPv4 protocol handler for all interfaces, only for IPv4-enabled interfaces.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3153
diff
changeset
|
389 |
node->RegisterProtocolHandler (MakeCallback (&ArpL3Protocol::Receive, PeekPointer (GetObject<ArpL3Protocol> ())), |
e661e08c3211
Don't register IPv4 protocol handler for all interfaces, only for IPv4-enabled interfaces.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3153
diff
changeset
|
390 |
ArpL3Protocol::PROT_NUMBER, device); |
e661e08c3211
Don't register IPv4 protocol handler for all interfaces, only for IPv4-enabled interfaces.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3153
diff
changeset
|
391 |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2537
diff
changeset
|
392 |
Ptr<ArpIpv4Interface> interface = CreateObject<ArpIpv4Interface> (); |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2537
diff
changeset
|
393 |
interface->SetNode (m_node); |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2537
diff
changeset
|
394 |
interface->SetDevice (device); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
395 |
return AddIpv4Interface (interface); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
396 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
397 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
398 |
uint32_t |
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1333
diff
changeset
|
399 |
Ipv4L3Protocol::AddIpv4Interface (Ptr<Ipv4Interface>interface) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
400 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
401 |
NS_LOG_FUNCTION (this << interface); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
402 |
uint32_t index = m_nInterfaces; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
403 |
m_interfaces.push_back (interface); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
404 |
m_nInterfaces++; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
405 |
return index; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
406 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
407 |
|
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1333
diff
changeset
|
408 |
Ptr<Ipv4Interface> |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
409 |
Ipv4L3Protocol::GetInterface (uint32_t index) const |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
410 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
411 |
NS_LOG_FUNCTION (this << index); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
412 |
uint32_t tmp = 0; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
413 |
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
|
414 |
{ |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
415 |
if (index == tmp) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
416 |
{ |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
417 |
return *i; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
418 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
419 |
tmp++; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
420 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
421 |
return 0; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
422 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
423 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
424 |
uint32_t |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
425 |
Ipv4L3Protocol::GetNInterfaces (void) const |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
426 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
427 |
NS_LOG_FUNCTION_NOARGS (); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
428 |
return m_nInterfaces; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
429 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
430 |
|
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
|
431 |
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
|
432 |
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
|
433 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
434 |
NS_LOG_FUNCTION (this << addr); |
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
|
435 |
|
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 |
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
|
437 |
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
|
438 |
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
|
439 |
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
|
440 |
{ |
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 |
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
|
442 |
{ |
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 |
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
|
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 |
|
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2325
diff
changeset
|
447 |
NS_FATAL_ERROR ("Ipv4L3Protocol::FindInterfaceForAddr (): " |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2325
diff
changeset
|
448 |
"Interface not found for IP address " << addr); |
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
|
449 |
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
|
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 |
|
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 |
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
|
453 |
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
|
454 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
455 |
NS_LOG_FUNCTION (this << addr << mask); |
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
|
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 |
|
2711
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
473 |
int32_t |
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
474 |
Ipv4L3Protocol::FindInterfaceIndexForDevice (Ptr<NetDevice> device) const |
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
475 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
476 |
NS_LOG_FUNCTION (this << device); |
2711
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
477 |
|
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
478 |
uint32_t ifIndex = 0; |
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
479 |
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
480 |
i != m_interfaces.end (); |
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
481 |
i++, ifIndex++) |
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
482 |
{ |
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
483 |
if ((*i)->GetDevice () == device) |
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
484 |
{ |
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
485 |
return ifIndex; |
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
486 |
} |
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
487 |
} |
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
488 |
|
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
489 |
return -1; |
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
490 |
} |
83addb15f632
ip helper and find ip interface for device method on ipv4
Craig Dowell <craigdo@ee.washington.edu>
parents:
2602
diff
changeset
|
491 |
|
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1333
diff
changeset
|
492 |
Ptr<Ipv4Interface> |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
493 |
Ipv4L3Protocol::FindInterfaceForDevice (Ptr<const NetDevice> device) |
242
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
494 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
495 |
NS_LOG_FUNCTION (this << &device); |
242
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
496 |
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
|
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) |
242
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
499 |
{ |
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
500 |
return *i; |
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
501 |
} |
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
502 |
} |
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
503 |
return 0; |
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
504 |
} |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
505 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
506 |
void |
3548
e5ab96db540e
bug 273: constify packet pointers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3461
diff
changeset
|
507 |
Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from, |
3448
0bd851bb1225
Simplify promiscuous mode API: NetDevices always operate in promiscuous mode, normal receive callbacks receive extra destination address and packet type.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3260
diff
changeset
|
508 |
const Address &to, NetDevice::PacketType packetType) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
509 |
{ |
3548
e5ab96db540e
bug 273: constify packet pointers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3461
diff
changeset
|
510 |
NS_LOG_FUNCTION (this << &device << p << protocol << from); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
511 |
|
2796
33fb53176f97
Fix multicast forwarding problem
Tom Henderson <tomh@tomh.org>
parents:
2711
diff
changeset
|
512 |
NS_LOG_LOGIC ("Packet from " << from << " received on node " << m_node->GetId ()); |
1443
580ed7a4dd1e
Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents:
1442
diff
changeset
|
513 |
|
3548
e5ab96db540e
bug 273: constify packet pointers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3461
diff
changeset
|
514 |
Ptr<Packet> packet = p->Copy (); |
e5ab96db540e
bug 273: constify packet pointers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3461
diff
changeset
|
515 |
|
457
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
516 |
uint32_t index = 0; |
1524
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1504
diff
changeset
|
517 |
Ptr<Ipv4Interface> ipv4Interface; |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
518 |
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
519 |
i != m_interfaces.end (); |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
520 |
i++) |
457
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
521 |
{ |
1524
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1504
diff
changeset
|
522 |
ipv4Interface = *i; |
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1504
diff
changeset
|
523 |
if (ipv4Interface->GetDevice () == device) |
457
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
524 |
{ |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
525 |
m_rxTrace (packet, index); |
457
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
526 |
break; |
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
527 |
} |
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
528 |
index++; |
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
529 |
} |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
530 |
Ipv4Header ipHeader; |
3235
c2f34dac1b9e
add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3216
diff
changeset
|
531 |
if (m_calcChecksum) |
c2f34dac1b9e
add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3216
diff
changeset
|
532 |
{ |
c2f34dac1b9e
add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3216
diff
changeset
|
533 |
ipHeader.EnableChecksum (); |
c2f34dac1b9e
add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3216
diff
changeset
|
534 |
} |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
535 |
packet->RemoveHeader (ipHeader); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
536 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
537 |
if (!ipHeader.IsChecksumOk ()) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
538 |
{ |
3235
c2f34dac1b9e
add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3216
diff
changeset
|
539 |
m_dropTrace (packet); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
540 |
return; |
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 |
|
3820 | 543 |
for (SocketList::iterator i = m_sockets.begin (); i != m_sockets.end (); ++i) |
544 |
{ |
|
545 |
Ptr<Ipv4RawSocketImpl> socket = *i; |
|
546 |
socket->ForwardUp (packet, ipHeader, device); |
|
547 |
} |
|
548 |
||
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
549 |
if (Forwarding (index, packet, ipHeader, device)) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
550 |
{ |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
551 |
return; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
552 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
553 |
|
1524
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1504
diff
changeset
|
554 |
ForwardUp (packet, ipHeader, ipv4Interface); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
555 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
556 |
|
3820 | 557 |
Ptr<Icmpv4L4Protocol> |
558 |
Ipv4L3Protocol::GetIcmp (void) const |
|
559 |
{ |
|
560 |
Ptr<Ipv4L4Protocol> prot = GetProtocol (Icmpv4L4Protocol::GetStaticProtocolNumber ()); |
|
561 |
if (prot != 0) |
|
562 |
{ |
|
563 |
return prot->GetObject<Icmpv4L4Protocol> (); |
|
564 |
} |
|
565 |
else |
|
566 |
{ |
|
567 |
return 0; |
|
568 |
} |
|
569 |
} |
|
570 |
||
571 |
bool |
|
572 |
Ipv4L3Protocol::IsUnicast (Ipv4Address ad, Ipv4Mask interfaceMask) const |
|
573 |
{ |
|
574 |
return !ad.IsMulticast () && !ad.IsSubnetDirectedBroadcast (interfaceMask); |
|
575 |
} |
|
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
|
576 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
577 |
void |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
578 |
Ipv4L3Protocol::Send (Ptr<Packet> packet, |
457
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
579 |
Ipv4Address source, |
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
580 |
Ipv4Address destination, |
a468fac09924
add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
581 |
uint8_t protocol) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
582 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
583 |
NS_LOG_FUNCTION (this << packet << source << destination << protocol); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
584 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
585 |
Ipv4Header ipHeader; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
586 |
|
3235
c2f34dac1b9e
add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3216
diff
changeset
|
587 |
if (m_calcChecksum) |
c2f34dac1b9e
add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3216
diff
changeset
|
588 |
{ |
c2f34dac1b9e
add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3216
diff
changeset
|
589 |
ipHeader.EnableChecksum (); |
c2f34dac1b9e
add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3216
diff
changeset
|
590 |
} |
c2f34dac1b9e
add support for attribtues to bug 34
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3216
diff
changeset
|
591 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
592 |
ipHeader.SetSource (source); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
593 |
ipHeader.SetDestination (destination); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
594 |
ipHeader.SetProtocol (protocol); |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
595 |
ipHeader.SetPayloadSize (packet->GetSize ()); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
596 |
ipHeader.SetIdentification (m_identification); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
597 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
598 |
m_identification ++; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
599 |
|
3820 | 600 |
SocketSetDontFragmentTag dfTag; |
601 |
bool found = packet->FindFirstMatchingTag (dfTag); |
|
602 |
if (found) |
|
603 |
{ |
|
604 |
if (dfTag.IsEnabled ()) |
|
605 |
{ |
|
606 |
ipHeader.SetDontFragment (); |
|
607 |
} |
|
608 |
else |
|
609 |
{ |
|
610 |
ipHeader.SetMayFragment (); |
|
611 |
} |
|
612 |
} |
|
613 |
||
614 |
||
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
615 |
// Set TTL to 1 if it is a broadcast packet of any type. Otherwise, |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
616 |
// possibly override the default TTL if the packet is tagged |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
617 |
SocketIpTtlTag tag; |
3820 | 618 |
found = packet->FindFirstMatchingTag (tag); |
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
619 |
|
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
620 |
if (destination.IsBroadcast ()) |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
621 |
{ |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
622 |
ipHeader.SetTtl (1); |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
623 |
} |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
624 |
else if (found) |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
625 |
{ |
3138 | 626 |
ipHeader.SetTtl (tag.GetTtl ()); |
627 |
// XXX remove tag here? |
|
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
628 |
} |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
629 |
else |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
630 |
{ |
3820 | 631 |
ipHeader.SetTtl (m_defaultTtl); |
3124
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
632 |
uint32_t ifaceIndex = 0; |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
633 |
for (Ipv4InterfaceList::iterator ifaceIter = m_interfaces.begin (); |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
634 |
ifaceIter != m_interfaces.end (); ifaceIter++, ifaceIndex++) |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
635 |
{ |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
636 |
Ptr<Ipv4Interface> outInterface = *ifaceIter; |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
637 |
if (destination.IsSubnetDirectedBroadcast ( |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
638 |
outInterface->GetNetworkMask ())) |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
639 |
{ |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
640 |
ipHeader.SetTtl (1); |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
641 |
} |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
642 |
} |
473e59b5e141
Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents:
2989
diff
changeset
|
643 |
} |
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
|
644 |
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
|
645 |
{ |
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
|
646 |
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
|
647 |
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
|
648 |
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
|
649 |
{ |
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1333
diff
changeset
|
650 |
Ptr<Ipv4Interface> outInterface = *ifaceIter; |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
651 |
Ptr<Packet> packetCopy = packet->Copy (); |
1308
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
652 |
|
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
653 |
packetCopy->AddHeader (ipHeader); |
3820 | 654 |
if (packetCopy->GetSize () > outInterface->GetMtu () && |
655 |
ipHeader.IsDontFragment () && |
|
656 |
IsUnicast (ipHeader.GetDestination (), outInterface->GetNetworkMask ())) |
|
657 |
{ |
|
658 |
Ptr<Icmpv4L4Protocol> icmp = GetIcmp (); |
|
659 |
NS_ASSERT (icmp != 0); |
|
660 |
icmp->SendDestUnreachFragNeeded (ipHeader, packet, outInterface->GetMtu ()); |
|
661 |
m_dropTrace (packetCopy); |
|
662 |
} |
|
663 |
else if (packet->GetSize () > outInterface->GetMtu () && |
|
664 |
!ipHeader.IsDontFragment ()) |
|
665 |
{ |
|
666 |
NS_LOG_LOGIC ("Too big: need fragmentation but no frag support."); |
|
667 |
m_dropTrace (packet); |
|
668 |
} |
|
669 |
else |
|
670 |
{ |
|
671 |
NS_ASSERT (packetCopy->GetSize () <= outInterface->GetMtu ()); |
|
672 |
m_txTrace (packetCopy, ifaceIndex); |
|
673 |
outInterface->Send (packetCopy, destination); |
|
674 |
} |
|
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 |
} |
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
|
676 |
} |
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
|
677 |
else |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
678 |
{ |
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
|
679 |
// 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
|
680 |
// 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
|
681 |
// 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
|
682 |
// 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
|
683 |
// 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
|
684 |
// 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
|
685 |
// 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
|
686 |
// 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
|
687 |
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
|
688 |
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
|
689 |
} |
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
|
690 |
} |
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
|
691 |
|
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
|
692 |
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
|
693 |
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
|
694 |
Ipv4Route const &route, |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
695 |
Ptr<Packet> 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
|
696 |
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
|
697 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
698 |
NS_LOG_FUNCTION (this << found << &route << packet << &ipHeader); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
699 |
|
2325
084b07dceafb
Add the IPv4 header before deciding whether to drop packets. Closes bug #135.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2324
diff
changeset
|
700 |
packet->AddHeader (ipHeader); |
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
|
701 |
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
|
702 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
703 |
NS_LOG_WARN ("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
|
704 |
m_dropTrace (packet); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
705 |
return; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
706 |
} |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
707 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
708 |
NS_LOG_LOGIC ("Send via interface " << route.GetInterface ()); |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
709 |
|
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1333
diff
changeset
|
710 |
Ptr<Ipv4Interface> outInterface = GetInterface (route.GetInterface ()); |
3820 | 711 |
if (packet->GetSize () > outInterface->GetMtu () && |
712 |
ipHeader.IsDontFragment () && |
|
713 |
IsUnicast (ipHeader.GetDestination (), outInterface->GetNetworkMask ())) |
|
714 |
{ |
|
715 |
NS_LOG_LOGIC ("Too big: need fragmentation but not allowed"); |
|
716 |
Ptr<Icmpv4L4Protocol> icmp = GetIcmp (); |
|
717 |
NS_ASSERT (icmp != 0); |
|
718 |
Ptr<Packet> copyNoHeader = packet->Copy (); |
|
719 |
Ipv4Header tmp; |
|
720 |
copyNoHeader->RemoveHeader (tmp); |
|
721 |
icmp->SendDestUnreachFragNeeded (ipHeader, copyNoHeader, outInterface->GetMtu ()); |
|
722 |
m_dropTrace (packet); |
|
723 |
} |
|
724 |
else if (packet->GetSize () > outInterface->GetMtu () && |
|
725 |
!ipHeader.IsDontFragment ()) |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
726 |
{ |
3820 | 727 |
NS_LOG_LOGIC ("Too big: need fragmentation but no frag support."); |
728 |
m_dropTrace (packet); |
|
729 |
} |
|
730 |
else |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
731 |
{ |
3820 | 732 |
m_txTrace (packet, route.GetInterface ()); |
733 |
if (route.IsGateway ()) |
|
734 |
{ |
|
735 |
NS_LOG_LOGIC ("Send to gateway " << route.GetGateway ()); |
|
736 |
outInterface->Send (packet, route.GetGateway ()); |
|
737 |
} |
|
738 |
else |
|
739 |
{ |
|
740 |
NS_LOG_LOGIC ("Send to destination " << ipHeader.GetDestination ()); |
|
741 |
outInterface->Send (packet, ipHeader.GetDestination ()); |
|
742 |
} |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
743 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
744 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
745 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
746 |
bool |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
747 |
Ipv4L3Protocol::Forwarding ( |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
748 |
uint32_t ifIndex, |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
749 |
Ptr<Packet> packet, |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
750 |
Ipv4Header &ipHeader, |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
751 |
Ptr<NetDevice> device) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
752 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
753 |
NS_LOG_FUNCTION (ifIndex << packet << &ipHeader<< device); |
2796
33fb53176f97
Fix multicast forwarding problem
Tom Henderson <tomh@tomh.org>
parents:
2711
diff
changeset
|
754 |
NS_LOG_LOGIC ("Forwarding logic for node: " << m_node->GetId ()); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
755 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
756 |
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
757 |
i != m_interfaces.end (); i++) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
758 |
{ |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
759 |
if ((*i)->GetAddress ().IsEqual (ipHeader.GetDestination ())) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
760 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
761 |
NS_LOG_LOGIC ("For me (destination match)"); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
762 |
return false; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
763 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
764 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
765 |
|
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
766 |
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
767 |
i != m_interfaces.end (); i++) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
768 |
{ |
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1333
diff
changeset
|
769 |
Ptr<Ipv4Interface> interface = *i; |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
555
diff
changeset
|
770 |
if (interface->GetDevice () == device) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
771 |
{ |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
772 |
if (ipHeader.GetDestination ().IsEqual (interface->GetBroadcast ())) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
773 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
774 |
NS_LOG_LOGIC ("For me (interface broadcast address)"); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
775 |
return false; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
776 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
777 |
break; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
778 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
779 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
780 |
|
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
|
781 |
if (ipHeader.GetDestination ().IsBroadcast ()) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
782 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
783 |
NS_LOG_LOGIC ("For me (Ipv4Addr broadcast address)"); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
784 |
return false; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
785 |
} |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1429
diff
changeset
|
786 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
787 |
if (ipHeader.GetDestination ().IsEqual (Ipv4Address::GetAny ())) |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
788 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
789 |
NS_LOG_LOGIC ("For me (Ipv4Addr any address)"); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
790 |
return false; |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
791 |
} |
2796
33fb53176f97
Fix multicast forwarding problem
Tom Henderson <tomh@tomh.org>
parents:
2711
diff
changeset
|
792 |
// |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
793 |
// 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
|
794 |
// indicated group we need to return false so the multicast is forwarded up. |
2796
33fb53176f97
Fix multicast forwarding problem
Tom Henderson <tomh@tomh.org>
parents:
2711
diff
changeset
|
795 |
// |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
796 |
for (Ipv4MulticastGroupList::const_iterator i = m_multicastGroups.begin (); |
2796
33fb53176f97
Fix multicast forwarding problem
Tom Henderson <tomh@tomh.org>
parents:
2711
diff
changeset
|
797 |
i != m_multicastGroups.end (); i++) |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
798 |
{ |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
799 |
if ((*i).first.IsEqual (ipHeader.GetSource ()) && |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
800 |
(*i).second.IsEqual (ipHeader.GetDestination ())) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
801 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
802 |
NS_LOG_LOGIC ("For me (Joined multicast group)"); |
2796
33fb53176f97
Fix multicast forwarding problem
Tom Henderson <tomh@tomh.org>
parents:
2711
diff
changeset
|
803 |
// We forward with a packet copy, since forwarding may change |
33fb53176f97
Fix multicast forwarding problem
Tom Henderson <tomh@tomh.org>
parents:
2711
diff
changeset
|
804 |
// the packet, affecting our local delivery |
33fb53176f97
Fix multicast forwarding problem
Tom Henderson <tomh@tomh.org>
parents:
2711
diff
changeset
|
805 |
NS_LOG_LOGIC ("Forwarding (multicast)."); |
3820 | 806 |
DoForward (ifIndex, packet->Copy (), ipHeader); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
807 |
return false; |
2796
33fb53176f97
Fix multicast forwarding problem
Tom Henderson <tomh@tomh.org>
parents:
2711
diff
changeset
|
808 |
} |
3820 | 809 |
} |
810 |
||
811 |
DoForward (ifIndex, packet, ipHeader); |
|
812 |
return true; |
|
813 |
} |
|
814 |
||
815 |
void |
|
816 |
Ipv4L3Protocol::DoForward (uint32_t ifIndex, |
|
817 |
Ptr<Packet> packet, |
|
818 |
Ipv4Header ipHeader) |
|
819 |
{ |
|
820 |
NS_LOG_FUNCTION (this << ifIndex << packet << ipHeader); |
|
821 |
||
822 |
ipHeader.SetTtl (ipHeader.GetTtl () - 1); |
|
823 |
if (ipHeader.GetTtl () == 0) |
|
824 |
{ |
|
825 |
if (IsUnicast (ipHeader.GetDestination (), GetInterface (ifIndex)->GetNetworkMask ())) |
|
826 |
{ |
|
827 |
Ptr<Icmpv4L4Protocol> icmp = GetIcmp (); |
|
828 |
icmp->SendTimeExceededTtl (ipHeader, packet); |
|
829 |
} |
|
830 |
m_dropTrace (packet); |
|
831 |
return; |
|
832 |
} |
|
2796
33fb53176f97
Fix multicast forwarding problem
Tom Henderson <tomh@tomh.org>
parents:
2711
diff
changeset
|
833 |
NS_LOG_LOGIC ("Not for me, forwarding."); |
33fb53176f97
Fix multicast forwarding problem
Tom Henderson <tomh@tomh.org>
parents:
2711
diff
changeset
|
834 |
Lookup (ifIndex, ipHeader, packet, |
3820 | 835 |
MakeCallback (&Ipv4L3Protocol::SendRealOut, this)); |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
836 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
837 |
|
3820 | 838 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
839 |
void |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
840 |
Ipv4L3Protocol::ForwardUp (Ptr<Packet> p, Ipv4Header const&ip, |
1524
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1504
diff
changeset
|
841 |
Ptr<Ipv4Interface> incomingInterface) |
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
842 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
843 |
NS_LOG_FUNCTION (this << p << &ip); |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
844 |
|
3588
ad0a36bfdb62
bug 282: remove Ipv4L4Demux
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3548
diff
changeset
|
845 |
Ptr<Ipv4L4Protocol> protocol = GetProtocol (ip.GetProtocol ()); |
3820 | 846 |
if (protocol != 0) |
847 |
{ |
|
848 |
// we need to make a copy in the unlikely event we hit the |
|
849 |
// RX_ENDPOINT_UNREACH codepath |
|
850 |
Ptr<Packet> copy = p->Copy (); |
|
851 |
enum Ipv4L4Protocol::RxStatus status = |
|
852 |
protocol->Receive (p, ip.GetSource (), ip.GetDestination (), incomingInterface); |
|
853 |
switch (status) { |
|
854 |
case Ipv4L4Protocol::RX_OK: |
|
855 |
// fall through |
|
856 |
case Ipv4L4Protocol::RX_CSUM_FAILED: |
|
857 |
break; |
|
858 |
case Ipv4L4Protocol::RX_ENDPOINT_UNREACH: |
|
859 |
if (IsUnicast (ip.GetDestination (), incomingInterface->GetNetworkMask ())) |
|
860 |
{ |
|
861 |
GetIcmp ()->SendDestUnreachPort (ip, copy); |
|
862 |
} |
|
863 |
break; |
|
864 |
} |
|
865 |
} |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
866 |
} |
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
867 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
868 |
void |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
869 |
Ipv4L3Protocol::JoinMulticastGroup (Ipv4Address origin, Ipv4Address group) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
870 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
871 |
NS_LOG_FUNCTION (this << origin << group); |
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
872 |
m_multicastGroups.push_back( |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
873 |
std::pair<Ipv4Address, Ipv4Address> (origin, group)); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
874 |
} |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
875 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
876 |
void |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
877 |
Ipv4L3Protocol::LeaveMulticastGroup (Ipv4Address origin, Ipv4Address group) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
878 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
879 |
NS_LOG_FUNCTION (this << origin << group); |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
880 |
|
1428
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
881 |
for (Ipv4MulticastGroupList::iterator i = m_multicastGroups.begin (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
882 |
i != m_multicastGroups.end (); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
883 |
i++) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
884 |
{ |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
885 |
if ((*i).first.IsEqual(origin) && (*i).second.IsEqual(group)) |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
886 |
{ |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
887 |
m_multicastGroups.erase (i); |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
888 |
return; |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
889 |
} |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
890 |
} |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
891 |
} |
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
892 |
|
a8f3d01d4a2c
untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents:
1235
diff
changeset
|
893 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
894 |
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
|
895 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
896 |
NS_LOG_FUNCTION (this << i << address); |
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1333
diff
changeset
|
897 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
898 |
interface->SetAddress (address); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
899 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
900 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
901 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
902 |
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
|
903 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
904 |
NS_LOG_FUNCTION (this << i << mask); |
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1333
diff
changeset
|
905 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
906 |
interface->SetNetworkMask (mask); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
907 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
908 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
909 |
Ipv4Mask |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
910 |
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
|
911 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
912 |
NS_LOG_FUNCTION (this << i); |
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1333
diff
changeset
|
913 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
914 |
return interface->GetNetworkMask (); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
915 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
916 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
917 |
Ipv4Address |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
918 |
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
|
919 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
920 |
NS_LOG_FUNCTION (this << i); |
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1333
diff
changeset
|
921 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
922 |
return interface->GetAddress (); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
923 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
924 |
|
1776
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
925 |
void |
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
926 |
Ipv4L3Protocol::SetMetric (uint32_t i, uint16_t metric) |
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
927 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
928 |
NS_LOG_FUNCTION (i << metric); |
1776
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
929 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
930 |
interface->SetMetric (metric); |
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
931 |
} |
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
932 |
|
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
933 |
uint16_t |
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
934 |
Ipv4L3Protocol::GetMetric (uint32_t i) const |
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
935 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
936 |
NS_LOG_FUNCTION (i); |
1776
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
937 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
938 |
return interface->GetMetric (); |
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
939 |
} |
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1524
diff
changeset
|
940 |
|
1434
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
941 |
bool |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
942 |
Ipv4L3Protocol::GetIfIndexForDestination ( |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
943 |
Ipv4Address destination, uint32_t& ifIndex) const |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
944 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
945 |
NS_LOG_FUNCTION (this << destination << &ifIndex); |
1442
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
946 |
// |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
947 |
// The first thing we do in trying to determine a source address is to |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
948 |
// consult the routing protocols. These will also check for a default route |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
949 |
// if one has been set. |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
950 |
// |
1434
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
951 |
for (Ipv4RoutingProtocolList::const_iterator i = m_routingProtocols.begin (); |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
952 |
i != m_routingProtocols.end (); |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
953 |
i++) |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
954 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
955 |
NS_LOG_LOGIC ("Requesting Source Address"); |
1435
a70de165a25a
set source IP address in udp-socket packets
Craig Dowell <craigdo@ee.washington.edu>
parents:
1434
diff
changeset
|
956 |
uint32_t ifIndexTmp; |
1434
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
957 |
|
1435
a70de165a25a
set source IP address in udp-socket packets
Craig Dowell <craigdo@ee.washington.edu>
parents:
1434
diff
changeset
|
958 |
if ((*i).second->RequestIfIndex (destination, ifIndexTmp)) |
1434
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
959 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
960 |
NS_LOG_LOGIC ("Found ifIndex " << ifIndexTmp); |
1435
a70de165a25a
set source IP address in udp-socket packets
Craig Dowell <craigdo@ee.washington.edu>
parents:
1434
diff
changeset
|
961 |
ifIndex = ifIndexTmp; |
1434
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
962 |
return true; |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
963 |
} |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
964 |
} |
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
|
965 |
// |
1442
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
966 |
// If there's no routing table entry telling us what *single* interface will |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
967 |
// be used to send a packet to this destination, we'll have to just pick one. |
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
|
968 |
// 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
|
969 |
// 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
|
970 |
// 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
|
971 |
// a situation where there are exactly two interfaces on the node, in which |
1442
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
972 |
// case interface one is the "single" interface connected to the outside world. |
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
|
973 |
// |
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
|
974 |
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
|
975 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
976 |
NS_LOG_LOGIC ("One Interface. Using interface 1."); |
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
|
977 |
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
|
978 |
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
|
979 |
} |
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
|
980 |
// |
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
|
981 |
// If we fall through to here, we have a node with multiple interfaces and |
1442
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
982 |
// no routes to guide us in determining what interface to choose. Either |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
983 |
// no default route was found (for unicast or multicast), or in the case of a |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
984 |
// multicast, the default route contained multiple outbound interfaces. |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
985 |
// |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
986 |
// The fallback position is to just get the unicast default route and use |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
987 |
// the outgoing interface specified there. We don't want to leave the source |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
988 |
// address unset, so we just assert here. |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
989 |
// |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
990 |
// N.B. that in the case of a multicast with a route containing multiple |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
991 |
// outgoing interfaces, the source address of packets from that node will be |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
992 |
// set to the IP address of the interface set in the default unicast route. |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
993 |
// Also, in the case of a broadcast, the same will be true. |
bb5cf98c0c64
real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
994 |
// |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
995 |
NS_LOG_LOGIC ("Using default unicast route"); |
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
|
996 |
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
|
997 |
|
2324
a3e10db411b9
The message "Unable to determine outbound interface. No default route set"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
998 |
if (route == NULL) |
a3e10db411b9
The message "Unable to determine outbound interface. No default route set"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
999 |
{ |
a3e10db411b9
The message "Unable to determine outbound interface. No default route set"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
1000 |
NS_LOG_LOGIC ("Ipv4L3Protocol::GetIfIndexForDestination (): " |
a3e10db411b9
The message "Unable to determine outbound interface. No default route set"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
1001 |
"Unable to determine outbound interface. No default route set"); |
a3e10db411b9
The message "Unable to determine outbound interface. No default route set"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
1002 |
return false; |
a3e10db411b9
The message "Unable to determine outbound interface. No default route set"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
1003 |
} |
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
|
1004 |
|
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
|
1005 |
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
|
1006 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1451
diff
changeset
|
1007 |
NS_LOG_LOGIC ("Default route specifies interface " << ifIndex); |
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
|
1008 |
return true; |
1434
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
1009 |
} |
2b63aafb050b
set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
1010 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
1011 |
uint16_t |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
1012 |
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
|
1013 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
1014 |
NS_LOG_FUNCTION (this << i); |
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1333
diff
changeset
|
1015 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
1016 |
return interface->GetMtu (); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
1017 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
1018 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
1019 |
bool |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
1020 |
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
|
1021 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
1022 |
NS_LOG_FUNCTION (this << i); |
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1333
diff
changeset
|
1023 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
1024 |
return interface->IsUp (); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
1025 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
1026 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
1027 |
void |
734
039fb338b6e9
Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
733
diff
changeset
|
1028 |
Ipv4L3Protocol::SetUp (uint32_t i) |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
1029 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
1030 |
NS_LOG_FUNCTION (this << i); |
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1333
diff
changeset
|
1031 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
1032 |
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
|
1033 |
|
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
1034 |
// 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
|
1035 |
// 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
|
1036 |
// Linux box) |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
1037 |
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
|
1038 |
&& (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
|
1039 |
{ |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
1040 |
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
|
1041 |
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
|
1042 |
} |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
1043 |
} |
1429
31cb0668defd
debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents:
1428
diff
changeset
|
1044 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
1045 |
void |
979
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
1046 |
Ipv4L3Protocol::SetDown (uint32_t ifaceIndex) |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
1047 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2977
diff
changeset
|
1048 |
NS_LOG_FUNCTION (this << ifaceIndex); |
1341
f685d4bf320f
use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1333
diff
changeset
|
1049 |
Ptr<Ipv4Interface> interface = GetInterface (ifaceIndex); |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
1050 |
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
|
1051 |
|
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
1052 |
// 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
|
1053 |
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
|
1054 |
while (modified) |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
1055 |
{ |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
1056 |
modified = false; |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
1057 |
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
|
1058 |
{ |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
1059 |
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
|
1060 |
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
|
1061 |
{ |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
1062 |
RemoveRoute (i); |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
1063 |
modified = true; |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
1064 |
break; |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
1065 |
} |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
1066 |
} |
cb805f7a2e8d
Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents:
734
diff
changeset
|
1067 |
} |
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
1068 |
} |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
1069 |
|
236
5673656dc2e7
a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
1070 |
}//namespace ns3 |