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) 2016 Universita' di Firenze, Italy | 3 * Copyright (c) 2016 Universita' di Firenze, Italy |
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 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 { | 777 { |
778 if (rtes.begin ()->GetPrefix () == Ipv4Address::GetAny () && | 778 if (rtes.begin ()->GetPrefix () == Ipv4Address::GetAny () && |
779 rtes.begin ()->GetSubnetMask ().GetPrefixLength () == 0 && | 779 rtes.begin ()->GetSubnetMask ().GetPrefixLength () == 0 && |
780 rtes.begin ()->GetRouteMetric () == m_linkDown) | 780 rtes.begin ()->GetRouteMetric () == m_linkDown) |
781 { | 781 { |
782 // Output whole thing. Use Split Horizon | 782 // Output whole thing. Use Split Horizon |
783 if (m_interfaceExclusions.find (incomingInterface) == m_interfaceExclu
sions.end ()) | 783 if (m_interfaceExclusions.find (incomingInterface) == m_interfaceExclu
sions.end ()) |
784 { | 784 { |
785 // we use one of the sending sockets, as they're bound to the righ
t interface | 785 // we use one of the sending sockets, as they're bound to the righ
t interface |
786 // and the local address might be used on different interfaces. | 786 // and the local address might be used on different interfaces. |
787 Ptr<Socket> sendingSoket; | 787 Ptr<Socket> sendingSocket; |
788 for (SocketListI iter = m_sendSocketList.begin (); iter != m_sendS
ocketList.end (); iter++ ) | 788 for (SocketListI iter = m_sendSocketList.begin (); iter != m_sendS
ocketList.end (); iter++ ) |
789 { | 789 { |
790 if (iter->second == incomingInterface) | 790 if (iter->second == incomingInterface) |
791 { | 791 { |
792 sendingSoket = iter->first; | 792 sendingSocket = iter->first; |
793 } | 793 } |
794 } | 794 } |
795 NS_ASSERT_MSG (sendingSoket, "HandleRequest - Impossible to find a
socket to send the reply"); | 795 NS_ASSERT_MSG (sendingSocket, "HandleRequest - Impossible to find
a socket to send the reply"); |
796 | 796 |
797 uint16_t mtu = m_ipv4->GetMtu (incomingInterface); | 797 uint16_t mtu = m_ipv4->GetMtu (incomingInterface); |
798 uint16_t maxRte = static_cast<uint16_t>((mtu - Ipv4Header ().GetSe
rializedSize () - UdpHeader ().GetSerializedSize () - RipHeader ().GetSerialized
Size ()) / RipRte ().GetSerializedSize ()); | 798 uint16_t maxRte = static_cast<uint16_t> ((mtu - Ipv4Header ().GetS
erializedSize () - UdpHeader ().GetSerializedSize () - RipHeader ().GetSerialize
dSize ()) / RipRte ().GetSerializedSize ()); |
799 | 799 |
800 Ptr<Packet> p = Create<Packet> (); | 800 Ptr<Packet> p = Create<Packet> (); |
801 SocketIpTtlTag tag; | 801 SocketIpTtlTag tag; |
802 p->RemovePacketTag (tag); | 802 p->RemovePacketTag (tag); |
803 if (senderAddress == Ipv4Address(RIP_ALL_NODE)) | 803 if (senderAddress == Ipv4Address(RIP_ALL_NODE)) |
804 { | 804 { |
805 tag.SetTtl (1); | 805 tag.SetTtl (1); |
806 } | 806 } |
807 else | 807 else |
808 { | 808 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 if ((m_splitHorizonStrategy != SPLIT_HORIZON) || | 842 if ((m_splitHorizonStrategy != SPLIT_HORIZON) || |
843 (m_splitHorizonStrategy == SPLIT_HORIZON && !splitHori
zoning)) | 843 (m_splitHorizonStrategy == SPLIT_HORIZON && !splitHori
zoning)) |
844 { | 844 { |
845 hdr.AddRte (rte); | 845 hdr.AddRte (rte); |
846 } | 846 } |
847 } | 847 } |
848 if (hdr.GetRteNumber () == maxRte) | 848 if (hdr.GetRteNumber () == maxRte) |
849 { | 849 { |
850 p->AddHeader (hdr); | 850 p->AddHeader (hdr); |
851 NS_LOG_DEBUG ("SendTo: " << *p); | 851 NS_LOG_DEBUG ("SendTo: " << *p); |
852 sendingSoket->SendTo (p, 0, InetSocketAddress (senderAddre
ss, RIP_PORT)); | 852 sendingSocket->SendTo (p, 0, InetSocketAddress (senderAddr
ess, RIP_PORT)); |
853 p->RemoveHeader (hdr); | 853 p->RemoveHeader (hdr); |
854 hdr.ClearRtes (); | 854 hdr.ClearRtes (); |
855 } | 855 } |
856 } | 856 } |
857 if (hdr.GetRteNumber () > 0) | 857 if (hdr.GetRteNumber () > 0) |
858 { | 858 { |
859 p->AddHeader (hdr); | 859 p->AddHeader (hdr); |
860 NS_LOG_DEBUG ("SendTo: " << *p); | 860 NS_LOG_DEBUG ("SendTo: " << *p); |
861 sendingSoket->SendTo (p, 0, InetSocketAddress (senderAddress,
RIP_PORT)); | 861 sendingSocket->SendTo (p, 0, InetSocketAddress (senderAddress,
RIP_PORT)); |
862 } | 862 } |
863 } | 863 } |
864 } | 864 } |
865 } | 865 } |
866 else | 866 else |
867 { | 867 { |
868 // note: we got the request as a single packet, so no check is necessary f
or MTU limit | 868 // note: we got the request as a single packet, so no check is necessary f
or MTU limit |
869 | 869 |
870 Ptr<Packet> p = Create<Packet> (); | 870 Ptr<Packet> p = Create<Packet> (); |
871 SocketIpTtlTag tag; | 871 SocketIpTtlTag tag; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 { | 1067 { |
1068 NS_LOG_FUNCTION (this << (periodic ? " periodic" : " triggered")); | 1068 NS_LOG_FUNCTION (this << (periodic ? " periodic" : " triggered")); |
1069 | 1069 |
1070 for (SocketListI iter = m_sendSocketList.begin (); iter != m_sendSocketList.en
d (); iter++ ) | 1070 for (SocketListI iter = m_sendSocketList.begin (); iter != m_sendSocketList.en
d (); iter++ ) |
1071 { | 1071 { |
1072 uint32_t interface = iter->second; | 1072 uint32_t interface = iter->second; |
1073 | 1073 |
1074 if (m_interfaceExclusions.find (interface) == m_interfaceExclusions.end ()
) | 1074 if (m_interfaceExclusions.find (interface) == m_interfaceExclusions.end ()
) |
1075 { | 1075 { |
1076 uint16_t mtu = m_ipv4->GetMtu (interface); | 1076 uint16_t mtu = m_ipv4->GetMtu (interface); |
1077 uint16_t maxRte = static_cast<uint16_t>((mtu - Ipv4Header ().GetSerial
izedSize () - UdpHeader ().GetSerializedSize () - RipHeader ().GetSerializedSize
()) / RipRte ().GetSerializedSize ()); | 1077 uint16_t maxRte = static_cast<uint16_t> ((mtu - Ipv4Header ().GetSeria
lizedSize () - UdpHeader ().GetSerializedSize () - RipHeader ().GetSerializedSiz
e ()) / RipRte ().GetSerializedSize ()); |
1078 | 1078 |
1079 Ptr<Packet> p = Create<Packet> (); | 1079 Ptr<Packet> p = Create<Packet> (); |
1080 SocketIpTtlTag tag; | 1080 SocketIpTtlTag tag; |
1081 tag.SetTtl (1); | 1081 tag.SetTtl (1); |
1082 p->AddPacketTag (tag); | 1082 p->AddPacketTag (tag); |
1083 | 1083 |
1084 RipHeader hdr; | 1084 RipHeader hdr; |
1085 hdr.SetCommand (RipHeader::RESPONSE); | 1085 hdr.SetCommand (RipHeader::RESPONSE); |
1086 | 1086 |
1087 for (RoutesI rtIter = m_routes.begin (); rtIter != m_routes.end (); rt
Iter++) | 1087 for (RoutesI rtIter = m_routes.begin (); rtIter != m_routes.end (); rt
Iter++) |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1357 { | 1357 { |
1358 os << static_cast<const Ipv4RoutingTableEntry &>(rte); | 1358 os << static_cast<const Ipv4RoutingTableEntry &>(rte); |
1359 os << ", metric: " << int (rte.GetRouteMetric ()) << ", tag: " << int (rte.Get
RouteTag ()); | 1359 os << ", metric: " << int (rte.GetRouteMetric ()) << ", tag: " << int (rte.Get
RouteTag ()); |
1360 | 1360 |
1361 return os; | 1361 return os; |
1362 } | 1362 } |
1363 | 1363 |
1364 | 1364 |
1365 } | 1365 } |
1366 | 1366 |
LEFT | RIGHT |