22 #include "ns3/assert.h"
23 #include "ns3/packet.h"
25 #include "ns3/boolean.h"
26 #include "ns3/object-vector.h"
28 #include "ns3/ipv4-route.h"
29 #include "ns3/ipv6-route.h"
30 #include "ns3/ipv6-header.h"
57 .AddConstructor<UdpL4Protocol> ()
58 .AddAttribute (
"SocketList",
"The list of sockets associated to this protocol.",
61 MakeObjectVectorChecker<UdpSocketImpl> ())
92 Ptr<Node> node = this->GetObject<Node> ();
93 Ptr<Ipv4> ipv4 = this->GetObject<Ipv4> ();
98 if ((node != 0) && (ipv4 != 0 || ipv6 != 0))
102 udpFactory->SetUdp (
this);
203 NS_LOG_FUNCTION (
this << localAddress << localPort << peerAddress << peerPort);
205 peerAddress, peerPort);
246 NS_LOG_FUNCTION (
this << localAddress << localPort << peerAddress << peerPort);
248 peerAddress, peerPort);
260 uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
262 const uint8_t payload[8])
264 NS_LOG_FUNCTION (
this << icmpSource << icmpTtl << icmpType << icmpCode << icmpInfo
265 << payloadSource << payloadDestination);
267 src = payload[0] << 8;
269 dst = payload[2] << 8;
275 endPoint->
ForwardIcmp (icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
279 NS_LOG_DEBUG (
"no endpoint found source=" << payloadSource <<
280 ", destination="<<payloadDestination<<
281 ", src=" << src <<
", dst=" << dst);
287 uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
289 const uint8_t payload[8])
291 NS_LOG_FUNCTION (
this << icmpSource << icmpTtl << icmpType << icmpCode << icmpInfo
292 << payloadSource << payloadDestination);
294 src = payload[0] << 8;
296 dst = payload[2] << 8;
302 endPoint->
ForwardIcmp (icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
306 NS_LOG_DEBUG (
"no endpoint found source=" << payloadSource <<
307 ", destination="<<payloadDestination<<
308 ", src=" << src <<
", dst=" << dst);
343 if (endPoints.empty ())
345 if (this->GetObject<Ipv6L3Protocol> () != 0)
347 NS_LOG_LOGIC (
" No Ipv4 endpoints matched on UdpL4Protocol, trying Ipv6 "<<
this);
351 return (this->
Receive (packet, src, dst, fakeInterface));
360 endPoint != endPoints.end (); endPoint++)
395 if (endPoints.empty ())
401 endPoint != endPoints.end (); endPoint++)
411 uint16_t sport, uint16_t dport)
436 NS_LOG_FUNCTION (
this << packet << saddr << daddr << sport << dport << route);
457 uint16_t sport, uint16_t dport)
482 NS_LOG_FUNCTION (
this << packet << saddr << daddr << sport << dport << route);