126818Skarels /* 226818Skarels * Copyright (c) 1983 Regents of the University of California. 333676Sbostic * All rights reserved. 433676Sbostic * 533676Sbostic * Redistribution and use in source and binary forms are permitted 6*34832Sbostic * provided that the above copyright notice and this paragraph are 7*34832Sbostic * duplicated in all such forms and that any documentation, 8*34832Sbostic * advertising materials, and other materials related to such 9*34832Sbostic * distribution and use acknowledge that the software was developed 10*34832Sbostic * by the University of California, Berkeley. The name of the 11*34832Sbostic * University may not be used to endorse or promote products derived 12*34832Sbostic * from this software without specific prior written permission. 13*34832Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14*34832Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15*34832Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1626818Skarels */ 178359Ssam 1826818Skarels #if defined(LIBC_SCCS) && !defined(lint) 19*34832Sbostic static char sccsid[] = "@(#)inet_makeaddr.c 5.3 (Berkeley) 06/27/88"; 2033676Sbostic #endif /* LIBC_SCCS and not lint */ 2126818Skarels 228359Ssam #include <sys/types.h> 239192Ssam #include <netinet/in.h> 248359Ssam 258359Ssam /* 268359Ssam * Formulate an Internet address from network + host. Used in 278359Ssam * building addresses stored in the ifnet structure. 288359Ssam */ 298359Ssam struct in_addr 308370Ssam inet_makeaddr(net, host) 318359Ssam int net, host; 328359Ssam { 338359Ssam u_long addr; 348359Ssam 358359Ssam if (net < 128) 3621762Skarels addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST); 378359Ssam else if (net < 65536) 3821762Skarels addr = (net << IN_CLASSB_NSHIFT) | (host & IN_CLASSB_HOST); 398359Ssam else 4021762Skarels addr = (net << IN_CLASSC_NSHIFT) | (host & IN_CLASSC_HOST); 418359Ssam addr = htonl(addr); 428359Ssam return (*(struct in_addr *)&addr); 438359Ssam } 44