change retry loop to decrement after test
[unix-history] / usr / src / lib / libc / net / inet_netof.c
CommitLineData
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
DS
7#if defined(LIBC_SCCS) && !defined(lint)
8static char sccsid[] = "@(#)inet_netof.c 5.2 (Berkeley) %G%";
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 */
3a3b7ace 18inet_netof(in)
031f37dd
SL
19 struct in_addr in;
20{
056d5bbd 21 register u_long i = ntohl(in.s_addr);
031f37dd 22
056d5bbd
SL
23 if (IN_CLASSA(i))
24 return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT);
25 else if (IN_CLASSB(i))
26 return (((i)&IN_CLASSB_NET) >> IN_CLASSB_NSHIFT);
27 else
28 return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT);
031f37dd 29}