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 726614Sdonn #if defined(LIBC_SCCS) && !defined(lint) 8*32317Sbostic static char sccsid[] = "@(#)inet_netof.c 5.3 (Berkeley) 10/01/87"; 926614Sdonn #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 */ 18*32317Sbostic u_long 198370Ssam inet_netof(in) 208360Ssam struct in_addr in; 218360Ssam { 229192Ssam register u_long i = ntohl(in.s_addr); 238360Ssam 249192Ssam if (IN_CLASSA(i)) 259192Ssam return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT); 269192Ssam else if (IN_CLASSB(i)) 279192Ssam return (((i)&IN_CLASSB_NET) >> IN_CLASSB_NSHIFT); 289192Ssam else 299192Ssam return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT); 308360Ssam } 31