Commit | Line | Data |
---|---|---|
bb0cfa24 DF |
1 | /* |
2 | * Copyright (c) 1983 Regents of the University of California. | |
140b4f5f KB |
3 | * All rights reserved. |
4 | * | |
269a7923 | 5 | * %sccs.include.redist.c% |
bb0cfa24 DF |
6 | */ |
7 | ||
2ce81398 | 8 | #if defined(LIBC_SCCS) && !defined(lint) |
24fac7d8 | 9 | static char sccsid[] = "@(#)inet_netof.c 5.7 (Berkeley) %G%"; |
140b4f5f | 10 | #endif /* LIBC_SCCS and not lint */ |
031f37dd | 11 | |
24fac7d8 | 12 | #include <sys/param.h> |
056d5bbd | 13 | #include <netinet/in.h> |
24fac7d8 | 14 | #include <arpa/inet.h> |
031f37dd SL |
15 | |
16 | /* | |
17 | * Return the network number from an internet | |
18 | * address; handles class a/b/c network #'s. | |
19 | */ | |
ed2be010 | 20 | u_long |
3a3b7ace | 21 | inet_netof(in) |
031f37dd SL |
22 | struct in_addr in; |
23 | { | |
056d5bbd | 24 | register u_long i = ntohl(in.s_addr); |
031f37dd | 25 | |
056d5bbd SL |
26 | if (IN_CLASSA(i)) |
27 | return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT); | |
28 | else if (IN_CLASSB(i)) | |
29 | return (((i)&IN_CLASSB_NET) >> IN_CLASSB_NSHIFT); | |
30 | else | |
31 | return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT); | |
031f37dd | 32 | } |