xref: /csrg-svn/sys/netinet/in_local.c (revision 11563)
1*11563Ssam /*	in_local.c	4.1	83/03/13	*/
2*11563Ssam 
3*11563Ssam /*
4*11563Ssam  * Site specific Internet routines.
5*11563Ssam  */
6*11563Ssam 
7*11563Ssam #ifndef if_localmakeaddr
8*11563Ssam /*
9*11563Ssam  * Formulate an Internet address from network + host.  Handle
10*11563Ssam  * local subnet interpretation.  Used in building addresses
11*11563Ssam  * stored in the ifnet structure.
12*11563Ssam  */
13*11563Ssam struct in_addr
if_localmakeaddr(net,host)14*11563Ssam if_localmakeaddr(net, host)
15*11563Ssam 	int net, host;
16*11563Ssam {
17*11563Ssam 	u_long addr, subnet;
18*11563Ssam 
19*11563Ssam 	subnet = net >> 24, net &= 0xffffff;
20*11563Ssam 	if (net < 128)
21*11563Ssam 		addr = (net << IN_CLASSA_NSHIFT) | host |
22*11563Ssam 		  (subnet << IN_CLASSA_NSHIFT - 8);
23*11563Ssam 	else if (net < 65536)
24*11563Ssam 		addr = (net << IN_CLASSB_NSHIFT) | host |
25*11563Ssam 		  (subnet << IN_CLASSB_NSHIFT - 8);
26*11563Ssam 	else
27*11563Ssam 		addr = (net << IN_CLASSC_NSHIFT) | host;
28*11563Ssam 	addr = htonl(addr);
29*11563Ssam 	return (*(struct in_addr *)&addr);
30*11563Ssam }
31*11563Ssam #endif
32