Commit | Line | Data |
---|---|---|
c4af8b24 | 1 | /* if.c 4.8 82/02/03 */ |
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 | { | |
c4af8b24 | 31 | register struct ifnet **p = &ifnet; |
405c9168 BJ |
32 | |
33 | COUNT(IF_ATTACH); | |
c4af8b24 BJ |
34 | while (*p) |
35 | p = &((*p)->if_next); | |
36 | *p = ifp; | |
405c9168 BJ |
37 | } |
38 | ||
4ad99bae BJ |
39 | /*ARGSUSED*/ |
40 | struct ifnet * | |
1bfd8df7 BJ |
41 | if_ifwithaddr(in) |
42 | struct in_addr in; | |
43 | { | |
44 | register struct ifnet *ifp; | |
45 | ||
4ad99bae | 46 | COUNT(IF_IFWITHADDR); |
1bfd8df7 BJ |
47 | for (ifp = ifnet; ifp; ifp = ifp->if_next) |
48 | if (ifp->if_addr.s_addr == in.s_addr) | |
49 | break; | |
1bfd8df7 BJ |
50 | return (ifp); |
51 | } | |
52 | ||
4ad99bae BJ |
53 | /*ARGSUSED*/ |
54 | struct ifnet * | |
1bfd8df7 BJ |
55 | if_ifonnetof(in) |
56 | struct in_addr in; | |
57 | { | |
58 | register struct ifnet *ifp; | |
1bfd8df7 BJ |
59 | int net; |
60 | ||
4ad99bae | 61 | COUNT(IF_IFONNETOF); |
8a13b737 | 62 | net = in.s_net; /* XXX */ |
1bfd8df7 BJ |
63 | for (ifp = ifnet; ifp; ifp = ifp->if_next) |
64 | if (ifp->if_net == net) | |
65 | break; | |
1bfd8df7 BJ |
66 | return (ifp); |
67 | } | |
68 | ||
f1b2fa5b | 69 | /*ARGSUSED*/ |
8a13b737 BJ |
70 | struct ifnet * |
71 | if_gatewayfor(addr) | |
72 | struct in_addr addr; | |
73 | { | |
74 | ||
75 | COUNT(IF_GATEWAYFOR); | |
76 | return (0); | |
77 | } | |
f1b2fa5b BJ |
78 | |
79 | struct in_addr | |
80 | if_makeaddr(net, host) | |
81 | int net, host; | |
82 | { | |
83 | u_long addr; | |
84 | ||
85 | if (net < 128) | |
85ce71f2 | 86 | addr = (net << 24) | host; |
f1b2fa5b | 87 | else if (net < 65536) |
85ce71f2 | 88 | addr = (net << 16) | host; |
f1b2fa5b | 89 | else |
85ce71f2 | 90 | addr = (net << 8) | host; |
72c68388 | 91 | #ifdef vax |
f1b2fa5b | 92 | addr = htonl(addr); |
72c68388 | 93 | #endif |
f1b2fa5b BJ |
94 | return (*(struct in_addr *)&addr); |
95 | } |