inet_lnaof.c revision 722:636b850d4ee9
1170263Sdarrenr/* 2255332Scy * CDDL HEADER START 3255332Scy * 4255332Scy * The contents of this file are subject to the terms of the 5255332Scy * Common Development and Distribution License, Version 1.0 only 6255332Scy * (the "License"). You may not use this file except in compliance 7255332Scy * with the License. 8145510Sdarrenr * 9145510Sdarrenr * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10145510Sdarrenr * or http://www.opensolaris.org/os/licensing. 11145510Sdarrenr * See the License for the specific language governing permissions 12170263Sdarrenr * and limitations under the License. 13170263Sdarrenr * 14255332Scy * When distributing Covered Code, include this CDDL HEADER in each 15255332Scy * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16145510Sdarrenr * If applicable, add the following below this CDDL HEADER, with the 17145510Sdarrenr * fields enclosed by brackets "[]" replaced with your own identifying 18145510Sdarrenr * information: Portions Copyright [yyyy] [name of copyright owner] 19145510Sdarrenr * 20255332Scy * CDDL HEADER END 21145510Sdarrenr */ 22145510Sdarrenr/* 23145510Sdarrenr * Copyright 1983 Sun Microsystems, Inc. All rights reserved. 24255332Scy * Use is subject to license terms. 25255332Scy */ 26145510Sdarrenr 27255332Scy#pragma ident "%Z%%M% %I% %E% SMI" 28255332Scy 29145510Sdarrenr#include <sys/types.h> 30255332Scy#include <netinet/in.h> 31255332Scy 32255332Scy/* 33145510Sdarrenr * Return the local network address portion of an 34255332Scy * internet address; handles class a/b/c network 35145510Sdarrenr * number formats. 36145510Sdarrenr */ 37145510Sdarrenrint 38145510Sdarrenrinet_lnaof(struct in_addr in) 39145510Sdarrenr{ 40145510Sdarrenr u_long i = ntohl(in.s_addr); 41145510Sdarrenr 42145510Sdarrenr if (IN_CLASSA(i)) 43255332Scy return ((i)&IN_CLASSA_HOST); 44255332Scy else if (IN_CLASSB(i)) 45145510Sdarrenr return ((i)&IN_CLASSB_HOST); 46255332Scy else 47145510Sdarrenr return ((i)&IN_CLASSC_HOST); 48145510Sdarrenr} 49255332Scy