home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
- *
- * $Source$
- * $Date$
- * $Revision$
- * $State$
- * $Author$
- *
- * $Log$
- ***************************************************************************/
-
- static const char rcs_id[] = "$Id$";
-
- #include <arpa/inet.h>
- #include <netinet/in.h>
-
- /*
- * Extract a network number from an internet address
- */
- u_long
- inet_netof (struct in_addr in)
- {
- u_long net;
-
- if (IN_CLASSA (in.s_addr))
- {
- /* Extract a class A network number */
- net = in.s_addr & IN_CLASSA_NET;
- }
- else if (IN_CLASSB (in.s_addr))
- {
- /* Extract a class B network number */
- net = in.s_addr & IN_CLASSB_NET;
- }
- else if (IN_CLASSC (in.s_addr))
- {
- /* Extract a class C network number */
- net = in.s_addr & IN_CLASSC_NET;
- }
- else
- {
- /* Not a known address format */
- net = 0;
- }
-
- return net;
- }
-