xref: /freebsd/contrib/ntp/libntp/netof.c (revision 77a0943ded95b9e6438f7db70c4a28e4d93946d4)
1 /*
2  * netof - return the net address part of an ip address
3  *         (zero out host part)
4  */
5 #include <stdio.h>
6 
7 #include "ntp_fp.h"
8 #include "ntp_stdlib.h"
9 
10 u_int32
11 netof(
12 	u_int32 num
13 	)
14 {
15 	register u_int32 netnum;
16 
17 	netnum = num;
18 	if(IN_CLASSC(netnum))
19 	    netnum &= IN_CLASSC_NET;
20 	else if (IN_CLASSB(netnum))
21 	    netnum &= IN_CLASSB_NET;
22 	else			/* treat all other like class A */
23 	    netnum &= IN_CLASSA_NET;
24 	return netnum;
25 }
26