src/usr.sbin/mountd/mountd.c
/*
 * Make a netmask according to the specified prefix length. The ss_family
 * and other non-address fields must be initialised before calling this.
 */
Make a netmask according to the specified prefix length. The ss_family
and other non-address fields must be initialised before calling this.
Make a netmask according to the specified prefix length . The ss_family and other non - address fields must be initialised before calling this .
static int
makemask(struct sockaddr_storage *ssp, int bitlen)
{
	u_char *p;
	int bits, i, len;
	if ((p = sa_rawaddr((struct sockaddr *)ssp, &len)) == NULL)
		return (-1);
	if (bitlen > len * CHAR_BIT)
		return (-1);
	for (i = 0; i < len; i++) {
		bits = MIN(CHAR_BIT, bitlen);
		*p++ = (u_char)~0 << (CHAR_BIT - bits);
		bitlen -= bits;
	}
	return 0;
}
static int makemask ( struct sockaddr_storage * ssp , int bitlen ) { u_char * p ; int bits , i , len ; if ( ( p = sa_rawaddr ( ( struct sockaddr * ) ssp , & len ) ) == NULL ) return ( -1 ) ; if ( bitlen > len * CHAR_BIT ) return ( -1 ) ; for ( i = 0 ; i < len ; i ++ ) { bits = MIN ( CHAR_BIT , bitlen ) ; * p ++ = ( u_char ) ~ 0 << ( CHAR_BIT - bits ) ; bitlen -= bits ; } return 0 ; }
Make a netmask according to the specified prefix length.
Make a netmask according to the specified prefix length .