1 /* if.c 4.5 81/12/02 */ 2 3 #include "../h/param.h" 4 #include "../h/systm.h" 5 #include "../net/in.h" 6 #include "../net/in_systm.h" 7 #include "../net/if.h" 8 9 if_attach(ifp) 10 struct ifnet *ifp; 11 { 12 13 COUNT(IF_ATTACH); 14 ifp->if_next = ifnet; 15 ifnet = ifp; 16 } 17 18 /*ARGSUSED*/ 19 struct ifnet * 20 if_ifwithaddr(in) 21 struct in_addr in; 22 { 23 register struct ifnet *ifp; 24 25 COUNT(IF_IFWITHADDR); 26 for (ifp = ifnet; ifp; ifp = ifp->if_next) 27 if (ifp->if_addr.s_addr == in.s_addr) 28 break; 29 return (ifp); 30 } 31 32 /*ARGSUSED*/ 33 struct ifnet * 34 if_ifonnetof(in) 35 struct in_addr in; 36 { 37 register struct ifnet *ifp; 38 int net; 39 40 COUNT(IF_IFONNETOF); 41 net = in.s_net; /* XXX */ 42 for (ifp = ifnet; ifp; ifp = ifp->if_next) 43 if (ifp->if_net == net) 44 break; 45 return (ifp); 46 } 47 48 /*ARGSUSED*/ 49 struct ifnet * 50 if_gatewayfor(addr) 51 struct in_addr addr; 52 { 53 54 COUNT(IF_GATEWAYFOR); 55 return (0); 56 } 57 58 struct in_addr 59 if_makeaddr(net, host) 60 int net, host; 61 { 62 u_long addr; 63 64 if (net < 128) 65 addr = (host << 8) | net; 66 else if (net < 65536) 67 addr = (host << 16) | net; 68 else 69 addr = (host << 24) | net; 70 addr = htonl(addr); 71 return (*(struct in_addr *)&addr); 72 } 73