xref: /original-bsd/lib/libc/net/inet_netof.c (revision 957a0273)
1 /*	inet_netof.c	4.2	82/10/07	*/
2 
3 #include <sys/types.h>
4 #include <net/in.h>
5 
6 /*
7  * Return the network number from an internet
8  * address; handles class a/b/c network #'s.
9  */
10 inet_netof(in)
11 	struct in_addr in;
12 {
13 #if vax || pdp11
14 	register u_long net;
15 
16 	if ((in.s_addr&IN_CLASSA) == 0)
17 		return (in.s_addr & IN_CLASSA_NET);
18 	if ((in.s_addr&IN_CLASSB) == 0)
19 		return ((int)htons((u_short)(in.s_addr & IN_CLASSB_NET)));
20 	net = htonl((u_long)(in.s_addr & IN_CLASSC_NET));
21 	net >>= 8;
22 	return ((int)net);
23 #else
24 	return (IN_NETOF(in));
25 #endif
26 }
27