|
Lines 87-92
ArpL3Protocol::Receive(Packet& packet, P
|
Link Here
|
|---|
|
| 87 |
ArpCache *cache = FindCache (device); |
87 |
ArpCache *cache = FindCache (device); |
| 88 |
ArpHeader arp; |
88 |
ArpHeader arp; |
| 89 |
packet.RemoveHeader (arp); |
89 |
packet.RemoveHeader (arp); |
|
|
90 |
|
| 91 |
NS_DEBUG ("ARP: received "<< (arp.IsRequest ()? "request" : "reply") << |
| 92 |
" node="<<m_node->GetId ()<<", got request from " << |
| 93 |
arp.GetSourceIpv4Address () << " for address " << |
| 94 |
arp.GetDestinationIpv4Address () << "; we have address " << |
| 95 |
cache->GetInterface ()->GetAddress ()); |
| 96 |
|
| 90 |
if (arp.IsRequest () && |
97 |
if (arp.IsRequest () && |
| 91 |
arp.GetDestinationIpv4Address () == cache->GetInterface ()->GetAddress ()) |
98 |
arp.GetDestinationIpv4Address () == cache->GetInterface ()->GetAddress ()) |
| 92 |
{ |
99 |
{ |
|
Lines 128-133
ArpL3Protocol::Receive(Packet& packet, P
|
Link Here
|
|---|
|
| 128 |
// XXX report packet as dropped. |
135 |
// XXX report packet as dropped. |
| 129 |
} |
136 |
} |
| 130 |
} |
137 |
} |
|
|
138 |
else |
| 139 |
{ |
| 140 |
NS_DEBUG ("node="<<m_node->GetId ()<<", got request from " << |
| 141 |
arp.GetSourceIpv4Address () << " for unknown address " << |
| 142 |
arp.GetDestinationIpv4Address () << " -- drop"); |
| 143 |
} |
| 131 |
} |
144 |
} |
| 132 |
bool |
145 |
bool |
| 133 |
ArpL3Protocol::Lookup (Packet &packet, Ipv4Address destination, |
146 |
ArpL3Protocol::Lookup (Packet &packet, Ipv4Address destination, |
|
|
| 203 |
ArpL3Protocol::SendArpRequest (ArpCache const *cache, Ipv4Address to) |
216 |
ArpL3Protocol::SendArpRequest (ArpCache const *cache, Ipv4Address to) |
| 204 |
{ |
217 |
{ |
| 205 |
ArpHeader arp; |
218 |
ArpHeader arp; |
|
|
219 |
NS_DEBUG ("ARP: sending request from node "<<m_node->GetId ()<< |
| 220 |
" || src: " << cache->GetDevice ()->GetAddress () << |
| 221 |
" / " << cache->GetInterface ()->GetAddress () << |
| 222 |
" || dst: " << cache->GetDevice ()->GetBroadcast () << |
| 223 |
" / " << to); |
| 206 |
arp.SetRequest (cache->GetDevice ()->GetAddress (), |
224 |
arp.SetRequest (cache->GetDevice ()->GetAddress (), |
| 207 |
cache->GetInterface ()->GetAddress (), |
225 |
cache->GetInterface ()->GetAddress (), |
| 208 |
cache->GetDevice ()->GetBroadcast (), |
226 |
cache->GetDevice ()->GetBroadcast (), |
|
|
| 216 |
ArpL3Protocol::SendArpReply (ArpCache const *cache, Ipv4Address toIp, MacAddress toMac) |
234 |
ArpL3Protocol::SendArpReply (ArpCache const *cache, Ipv4Address toIp, MacAddress toMac) |
| 217 |
{ |
235 |
{ |
| 218 |
ArpHeader arp; |
236 |
ArpHeader arp; |
|
|
237 |
NS_DEBUG ("ARP: sending reply from node "<<m_node->GetId ()<< |
| 238 |
"|| src: " << cache->GetDevice ()->GetAddress () << |
| 239 |
" / " << cache->GetInterface ()->GetAddress () << |
| 240 |
" || dst: " << toMac << " / " << toIp); |
| 219 |
arp.SetReply (cache->GetDevice ()->GetAddress (), |
241 |
arp.SetReply (cache->GetDevice ()->GetAddress (), |
| 220 |
cache->GetInterface ()->GetAddress (), |
242 |
cache->GetInterface ()->GetAddress (), |
| 221 |
toMac, toIp); |
243 |
toMac, toIp); |