1156952Sume/*
2156952Sume * Copyright (c) 1983, 1993
3156952Sume *	The Regents of the University of California.  All rights reserved.
4156952Sume *
5156952Sume * Redistribution and use in source and binary forms, with or without
6156952Sume * modification, are permitted provided that the following conditions
7156952Sume * are met:
8156952Sume * 1. Redistributions of source code must retain the above copyright
9156952Sume *    notice, this list of conditions and the following disclaimer.
10156952Sume * 2. Redistributions in binary form must reproduce the above copyright
11156952Sume *    notice, this list of conditions and the following disclaimer in the
12156952Sume *    documentation and/or other materials provided with the distribution.
13156952Sume * 4. Neither the name of the University nor the names of its contributors
14156952Sume *    may be used to endorse or promote products derived from this software
15156952Sume *    without specific prior written permission.
16156952Sume *
17156952Sume * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18156952Sume * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19156952Sume * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20156952Sume * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21156952Sume * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22156952Sume * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23156952Sume * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24156952Sume * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25156952Sume * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26156952Sume * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27156952Sume * SUCH DAMAGE.
28156952Sume */
29156952Sume
30156952Sume#if defined(LIBC_SCCS) && !defined(lint)
31156952Sumestatic const char sccsid[] = "@(#)inet_lnaof.c	8.1 (Berkeley) 6/4/93";
32156952Sume#endif /* LIBC_SCCS and not lint */
33156956Sume#include <sys/cdefs.h>
34156956Sume__FBSDID("$FreeBSD$");
35156952Sume
36156952Sume#include "port_before.h"
37156952Sume
38156952Sume#include <sys/param.h>
39156952Sume#include <netinet/in.h>
40156952Sume#include <arpa/inet.h>
41156952Sume
42156952Sume#include "port_after.h"
43156952Sume
44170244Sume/*%
45156952Sume * Return the local network address portion of an
46156952Sume * internet address; handles class a/b/c network
47156952Sume * number formats.
48156952Sume */
49156956Sumein_addr_t
50156952Sumeinet_lnaof(in)
51156952Sume	struct in_addr in;
52156952Sume{
53156956Sume	in_addr_t i = ntohl(in.s_addr);
54156952Sume
55156952Sume	if (IN_CLASSA(i))
56156952Sume		return ((i)&IN_CLASSA_HOST);
57156952Sume	else if (IN_CLASSB(i))
58156952Sume		return ((i)&IN_CLASSB_HOST);
59156952Sume	else
60156952Sume		return ((i)&IN_CLASSC_HOST);
61156952Sume}
62156956Sume
63156956Sume/*
64156956Sume * Weak aliases for applications that use certain private entry points,
65156956Sume * and fail to include <arpa/inet.h>.
66156956Sume */
67156956Sume#undef inet_lnaof
68156956Sume__weak_reference(__inet_lnaof, inet_lnaof);
69170244Sume
70170244Sume/*! \file */
71