1254721Semaste/* 2254721Semaste * Copyright (c) 1983, 1993 3353358Sdim * The Regents of the University of California. All rights reserved. 4353358Sdim * 5353358Sdim * Redistribution and use in source and binary forms, with or without 6254721Semaste * modification, are permitted provided that the following conditions 7254721Semaste * are met: 8254721Semaste * 1. Redistributions of source code must retain the above copyright 9309124Sdim * notice, this list of conditions and the following disclaimer. 10288943Sdim * 2. Redistributions in binary form must reproduce the above copyright 11288943Sdim * notice, this list of conditions and the following disclaimer in the 12288943Sdim * documentation and/or other materials provided with the distribution. 13296417Sdim * 4. Neither the name of the University nor the names of its contributors 14353358Sdim * may be used to endorse or promote products derived from this software 15314564Sdim * without specific prior written permission. 16327952Sdim * 17288943Sdim * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18254721Semaste * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19254721Semaste * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20314564Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21314564Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22314564Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23314564Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24314564Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25314564Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26314564Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27314564Sdim * SUCH DAMAGE. 28254721Semaste */ 29254721Semaste 30314564Sdim#if defined(LIBC_SCCS) && !defined(lint) 31314564Sdimstatic const char sccsid[] = "@(#)inet_lnaof.c 8.1 (Berkeley) 6/4/93"; 32314564Sdim#endif /* LIBC_SCCS and not lint */ 33314564Sdim#include <sys/cdefs.h> 34314564Sdim__FBSDID("$FreeBSD$"); 35314564Sdim 36314564Sdim#include "port_before.h" 37314564Sdim 38314564Sdim#include <sys/param.h> 39314564Sdim#include <netinet/in.h> 40314564Sdim#include <arpa/inet.h> 41314564Sdim 42288943Sdim#include "port_after.h" 43314564Sdim 44314564Sdim/*% 45314564Sdim * Return the local network address portion of an 46314564Sdim * internet address; handles class a/b/c network 47314564Sdim * number formats. 48314564Sdim */ 49314564Sdimin_addr_t 50314564Sdiminet_lnaof(in) 51314564Sdim struct in_addr in; 52288943Sdim{ 53288943Sdim in_addr_t i = ntohl(in.s_addr); 54353358Sdim 55353358Sdim if (IN_CLASSA(i)) 56353358Sdim return ((i)&IN_CLASSA_HOST); 57353358Sdim else if (IN_CLASSB(i)) 58353358Sdim return ((i)&IN_CLASSB_HOST); 59353358Sdim else 60254721Semaste return ((i)&IN_CLASSC_HOST); 61314564Sdim} 62254721Semaste 63314564Sdim/* 64288943Sdim * Weak aliases for applications that use certain private entry points, 65309124Sdim * and fail to include <arpa/inet.h>. 66254721Semaste */ 67314564Sdim#undef inet_lnaof 68314564Sdim__weak_reference(__inet_lnaof, inet_lnaof); 69341825Sdim 70341825Sdim/*! \file */ 71314564Sdim