126818Skarels /* 226818Skarels * Copyright (c) 1983 Regents of the University of California. 3*33676Sbostic * All rights reserved. 4*33676Sbostic * 5*33676Sbostic * Redistribution and use in source and binary forms are permitted 6*33676Sbostic * provided that this notice is preserved and that due credit is given 7*33676Sbostic * to the University of California at Berkeley. The name of the University 8*33676Sbostic * may not be used to endorse or promote products derived from this 9*33676Sbostic * software without specific prior written permission. This software 10*33676Sbostic * is provided ``as is'' without express or implied warranty. 1126818Skarels */ 128359Ssam 1326818Skarels #if defined(LIBC_SCCS) && !defined(lint) 14*33676Sbostic static char sccsid[] = "@(#)inet_makeaddr.c 5.2 (Berkeley) 03/07/88"; 15*33676Sbostic #endif /* LIBC_SCCS and not lint */ 1626818Skarels 178359Ssam #include <sys/types.h> 189192Ssam #include <netinet/in.h> 198359Ssam 208359Ssam /* 218359Ssam * Formulate an Internet address from network + host. Used in 228359Ssam * building addresses stored in the ifnet structure. 238359Ssam */ 248359Ssam struct in_addr 258370Ssam inet_makeaddr(net, host) 268359Ssam int net, host; 278359Ssam { 288359Ssam u_long addr; 298359Ssam 308359Ssam if (net < 128) 3121762Skarels addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST); 328359Ssam else if (net < 65536) 3321762Skarels addr = (net << IN_CLASSB_NSHIFT) | (host & IN_CLASSB_HOST); 348359Ssam else 3521762Skarels addr = (net << IN_CLASSC_NSHIFT) | (host & IN_CLASSC_HOST); 368359Ssam addr = htonl(addr); 378359Ssam return (*(struct in_addr *)&addr); 388359Ssam } 39