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