121369Sdist /* 221369Sdist * Copyright (c) 1983 Regents of the University of California. 321369Sdist * All rights reserved. The Berkeley software License Agreement 421369Sdist * specifies the terms and conditions for redistribution. 521369Sdist */ 68360Ssam 7*26614Sdonn #if defined(LIBC_SCCS) && !defined(lint) 8*26614Sdonn static char sccsid[] = "@(#)inet_netof.c 5.2 (Berkeley) 03/09/86"; 9*26614Sdonn #endif LIBC_SCCS and not lint 1021369Sdist 118360Ssam #include <sys/types.h> 129192Ssam #include <netinet/in.h> 138360Ssam 148360Ssam /* 158360Ssam * Return the network number from an internet 168360Ssam * address; handles class a/b/c network #'s. 178360Ssam */ 188370Ssam inet_netof(in) 198360Ssam struct in_addr in; 208360Ssam { 219192Ssam register u_long i = ntohl(in.s_addr); 228360Ssam 239192Ssam if (IN_CLASSA(i)) 249192Ssam return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT); 259192Ssam else if (IN_CLASSB(i)) 269192Ssam return (((i)&IN_CLASSB_NET) >> IN_CLASSB_NSHIFT); 279192Ssam else 289192Ssam return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT); 298360Ssam } 30