Bitwise operation for manipulating IP addresses
This commit is contained in:
parent
680f5e91c3
commit
c049506a56
1 changed files with 1 additions and 1 deletions
2
arp.c
2
arp.c
|
@ -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];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue