mirror of
https://git.busybox.net/udhcp
synced 2025-10-14 01:59:23 +08:00
byte order fix for mton
This commit is contained in:
9
script.c
9
script.c
@@ -68,10 +68,11 @@ static int sprintip(char *dest, char *pre, unsigned char *ip)
|
||||
static int mton(struct in_addr *mask)
|
||||
{
|
||||
int i;
|
||||
/* note: mask will always be in network byte order, so
|
||||
* there are no endian issues */
|
||||
for (i = 31; i >= 0 && !((mask->s_addr >> i) & 1); i--);
|
||||
return i + 1;
|
||||
unsigned long bits = ntohl(mask->s_addr);
|
||||
/* too bad one can't check the carry bit, etc in c bit
|
||||
* shifting */
|
||||
for (i = 0; i < 32 && !((bits >> i) & 1); i++);
|
||||
return 32 - i;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user