xref: /original-bsd/lib/libc/net/inet_lnaof.c (revision cf2124ff)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #if defined(LIBC_SCCS) && !defined(lint)
9 static char sccsid[] = "@(#)inet_lnaof.c	5.7 (Berkeley) 02/24/91";
10 #endif /* LIBC_SCCS and not lint */
11 
12 #include <sys/param.h>
13 #include <netinet/in.h>
14 #include <arpa/inet.h>
15 
16 /*
17  * Return the local network address portion of an
18  * internet address; handles class a/b/c network
19  * number formats.
20  */
21 u_long
22 inet_lnaof(in)
23 	struct in_addr in;
24 {
25 	register u_long i = ntohl(in.s_addr);
26 
27 	if (IN_CLASSA(i))
28 		return ((i)&IN_CLASSA_HOST);
29 	else if (IN_CLASSB(i))
30 		return ((i)&IN_CLASSB_HOST);
31 	else
32 		return ((i)&IN_CLASSC_HOST);
33 }
34