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) 03/11/86"; 9 #endif LIBC_SCCS and not lint 10 11 #include <sys/types.h> 12 #include <netinet/in.h> 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 19 inet_makeaddr(net, host) 20 int net, host; 21 { 22 u_long addr; 23 24 if (net < 128) 25 addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST); 26 else if (net < 65536) 27 addr = (net << IN_CLASSB_NSHIFT) | (host & IN_CLASSB_HOST); 28 else 29 addr = (net << IN_CLASSC_NSHIFT) | (host & IN_CLASSC_HOST); 30 addr = htonl(addr); 31 return (*(struct in_addr *)&addr); 32 } 33