xref: /csrg-svn/lib/libc/net/inet_lnaof.c (revision 26613)
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 
7*26613Sdonn #if defined(LIBC_SCCS) && !defined(lint)
8*26613Sdonn static char sccsid[] = "@(#)inet_lnaof.c	5.2 (Berkeley) 03/09/86";
9*26613Sdonn #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  */
198370Ssam inet_lnaof(in)
208358Ssam 	struct in_addr in;
218358Ssam {
229192Ssam 	register u_long i = ntohl(in.s_addr);
239192Ssam 
249192Ssam 	if (IN_CLASSA(i))
259192Ssam 		return ((i)&IN_CLASSA_HOST);
269192Ssam 	else if (IN_CLASSB(i))
279192Ssam 		return ((i)&IN_CLASSB_HOST);
289192Ssam 	else
299192Ssam 		return ((i)&IN_CLASSC_HOST);
308358Ssam }
31