diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/arp-l3-protocol.cc src/internet-stack/arp-l3-protocol.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/arp-l3-protocol.cc Tue Nov 17 17:00:49 2009 --- src/internet-stack/arp-l3-protocol.cc Tue Nov 17 16:00:34 2009 *************** *** 316,323 **** ArpHeader arp; // need to pick a source address; use routing implementation to select Ptr ipv4 = m_node->GetObject (); ! int32_t interface = ipv4->GetInterfaceForDevice (cache->GetDevice ()); ! NS_ASSERT (interface >= 0); Ipv4Header header; header.SetDestination (to); Socket::SocketErrno errno_; --- 316,323 ---- ArpHeader arp; // need to pick a source address; use routing implementation to select Ptr ipv4 = m_node->GetObject (); ! Ptr interface = cache->GetDevice (); ! NS_ASSERT (interface != 0); Ipv4Header header; header.SetDestination (to); Socket::SocketErrno errno_; diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/icmpv4-l4-protocol.cc src/internet-stack/icmpv4-l4-protocol.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/icmpv4-l4-protocol.cc Tue Nov 17 17:00:49 2009 --- src/internet-stack/icmpv4-l4-protocol.cc Tue Nov 17 16:03:26 2009 *************** *** 89,95 **** header.SetProtocol (PROT_NUMBER); Socket::SocketErrno errno_; Ptr route; ! uint32_t oif = 0; //specify non-zero if bound to a source address route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_); if (route != 0) { --- 89,95 ---- header.SetProtocol (PROT_NUMBER); Socket::SocketErrno errno_; Ptr route; ! Ptr oif(0); //specify non-zero if bound to a source address route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_); if (route != 0) { diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/icmpv6-l4-protocol.cc src/internet-stack/icmpv6-l4-protocol.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/icmpv6-l4-protocol.cc Tue Nov 17 17:00:49 2009 --- src/internet-stack/icmpv6-l4-protocol.cc Tue Nov 17 16:09:46 2009 *************** *** 742,748 **** SocketIpTtlTag tag; Socket::SocketErrno err; Ptr route; ! uint32_t oif = 0; //specify non-zero if bound to a source address header.SetDestinationAddress (dst); route = ipv6->GetRoutingProtocol ()->RouteOutput (packet, header, oif, err); --- 742,748 ---- SocketIpTtlTag tag; Socket::SocketErrno err; Ptr route; ! Ptr oif(0); //specify non-zero if bound to a source address header.SetDestinationAddress (dst); route = ipv6->GetRoutingProtocol ()->RouteOutput (packet, header, oif, err); diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/ipv4-end-point-demux.cc src/internet-stack/ipv4-end-point-demux.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/ipv4-end-point-demux.cc Tue Nov 17 17:00:49 2009 --- src/internet-stack/ipv4-end-point-demux.cc Wed Nov 18 12:31:51 2009 *************** *** 219,224 **** --- 219,235 ---- << " does not match packet dport " << dport); continue; } + if (endP->GetBoundNetDevice()) + { + if (endP->GetBoundNetDevice() != incomingInterface->GetDevice()) + { + NS_LOG_LOGIC ("Skipping endpoint " << &endP + << " because endpoint is bound to specific device and" + << endP->GetBoundNetDevice () + << " does not match packet device " << incomingInterface->GetDevice()); + continue; + } + } bool subnetDirected = false; Ipv4Address incomingInterfaceAddr = daddr; // may be a broadcast for (uint32_t i = 0; i < incomingInterface->GetNAddresses (); i++) diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/ipv4-end-point.cc src/internet-stack/ipv4-end-point.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/ipv4-end-point.cc Tue Nov 17 17:00:49 2009 --- src/internet-stack/ipv4-end-point.cc Wed Nov 18 12:29:11 2009 *************** *** 75,80 **** --- 75,93 ---- m_peerPort = port; } + void + Ipv4EndPoint::BindToNetDevice (Ptr netdevice) + { + m_boundnetdevice = netdevice; + return; + } + + Ptr + Ipv4EndPoint::GetBoundNetDevice (void) + { + return m_boundnetdevice; + } + void Ipv4EndPoint::SetRxCallback (Callback, Ipv4Address, uint16_t> callback) { diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/ipv4-end-point.h src/internet-stack/ipv4-end-point.h *** ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/ipv4-end-point.h Tue Nov 17 17:00:49 2009 --- src/internet-stack/ipv4-end-point.h Wed Nov 18 12:28:53 2009 *************** *** 24,29 **** --- 24,30 ---- #include #include "ns3/ipv4-address.h" #include "ns3/callback.h" + #include "ns3/net-device.h" namespace ns3 { *************** *** 53,58 **** --- 54,62 ---- uint16_t GetPeerPort (void); void SetPeer (Ipv4Address address, uint16_t port); + + void BindToNetDevice (Ptr netdevice); + Ptr GetBoundNetDevice (void); // Called from socket implementations to get notified about important events. void SetRxCallback (Callback, Ipv4Address, uint16_t> callback); *************** *** 77,82 **** --- 81,87 ---- uint16_t m_localPort; Ipv4Address m_peerAddr; uint16_t m_peerPort; + Ptr m_boundnetdevice; Callback, Ipv4Address, uint16_t> m_rxCallback; Callback m_icmpCallback; Callback m_destroyCallback; diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/ipv4-l3-protocol.cc src/internet-stack/ipv4-l3-protocol.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/ipv4-l3-protocol.cc Tue Nov 17 17:00:49 2009 --- src/internet-stack/ipv4-l3-protocol.cc Tue Nov 17 15:58:17 2009 *************** *** 536,542 **** // 5) packet is not broadcast, and route is NULL (e.g., a raw socket call) NS_LOG_LOGIC ("Ipv4L3Protocol::Send case 4: passed in with no route " << destination); Socket::SocketErrno errno_; ! uint32_t oif = 0; // unused for now ipHeader = BuildHeader (source, destination, protocol, packet->GetSize (), ttl, mayFragment); Ptr newRoute = m_routingProtocol->RouteOutput (packet, ipHeader, oif, errno_); if (newRoute) --- 536,542 ---- // 5) packet is not broadcast, and route is NULL (e.g., a raw socket call) NS_LOG_LOGIC ("Ipv4L3Protocol::Send case 4: passed in with no route " << destination); Socket::SocketErrno errno_; ! Ptr oif(0); // unused for now ipHeader = BuildHeader (source, destination, protocol, packet->GetSize (), ttl, mayFragment); Ptr newRoute = m_routingProtocol->RouteOutput (packet, ipHeader, oif, errno_); if (newRoute) diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/ipv4-raw-socket-impl.cc src/internet-stack/ipv4-raw-socket-impl.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/ipv4-raw-socket-impl.cc Tue Nov 17 17:00:49 2009 --- src/internet-stack/ipv4-raw-socket-impl.cc Tue Nov 17 16:02:56 2009 *************** *** 177,183 **** header.SetProtocol (m_protocol); SocketErrno errno_ = ERROR_NOTERROR;//do not use errno as it is the standard C last error number Ptr route; ! uint32_t oif = 0; //specify non-zero if bound to a source address // TBD-- we could cache the route and just check its validity route = ipv4->GetRoutingProtocol ()->RouteOutput (p, header, oif, errno_); if (route != 0) --- 177,183 ---- header.SetProtocol (m_protocol); SocketErrno errno_ = ERROR_NOTERROR;//do not use errno as it is the standard C last error number Ptr route; ! Ptr oif = m_boundnetdevice; //specify non-zero if bound to a source address // TBD-- we could cache the route and just check its validity route = ipv4->GetRoutingProtocol ()->RouteOutput (p, header, oif, errno_); if (route != 0) diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/ipv6-l3-protocol.cc src/internet-stack/ipv6-l3-protocol.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/ipv6-l3-protocol.cc Tue Nov 17 17:00:49 2009 --- src/internet-stack/ipv6-l3-protocol.cc Wed Nov 18 11:11:33 2009 *************** *** 626,632 **** /* 3) */ NS_LOG_LOGIC ("Ipv6L3Protocol::Send case 3: passed in with no route " << destination); Socket::SocketErrno err; ! uint32_t oif = 0; Ptr newRoute = 0; hdr = BuildHeader (source, destination, protocol, packet->GetSize (), ttl); --- 626,632 ---- /* 3) */ NS_LOG_LOGIC ("Ipv6L3Protocol::Send case 3: passed in with no route " << destination); Socket::SocketErrno err; ! Ptr oif(0); Ptr newRoute = 0; hdr = BuildHeader (source, destination, protocol, packet->GetSize (), ttl); *************** *** 635,641 **** { int32_t index = GetInterfaceForAddress (source); NS_ASSERT (index >= 0); ! oif = index; } newRoute = m_routingProtocol->RouteOutput (packet, hdr, oif, err); --- 635,641 ---- { int32_t index = GetInterfaceForAddress (source); NS_ASSERT (index >= 0); ! oif = GetNetDevice(index); } newRoute = m_routingProtocol->RouteOutput (packet, hdr, oif, err); *************** *** 647,653 **** else { NS_LOG_WARN ("No route to host, drop!"); ! m_dropTrace (hdr, packet, DROP_NO_ROUTE, oif); } } --- 647,653 ---- else { NS_LOG_WARN ("No route to host, drop!"); ! m_dropTrace (hdr, packet, DROP_NO_ROUTE, GetInterfaceForDevice(oif)); } } diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/ipv6-raw-socket-impl.cc src/internet-stack/ipv6-raw-socket-impl.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/ipv6-raw-socket-impl.cc Tue Nov 17 17:00:49 2009 --- src/internet-stack/ipv6-raw-socket-impl.cc Tue Nov 17 16:09:16 2009 *************** *** 203,215 **** hdr.SetDestinationAddress (dst); SocketErrno err = ERROR_NOTERROR; Ptr route = 0; ! uint32_t oif = 0; /* specify non-zero if bound to a source address */ if (!m_src.IsAny ()) { int32_t index = ipv6->GetInterfaceForAddress (m_src); NS_ASSERT (index >= 0); ! oif = index; } route = ipv6->GetRoutingProtocol ()->RouteOutput (p, hdr, oif, err); --- 203,215 ---- hdr.SetDestinationAddress (dst); SocketErrno err = ERROR_NOTERROR; Ptr route = 0; ! Ptr oif(0); /* specify non-zero if bound to a source address */ if (!m_src.IsAny ()) { int32_t index = ipv6->GetInterfaceForAddress (m_src); NS_ASSERT (index >= 0); ! oif = ipv6->GetNetDevice (index); } route = ipv6->GetRoutingProtocol ()->RouteOutput (p, hdr, oif, err); diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/tcp-l4-protocol.cc src/internet-stack/tcp-l4-protocol.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/tcp-l4-protocol.cc Tue Nov 17 17:00:50 2009 --- src/internet-stack/tcp-l4-protocol.cc Wed Nov 18 13:30:40 2009 *************** *** 549,557 **** void TcpL4Protocol::Send (Ptr packet, Ipv4Address saddr, Ipv4Address daddr, ! uint16_t sport, uint16_t dport) { ! NS_LOG_FUNCTION (this << packet << saddr << daddr << sport << dport); TcpHeader tcpHeader; tcpHeader.SetDestinationPort (dport); --- 549,557 ---- void TcpL4Protocol::Send (Ptr packet, Ipv4Address saddr, Ipv4Address daddr, ! uint16_t sport, uint16_t dport, Ptr oif) { ! NS_LOG_FUNCTION (this << packet << saddr << daddr << sport << dport << oif); TcpHeader tcpHeader; tcpHeader.SetDestinationPort (dport); *************** *** 579,585 **** header.SetProtocol (PROT_NUMBER); Socket::SocketErrno errno_; Ptr route; ! uint32_t oif = 0; //specify non-zero if bound to a source address route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_); ipv4->Send (packet, saddr, daddr, PROT_NUMBER, route); } --- 579,585 ---- header.SetProtocol (PROT_NUMBER); Socket::SocketErrno errno_; Ptr route; ! Ptr oif(0); //specify non-zero if bound to a source address route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_); ipv4->Send (packet, saddr, daddr, PROT_NUMBER, route); } *************** *** 587,600 **** void TcpL4Protocol::SendPacket (Ptr packet, const TcpHeader &outgoing, ! Ipv4Address saddr, Ipv4Address daddr) { NS_LOG_LOGIC("TcpL4Protocol " << this << " sending seq " << outgoing.GetSequenceNumber() << " ack " << outgoing.GetAckNumber() << " flags " << std::hex << (int)outgoing.GetFlags() << std::dec << " data size " << packet->GetSize()); ! NS_LOG_FUNCTION (this << packet << saddr << daddr); // XXX outgoingHeader cannot be logged TcpHeader outgoingHeader = outgoing; --- 587,600 ---- void TcpL4Protocol::SendPacket (Ptr packet, const TcpHeader &outgoing, ! Ipv4Address saddr, Ipv4Address daddr, Ptr oif) { NS_LOG_LOGIC("TcpL4Protocol " << this << " sending seq " << outgoing.GetSequenceNumber() << " ack " << outgoing.GetAckNumber() << " flags " << std::hex << (int)outgoing.GetFlags() << std::dec << " data size " << packet->GetSize()); ! NS_LOG_FUNCTION (this << packet << saddr << daddr << oif); // XXX outgoingHeader cannot be logged TcpHeader outgoingHeader = outgoing; *************** *** 619,625 **** header.SetProtocol (PROT_NUMBER); Socket::SocketErrno errno_; Ptr route; ! uint32_t oif = 0; //specify non-zero if bound to a source address route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_); ipv4->Send (packet, saddr, daddr, PROT_NUMBER, route); } --- 619,625 ---- header.SetProtocol (PROT_NUMBER); Socket::SocketErrno errno_; Ptr route; ! Ptr oif(0); //specify non-zero if bound to a source address route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_); ipv4->Send (packet, saddr, daddr, PROT_NUMBER, route); } diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/tcp-l4-protocol.h src/internet-stack/tcp-l4-protocol.h *** ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/tcp-l4-protocol.h Tue Nov 17 17:00:50 2009 --- src/internet-stack/tcp-l4-protocol.h Wed Nov 18 13:29:38 2009 *************** *** 28,33 **** --- 28,34 ---- #include "ns3/ptr.h" #include "ns3/object-factory.h" #include "ipv4-l4-protocol.h" + #include "ns3/net-device.h" namespace ns3 { *************** *** 92,98 **** */ void Send (Ptr packet, Ipv4Address saddr, Ipv4Address daddr, ! uint16_t sport, uint16_t dport); /** * \brief Recieve a packet up the protocol stack * \param p The Packet to dump the contents into --- 93,99 ---- */ void Send (Ptr packet, Ipv4Address saddr, Ipv4Address daddr, ! uint16_t sport, uint16_t dport, Ptr oif = 0); /** * \brief Recieve a packet up the protocol stack * \param p The Packet to dump the contents into *************** *** 119,125 **** private: friend class TcpSocketImpl; void SendPacket (Ptr, const TcpHeader &, ! Ipv4Address, Ipv4Address); static ObjectFactory GetDefaultRttEstimatorFactory (void); TcpL4Protocol (const TcpL4Protocol &o); TcpL4Protocol &operator = (const TcpL4Protocol &o); --- 120,126 ---- private: friend class TcpSocketImpl; void SendPacket (Ptr, const TcpHeader &, ! Ipv4Address, Ipv4Address, Ptr oif = 0); static ObjectFactory GetDefaultRttEstimatorFactory (void); TcpL4Protocol (const TcpL4Protocol &o); TcpL4Protocol &operator = (const TcpL4Protocol &o); diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/tcp-socket-impl.cc src/internet-stack/tcp-socket-impl.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/tcp-socket-impl.cc Tue Nov 17 17:00:50 2009 --- src/internet-stack/tcp-socket-impl.cc Wed Nov 18 13:31:45 2009 *************** *** 384,390 **** header.SetDestination (m_remoteAddress); Socket::SocketErrno errno_; Ptr route; ! uint32_t oif = 0; //specify non-zero if bound to a source address // XXX here, cache the route in the endpoint? route = ipv4->GetRoutingProtocol ()->RouteOutput (Ptr (), header, oif, errno_); if (route != 0) --- 384,390 ---- header.SetDestination (m_remoteAddress); Socket::SocketErrno errno_; Ptr route; ! Ptr oif = m_boundnetdevice; //specify non-zero if bound to a source address // XXX here, cache the route in the endpoint? route = ipv4->GetRoutingProtocol ()->RouteOutput (Ptr (), header, oif, errno_); if (route != 0) *************** *** 480,486 **** // about payload sent, not with headers uint32_t sentSize = p->GetSize(); m_tcp->Send (p, m_endPoint->GetLocalAddress (), ipv4, ! m_endPoint->GetLocalPort (), port); NotifyDataSent (sentSize); return 0; } --- 480,486 ---- // about payload sent, not with headers uint32_t sentSize = p->GetSize(); m_tcp->Send (p, m_endPoint->GetLocalAddress (), ipv4, ! m_endPoint->GetLocalPort (), port, m_boundnetdevice); NotifyDataSent (sentSize); return 0; } *************** *** 641,646 **** --- 641,664 ---- } void + TcpSocketImpl::BindToNetDevice(Ptr netdevice) + { + NS_LOG_FUNCTION(netdevice); + Socket::BindToNetDevice(netdevice); // Includes sanity check + if (m_endPoint == 0) + { + if (Bind () == -1) + { + NS_ASSERT (m_endPoint == 0); + return; + } + NS_ASSERT (m_endPoint != 0); + } + m_endPoint->BindToNetDevice(netdevice); + return; + } + + void TcpSocketImpl::ForwardUp (Ptr packet, Ipv4Address ipv4, uint16_t port) { NS_LOG_DEBUG("Socket " << this << " got forward up" << *************** *** 787,793 **** header.SetDestinationPort (m_remotePort); header.SetWindowSize (AdvertisedWindowSize()); m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (), ! m_remoteAddress); Time rto = m_rtt->RetransmitTimeout (); bool hasSyn = flags & TcpHeader::SYN; bool hasFin = flags & TcpHeader::FIN; --- 805,811 ---- header.SetDestinationPort (m_remotePort); header.SetWindowSize (AdvertisedWindowSize()); m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (), ! m_remoteAddress, m_boundnetdevice); Time rto = m_rtt->RetransmitTimeout (); bool hasSyn = flags & TcpHeader::SYN; bool hasFin = flags & TcpHeader::FIN; *************** *** 938,944 **** Ipv4Header header; Socket::SocketErrno errno_; Ptr route; ! uint32_t oif = 0; //specify non-zero if bound to a source address header.SetDestination (m_remoteAddress); route = ipv4->GetRoutingProtocol ()->RouteOutput (Ptr (), header, oif, errno_); if (route != 0) --- 956,962 ---- Ipv4Header header; Socket::SocketErrno errno_; Ptr route; ! Ptr oif = m_boundnetdevice; //specify non-zero if bound to a source address header.SetDestination (m_remoteAddress); route = ipv4->GetRoutingProtocol ()->RouteOutput (Ptr (), header, oif, errno_); if (route != 0) *************** *** 1176,1182 **** NS_LOG_LOGIC ("About to send a packet with flags: " << flags); m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (), ! m_remoteAddress); m_rtt->SentSeq(m_nextTxSequence, sz); // notify the RTT // Notify the application of the data being sent Simulator::ScheduleNow(&TcpSocketImpl::NotifyDataSent, this, sz); --- 1194,1200 ---- NS_LOG_LOGIC ("About to send a packet with flags: " << flags); m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (), ! m_remoteAddress, m_boundnetdevice); m_rtt->SentSeq(m_nextTxSequence, sz); // notify the RTT // Notify the application of the data being sent Simulator::ScheduleNow(&TcpSocketImpl::NotifyDataSent, this, sz); *************** *** 1622,1628 **** tcpHeader.SetWindowSize (AdvertisedWindowSize()); m_tcp->SendPacket (p, tcpHeader, m_endPoint->GetLocalAddress (), ! m_remoteAddress); NS_LOG_LOGIC ("Schedule persist timeout at time " <SendPacket (p, tcpHeader, m_endPoint->GetLocalAddress (), ! m_remoteAddress, m_boundnetdevice); NS_LOG_LOGIC ("Schedule persist timeout at time " <SendPacket (p, tcpHeader, m_endPoint->GetLocalAddress (), ! m_remoteAddress); } void --- 1706,1712 ---- tcpHeader.SetWindowSize (AdvertisedWindowSize()); m_tcp->SendPacket (p, tcpHeader, m_endPoint->GetLocalAddress (), ! m_remoteAddress, m_boundnetdevice); } void diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/tcp-socket-impl.h src/internet-stack/tcp-socket-impl.h *** ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/tcp-socket-impl.h Tue Nov 17 17:00:50 2009 --- src/internet-stack/tcp-socket-impl.h Wed Nov 18 13:14:25 2009 *************** *** 95,100 **** --- 95,101 ---- virtual Ptr RecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress); virtual int GetSockName (Address &address) const; + virtual void BindToNetDevice(Ptr netdevice); private: friend class Tcp; diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/udp-socket-impl.cc src/internet-stack/udp-socket-impl.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/udp-socket-impl.cc Tue Nov 17 17:00:50 2009 --- src/internet-stack/udp-socket-impl.cc Wed Nov 18 13:04:30 2009 *************** *** 296,302 **** UdpSocketImpl::DoSendTo (Ptr p, Ipv4Address dest, uint16_t port) { NS_LOG_FUNCTION (this << p << dest << port); ! if (m_endPoint == 0) { if (Bind () == -1) --- 296,305 ---- UdpSocketImpl::DoSendTo (Ptr p, Ipv4Address dest, uint16_t port) { NS_LOG_FUNCTION (this << p << dest << port); ! if (m_boundnetdevice) ! { ! NS_LOG_LOGIC("Bound interface number " << m_boundnetdevice->GetIfIndex()); ! } if (m_endPoint == 0) { if (Bind () == -1) *************** *** 375,380 **** --- 378,389 ---- Ipv4Address addri = iaddr.GetLocal (); if (addri == Ipv4Address ("127.0.0.1")) continue; + // Check if interface-bound socket + if (m_boundnetdevice) + { + if (ipv4->GetNetDevice(i) != m_boundnetdevice) + continue; + } Ipv4Mask maski = iaddr.GetMask (); if (maski == Ipv4Mask::GetOnes ()) { *************** *** 408,414 **** header.SetProtocol (UdpL4Protocol::PROT_NUMBER); Socket::SocketErrno errno_; Ptr route; ! uint32_t oif = 0; //specify non-zero if bound to a source address // TBD-- we could cache the route and just check its validity route = ipv4->GetRoutingProtocol ()->RouteOutput (p, header, oif, errno_); if (route != 0) --- 417,423 ---- header.SetProtocol (UdpL4Protocol::PROT_NUMBER); Socket::SocketErrno errno_; Ptr route; ! Ptr oif = m_boundnetdevice; //specify non-zero if bound to a specific device // TBD-- we could cache the route and just check its validity route = ipv4->GetRoutingProtocol ()->RouteOutput (p, header, oif, errno_); if (route != 0) *************** *** 550,555 **** --- 559,582 ---- return 0; } + void + UdpSocketImpl::BindToNetDevice(Ptr netdevice) + { + NS_LOG_FUNCTION(netdevice); + Socket::BindToNetDevice(netdevice); // Includes sanity check + if (m_endPoint == 0) + { + if (Bind () == -1) + { + NS_ASSERT (m_endPoint == 0); + return; + } + NS_ASSERT (m_endPoint != 0); + } + m_endPoint->BindToNetDevice(netdevice); + return; + } + void UdpSocketImpl::ForwardUp (Ptr packet, Ipv4Address ipv4, uint16_t port) { diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/udp-socket-impl.h src/internet-stack/udp-socket-impl.h *** ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/udp-socket-impl.h Tue Nov 17 17:00:50 2009 --- src/internet-stack/udp-socket-impl.h Wed Nov 18 13:00:46 2009 *************** *** 77,82 **** --- 77,83 ---- virtual int GetSockName (Address &address) const; virtual int MulticastJoinGroup (uint32_t interfaceIndex, const Address &groupAddress); virtual int MulticastLeaveGroup (uint32_t interfaceIndex, const Address &groupAddress); + virtual void BindToNetDevice(Ptr netdevice); private: // Attributes set through UdpSocket base class diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/wscript src/internet-stack/wscript *** ../ns-3-dev-unaltered/ns-3-dev/src/internet-stack/wscript Tue Nov 17 17:00:50 2009 --- src/internet-stack/wscript Wed Nov 18 11:50:55 2009 *************** *** 110,116 **** 'ipv6-raw-socket-impl.cc', 'ipv6-autoconfigured-prefix.cc', 'icmpv6-l4-protocol.cc', ! 'ipv6-test.cc' ] headers = bld.new_task_gen('ns3header') --- 110,116 ---- 'ipv6-raw-socket-impl.cc', 'ipv6-autoconfigured-prefix.cc', 'icmpv6-l4-protocol.cc', ! 'ipv6-test.cc', ] headers = bld.new_task_gen('ns3header') *************** *** 134,139 **** --- 134,140 ---- 'icmpv6-l4-protocol.h', 'ipv6-l4-protocol.h', 'ndisc-cache.h', + 'loopback-net-device.h' ] if bld.env['NSC_ENABLED']: diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/node/ipv4-routing-protocol.h src/node/ipv4-routing-protocol.h *** ../ns-3-dev-unaltered/ns-3-dev/src/node/ipv4-routing-protocol.h Tue Nov 17 17:00:50 2009 --- src/node/ipv4-routing-protocol.h Tue Nov 17 16:25:48 2009 *************** *** 66,78 **** * \param p packet to be routed. Note that this method may modify the packet. * Callers may also pass in a null pointer. * \param header input parameter (used to form key to search for the route) ! * \param oif Output interface index. May be zero, or may be bound via * socket options to a particular output interface. * \param sockerr Output parameter; socket errno * * \returns a code that indicates what happened in the lookup */ ! virtual Ptr RouteOutput (Ptr p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr) = 0; /** * \brief Route an input packet (to be forwarded or locally delivered) --- 66,78 ---- * \param p packet to be routed. Note that this method may modify the packet. * Callers may also pass in a null pointer. * \param header input parameter (used to form key to search for the route) ! * \param oif Output interface Netdevice. May be zero, or may be bound via * socket options to a particular output interface. * \param sockerr Output parameter; socket errno * * \returns a code that indicates what happened in the lookup */ ! virtual Ptr RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr) = 0; /** * \brief Route an input packet (to be forwarded or locally delivered) diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/node/ipv6-routing-protocol.h src/node/ipv6-routing-protocol.h *** ../ns-3-dev-unaltered/ns-3-dev/src/node/ipv6-routing-protocol.h Tue Nov 17 17:00:50 2009 --- src/node/ipv6-routing-protocol.h Tue Nov 17 16:10:46 2009 *************** *** 70,82 **** * \param p packet to be routed. Note that this method may modify the packet. * Callers may also pass in a null pointer. * \param header input parameter (used to form key to search for the route) ! * \param oif Output interface index. May be zero, or may be bound via * socket options to a particular output interface. * \param sockerr Output parameter; socket errno * * \returns a code that indicates what happened in the lookup */ ! virtual Ptr RouteOutput (Ptr p, const Ipv6Header &header, uint32_t oif, Socket::SocketErrno &sockerr) = 0; /** * \brief Route an input packet (to be forwarded or locally delivered) --- 70,82 ---- * \param p packet to be routed. Note that this method may modify the packet. * Callers may also pass in a null pointer. * \param header input parameter (used to form key to search for the route) ! * \param oif Output interface device. May be zero, or may be bound via * socket options to a particular output interface. * \param sockerr Output parameter; socket errno * * \returns a code that indicates what happened in the lookup */ ! virtual Ptr RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr) = 0; /** * \brief Route an input packet (to be forwarded or locally delivered) diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/node/socket.cc src/node/socket.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/node/socket.cc Tue Nov 17 17:00:50 2009 --- src/node/socket.cc Tue Nov 17 15:28:13 2009 *************** *** 33,38 **** --- 33,39 ---- Socket::Socket (void) { + m_boundnetdevice=0; NS_LOG_FUNCTION_NOARGS (); } *************** *** 297,302 **** --- 298,329 ---- m_receivedData = MakeNullCallback > (); } + void + Socket::BindToNetDevice(Ptr netdevice) + { + if (netdevice != 0) + { + bool found = false; + for (uint32_t i = 0; i < GetNode()->GetNDevices(); i++) + { + if (GetNode()->GetDevice(i) == netdevice) + { + found = true; + break; + } + } + NS_ASSERT_MSG(found, "Socket cannot be bound to a NetDevice not existing on the Node"); + } + m_boundnetdevice=netdevice; + return; + } + + Ptr + Socket::GetBoundNetDevice() + { + return m_boundnetdevice; + } + /*************************************************************** * Socket Tags ***************************************************************/ diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/node/socket.h src/node/socket.h *** ../ns-3-dev-unaltered/ns-3-dev/src/node/socket.h Tue Nov 17 17:00:50 2009 --- src/node/socket.h Wed Nov 18 12:56:10 2009 *************** *** 27,32 **** --- 27,33 ---- #include "ns3/ptr.h" #include "ns3/tag.h" #include "ns3/object.h" + #include "ns3/net-device.h" #include "address.h" #include *************** *** 511,516 **** --- 512,538 ---- * \returns 0 if success, -1 otherwise */ virtual int GetSockName (Address &address) const = 0; + + /** + * \brief Bind a socket to specific device. + * + * This method corresponds to using setsockopt() SO_BINDTODEVICE + * of real network or BSD sockets. + * + * \param Netdevice Pointer to Netdevice of desired interface + * \returns nothing + */ + virtual void BindToNetDevice(Ptr netdevice); + + /** + * \brief Returns socket's bound netdevice, if any. + * + * This method corresponds to using getsockopt() SO_BINDTODEVICE + * of real network or BSD sockets. + * + * \returns Pointer to interface. + */ + Ptr GetBoundNetDevice (); protected: void NotifyConnectionSucceeded (void); *************** *** 523,528 **** --- 545,551 ---- void NotifySend (uint32_t spaceAvailable); void NotifyDataRecv (void); virtual void DoDispose (void); + Ptr m_boundnetdevice; private: Callback > m_connectionSucceeded; Callback > m_connectionFailed; diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/routing/global-routing/ipv4-global-routing.cc src/routing/global-routing/ipv4-global-routing.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/routing/global-routing/ipv4-global-routing.cc Tue Nov 17 17:00:50 2009 --- src/routing/global-routing/ipv4-global-routing.cc Tue Nov 17 16:15:01 2009 *************** *** 115,121 **** Ptr ! Ipv4GlobalRouting::LookupGlobal (Ipv4Address dest) { NS_LOG_FUNCTION_NOARGS (); NS_LOG_LOGIC ("Looking for route for destination " << dest); --- 115,121 ---- Ptr ! Ipv4GlobalRouting::LookupGlobal (Ipv4Address dest, Ptr oif) { NS_LOG_FUNCTION_NOARGS (); NS_LOG_LOGIC ("Looking for route for destination " << dest); *************** *** 131,136 **** --- 131,144 ---- if ((*i)->GetDest ().IsEqual (dest)) { NS_LOG_LOGIC ("Found global host route" << *i); + if (oif != 0) + { + if (oif != m_ipv4->GetNetDevice(route->GetInterface())) + { + NS_LOG_LOGIC ("Not on requested interface, skipping"); + continue; + } + } route = (*i); found = true; break; *************** *** 148,153 **** --- 156,169 ---- if (mask.IsMatch (dest, entry)) { NS_LOG_LOGIC ("Found global network route" << *j); + if (oif != 0) + { + if (oif != m_ipv4->GetNetDevice(route->GetInterface())) + { + NS_LOG_LOGIC ("Not on requested interface, skipping"); + continue; + } + } route = (*j); found = true; break; *************** *** 165,170 **** --- 181,194 ---- if (mask.IsMatch (dest, entry)) { NS_LOG_LOGIC ("Found external route" << *k); + if (oif != 0) + { + if (oif != m_ipv4->GetNetDevice(route->GetInterface())) + { + NS_LOG_LOGIC ("Not on requested interface, skipping"); + continue; + } + } route = (*k); found = true; break; *************** *** 332,338 **** } Ptr ! Ipv4GlobalRouting::RouteOutput (Ptr p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr) { // --- 356,362 ---- } Ptr ! Ipv4GlobalRouting::RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr) { // *************** *** 348,354 **** // See if this is a unicast packet we have a route for. // NS_LOG_LOGIC ("Unicast destination- looking up"); ! Ptr rtentry = LookupGlobal (header.GetDestination()); if (rtentry) { sockerr = Socket::ERROR_NOTERROR; --- 372,378 ---- // See if this is a unicast packet we have a route for. // NS_LOG_LOGIC ("Unicast destination- looking up"); ! Ptr rtentry = LookupGlobal (header.GetDestination(), oif); if (rtentry) { sockerr = Socket::ERROR_NOTERROR; diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/routing/global-routing/ipv4-global-routing.h src/routing/global-routing/ipv4-global-routing.h *** ../ns-3-dev-unaltered/ns-3-dev/src/routing/global-routing/ipv4-global-routing.h Tue Nov 17 17:00:50 2009 --- src/routing/global-routing/ipv4-global-routing.h Tue Nov 17 16:17:45 2009 *************** *** 80,86 **** Ipv4GlobalRouting (); virtual ~Ipv4GlobalRouting (); ! virtual Ptr RouteOutput (Ptr p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr); virtual bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, --- 80,86 ---- Ipv4GlobalRouting (); virtual ~Ipv4GlobalRouting (); ! virtual Ptr RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr); virtual bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, *************** *** 222,228 **** typedef std::list::const_iterator ASExternalRoutesCI; typedef std::list::iterator ASExternalRoutesI; ! Ptr LookupGlobal (Ipv4Address dest); HostRoutes m_hostRoutes; NetworkRoutes m_networkRoutes; --- 222,228 ---- typedef std::list::const_iterator ASExternalRoutesCI; typedef std::list::iterator ASExternalRoutesI; ! Ptr LookupGlobal (Ipv4Address dest, Ptr oif = 0); HostRoutes m_hostRoutes; NetworkRoutes m_networkRoutes; diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/routing/list-routing/ipv4-list-routing.cc src/routing/list-routing/ipv4-list-routing.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/routing/list-routing/ipv4-list-routing.cc Tue Nov 17 17:00:50 2009 --- src/routing/list-routing/ipv4-list-routing.cc Tue Nov 17 16:30:39 2009 *************** *** 82,88 **** Ptr ! Ipv4ListRouting::RouteOutput (Ptr p, const Ipv4Header &header, uint32_t oif, enum Socket::SocketErrno &sockerr) { NS_LOG_FUNCTION (this << header.GetDestination () << " " << header.GetSource () << " " << oif); Ptr route; --- 82,88 ---- Ptr ! Ipv4ListRouting::RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, enum Socket::SocketErrno &sockerr) { NS_LOG_FUNCTION (this << header.GetDestination () << " " << header.GetSource () << " " << oif); Ptr route; *************** *** 334,340 **** class Ipv4ARouting : public Ipv4RoutingProtocol { public: ! Ptr RouteOutput (Ptr p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr) { return 0;} bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb) {return false;} --- 334,340 ---- class Ipv4ARouting : public Ipv4RoutingProtocol { public: ! Ptr RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr) { return 0;} bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb) {return false;} *************** *** 347,353 **** class Ipv4BRouting : public Ipv4RoutingProtocol { public: ! Ptr RouteOutput (Ptr p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr) { return 0;} bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb) {return false;} --- 347,353 ---- class Ipv4BRouting : public Ipv4RoutingProtocol { public: ! Ptr RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr) { return 0;} bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb) {return false;} diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/routing/list-routing/ipv4-list-routing.h src/routing/list-routing/ipv4-list-routing.h *** ../ns-3-dev-unaltered/ns-3-dev/src/routing/list-routing/ipv4-list-routing.h Tue Nov 17 17:00:50 2009 --- src/routing/list-routing/ipv4-list-routing.h Tue Nov 17 15:45:55 2009 *************** *** 75,81 **** virtual Ptr GetRoutingProtocol (uint32_t index, int16_t& priority) const; // Below are from Ipv4RoutingProtocol ! virtual Ptr RouteOutput (Ptr p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr); virtual bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, --- 75,81 ---- virtual Ptr GetRoutingProtocol (uint32_t index, int16_t& priority) const; // Below are from Ipv4RoutingProtocol ! virtual Ptr RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr); virtual bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/routing/list-routing/ipv6-list-routing.cc src/routing/list-routing/ipv6-list-routing.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/routing/list-routing/ipv6-list-routing.cc Tue Nov 17 17:00:50 2009 --- src/routing/list-routing/ipv6-list-routing.cc Tue Nov 17 16:31:08 2009 *************** *** 69,75 **** } Ptr ! Ipv6ListRouting::RouteOutput (Ptr p, const Ipv6Header &header, uint32_t oif, enum Socket::SocketErrno &sockerr) { NS_LOG_FUNCTION (this << header.GetDestinationAddress () << header.GetSourceAddress () << oif); Ptr route; --- 69,75 ---- } Ptr ! Ipv6ListRouting::RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, enum Socket::SocketErrno &sockerr) { NS_LOG_FUNCTION (this << header.GetDestinationAddress () << header.GetSourceAddress () << oif); Ptr route; *************** *** 342,348 **** class Ipv6ARouting : public Ipv6RoutingProtocol { public: ! Ptr RouteOutput (Ptr p, const Ipv6Header &header, uint32_t oif, Socket::SocketErrno &sockerr) { return 0;} bool RouteInput (Ptr p, const Ipv6Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb) {return false;} --- 342,348 ---- class Ipv6ARouting : public Ipv6RoutingProtocol { public: ! Ptr RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr) { return 0;} bool RouteInput (Ptr p, const Ipv6Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb) {return false;} *************** *** 358,364 **** class Ipv6BRouting : public Ipv6RoutingProtocol { public: ! Ptr RouteOutput (Ptr p, const Ipv6Header &header, uint32_t oif, Socket::SocketErrno &sockerr) { return 0;} bool RouteInput (Ptr p, const Ipv6Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb) {return false;} --- 358,364 ---- class Ipv6BRouting : public Ipv6RoutingProtocol { public: ! Ptr RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr) { return 0;} bool RouteInput (Ptr p, const Ipv6Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb) {return false;} diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/routing/list-routing/ipv6-list-routing.h src/routing/list-routing/ipv6-list-routing.h *** ../ns-3-dev-unaltered/ns-3-dev/src/routing/list-routing/ipv6-list-routing.h Tue Nov 17 17:00:50 2009 --- src/routing/list-routing/ipv6-list-routing.h Tue Nov 17 15:45:55 2009 *************** *** 91,97 **** virtual Ptr GetRoutingProtocol (uint32_t index, int16_t& priority) const; // Below are from Ipv6RoutingProtocol ! virtual Ptr RouteOutput (Ptr p, const Ipv6Header &header, uint32_t oif, Socket::SocketErrno &sockerr); virtual bool RouteInput (Ptr p, const Ipv6Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, --- 91,97 ---- virtual Ptr GetRoutingProtocol (uint32_t index, int16_t& priority) const; // Below are from Ipv6RoutingProtocol ! virtual Ptr RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr); virtual bool RouteInput (Ptr p, const Ipv6Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/routing/manet/aodv/aodv-routing-protocol.cc src/routing/manet/aodv/aodv-routing-protocol.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/routing/manet/aodv/aodv-routing-protocol.cc Tue Nov 17 17:00:50 2009 --- src/routing/manet/aodv/aodv-routing-protocol.cc Tue Nov 17 16:31:55 2009 *************** *** 215,221 **** Ptr RoutingProtocol::RouteOutput (Ptr p, const Ipv4Header &header, ! uint32_t oif, Socket::SocketErrno &sockerr) { NS_LOG_FUNCTION (this << header.GetDestination ()); if (m_socketAddresses.empty ()) --- 215,221 ---- Ptr RoutingProtocol::RouteOutput (Ptr p, const Ipv4Header &header, ! Ptr oif, Socket::SocketErrno &sockerr) { NS_LOG_FUNCTION (this << header.GetDestination ()); if (m_socketAddresses.empty ()) diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/routing/manet/aodv/aodv-routing-protocol.h src/routing/manet/aodv/aodv-routing-protocol.h *** ../ns-3-dev-unaltered/ns-3-dev/src/routing/manet/aodv/aodv-routing-protocol.h Tue Nov 17 17:00:50 2009 --- src/routing/manet/aodv/aodv-routing-protocol.h Tue Nov 17 16:31:55 2009 *************** *** 62,68 **** ///\name From Ipv4RoutingProtocol //\{ ! Ptr RouteOutput (Ptr p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr); bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb); --- 62,68 ---- ///\name From Ipv4RoutingProtocol //\{ ! Ptr RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr); bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb); diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/routing/nix-vector-routing/ipv4-nix-vector-routing.cc src/routing/nix-vector-routing/ipv4-nix-vector-routing.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/routing/nix-vector-routing/ipv4-nix-vector-routing.cc Tue Nov 17 17:00:50 2009 --- src/routing/nix-vector-routing/ipv4-nix-vector-routing.cc Tue Nov 17 16:10:38 2009 *************** *** 478,484 **** } Ptr ! Ipv4NixVectorRouting::RouteOutput (Ptr p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr) { NS_LOG_FUNCTION_NOARGS (); Ptr rtentry; --- 478,484 ---- } Ptr ! Ipv4NixVectorRouting::RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr) { NS_LOG_FUNCTION_NOARGS (); Ptr rtentry; diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/routing/nix-vector-routing/ipv4-nix-vector-routing.h src/routing/nix-vector-routing/ipv4-nix-vector-routing.h *** ../ns-3-dev-unaltered/ns-3-dev/src/routing/nix-vector-routing/ipv4-nix-vector-routing.h Tue Nov 17 17:00:50 2009 --- src/routing/nix-vector-routing/ipv4-nix-vector-routing.h Tue Nov 17 16:10:46 2009 *************** *** 129,135 **** void DoDispose (void); /* From Ipv4RoutingProtocol */ ! virtual Ptr RouteOutput (Ptr p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr); virtual bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb); --- 129,135 ---- void DoDispose (void); /* From Ipv4RoutingProtocol */ ! virtual Ptr RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr); virtual bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb); diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/routing/olsr/olsr-routing-protocol.cc src/routing/olsr/olsr-routing-protocol.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/routing/olsr/olsr-routing-protocol.cc Tue Nov 17 17:00:50 2009 --- src/routing/olsr/olsr-routing-protocol.cc Tue Nov 17 16:11:33 2009 *************** *** 2600,2606 **** } Ptr ! RoutingProtocol::RouteOutput (Ptr p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr) { NS_LOG_FUNCTION (this << " " << m_ipv4->GetObject ()->GetId() << " " << header.GetDestination () << " " << oif); // TBD: oif is unused; can be used to restrict the outgoing interface --- 2600,2606 ---- } Ptr ! RoutingProtocol::RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr) { NS_LOG_FUNCTION (this << " " << m_ipv4->GetObject ()->GetId() << " " << header.GetDestination () << " " << oif); // TBD: oif is unused; can be used to restrict the outgoing interface diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/routing/olsr/olsr-routing-protocol.h src/routing/olsr/olsr-routing-protocol.h *** ../ns-3-dev-unaltered/ns-3-dev/src/routing/olsr/olsr-routing-protocol.h Tue Nov 17 17:00:50 2009 --- src/routing/olsr/olsr-routing-protocol.h Tue Nov 17 16:11:17 2009 *************** *** 132,138 **** RoutingTableEntry &outEntry) const; // From Ipv4RoutingProtocol ! virtual Ptr RouteOutput (Ptr p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr); virtual bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb); --- 132,138 ---- RoutingTableEntry &outEntry) const; // From Ipv4RoutingProtocol ! virtual Ptr RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr); virtual bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb); diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/routing/static-routing/ipv4-static-routing.cc src/routing/static-routing/ipv4-static-routing.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/routing/static-routing/ipv4-static-routing.cc Tue Nov 17 17:00:50 2009 --- src/routing/static-routing/ipv4-static-routing.cc Wed Nov 18 11:57:22 2009 *************** *** 210,216 **** } Ptr ! Ipv4StaticRouting::LookupStatic (Ipv4Address dest) { NS_LOG_FUNCTION_NOARGS (); Ptr rtentry = 0; --- 210,216 ---- } Ptr ! Ipv4StaticRouting::LookupStatic (Ipv4Address dest, Ptr oif) { NS_LOG_FUNCTION_NOARGS (); Ptr rtentry = 0; *************** *** 229,234 **** --- 229,242 ---- if (mask.IsMatch (dest, entry)) { NS_LOG_LOGIC ("Found global network route " << j << ", mask length " << masklen << ", metric " << metric); + if (oif != 0) + { + if (oif != m_ipv4->GetNetDevice(j->GetInterface())) + { + NS_LOG_LOGIC ("Not on requested interface, skipping"); + continue; + } + } if (masklen < longest_mask) // Not interested if got shorter mask { NS_LOG_LOGIC ("Previous match longer, skipping"); *************** *** 254,260 **** rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx)); } } ! NS_LOG_LOGIC ("Matching route via " << rtentry << " at the end"); return rtentry; } --- 262,268 ---- rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx)); } } ! NS_LOG_LOGIC ("Matching route via " << rtentry->GetGateway() << " at the end"); return rtentry; } *************** *** 415,421 **** } Ptr ! Ipv4StaticRouting::RouteOutput (Ptr p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr) { NS_LOG_FUNCTION (this << header << oif); Ipv4Address destination = header.GetDestination (); --- 423,429 ---- } Ptr ! Ipv4StaticRouting::RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr) { NS_LOG_FUNCTION (this << header << oif); Ipv4Address destination = header.GetDestination (); *************** *** 432,438 **** // So, we just log it and fall through to LookupStatic () NS_LOG_LOGIC ("RouteOutput()::Multicast destination"); } ! rtentry = LookupStatic (destination); if (rtentry) { sockerr = Socket::ERROR_NOTERROR; --- 440,446 ---- // So, we just log it and fall through to LookupStatic () NS_LOG_LOGIC ("RouteOutput()::Multicast destination"); } ! rtentry = LookupStatic (destination, oif); if (rtentry) { sockerr = Socket::ERROR_NOTERROR; diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/routing/static-routing/ipv4-static-routing.h src/routing/static-routing/ipv4-static-routing.h *** ../ns-3-dev-unaltered/ns-3-dev/src/routing/static-routing/ipv4-static-routing.h Tue Nov 17 17:00:50 2009 --- src/routing/static-routing/ipv4-static-routing.h Tue Nov 17 16:17:50 2009 *************** *** 74,80 **** Ipv4StaticRouting (); virtual ~Ipv4StaticRouting (); ! virtual Ptr RouteOutput (Ptr p, const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr); virtual bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, --- 74,80 ---- Ipv4StaticRouting (); virtual ~Ipv4StaticRouting (); ! virtual Ptr RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr); virtual bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, *************** *** 382,388 **** typedef std::list::const_iterator MulticastRoutesCI; typedef std::list::iterator MulticastRoutesI; ! Ptr LookupStatic (Ipv4Address dest); Ptr LookupStatic (Ipv4Address origin, Ipv4Address group, uint32_t interface); --- 382,388 ---- typedef std::list::const_iterator MulticastRoutesCI; typedef std::list::iterator MulticastRoutesI; ! Ptr LookupStatic (Ipv4Address dest, Ptr oif = 0); Ptr LookupStatic (Ipv4Address origin, Ipv4Address group, uint32_t interface); diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/routing/static-routing/ipv6-static-routing.cc src/routing/static-routing/ipv6-static-routing.cc *** ../ns-3-dev-unaltered/ns-3-dev/src/routing/static-routing/ipv6-static-routing.cc Tue Nov 17 17:00:50 2009 --- src/routing/static-routing/ipv6-static-routing.cc Wed Nov 18 11:09:55 2009 *************** *** 214,220 **** return false; } ! Ptr Ipv6StaticRouting::LookupStatic (Ipv6Address dst, uint32_t interface) { NS_LOG_FUNCTION (this << dst << interface); Ptr rtentry = 0; --- 214,220 ---- return false; } ! Ptr Ipv6StaticRouting::LookupStatic (Ipv6Address dst, Ptr interface) { NS_LOG_FUNCTION (this << dst << interface); Ptr rtentry = 0; *************** *** 225,236 **** if (dst == Ipv6Address::GetAllNodesMulticast () || dst.IsSolicitedMulticast () || dst == Ipv6Address::GetAllRoutersMulticast () || dst == Ipv6Address::GetAllHostsMulticast ()) { ! NS_ASSERT_MSG (interface > 0, "Try to send on link-local multicast address, and no interface index is given!"); rtentry = Create (); ! rtentry->SetSource (SourceAddressSelection (interface, dst)); rtentry->SetDestination (dst); rtentry->SetGateway (Ipv6Address::GetZero ()); ! rtentry->SetOutputDevice (m_ipv6->GetNetDevice (interface)); return rtentry; } --- 225,236 ---- if (dst == Ipv6Address::GetAllNodesMulticast () || dst.IsSolicitedMulticast () || dst == Ipv6Address::GetAllRoutersMulticast () || dst == Ipv6Address::GetAllHostsMulticast ()) { ! NS_ASSERT_MSG (interface, "Try to send on link-local multicast address, and no interface index is given!"); rtentry = Create (); ! rtentry->SetSource (SourceAddressSelection (m_ipv6->GetInterfaceForDevice(interface), dst)); rtentry->SetDestination (dst); rtentry->SetGateway (Ipv6Address::GetZero ()); ! rtentry->SetOutputDevice (interface); return rtentry; } *************** *** 249,255 **** NS_LOG_LOGIC ("Found global network route " << j << ", mask length " << maskLen << ", metric " << metric); /* if interface is given, check the route will output on this interface */ ! if (!interface || interface == j->GetInterface ()) { if (maskLen < longestMask) { --- 249,255 ---- NS_LOG_LOGIC ("Found global network route " << j << ", mask length " << maskLen << ", metric " << metric); /* if interface is given, check the route will output on this interface */ ! if (!interface || interface == m_ipv6->GetNetDevice(j->GetInterface())) { if (maskLen < longestMask) { *************** *** 485,491 **** } } ! Ptr Ipv6StaticRouting::RouteOutput (Ptr p, const Ipv6Header &header, uint32_t oif, Socket::SocketErrno &sockerr) { NS_LOG_FUNCTION (this << header << oif); Ipv6Address destination = header.GetDestinationAddress (); --- 485,491 ---- } } ! Ptr Ipv6StaticRouting::RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr) { NS_LOG_FUNCTION (this << header << oif); Ipv6Address destination = header.GetDestinationAddress (); diff -crB ../ns-3-dev-unaltered/ns-3-dev/src/routing/static-routing/ipv6-static-routing.h src/routing/static-routing/ipv6-static-routing.h *** ../ns-3-dev-unaltered/ns-3-dev/src/routing/static-routing/ipv6-static-routing.h Tue Nov 17 17:00:50 2009 --- src/routing/static-routing/ipv6-static-routing.h Tue Nov 17 16:19:39 2009 *************** *** 223,229 **** */ bool HasNetworkDest (Ipv6Address dest, uint32_t interfaceIndex); ! virtual Ptr RouteOutput (Ptr p, const Ipv6Header &header, uint32_t oif, Socket::SocketErrno &sockerr); virtual bool RouteInput (Ptr p, const Ipv6Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, --- 223,229 ---- */ bool HasNetworkDest (Ipv6Address dest, uint32_t interfaceIndex); ! virtual Ptr RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr); virtual bool RouteInput (Ptr p, const Ipv6Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, *************** *** 258,264 **** * \param interface output interface if any (put 0 otherwise) * \return Ipv6Route to route the packet to reach dest address */ ! Ptr LookupStatic (Ipv6Address dest, uint32_t interface = 0); /** * \brief Lookup in the multicast forwarding table for destination. --- 258,264 ---- * \param interface output interface if any (put 0 otherwise) * \return Ipv6Route to route the packet to reach dest address */ ! Ptr LookupStatic (Ipv6Address dest, Ptr = 0); /** * \brief Lookup in the multicast forwarding table for destination.