1 /* 2 * Copyright (c) 1983 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #if defined(LIBC_SCCS) && !defined(lint) 9 static char sccsid[] = "@(#)inet_netof.c 5.6 (Berkeley) 06/01/90"; 10 #endif /* LIBC_SCCS and not lint */ 11 12 #include <sys/types.h> 13 #include <netinet/in.h> 14 15 /* 16 * Return the network number from an internet 17 * address; handles class a/b/c network #'s. 18 */ 19 u_long 20 inet_netof(in) 21 struct in_addr in; 22 { 23 register u_long i = ntohl(in.s_addr); 24 25 if (IN_CLASSA(i)) 26 return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT); 27 else if (IN_CLASSB(i)) 28 return (((i)&IN_CLASSB_NET) >> IN_CLASSB_NSHIFT); 29 else 30 return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT); 31 } 32