author | Hajime Tazaki <tazaki@sfc.wide.ad.jp> |
Tue, 07 Jan 2014 00:26:21 +0900 | |
changeset 541 | de7335a01743 |
parent 495 | da74de98d8fa |
child 546 | d7753e122d06 |
permissions | -rw-r--r-- |
239
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
2 |
/* |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
3 |
* Copyright (c) 2012 INRIA |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
4 |
* |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
8 |
* |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
13 |
* |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
17 |
* |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
18 |
* Author: Frédéric Urbani |
418
4359ef53a0af
Bug 1449 - Use Linux kernel stack for ns-3 applications
Hajime Tazaki <tazaki@nict.go.jp>
parents:
413
diff
changeset
|
19 |
* Hajime Tazaki <tazaki@nict.go.jp> |
239
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
20 |
*/ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
21 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
22 |
#include "ipv4-linux.h" |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
23 |
#include "ns3/log.h" |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
24 |
#include "ns3/node.h" |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
25 |
#include "ns3/ipv4-list-routing-helper.h" |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
26 |
#include "ns3/ipv4-static-routing-helper.h" |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
27 |
#include "ns3/ipv4-global-routing-helper.h" |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
28 |
#include "ns3/ipv4-interface.h" |
403
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
29 |
#include "ns3/ipv4-global-routing.h" |
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
30 |
#include "ns3/ipv4-routing-table-entry.h" |
541
de7335a01743
Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
495
diff
changeset
|
31 |
#include "linux-stack-helper.h" |
418
4359ef53a0af
Bug 1449 - Use Linux kernel stack for ns-3 applications
Hajime Tazaki <tazaki@nict.go.jp>
parents:
413
diff
changeset
|
32 |
#include "linux-ipv4-raw-socket-factory-impl.h" |
4359ef53a0af
Bug 1449 - Use Linux kernel stack for ns-3 applications
Hajime Tazaki <tazaki@nict.go.jp>
parents:
413
diff
changeset
|
33 |
#include "linux-udp-socket-factory-impl.h" |
4359ef53a0af
Bug 1449 - Use Linux kernel stack for ns-3 applications
Hajime Tazaki <tazaki@nict.go.jp>
parents:
413
diff
changeset
|
34 |
#include "linux-tcp-socket-factory-impl.h" |
4359ef53a0af
Bug 1449 - Use Linux kernel stack for ns-3 applications
Hajime Tazaki <tazaki@nict.go.jp>
parents:
413
diff
changeset
|
35 |
#include "linux-dccp-socket-factory-impl.h" |
239
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
36 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
37 |
NS_LOG_COMPONENT_DEFINE ("Ipv4Linux"); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
38 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
39 |
namespace ns3 { |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
40 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
41 |
NS_OBJECT_ENSURE_REGISTERED (Ipv4Linux); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
42 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
43 |
TypeId |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
44 |
Ipv4Linux::GetTypeId (void) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
45 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
46 |
static TypeId tid = TypeId ("ns3::Ipv4Linux") |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
47 |
.SetParent<Ipv4> () |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
48 |
.AddConstructor<Ipv4Linux> (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
49 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
50 |
return tid; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
51 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
52 |
|
367
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
53 |
Ipv4Linux::Ipv4Linux () |
403
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
54 |
: m_nanoSec (0) |
239
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
55 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
56 |
NS_LOG_FUNCTION (this); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
57 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
58 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
59 |
Ipv4Linux::~Ipv4Linux () |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
60 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
61 |
NS_LOG_FUNCTION (this); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
62 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
63 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
64 |
void |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
65 |
Ipv4Linux::SetRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
66 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
67 |
NS_LOG_FUNCTION (this); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
68 |
m_routingProtocol = routingProtocol; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
69 |
m_routingProtocol->SetIpv4 (this); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
70 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
71 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
72 |
Ptr<Ipv4RoutingProtocol> |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
73 |
Ipv4Linux::GetRoutingProtocol (void) const |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
74 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
75 |
NS_LOG_FUNCTION (this); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
76 |
return m_routingProtocol; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
77 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
78 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
79 |
uint32_t |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
80 |
Ipv4Linux::AddInterface (Ptr<NetDevice> device) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
81 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
82 |
NS_LOG_FUNCTION (this << &device); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
83 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
84 |
Ptr<Ipv4Interface> interface = CreateObject<Ipv4Interface> (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
85 |
interface->SetDevice (device); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
86 |
interface->SetForwarding (m_ipForward); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
87 |
return AddIpv4Interface (interface); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
88 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
89 |
uint32_t |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
90 |
Ipv4Linux::AddIpv4Interface (Ptr<Ipv4Interface>interface) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
91 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
92 |
NS_LOG_FUNCTION (this << interface); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
93 |
uint32_t index = m_interfaces.size (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
94 |
m_interfaces.push_back (interface); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
95 |
return index; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
96 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
97 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
98 |
uint32_t |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
99 |
Ipv4Linux::GetNInterfaces (void) const |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
100 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
101 |
NS_LOG_FUNCTION (this); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
102 |
return m_interfaces.size (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
103 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
104 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
105 |
int32_t |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
106 |
Ipv4Linux::GetInterfaceForAddress (Ipv4Address address) const |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
107 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
108 |
NS_LOG_FUNCTION (this); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
109 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
110 |
int32_t interface = 0; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
111 |
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
112 |
i != m_interfaces.end (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
113 |
i++, interface++) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
114 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
115 |
for (uint32_t j = 0; j < (*i)->GetNAddresses (); j++) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
116 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
117 |
if ((*i)->GetAddress (j).GetLocal () == address) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
118 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
119 |
return interface; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
120 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
121 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
122 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
123 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
124 |
return -1; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
125 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
126 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
127 |
void |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
128 |
Ipv4Linux::Send (Ptr<Packet> packet, Ipv4Address source, |
367
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
129 |
Ipv4Address destination, uint8_t protocol, Ptr<Ipv4Route> route) |
239
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
130 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
131 |
NS_LOG_FUNCTION (this << "empty method."); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
132 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
133 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
134 |
void |
259 | 135 |
Ipv4Linux::SendWithHeader (Ptr<Packet> packet, Ipv4Header ipHeader, Ptr<Ipv4Route> route) |
136 |
{ |
|
137 |
NS_LOG_FUNCTION (this << "empty method."); |
|
138 |
} |
|
139 |
||
140 |
void |
|
239
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
141 |
Ipv4Linux::Insert (Ptr<IpL4Protocol> protocol) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
142 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
143 |
NS_LOG_FUNCTION (this << "empty method."); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
144 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
145 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
146 |
bool |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
147 |
Ipv4Linux::IsDestinationAddress (Ipv4Address address, uint32_t iif) const |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
148 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
149 |
// First check the incoming interface for a unicast address match |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
150 |
for (uint32_t i = 0; i < GetNAddresses (iif); i++) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
151 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
152 |
Ipv4InterfaceAddress iaddr = GetAddress (iif, i); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
153 |
if (address == iaddr.GetLocal ()) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
154 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
155 |
NS_LOG_LOGIC ("For me (destination " << address << " match)"); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
156 |
return true; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
157 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
158 |
if (address == iaddr.GetBroadcast ()) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
159 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
160 |
NS_LOG_LOGIC ("For me (interface broadcast address)"); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
161 |
return true; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
162 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
163 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
164 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
165 |
if (address.IsMulticast ()) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
166 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
167 |
#ifdef NOTYET |
375 | 168 |
if (MulticastCheckGroup (iif, address)) |
239
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
169 |
#endif |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
170 |
if (true) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
171 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
172 |
NS_LOG_LOGIC ("For me (Ipv4Addr multicast address"); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
173 |
return true; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
174 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
175 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
176 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
177 |
if (address.IsBroadcast ()) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
178 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
179 |
NS_LOG_LOGIC ("For me (Ipv4Addr broadcast address)"); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
180 |
return true; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
181 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
182 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
183 |
if (GetWeakEsModel ()) // Check other interfaces |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
184 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
185 |
for (uint32_t j = 0; j < GetNInterfaces (); j++) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
186 |
{ |
367
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
187 |
if (j == uint32_t (iif)) |
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
188 |
{ |
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
189 |
continue; |
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
190 |
} |
239
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
191 |
for (uint32_t i = 0; i < GetNAddresses (j); i++) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
192 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
193 |
Ipv4InterfaceAddress iaddr = GetAddress (j, i); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
194 |
if (address == iaddr.GetLocal ()) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
195 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
196 |
NS_LOG_LOGIC ("For me (destination " << address << " match) on another interface"); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
197 |
return true; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
198 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
199 |
// This is a small corner case: match another interface's broadcast address |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
200 |
if (address == iaddr.GetBroadcast ()) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
201 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
202 |
NS_LOG_LOGIC ("For me (interface broadcast address on another interface)"); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
203 |
return true; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
204 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
205 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
206 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
207 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
208 |
return false; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
209 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
210 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
211 |
int32_t |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
212 |
Ipv4Linux::GetInterfaceForPrefix (Ipv4Address address, Ipv4Mask mask) const |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
213 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
214 |
NS_LOG_FUNCTION (this); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
215 |
int32_t interface = 0; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
216 |
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
217 |
i != m_interfaces.end (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
218 |
i++, interface++) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
219 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
220 |
for (uint32_t j = 0; j < (*i)->GetNAddresses (); j++) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
221 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
222 |
if ((*i)->GetAddress (j).GetLocal ().CombineMask (mask) == address.CombineMask (mask)) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
223 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
224 |
return interface; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
225 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
226 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
227 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
228 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
229 |
return -1; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
230 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
231 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
232 |
Ptr<NetDevice> |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
233 |
Ipv4Linux::GetNetDevice (uint32_t i) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
234 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
235 |
NS_LOG_FUNCTION (this); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
236 |
return GetInterface (i)->GetDevice (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
237 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
238 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
239 |
int32_t |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
240 |
Ipv4Linux::GetInterfaceForDevice (Ptr<const NetDevice> device) const |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
241 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
242 |
NS_LOG_FUNCTION (this); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
243 |
int32_t interface = 0; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
244 |
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
245 |
i != m_interfaces.end (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
246 |
i++, interface++) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
247 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
248 |
if ((*i)->GetDevice () == device) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
249 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
250 |
return interface; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
251 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
252 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
253 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
254 |
return -1; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
255 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
256 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
257 |
bool |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
258 |
Ipv4Linux::AddAddress (uint32_t i, Ipv4InterfaceAddress address) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
259 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
260 |
NS_LOG_FUNCTION (this << i << address); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
261 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
262 |
bool retVal = interface->AddAddress (address); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
263 |
if (m_routingProtocol != 0) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
264 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
265 |
m_routingProtocol->NotifyAddAddress (i, address); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
266 |
} |
403
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
267 |
|
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
268 |
std::ostringstream oss; |
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
269 |
Ptr<Node> node = this->GetObject<Node> (); |
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
270 |
oss << "-f inet addr add "; |
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
271 |
address.GetLocal ().Print (oss); |
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
272 |
oss << '/' << address.GetMask ().GetPrefixLength () << " dev sim" << i; |
541
de7335a01743
Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
495
diff
changeset
|
273 |
LinuxStackHelper::RunIp (node, NanoSeconds (++m_nanoSec), oss.str ()); |
403
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
274 |
oss.str (""); |
413 | 275 |
oss << "link set sim" << i << " up arp " |
474
4986746f314a
add mptcp example with LTE ue device
Hajime Tazaki <tazaki@nict.go.jp>
parents:
418
diff
changeset
|
276 |
<< ((interface->GetDevice ()->NeedsArp ()) ? "on" : "off"); |
541
de7335a01743
Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
495
diff
changeset
|
277 |
LinuxStackHelper::RunIp (node, NanoSeconds (++m_nanoSec), oss.str ()); |
403
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
278 |
|
239
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
279 |
return retVal; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
280 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
281 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
282 |
uint32_t |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
283 |
Ipv4Linux::GetNAddresses (uint32_t interface) const |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
284 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
285 |
Ptr<Ipv4Interface> iface = GetInterface (interface); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
286 |
return iface->GetNAddresses (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
287 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
288 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
289 |
Ipv4InterfaceAddress |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
290 |
Ipv4Linux::GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
291 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
292 |
NS_LOG_FUNCTION (this); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
293 |
Ptr<Ipv4Interface> interface = GetInterface (interfaceIndex); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
294 |
return interface->GetAddress (addressIndex); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
295 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
296 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
297 |
bool |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
298 |
Ipv4Linux::RemoveAddress (uint32_t i, uint32_t addressIndex) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
299 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
300 |
NS_LOG_FUNCTION (this << i << addressIndex); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
301 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
302 |
Ipv4InterfaceAddress address = interface->RemoveAddress (addressIndex); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
303 |
if (address != Ipv4InterfaceAddress ()) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
304 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
305 |
if (m_routingProtocol != 0) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
306 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
307 |
m_routingProtocol->NotifyRemoveAddress (i, address); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
308 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
309 |
return true; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
310 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
311 |
return false; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
312 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
313 |
|
495
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
314 |
bool |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
315 |
Ipv4Linux::RemoveAddress (uint32_t i, Ipv4Address address) |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
316 |
{ |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
317 |
NS_LOG_FUNCTION (this << i << address); |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
318 |
|
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
319 |
if (address == Ipv4Address::GetLoopback()) |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
320 |
{ |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
321 |
NS_LOG_WARN ("Cannot remove loopback address."); |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
322 |
return false; |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
323 |
} |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
324 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
325 |
Ipv4InterfaceAddress ifAddr = interface->RemoveAddress (address); |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
326 |
if (ifAddr != Ipv4InterfaceAddress ()) |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
327 |
{ |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
328 |
if (m_routingProtocol != 0) |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
329 |
{ |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
330 |
m_routingProtocol->NotifyRemoveAddress (i, ifAddr); |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
331 |
} |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
332 |
return true; |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
333 |
} |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
334 |
return false; |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
335 |
} |
da74de98d8fa
update with Bug 760 - IP address removal can be painful
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
474
diff
changeset
|
336 |
|
239
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
337 |
Ipv4Address |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
338 |
Ipv4Linux::SelectSourceAddress (Ptr<const NetDevice> device, |
367
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
339 |
Ipv4Address dst, Ipv4InterfaceAddress::InterfaceAddressScope_e scope) |
239
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
340 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
341 |
NS_LOG_FUNCTION (this << device << dst << scope); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
342 |
Ipv4Address addr ("0.0.0.0"); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
343 |
Ipv4InterfaceAddress iaddr; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
344 |
bool found = false; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
345 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
346 |
if (device != 0) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
347 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
348 |
int32_t i = GetInterfaceForDevice (device); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
349 |
NS_ASSERT_MSG (i >= 0, "No device found on node"); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
350 |
for (uint32_t j = 0; j < GetNAddresses (i); j++) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
351 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
352 |
iaddr = GetAddress (i, j); |
367
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
353 |
if (iaddr.IsSecondary ()) |
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
354 |
{ |
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
355 |
continue; |
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
356 |
} |
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
357 |
if (iaddr.GetScope () > scope) |
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
358 |
{ |
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
359 |
continue; |
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
360 |
} |
239
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
361 |
if (dst.CombineMask (iaddr.GetMask ()) == iaddr.GetLocal ().CombineMask (iaddr.GetMask ()) ) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
362 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
363 |
return iaddr.GetLocal (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
364 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
365 |
if (!found) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
366 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
367 |
addr = iaddr.GetLocal (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
368 |
found = true; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
369 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
370 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
371 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
372 |
if (found) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
373 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
374 |
return addr; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
375 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
376 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
377 |
// Iterate among all interfaces |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
378 |
for (uint32_t i = 0; i < GetNInterfaces (); i++) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
379 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
380 |
for (uint32_t j = 0; j < GetNAddresses (i); j++) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
381 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
382 |
iaddr = GetAddress (i, j); |
367
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
383 |
if (iaddr.IsSecondary ()) |
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
384 |
{ |
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
385 |
continue; |
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
386 |
} |
239
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
387 |
if (iaddr.GetScope () != Ipv4InterfaceAddress::LINK |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
388 |
&& iaddr.GetScope () <= scope) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
389 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
390 |
return iaddr.GetLocal (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
391 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
392 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
393 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
394 |
NS_LOG_WARN ("Could not find source address for " << dst << " and scope " |
367
be749a6bbde0
coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
259
diff
changeset
|
395 |
<< scope << ", returning 0"); |
239
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
396 |
return addr; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
397 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
398 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
399 |
void |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
400 |
Ipv4Linux::SetMetric (uint32_t i, uint16_t metric) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
401 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
402 |
NS_LOG_FUNCTION (this << i << metric); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
403 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
404 |
interface->SetMetric (metric); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
405 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
406 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
407 |
uint16_t |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
408 |
Ipv4Linux::GetMetric (uint32_t i) const |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
409 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
410 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
411 |
return interface->GetMetric (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
412 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
413 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
414 |
uint16_t |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
415 |
Ipv4Linux::GetMtu (uint32_t i) const |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
416 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
417 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
418 |
return interface->GetDevice ()->GetMtu (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
419 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
420 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
421 |
bool |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
422 |
Ipv4Linux::IsUp (uint32_t i) const |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
423 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
424 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
425 |
return interface->IsUp (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
426 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
427 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
428 |
void |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
429 |
Ipv4Linux::SetUp (uint32_t i) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
430 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
431 |
NS_LOG_FUNCTION (this << i); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
432 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
433 |
interface->SetUp (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
434 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
435 |
if (m_routingProtocol != 0) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
436 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
437 |
m_routingProtocol->NotifyInterfaceUp (i); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
438 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
439 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
440 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
441 |
void |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
442 |
Ipv4Linux::SetDown (uint32_t ifaceIndex) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
443 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
444 |
NS_LOG_FUNCTION (this << ifaceIndex); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
445 |
Ptr<Ipv4Interface> interface = GetInterface (ifaceIndex); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
446 |
interface->SetDown (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
447 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
448 |
if (m_routingProtocol != 0) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
449 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
450 |
m_routingProtocol->NotifyInterfaceDown (ifaceIndex); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
451 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
452 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
453 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
454 |
bool |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
455 |
Ipv4Linux::IsForwarding (uint32_t i) const |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
456 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
457 |
NS_LOG_FUNCTION (this << i); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
458 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
459 |
NS_LOG_LOGIC ("Forwarding state: " << interface->IsForwarding ()); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
460 |
return interface->IsForwarding (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
461 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
462 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
463 |
void |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
464 |
Ipv4Linux::SetForwarding (uint32_t i, bool val) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
465 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
466 |
NS_LOG_FUNCTION (this << i); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
467 |
Ptr<Ipv4Interface> interface = GetInterface (i); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
468 |
interface->SetForwarding (val); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
469 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
470 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
471 |
void |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
472 |
Ipv4Linux::SetIpForward (bool forward) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
473 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
474 |
NS_LOG_FUNCTION (this << forward); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
475 |
m_ipForward = forward; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
476 |
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
477 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
478 |
(*i)->SetForwarding (forward); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
479 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
480 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
481 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
482 |
bool |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
483 |
Ipv4Linux::GetIpForward (void) const |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
484 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
485 |
return m_ipForward; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
486 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
487 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
488 |
void |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
489 |
Ipv4Linux::SetWeakEsModel (bool model) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
490 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
491 |
m_weakEsModel = model; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
492 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
493 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
494 |
bool |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
495 |
Ipv4Linux::GetWeakEsModel (void) const |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
496 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
497 |
return m_weakEsModel; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
498 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
499 |
|
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
500 |
void |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
501 |
Ipv4Linux::InstallNode (Ptr<Node> node) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
502 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
503 |
ObjectFactory factory; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
504 |
factory.SetTypeId ("ns3::Ipv4Linux"); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
505 |
Ptr<Object> protocol = factory.Create <Object> (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
506 |
node->AggregateObject (protocol); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
507 |
Ipv4GlobalRoutingHelper globalRouting; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
508 |
// Set routing |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
509 |
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> (); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
510 |
Ptr<Ipv4RoutingProtocol> ipv4Routing = globalRouting.Create (node); |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
511 |
ipv4->SetRoutingProtocol (ipv4Routing); |
418
4359ef53a0af
Bug 1449 - Use Linux kernel stack for ns-3 applications
Hajime Tazaki <tazaki@nict.go.jp>
parents:
413
diff
changeset
|
512 |
// Socket related stuff |
4359ef53a0af
Bug 1449 - Use Linux kernel stack for ns-3 applications
Hajime Tazaki <tazaki@nict.go.jp>
parents:
413
diff
changeset
|
513 |
Ptr<LinuxIpv4RawSocketFactoryImpl> ipv4rawFactory = CreateObject<LinuxIpv4RawSocketFactoryImpl> (); |
4359ef53a0af
Bug 1449 - Use Linux kernel stack for ns-3 applications
Hajime Tazaki <tazaki@nict.go.jp>
parents:
413
diff
changeset
|
514 |
node->AggregateObject (ipv4rawFactory); |
4359ef53a0af
Bug 1449 - Use Linux kernel stack for ns-3 applications
Hajime Tazaki <tazaki@nict.go.jp>
parents:
413
diff
changeset
|
515 |
Ptr<LinuxUdpSocketFactoryImpl> udpFactory = CreateObject<LinuxUdpSocketFactoryImpl> (); |
4359ef53a0af
Bug 1449 - Use Linux kernel stack for ns-3 applications
Hajime Tazaki <tazaki@nict.go.jp>
parents:
413
diff
changeset
|
516 |
node->AggregateObject (udpFactory); |
4359ef53a0af
Bug 1449 - Use Linux kernel stack for ns-3 applications
Hajime Tazaki <tazaki@nict.go.jp>
parents:
413
diff
changeset
|
517 |
Ptr<LinuxTcpSocketFactoryImpl> tcpFactory = CreateObject<LinuxTcpSocketFactoryImpl> (); |
4359ef53a0af
Bug 1449 - Use Linux kernel stack for ns-3 applications
Hajime Tazaki <tazaki@nict.go.jp>
parents:
413
diff
changeset
|
518 |
node->AggregateObject (tcpFactory); |
4359ef53a0af
Bug 1449 - Use Linux kernel stack for ns-3 applications
Hajime Tazaki <tazaki@nict.go.jp>
parents:
413
diff
changeset
|
519 |
Ptr<LinuxDccpSocketFactoryImpl> dccpFactory = CreateObject<LinuxDccpSocketFactoryImpl> (); |
4359ef53a0af
Bug 1449 - Use Linux kernel stack for ns-3 applications
Hajime Tazaki <tazaki@nict.go.jp>
parents:
413
diff
changeset
|
520 |
node->AggregateObject (dccpFactory); |
239
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
521 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
522 |
Ptr<Ipv4Interface> |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
523 |
Ipv4Linux::GetInterface (uint32_t index) const |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
524 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
525 |
if (index < m_interfaces.size ()) |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
526 |
{ |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
527 |
return m_interfaces[index]; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
528 |
} |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
529 |
return 0; |
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
530 |
} |
259 | 531 |
|
532 |
Ptr<IpL4Protocol> |
|
533 |
Ipv4Linux::GetProtocol (int protocolNumber) const |
|
534 |
{ |
|
535 |
return 0; |
|
239
46380fd02339
Add LinuxStackHelper classes which help you to assign ip to devices,
frederic.urbani@inria.fr
parents:
diff
changeset
|
536 |
} |
259 | 537 |
|
538 |
Ptr<Socket> |
|
539 |
Ipv4Linux::CreateRawSocket (void) |
|
540 |
{ |
|
541 |
return 0; |
|
542 |
} |
|
543 |
||
544 |
/** |
|
545 |
* Do nothing |
|
546 |
*/ |
|
547 |
void |
|
548 |
Ipv4Linux::DeleteRawSocket (Ptr<Socket> socket) |
|
549 |
{ |
|
550 |
||
551 |
} |
|
403
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
552 |
|
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
553 |
void |
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
554 |
Ipv4Linux::PopulateRoutingTable () |
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
555 |
{ |
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
556 |
// Only support Ipv4GlobalRouting |
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
557 |
Ptr<Node> node = this->GetObject<Node> (); |
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
558 |
Ptr<Ipv4GlobalRouting> globalRouting = DynamicCast<Ipv4GlobalRouting> (GetRoutingProtocol ()); |
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
559 |
NS_ASSERT_MSG (globalRouting, "No global routing"); |
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
560 |
|
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
561 |
for (uint32_t i = 0; i < globalRouting->GetNRoutes (); i++) |
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
562 |
{ |
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
563 |
Ipv4RoutingTableEntry route = globalRouting->GetRoute (i); |
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
564 |
std::ostringstream oss; |
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
565 |
oss << "route add to " << route.GetDest () << '/' << route.GetDestNetworkMask () << " via " << route.GetGateway (); |
541
de7335a01743
Bug 1713 - Ipv6 address configuration support for LinuxStackHelper
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
495
diff
changeset
|
566 |
LinuxStackHelper::RunIp (node, NanoSeconds (++m_nanoSec), oss.str ()); |
403
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
567 |
} |
259 | 568 |
} |
403
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
569 |
|
6998fb05cf4f
Bug 1448 - DCE Kernel mode. Create a helper in order to create automatically the static routes.
Hajime Tazaki <tazaki@nict.go.jp>
parents:
375
diff
changeset
|
570 |
} |