busybox-1.32.0/networking/httpd.c
static int scan_ip_mask(const char *str, unsigned *ipp, unsigned *maskp)
{
	int i;
	unsigned mask;
	char *p;

	i = scan_ip(&str, ipp, '/');
	if (i < 0)
		return i;

	if (*str) {
		/* there is /xxx after dotted-IP address */
		i = bb_strtou(str, &p, 10);
		if (*p == '.') {
			/* 'xxx' itself is dotted-IP mask, parse it */
			/* (return 0 (success) only if it has N.N.N.N form) */
			return scan_ip(&str, maskp, '\0') - 32;
		}
		if (*p)
			return -1;
	}

	if (i > 32)
		return -1;

	if (sizeof(unsigned) == 4 && i == 32) {
		/* mask >>= 32 below may not work */
		mask = 0;
	} else {
		mask = 0xffffffff;
		mask >>= i;
	}
	/* i == 0 -> *maskp = 0x00000000
	 * i == 1 -> *maskp = 0x80000000
	 * i == 4 -> *maskp = 0xf0000000
	 * i == 31 -> *maskp = 0xfffffffe
	 * i == 32 -> *maskp = 0xffffffff */
	*maskp = (uint32_t)(~mask);
	return 0;
}
/* Returns 0 on success. Stores IP and mask at provided pointers */
Returns 0 on success. Stores IP and mask at provided pointers
Returns 0 on success . Stores IP and mask at provided pointers
static int scan_ip_mask(const char *str, unsigned *ipp, unsigned *maskp)
{
	int i;
	unsigned mask;
	char *p;
	i = scan_ip(&str, ipp, '/');
	if (i < 0)
		return i;
	if (*str) {
		i = bb_strtou(str, &p, 10);
		if (*p == '.') {
			return scan_ip(&str, maskp, '\0') - 32;
		}
		if (*p)
			return -1;
	}
	if (i > 32)
		return -1;
	if (sizeof(unsigned) == 4 && i == 32) {
		mask = 0;
	} else {
		mask = 0xffffffff;
		mask >>= i;
	}
	*maskp = (uint32_t)(~mask);
	return 0;
}
static int scan_ip_mask ( const char * str , unsigned * ipp , unsigned * maskp ) { int i ; unsigned mask ; char * p ; i = scan_ip ( & str , ipp , ' ' ) ; if ( i < 0 ) return i ; if ( * str ) { i = bb_strtou ( str , & p , 10 ) ; if ( * p == ' ' ) { return scan_ip ( & str , maskp , ' \0 ' ) - 32 ; } if ( * p ) return -1 ; } if ( i > 32 ) return -1 ; if ( sizeof ( unsigned ) == 4 && i == 32 ) { mask = 0 ; } else { mask = 0xffffffff ; mask >>= i ; } * maskp = ( uint32_t ) ( ~ mask ) ; return 0 ; }
Returns 0 on success.
Returns 0 on success .
/* there is /xxx after dotted-IP address */ /* 'xxx' itself is dotted-IP mask, parse it */ /* (return 0 (success) only if it has N.N.N.N form) */ /* mask >>= 32 below may not work */ /* i == 0 -> *maskp = 0x00000000
	 * i == 1 -> *maskp = 0x80000000
	 * i == 4 -> *maskp = 0xf0000000
	 * i == 31 -> *maskp = 0xfffffffe
	 * i == 32 -> *maskp = 0xffffffff */