Commit | Line | Data |
---|---|---|
1dd55890 | 1 | /* if.c 4.9 82/03/09 */ |
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 | 47 | for (ifp = ifnet; ifp; ifp = ifp->if_next) |
1dd55890 BJ |
48 | if (in.s_addr == ifp->if_addr.s_addr || |
49 | (ifp->if_broadaddr.s_addr != 0 && | |
50 | in.s_addr == ifp->if_broadaddr.s_addr)) | |
1bfd8df7 | 51 | break; |
1bfd8df7 BJ |
52 | return (ifp); |
53 | } | |
54 | ||
4ad99bae BJ |
55 | /*ARGSUSED*/ |
56 | struct ifnet * | |
1bfd8df7 BJ |
57 | if_ifonnetof(in) |
58 | struct in_addr in; | |
59 | { | |
60 | register struct ifnet *ifp; | |
1bfd8df7 BJ |
61 | int net; |
62 | ||
4ad99bae | 63 | COUNT(IF_IFONNETOF); |
8a13b737 | 64 | net = in.s_net; /* XXX */ |
1bfd8df7 BJ |
65 | for (ifp = ifnet; ifp; ifp = ifp->if_next) |
66 | if (ifp->if_net == net) | |
67 | break; | |
1bfd8df7 BJ |
68 | return (ifp); |
69 | } | |
70 | ||
f1b2fa5b | 71 | /*ARGSUSED*/ |
8a13b737 BJ |
72 | struct ifnet * |
73 | if_gatewayfor(addr) | |
74 | struct in_addr addr; | |
75 | { | |
76 | ||
77 | COUNT(IF_GATEWAYFOR); | |
78 | return (0); | |
79 | } | |
f1b2fa5b BJ |
80 | |
81 | struct in_addr | |
82 | if_makeaddr(net, host) | |
83 | int net, host; | |
84 | { | |
85 | u_long addr; | |
86 | ||
87 | if (net < 128) | |
85ce71f2 | 88 | addr = (net << 24) | host; |
f1b2fa5b | 89 | else if (net < 65536) |
85ce71f2 | 90 | addr = (net << 16) | host; |
f1b2fa5b | 91 | else |
85ce71f2 | 92 | addr = (net << 8) | host; |
72c68388 | 93 | #ifdef vax |
f1b2fa5b | 94 | addr = htonl(addr); |
72c68388 | 95 | #endif |
f1b2fa5b BJ |
96 | return (*(struct in_addr *)&addr); |
97 | } |