xref: /csrg-svn/lib/libc/net/inet_lnaof.c (revision 32317)
121368Sdist /*
221368Sdist  * Copyright (c) 1983 Regents of the University of California.
321368Sdist  * All rights reserved.  The Berkeley software License Agreement
421368Sdist  * specifies the terms and conditions for redistribution.
521368Sdist  */
68358Ssam 
726613Sdonn #if defined(LIBC_SCCS) && !defined(lint)
8*32317Sbostic static char sccsid[] = "@(#)inet_lnaof.c	5.3 (Berkeley) 10/01/87";
926613Sdonn #endif LIBC_SCCS and not lint
1021368Sdist 
118358Ssam #include <sys/types.h>
129192Ssam #include <netinet/in.h>
138358Ssam 
148358Ssam /*
158358Ssam  * Return the local network address portion of an
168358Ssam  * internet address; handles class a/b/c network
178358Ssam  * number formats.
188358Ssam  */
19*32317Sbostic u_long
208370Ssam inet_lnaof(in)
218358Ssam 	struct in_addr in;
228358Ssam {
239192Ssam 	register u_long i = ntohl(in.s_addr);
249192Ssam 
259192Ssam 	if (IN_CLASSA(i))
269192Ssam 		return ((i)&IN_CLASSA_HOST);
279192Ssam 	else if (IN_CLASSB(i))
289192Ssam 		return ((i)&IN_CLASSB_HOST);
299192Ssam 	else
309192Ssam 		return ((i)&IN_CLASSC_HOST);
318358Ssam }
32