1 /* 2 * Copyright (c) 1983 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that this notice is preserved and that due credit is given 7 * to the University of California at Berkeley. The name of the University 8 * may not be used to endorse or promote products derived from this 9 * software without specific prior written permission. This software 10 * is provided ``as is'' without express or implied warranty. 11 */ 12 13 #if defined(LIBC_SCCS) && !defined(lint) 14 static char sccsid[] = "@(#)inet_lnaof.c 5.4 (Berkeley) 03/07/88"; 15 #endif /* LIBC_SCCS and not lint */ 16 17 #include <sys/types.h> 18 #include <netinet/in.h> 19 20 /* 21 * Return the local network address portion of an 22 * internet address; handles class a/b/c network 23 * number formats. 24 */ 25 u_long 26 inet_lnaof(in) 27 struct in_addr in; 28 { 29 register u_long i = ntohl(in.s_addr); 30 31 if (IN_CLASSA(i)) 32 return ((i)&IN_CLASSA_HOST); 33 else if (IN_CLASSB(i)) 34 return ((i)&IN_CLASSB_HOST); 35 else 36 return ((i)&IN_CLASSC_HOST); 37 } 38