Commit | Line | Data |
---|---|---|
85ce71f2 | 1 | /* if.c 4.6 81/12/07 */ |
1bfd8df7 BJ |
2 | |
3 | #include "../h/param.h" | |
4 | #include "../h/systm.h" | |
8a13b737 BJ |
5 | #include "../net/in.h" |
6 | #include "../net/in_systm.h" | |
1bfd8df7 BJ |
7 | #include "../net/if.h" |
8 | ||
85ce71f2 BJ |
9 | ifinit() |
10 | { | |
11 | register struct ifnet *ifp; | |
12 | ||
13 | for (ifp = ifnet; ifp; ifp = ifp->if_next) | |
14 | if (ifp->if_init) | |
15 | (*ifp->if_init)(); | |
16 | } | |
17 | ||
18 | ifubareset(uban) | |
19 | int uban; | |
20 | { | |
21 | register struct ifnet *ifp; | |
22 | ||
23 | for (ifp = ifnet; ifp; ifp = ifp->if_next) | |
24 | if (ifp->if_ubareset) | |
25 | (*ifp->if_ubareset)(uban); | |
26 | } | |
27 | ||
405c9168 BJ |
28 | if_attach(ifp) |
29 | struct ifnet *ifp; | |
30 | { | |
31 | ||
32 | COUNT(IF_ATTACH); | |
33 | ifp->if_next = ifnet; | |
34 | ifnet = ifp; | |
35 | } | |
36 | ||
4ad99bae BJ |
37 | /*ARGSUSED*/ |
38 | struct ifnet * | |
1bfd8df7 BJ |
39 | if_ifwithaddr(in) |
40 | struct in_addr in; | |
41 | { | |
42 | register struct ifnet *ifp; | |
43 | ||
4ad99bae | 44 | COUNT(IF_IFWITHADDR); |
1bfd8df7 BJ |
45 | for (ifp = ifnet; ifp; ifp = ifp->if_next) |
46 | if (ifp->if_addr.s_addr == in.s_addr) | |
47 | break; | |
1bfd8df7 BJ |
48 | return (ifp); |
49 | } | |
50 | ||
4ad99bae BJ |
51 | /*ARGSUSED*/ |
52 | struct ifnet * | |
1bfd8df7 BJ |
53 | if_ifonnetof(in) |
54 | struct in_addr in; | |
55 | { | |
56 | register struct ifnet *ifp; | |
1bfd8df7 BJ |
57 | int net; |
58 | ||
4ad99bae | 59 | COUNT(IF_IFONNETOF); |
8a13b737 | 60 | net = in.s_net; /* XXX */ |
1bfd8df7 BJ |
61 | for (ifp = ifnet; ifp; ifp = ifp->if_next) |
62 | if (ifp->if_net == net) | |
63 | break; | |
1bfd8df7 BJ |
64 | return (ifp); |
65 | } | |
66 | ||
f1b2fa5b | 67 | /*ARGSUSED*/ |
8a13b737 BJ |
68 | struct ifnet * |
69 | if_gatewayfor(addr) | |
70 | struct in_addr addr; | |
71 | { | |
72 | ||
73 | COUNT(IF_GATEWAYFOR); | |
74 | return (0); | |
75 | } | |
f1b2fa5b BJ |
76 | |
77 | struct in_addr | |
78 | if_makeaddr(net, host) | |
79 | int net, host; | |
80 | { | |
81 | u_long addr; | |
82 | ||
83 | if (net < 128) | |
85ce71f2 | 84 | addr = (net << 24) | host; |
f1b2fa5b | 85 | else if (net < 65536) |
85ce71f2 | 86 | addr = (net << 16) | host; |
f1b2fa5b | 87 | else |
85ce71f2 | 88 | addr = (net << 8) | host; |
f1b2fa5b BJ |
89 | addr = htonl(addr); |
90 | return (*(struct in_addr *)&addr); | |
91 | } |