File tree Expand file tree Collapse file tree 1 file changed +18
-7
lines changed
Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -230,15 +230,26 @@ int arp_check(const char *dev, uint32_t destaddr) {
230230 if (framerx [12 ] != (ETH_P_ARP / 256 ) || framerx [13 ] != (ETH_P_ARP % 256 ))
231231 continue ;
232232 memcpy (& hdr , framerx + 14 , sizeof (ArpHdr ));
233- if (hdr .opcode == htons (1 ))
234- continue ;
235- if (hdr .opcode == htons (2 )) {
236- // check my mac and my address
237- if (memcmp (ifr .ifr_hwaddr .sa_data , hdr .target_mac , 6 ) != 0 )
238- continue ;
233+ if (hdr .opcode == htons (1 )) {
234+ // request, check if someone else is probing the same IP
235+ if (memcmp (ifr .ifr_hwaddr .sa_data , hdr .sender_mac , 6 ) == 0 )
236+ continue ; // it was our own probe, ignore it
237+
239238 uint32_t ip ;
240239 memcpy (& ip , hdr .target_ip , 4 );
241- if (ip != srcaddr ) {
240+ if (ip != destaddr ) {
241+ continue ;
242+ }
243+ close (sock );
244+ return -1 ;
245+ }
246+ if (hdr .opcode == htons (2 )) {
247+ // reply, check if someone else has the address we are probing for
248+ /*if (memcmp(ifr.ifr_hwaddr.sa_data, hdr.target_mac, 6) != 0)
249+ continue;*/
250+ uint32_t ip ;
251+ memcpy (& ip , hdr .sender_ip , 4 );
252+ if (ip != destaddr ) {
242253 continue ;
243254 }
244255 close (sock );
You can’t perform that action at this time.
0 commit comments