Commit | Line | Data |
---|---|---|
5b25cd8a MK |
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 | ||
7 | #if defined(LIBC_SCCS) && !defined(lint) | |
8 | static char sccsid[] = "@(#)inet_makeaddr.c 5.1 (Berkeley) %G%"; | |
9 | #endif LIBC_SCCS and not lint | |
9b8667c0 SL |
10 | |
11 | #include <sys/types.h> | |
056d5bbd | 12 | #include <netinet/in.h> |
9b8667c0 SL |
13 | |
14 | /* | |
15 | * Formulate an Internet address from network + host. Used in | |
16 | * building addresses stored in the ifnet structure. | |
17 | */ | |
18 | struct in_addr | |
3a3b7ace | 19 | inet_makeaddr(net, host) |
9b8667c0 SL |
20 | int net, host; |
21 | { | |
22 | u_long addr; | |
23 | ||
24 | if (net < 128) | |
4efde109 | 25 | addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST); |
9b8667c0 | 26 | else if (net < 65536) |
4efde109 | 27 | addr = (net << IN_CLASSB_NSHIFT) | (host & IN_CLASSB_HOST); |
9b8667c0 | 28 | else |
4efde109 | 29 | addr = (net << IN_CLASSC_NSHIFT) | (host & IN_CLASSC_HOST); |
9b8667c0 SL |
30 | addr = htonl(addr); |
31 | return (*(struct in_addr *)&addr); | |
32 | } |