xref: /original-bsd/lib/libc/net/inet_makeaddr.c (revision 3aaceb89)
1 /*	inet_makeaddr.c	4.2	82/10/07	*/
2 
3 #include <sys/types.h>
4 #include <net/in.h>
5 
6 /*
7  * Formulate an Internet address from network + host.  Used in
8  * building addresses stored in the ifnet structure.
9  */
10 struct in_addr
11 inet_makeaddr(net, host)
12 	int net, host;
13 {
14 	u_long addr;
15 
16 	if (net < 128)
17 		addr = (net << 24) | host;
18 	else if (net < 65536)
19 		addr = (net << 16) | host;
20 	else
21 		addr = (net << 8) | host;
22 	addr = htonl(addr);
23 	return (*(struct in_addr *)&addr);
24 }
25