Bitwise operation for manipulating IP addresses

This commit is contained in:
Dimitri Lozeve 2016-06-11 14:01:40 +02:00
parent 680f5e91c3
commit c049506a56

2
arp.c
View file

@ -254,7 +254,7 @@ int arp_scan(int sockfd, int ifindex, struct sockaddr_in *ipaddr, unsigned char
current subnet */ current subnet */
unsigned long ip_counter = ntohl(ipaddr->sin_addr.s_addr) & ntohl(netmask->sin_addr.s_addr); unsigned long ip_counter = ntohl(ipaddr->sin_addr.s_addr) & ntohl(netmask->sin_addr.s_addr);
/* The maximum address on the subnet */ /* The maximum address on the subnet */
unsigned long ip_max = ip_counter + (~ntohl(netmask->sin_addr.s_addr)); unsigned long ip_max = ip_counter | (~ntohl(netmask->sin_addr.s_addr));
while (ip_counter < ip_max) { while (ip_counter < ip_max) {
char ip_string[16]; char ip_string[16];