xref: /csrg-svn/lib/libc/net/inet_lnaof.c (revision 46604)
121368Sdist /*
221368Sdist  * Copyright (c) 1983 Regents of the University of California.
333676Sbostic  * All rights reserved.
433676Sbostic  *
542626Sbostic  * %sccs.include.redist.c%
621368Sdist  */
78358Ssam 
826613Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*46604Sbostic static char sccsid[] = "@(#)inet_lnaof.c	5.7 (Berkeley) 02/24/91";
1033676Sbostic #endif /* LIBC_SCCS and not lint */
1121368Sdist 
12*46604Sbostic #include <sys/param.h>
139192Ssam #include <netinet/in.h>
14*46604Sbostic #include <arpa/inet.h>
158358Ssam 
168358Ssam /*
178358Ssam  * Return the local network address portion of an
188358Ssam  * internet address; handles class a/b/c network
198358Ssam  * number formats.
208358Ssam  */
2132317Sbostic u_long
228370Ssam inet_lnaof(in)
238358Ssam 	struct in_addr in;
248358Ssam {
259192Ssam 	register u_long i = ntohl(in.s_addr);
269192Ssam 
279192Ssam 	if (IN_CLASSA(i))
289192Ssam 		return ((i)&IN_CLASSA_HOST);
299192Ssam 	else if (IN_CLASSB(i))
309192Ssam 		return ((i)&IN_CLASSB_HOST);
319192Ssam 	else
329192Ssam 		return ((i)&IN_CLASSC_HOST);
338358Ssam }
34