121369Sdist /* 221369Sdist * Copyright (c) 1983 Regents of the University of California. 333676Sbostic * All rights reserved. 433676Sbostic * 542626Sbostic * %sccs.include.redist.c% 621369Sdist */ 78360Ssam 826614Sdonn #if defined(LIBC_SCCS) && !defined(lint) 9*46604Sbostic static char sccsid[] = "@(#)inet_netof.c 5.7 (Berkeley) 02/24/91"; 1033676Sbostic #endif /* LIBC_SCCS and not lint */ 1121369Sdist 12*46604Sbostic #include <sys/param.h> 139192Ssam #include <netinet/in.h> 14*46604Sbostic #include <arpa/inet.h> 158360Ssam 168360Ssam /* 178360Ssam * Return the network number from an internet 188360Ssam * address; handles class a/b/c network #'s. 198360Ssam */ 2032317Sbostic u_long 218370Ssam inet_netof(in) 228360Ssam struct in_addr in; 238360Ssam { 249192Ssam register u_long i = ntohl(in.s_addr); 258360Ssam 269192Ssam if (IN_CLASSA(i)) 279192Ssam return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT); 289192Ssam else if (IN_CLASSB(i)) 299192Ssam return (((i)&IN_CLASSB_NET) >> IN_CLASSB_NSHIFT); 309192Ssam else 319192Ssam return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT); 328360Ssam } 33