LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2007-2009 Strasbourg University | 3 * Copyright (c) 2007-2009 Strasbourg University |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 NS_ASSERT (tc != 0); | 198 NS_ASSERT (tc != 0); |
199 | 199 |
200 m_node->RegisterProtocolHandler (MakeCallback (&TrafficControlLayer::Receive,
tc), | 200 m_node->RegisterProtocolHandler (MakeCallback (&TrafficControlLayer::Receive,
tc), |
201 Ipv6L3Protocol::PROT_NUMBER, device); | 201 Ipv6L3Protocol::PROT_NUMBER, device); |
202 | 202 |
203 tc->RegisterProtocolHandler (MakeCallback (&Ipv6L3Protocol::Receive, this), | 203 tc->RegisterProtocolHandler (MakeCallback (&Ipv6L3Protocol::Receive, this), |
204 Ipv6L3Protocol::PROT_NUMBER, device); | 204 Ipv6L3Protocol::PROT_NUMBER, device); |
205 | 205 |
206 interface->SetNode (m_node); | 206 interface->SetNode (m_node); |
207 interface->SetDevice (device); | 207 interface->SetDevice (device); |
| 208 interface->SetTrafficControl (tc); |
208 interface->SetForwarding (m_ipForward); | 209 interface->SetForwarding (m_ipForward); |
209 return AddIpv6Interface (interface); | 210 return AddIpv6Interface (interface); |
210 } | 211 } |
211 | 212 |
212 uint32_t Ipv6L3Protocol::AddIpv6Interface (Ptr<Ipv6Interface> interface) | 213 uint32_t Ipv6L3Protocol::AddIpv6Interface (Ptr<Ipv6Interface> interface) |
213 { | 214 { |
214 NS_LOG_FUNCTION (this << interface); | 215 NS_LOG_FUNCTION (this << interface); |
215 uint32_t index = m_nInterfaces; | 216 uint32_t index = m_nInterfaces; |
216 | 217 |
217 m_interfaces.push_back (interface); | 218 m_interfaces.push_back (interface); |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 MakeCallback (&Ipv6L3Protocol::IpMulticast
Forward, this), | 1062 MakeCallback (&Ipv6L3Protocol::IpMulticast
Forward, this), |
1062 MakeCallback (&Ipv6L3Protocol::LocalDelive
r, this), | 1063 MakeCallback (&Ipv6L3Protocol::LocalDelive
r, this), |
1063 MakeCallback (&Ipv6L3Protocol::RouteInputE
rror, this))) | 1064 MakeCallback (&Ipv6L3Protocol::RouteInputE
rror, this))) |
1064 { | 1065 { |
1065 NS_LOG_WARN ("No route found for forwarding packet. Drop."); | 1066 NS_LOG_WARN ("No route found for forwarding packet. Drop."); |
1066 // Drop trace and ICMPs are courtesy of RouteInputError | 1067 // Drop trace and ICMPs are courtesy of RouteInputError |
1067 } | 1068 } |
1068 } | 1069 } |
1069 | 1070 |
1070 void | 1071 void |
1071 Ipv6L3Protocol::copyPacketAndTrace (const Ipv6Header & ipHeader, Ptr<Packet> pac
ket, | 1072 Ipv6L3Protocol::CopyPacketAndTrace (const Ipv6Header & ipHeader, Ptr<Packet> pac
ket, |
1072 Ptr<Ipv6> ipv6, uint32_t interface) | 1073 Ptr<Ipv6> ipv6, uint32_t interface) |
1073 { | 1074 { |
1074 Ptr<Packet> packetCopy = packet->Copy (); | 1075 Ptr<Packet> packetCopy = packet->Copy (); |
1075 packetCopy->AddHeader (ipHeader); | 1076 packetCopy->AddHeader (ipHeader); |
1076 m_txTrace (packetCopy, ipv6, interface); | 1077 m_txTrace (packetCopy, ipv6, interface); |
1077 } | 1078 } |
1078 | 1079 |
1079 void Ipv6L3Protocol::SendRealOut (Ptr<Ipv6Route> route, Ptr<Packet> packet, Ipv6
Header const& ipHeader) | 1080 void Ipv6L3Protocol::SendRealOut (Ptr<Ipv6Route> route, Ptr<Packet> packet, Ipv6
Header const& ipHeader) |
1080 { | 1081 { |
1081 NS_LOG_FUNCTION (this << route << packet << ipHeader); | 1082 NS_LOG_FUNCTION (this << route << packet << ipHeader); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 if (outInterface->IsUp ()) | 1144 if (outInterface->IsUp ()) |
1144 { | 1145 { |
1145 NS_LOG_LOGIC ("Send to gateway " << route->GetGateway ()); | 1146 NS_LOG_LOGIC ("Send to gateway " << route->GetGateway ()); |
1146 | 1147 |
1147 if (fragments.size () != 0) | 1148 if (fragments.size () != 0) |
1148 { | 1149 { |
1149 std::ostringstream oss; | 1150 std::ostringstream oss; |
1150 | 1151 |
1151 for (std::list<Ipv6ExtensionFragment::PacketWithIpv6Header>::const
_iterator it = fragments.begin (); it != fragments.end (); it++) | 1152 for (std::list<Ipv6ExtensionFragment::PacketWithIpv6Header>::const
_iterator it = fragments.begin (); it != fragments.end (); it++) |
1152 { | 1153 { |
1153 copyPacketAndTrace (it->second, it->first, m_node->GetObject<I
pv6> (), interface); | 1154 CopyPacketAndTrace (it->second, it->first, m_node->GetObject<I
pv6> (), interface); |
1154 outInterface->Send (it->first, it->second, route->GetGateway (
)); | 1155 outInterface->Send (it->first, it->second, route->GetGateway (
)); |
1155 } | 1156 } |
1156 } | 1157 } |
1157 else | 1158 else |
1158 { | 1159 { |
1159 copyPacketAndTrace (ipHeader, packet, m_node->GetObject<Ipv6> (),
interface); | 1160 CopyPacketAndTrace (ipHeader, packet, m_node->GetObject<Ipv6> (),
interface); |
1160 outInterface->Send (packet, ipHeader, route->GetGateway ()); | 1161 outInterface->Send (packet, ipHeader, route->GetGateway ()); |
1161 } | 1162 } |
1162 } | 1163 } |
1163 else | 1164 else |
1164 { | 1165 { |
1165 NS_LOG_LOGIC ("Dropping-- outgoing interface is down: " << route->GetG
ateway ()); | 1166 NS_LOG_LOGIC ("Dropping-- outgoing interface is down: " << route->GetG
ateway ()); |
1166 m_dropTrace (ipHeader, packet, DROP_INTERFACE_DOWN, m_node->GetObject<
Ipv6> (), interface); | 1167 m_dropTrace (ipHeader, packet, DROP_INTERFACE_DOWN, m_node->GetObject<
Ipv6> (), interface); |
1167 } | 1168 } |
1168 } | 1169 } |
1169 else | 1170 else |
1170 { | 1171 { |
1171 if (outInterface->IsUp ()) | 1172 if (outInterface->IsUp ()) |
1172 { | 1173 { |
1173 NS_LOG_LOGIC ("Send to destination " << ipHeader.GetDestinationAddress
()); | 1174 NS_LOG_LOGIC ("Send to destination " << ipHeader.GetDestinationAddress
()); |
1174 | 1175 |
1175 if (fragments.size () != 0) | 1176 if (fragments.size () != 0) |
1176 { | 1177 { |
1177 std::ostringstream oss; | 1178 std::ostringstream oss; |
1178 | 1179 |
1179 for (std::list<Ipv6ExtensionFragment::PacketWithIpv6Header>::const
_iterator it = fragments.begin (); it != fragments.end (); it++) | 1180 for (std::list<Ipv6ExtensionFragment::PacketWithIpv6Header>::const
_iterator it = fragments.begin (); it != fragments.end (); it++) |
1180 { | 1181 { |
1181 copyPacketAndTrace (it->second, it->first, m_node->GetObject<I
pv6> (), interface); | 1182 CopyPacketAndTrace (it->second, it->first, m_node->GetObject<I
pv6> (), interface); |
1182 outInterface->Send (it->first, it->second, ipHeader.GetDestina
tionAddress ()); | 1183 outInterface->Send (it->first, it->second, ipHeader.GetDestina
tionAddress ()); |
1183 } | 1184 } |
1184 } | 1185 } |
1185 else | 1186 else |
1186 { | 1187 { |
1187 copyPacketAndTrace (ipHeader, packet, m_node->GetObject<Ipv6> (),
interface); | 1188 CopyPacketAndTrace (ipHeader, packet, m_node->GetObject<Ipv6> (),
interface); |
1188 outInterface->Send (packet, ipHeader, ipHeader.GetDestinationAddre
ss ()); | 1189 outInterface->Send (packet, ipHeader, ipHeader.GetDestinationAddre
ss ()); |
1189 } | 1190 } |
1190 } | 1191 } |
1191 else | 1192 else |
1192 { | 1193 { |
1193 NS_LOG_LOGIC ("Dropping-- outgoing interface is down: " << ipHeader.Ge
tDestinationAddress ()); | 1194 NS_LOG_LOGIC ("Dropping-- outgoing interface is down: " << ipHeader.Ge
tDestinationAddress ()); |
1194 m_dropTrace (ipHeader, packet, DROP_INTERFACE_DOWN, m_node->GetObject<
Ipv6> (), interface); | 1195 m_dropTrace (ipHeader, packet, DROP_INTERFACE_DOWN, m_node->GetObject<
Ipv6> (), interface); |
1195 } | 1196 } |
1196 } | 1197 } |
1197 } | 1198 } |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1583 | 1584 |
1584 if (iter == m_multicastAddressesNoInterface.end ()) | 1585 if (iter == m_multicastAddressesNoInterface.end ()) |
1585 { | 1586 { |
1586 return false; | 1587 return false; |
1587 } | 1588 } |
1588 return true; | 1589 return true; |
1589 } | 1590 } |
1590 | 1591 |
1591 } /* namespace ns3 */ | 1592 } /* namespace ns3 */ |
1592 | 1593 |
LEFT | RIGHT |