| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_ecosubr.c,v 1.30 2008/12/17 20:51:36 cegger Exp $ */ | | 1 | /* $NetBSD: if_ecosubr.c,v 1.31 2009/01/07 20:56:40 bjh21 Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2001 Ben Harris | | 4 | * Copyright (c) 2001 Ben Harris |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -48,27 +48,27 @@ | | | @@ -48,27 +48,27 @@ |
48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
55 | * SUCH DAMAGE. | | 55 | * SUCH DAMAGE. |
56 | * | | 56 | * |
57 | * @(#)if_ethersubr.c 8.2 (Berkeley) 4/4/96 | | 57 | * @(#)if_ethersubr.c 8.2 (Berkeley) 4/4/96 |
58 | */ | | 58 | */ |
59 | | | 59 | |
60 | #include <sys/cdefs.h> | | 60 | #include <sys/cdefs.h> |
61 | __KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.30 2008/12/17 20:51:36 cegger Exp $"); | | 61 | __KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.31 2009/01/07 20:56:40 bjh21 Exp $"); |
62 | | | 62 | |
63 | #include "bpfilter.h" | | 63 | #include "bpfilter.h" |
64 | #include "opt_inet.h" | | 64 | #include "opt_inet.h" |
65 | #include "opt_pfil_hooks.h" | | 65 | #include "opt_pfil_hooks.h" |
66 | | | 66 | |
67 | #include <sys/param.h> | | 67 | #include <sys/param.h> |
68 | #include <sys/errno.h> | | 68 | #include <sys/errno.h> |
69 | #include <sys/kernel.h> | | 69 | #include <sys/kernel.h> |
70 | #include <sys/socket.h> | | 70 | #include <sys/socket.h> |
71 | #include <sys/sockio.h> | | 71 | #include <sys/sockio.h> |
72 | #include <sys/syslog.h> | | 72 | #include <sys/syslog.h> |
73 | #include <sys/systm.h> | | 73 | #include <sys/systm.h> |
74 | | | 74 | |
| @@ -88,27 +88,27 @@ __KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c | | | @@ -88,27 +88,27 @@ __KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c |
88 | #include <net/if_arp.h> | | 88 | #include <net/if_arp.h> |
89 | #include <netinet/in.h> | | 89 | #include <netinet/in.h> |
90 | #include <netinet/in_var.h> | | 90 | #include <netinet/in_var.h> |
91 | #endif | | 91 | #endif |
92 | | | 92 | |
93 | struct eco_retryparms { | | 93 | struct eco_retryparms { |
94 | int erp_delay; | | 94 | int erp_delay; |
95 | int erp_count; | | 95 | int erp_count; |
96 | }; | | 96 | }; |
97 | | | 97 | |
98 | /* Default broadcast address */ | | 98 | /* Default broadcast address */ |
99 | static const uint8_t eco_broadcastaddr[] = { 0xff, 0xff }; | | 99 | static const uint8_t eco_broadcastaddr[] = { 0xff, 0xff }; |
100 | | | 100 | |
101 | static int eco_output(struct ifnet *, struct mbuf *, struct sockaddr *, | | 101 | static int eco_output(struct ifnet *, struct mbuf *, const struct sockaddr *, |
102 | struct rtentry *); | | 102 | struct rtentry *); |
103 | static void eco_input(struct ifnet *, struct mbuf *); | | 103 | static void eco_input(struct ifnet *, struct mbuf *); |
104 | static void eco_start(struct ifnet *); | | 104 | static void eco_start(struct ifnet *); |
105 | static int eco_ioctl(struct ifnet *, u_long, void *); | | 105 | static int eco_ioctl(struct ifnet *, u_long, void *); |
106 | | | 106 | |
107 | static int eco_interestingp(struct ifnet *ifp, struct mbuf *m); | | 107 | static int eco_interestingp(struct ifnet *ifp, struct mbuf *m); |
108 | static struct mbuf *eco_immediate(struct ifnet *ifp, struct mbuf *m); | | 108 | static struct mbuf *eco_immediate(struct ifnet *ifp, struct mbuf *m); |
109 | static struct mbuf *eco_ack(struct ifnet *ifp, struct mbuf *m); | | 109 | static struct mbuf *eco_ack(struct ifnet *ifp, struct mbuf *m); |
110 | | | 110 | |
111 | static void eco_defer(struct ifnet *, struct mbuf *, int); | | 111 | static void eco_defer(struct ifnet *, struct mbuf *, int); |
112 | static void eco_retry_free(struct eco_retry *er); | | 112 | static void eco_retry_free(struct eco_retry *er); |
113 | static void eco_retry(void *); | | 113 | static void eco_retry(void *); |
114 | | | 114 | |
| @@ -119,29 +119,27 @@ eco_ifattach(struct ifnet *ifp, const ui | | | @@ -119,29 +119,27 @@ eco_ifattach(struct ifnet *ifp, const ui |
119 | | | 119 | |
120 | ifp->if_type = IFT_ECONET; | | 120 | ifp->if_type = IFT_ECONET; |
121 | ifp->if_addrlen = ECO_ADDR_LEN; | | 121 | ifp->if_addrlen = ECO_ADDR_LEN; |
122 | ifp->if_hdrlen = ECO_HDR_LEN; | | 122 | ifp->if_hdrlen = ECO_HDR_LEN; |
123 | ifp->if_dlt = DLT_ECONET; | | 123 | ifp->if_dlt = DLT_ECONET; |
124 | ifp->if_mtu = ECO_MTU; | | 124 | ifp->if_mtu = ECO_MTU; |
125 | | | 125 | |
126 | ifp->if_output = eco_output; | | 126 | ifp->if_output = eco_output; |
127 | ifp->if_input = eco_input; | | 127 | ifp->if_input = eco_input; |
128 | ifp->if_start = eco_start; | | 128 | ifp->if_start = eco_start; |
129 | ifp->if_ioctl = eco_ioctl; | | 129 | ifp->if_ioctl = eco_ioctl; |
130 | | | 130 | |
131 | /* ifp->if_baudrate...; */ | | 131 | /* ifp->if_baudrate...; */ |
132 | if_alloc_sadl(ifp); | | 132 | if_set_sadl(ifp, lla, ECO_ADDR_LEN, FALSE); |
133 | (void)sockaddr_dl_setaddr(ifp->if_sadl, ifp->if_sadl->sdl_len, lla, | | | |
134 | ifp->if_addrlen); | | | |
135 | | | 133 | |
136 | ifp->if_broadcastaddr = eco_broadcastaddr; | | 134 | ifp->if_broadcastaddr = eco_broadcastaddr; |
137 | | | 135 | |
138 | LIST_INIT(&ec->ec_retries); | | 136 | LIST_INIT(&ec->ec_retries); |
139 | | | 137 | |
140 | #if NBPFILTER > 0 | | 138 | #if NBPFILTER > 0 |
141 | bpfattach(ifp, ifp->if_dlt, ECO_HDR_LEN); | | 139 | bpfattach(ifp, ifp->if_dlt, ECO_HDR_LEN); |
142 | #endif | | 140 | #endif |
143 | } | | 141 | } |
144 | | | 142 | |
145 | #define senderr(e) do { \ | | 143 | #define senderr(e) do { \ |
146 | error = (e); \ | | 144 | error = (e); \ |
147 | goto bad; \ | | 145 | goto bad; \ |
| @@ -157,40 +155,41 @@ eco_init(struct ifnet *ifp) | | | @@ -157,40 +155,41 @@ eco_init(struct ifnet *ifp) |
157 | return 0; | | 155 | return 0; |
158 | } | | 156 | } |
159 | | | 157 | |
160 | void | | 158 | void |
161 | eco_stop(struct ifnet *ifp, int disable) | | 159 | eco_stop(struct ifnet *ifp, int disable) |
162 | { | | 160 | { |
163 | struct ecocom *ec = (struct ecocom *)ifp; | | 161 | struct ecocom *ec = (struct ecocom *)ifp; |
164 | | | 162 | |
165 | while (!LIST_EMPTY(&ec->ec_retries)) | | 163 | while (!LIST_EMPTY(&ec->ec_retries)) |
166 | eco_retry_free(LIST_FIRST(&ec->ec_retries)); | | 164 | eco_retry_free(LIST_FIRST(&ec->ec_retries)); |
167 | } | | 165 | } |
168 | | | 166 | |
169 | static int | | 167 | static int |
170 | eco_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, | | 168 | eco_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, |
171 | struct rtentry *rt0) | | 169 | struct rtentry *rt0) |
172 | { | | 170 | { |
173 | struct eco_header ehdr, *eh; | | 171 | struct eco_header ehdr, *eh; |
174 | int error; | | 172 | int error; |
175 | struct mbuf *m = m0, *mcopy = NULL; | | 173 | struct mbuf *m = m0, *mcopy = NULL; |
176 | struct rtentry *rt; | | 174 | struct rtentry *rt; |
177 | int hdrcmplt; | | 175 | int hdrcmplt; |
178 | int retry_delay, retry_count; | | 176 | int retry_delay, retry_count; |
179 | struct m_tag *mtag; | | 177 | struct m_tag *mtag; |
180 | struct eco_retryparms *erp; | | 178 | struct eco_retryparms *erp; |
181 | #ifdef INET | | 179 | #ifdef INET |
182 | struct mbuf *m1; | | 180 | struct mbuf *m1; |
183 | struct arphdr *ah; | | 181 | struct arphdr *ah; |
| | | 182 | void *tha; |
184 | struct eco_arp *ecah; | | 183 | struct eco_arp *ecah; |
185 | #endif | | 184 | #endif |
186 | ALTQ_DECL(struct altq_pktattr pktattr;) | | 185 | ALTQ_DECL(struct altq_pktattr pktattr;) |
187 | | | 186 | |
188 | if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) | | 187 | if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) |
189 | senderr(ENETDOWN); | | 188 | senderr(ENETDOWN); |
190 | if ((rt = rt0) != NULL) { | | 189 | if ((rt = rt0) != NULL) { |
191 | if ((rt->rt_flags & RTF_UP) == 0) { | | 190 | if ((rt->rt_flags & RTF_UP) == 0) { |
192 | if ((rt0 = rt = rtalloc1(dst, 1)) != NULL) { | | 191 | if ((rt0 = rt = rtalloc1(dst, 1)) != NULL) { |
193 | rt->rt_refcnt--; | | 192 | rt->rt_refcnt--; |
194 | if (rt->rt_ifp != ifp) | | 193 | if (rt->rt_ifp != ifp) |
195 | return (*rt->rt_ifp->if_output) | | 194 | return (*rt->rt_ifp->if_output) |
196 | (ifp, m0, dst, rt); | | 195 | (ifp, m0, dst, rt); |
| @@ -254,50 +253,52 @@ eco_output(struct ifnet *ifp, struct mbu | | | @@ -254,50 +253,52 @@ eco_output(struct ifnet *ifp, struct mbu |
254 | case ARPOP_REQUEST: | | 253 | case ARPOP_REQUEST: |
255 | ehdr.eco_control = ECO_CTL_ARP_REQUEST; | | 254 | ehdr.eco_control = ECO_CTL_ARP_REQUEST; |
256 | break; | | 255 | break; |
257 | case ARPOP_REPLY: | | 256 | case ARPOP_REPLY: |
258 | ehdr.eco_control = ECO_CTL_ARP_REPLY; | | 257 | ehdr.eco_control = ECO_CTL_ARP_REPLY; |
259 | break; | | 258 | break; |
260 | default: | | 259 | default: |
261 | return EOPNOTSUPP; | | 260 | return EOPNOTSUPP; |
262 | } | | 261 | } |
263 | | | 262 | |
264 | if (m->m_flags & M_BCAST) | | 263 | if (m->m_flags & M_BCAST) |
265 | memcpy(ehdr.eco_dhost, eco_broadcastaddr, | | 264 | memcpy(ehdr.eco_dhost, eco_broadcastaddr, |
266 | ECO_ADDR_LEN); | | 265 | ECO_ADDR_LEN); |
267 | else | | 266 | else { |
268 | memcpy(ehdr.eco_dhost, ar_tha(ah), ECO_ADDR_LEN); | | 267 | tha = ar_tha(ah); |
| | | 268 | KASSERT(tha != NULL); |
| | | 269 | memcpy(ehdr.eco_dhost, tha, ECO_ADDR_LEN); |
| | | 270 | } |
269 | | | 271 | |
270 | MGETHDR(m1, M_DONTWAIT, MT_DATA); | | 272 | MGETHDR(m1, M_DONTWAIT, MT_DATA); |
271 | if (m1 == NULL) | | 273 | if (m1 == NULL) |
272 | senderr(ENOBUFS); | | 274 | senderr(ENOBUFS); |
273 | M_MOVE_PKTHDR(m1, m); | | 275 | M_MOVE_PKTHDR(m1, m); |
274 | m1->m_len = sizeof(*ecah); | | 276 | m1->m_len = sizeof(*ecah); |
275 | m1->m_pkthdr.len = m1->m_len; | | 277 | m1->m_pkthdr.len = m1->m_len; |
276 | MH_ALIGN(m1, m1->m_len); | | 278 | MH_ALIGN(m1, m1->m_len); |
277 | ecah = mtod(m1, struct eco_arp *); | | 279 | ecah = mtod(m1, struct eco_arp *); |
278 | memset(ecah, 0, m1->m_len); | | 280 | memset(ecah, 0, m1->m_len); |
279 | memcpy(ecah->ecar_spa, ar_spa(ah), ah->ar_pln); | | 281 | memcpy(ecah->ecar_spa, ar_spa(ah), ah->ar_pln); |
280 | memcpy(ecah->ecar_tpa, ar_tpa(ah), ah->ar_pln); | | 282 | memcpy(ecah->ecar_tpa, ar_tpa(ah), ah->ar_pln); |
281 | m_freem(m); | | 283 | m_freem(m); |
282 | m = m1; | | 284 | m = m1; |
283 | break; | | 285 | break; |
284 | #endif | | 286 | #endif |
285 | case pseudo_AF_HDRCMPLT: | | 287 | case pseudo_AF_HDRCMPLT: |
286 | hdrcmplt = 1; | | 288 | hdrcmplt = 1; |
287 | /* FALLTHROUGH */ | | 289 | /* FALLTHROUGH */ |
288 | case AF_UNSPEC: | | 290 | case AF_UNSPEC: |
289 | eh = (struct eco_header *)dst->sa_data; | | 291 | ehdr = *(struct eco_header const *)dst->sa_data; |
290 | ehdr = *eh; | | | |
291 | break; | | 292 | break; |
292 | default: | | 293 | default: |
293 | log(LOG_ERR, "%s: can't handle af%d\n", ifp->if_xname, | | 294 | log(LOG_ERR, "%s: can't handle af%d\n", ifp->if_xname, |
294 | dst->sa_family); | | 295 | dst->sa_family); |
295 | senderr(EAFNOSUPPORT); | | 296 | senderr(EAFNOSUPPORT); |
296 | } | | 297 | } |
297 | | | 298 | |
298 | if (mcopy) | | 299 | if (mcopy) |
299 | (void) looutput(ifp, mcopy, dst, rt); | | 300 | (void) looutput(ifp, mcopy, dst, rt); |
300 | | | 301 | |
301 | /* | | 302 | /* |
302 | * Add local net header. If no space in first mbuf, | | 303 | * Add local net header. If no space in first mbuf, |
303 | * allocate another. | | 304 | * allocate another. |
| @@ -355,26 +356,27 @@ eco_interestingp(struct ifnet *ifp, stru | | | @@ -355,26 +356,27 @@ eco_interestingp(struct ifnet *ifp, stru |
355 | return 0; | | 356 | return 0; |
356 | } | | 357 | } |
357 | | | 358 | |
358 | static void | | 359 | static void |
359 | eco_input(struct ifnet *ifp, struct mbuf *m) | | 360 | eco_input(struct ifnet *ifp, struct mbuf *m) |
360 | { | | 361 | { |
361 | struct ifqueue *inq; | | 362 | struct ifqueue *inq; |
362 | struct eco_header ehdr, *eh; | | 363 | struct eco_header ehdr, *eh; |
363 | int s, i; | | 364 | int s, i; |
364 | #ifdef INET | | 365 | #ifdef INET |
365 | struct arphdr *ah; | | 366 | struct arphdr *ah; |
366 | struct eco_arp *ecah; | | 367 | struct eco_arp *ecah; |
367 | struct mbuf *m1; | | 368 | struct mbuf *m1; |
| | | 369 | void *tha; |
368 | #endif | | 370 | #endif |
369 | | | 371 | |
370 | #ifdef PFIL_HOOKS | | 372 | #ifdef PFIL_HOOKS |
371 | if (pfil_run_hooks(&ifp->if_pfil, &m, ifp, PFIL_IN) != 0) | | 373 | if (pfil_run_hooks(&ifp->if_pfil, &m, ifp, PFIL_IN) != 0) |
372 | return; | | 374 | return; |
373 | if (m == NULL) | | 375 | if (m == NULL) |
374 | return; | | 376 | return; |
375 | #endif | | 377 | #endif |
376 | | | 378 | |
377 | /* Copy the mbuf header and trim it off. */ | | 379 | /* Copy the mbuf header and trim it off. */ |
378 | /* XXX use m_split? */ | | 380 | /* XXX use m_split? */ |
379 | eh = &ehdr; | | 381 | eh = &ehdr; |
380 | m_copydata(m, 0, ECO_HDR_LEN, (void *)eh); | | 382 | m_copydata(m, 0, ECO_HDR_LEN, (void *)eh); |
| @@ -413,28 +415,30 @@ eco_input(struct ifnet *ifp, struct mbuf | | | @@ -413,28 +415,30 @@ eco_input(struct ifnet *ifp, struct mbuf |
413 | m1->m_len = sizeof(*ah) + 2*sizeof(struct in_addr) + | | 415 | m1->m_len = sizeof(*ah) + 2*sizeof(struct in_addr) + |
414 | 2*ifp->if_data.ifi_addrlen; | | 416 | 2*ifp->if_data.ifi_addrlen; |
415 | m1->m_pkthdr.len = m1->m_len; | | 417 | m1->m_pkthdr.len = m1->m_len; |
416 | MH_ALIGN(m1, m1->m_len); | | 418 | MH_ALIGN(m1, m1->m_len); |
417 | ah = mtod(m1, struct arphdr *); | | 419 | ah = mtod(m1, struct arphdr *); |
418 | bzero((void *)ah, m1->m_len); | | 420 | bzero((void *)ah, m1->m_len); |
419 | ah->ar_pro = htons(ETHERTYPE_IP); | | 421 | ah->ar_pro = htons(ETHERTYPE_IP); |
420 | ah->ar_hln = ifp->if_data.ifi_addrlen; | | 422 | ah->ar_hln = ifp->if_data.ifi_addrlen; |
421 | ah->ar_pln = sizeof(struct in_addr); | | 423 | ah->ar_pln = sizeof(struct in_addr); |
422 | if (eh->eco_control == ECO_CTL_ARP_REQUEST) | | 424 | if (eh->eco_control == ECO_CTL_ARP_REQUEST) |
423 | ah->ar_op = htons(ARPOP_REQUEST); | | 425 | ah->ar_op = htons(ARPOP_REQUEST); |
424 | else | | 426 | else |
425 | ah->ar_op = htons(ARPOP_REPLY); | | 427 | ah->ar_op = htons(ARPOP_REPLY); |
| | | 428 | tha = ar_tha(ah); |
| | | 429 | KASSERT(tha != NULL); |
426 | memcpy(ar_sha(ah), eh->eco_shost, ah->ar_hln); | | 430 | memcpy(ar_sha(ah), eh->eco_shost, ah->ar_hln); |
427 | memcpy(ar_tha(ah), eh->eco_dhost, ah->ar_hln); | | 431 | memcpy(tha, eh->eco_dhost, ah->ar_hln); |
428 | memcpy(ar_spa(ah), ecah->ecar_spa, ah->ar_pln); | | 432 | memcpy(ar_spa(ah), ecah->ecar_spa, ah->ar_pln); |
429 | memcpy(ar_tpa(ah), ecah->ecar_tpa, ah->ar_pln); | | 433 | memcpy(ar_tpa(ah), ecah->ecar_tpa, ah->ar_pln); |
430 | m_freem(m); | | 434 | m_freem(m); |
431 | m = m1; | | 435 | m = m1; |
432 | schednetisr(NETISR_ARP); | | 436 | schednetisr(NETISR_ARP); |
433 | inq = &arpintrq; | | 437 | inq = &arpintrq; |
434 | break; | | 438 | break; |
435 | case ECO_CTL_IPBCAST_REQUEST: | | 439 | case ECO_CTL_IPBCAST_REQUEST: |
436 | { | | 440 | { |
437 | struct sockaddr_storage dst_store; | | 441 | struct sockaddr_storage dst_store; |
438 | struct sockaddr *dst = (struct sockaddr *)&dst_store; | | 442 | struct sockaddr *dst = (struct sockaddr *)&dst_store; |
439 | | | 443 | |
440 | /* Queue? */ | | 444 | /* Queue? */ |
| @@ -511,48 +515,47 @@ eco_start(struct ifnet *ifp) | | | @@ -511,48 +515,47 @@ eco_start(struct ifnet *ifp) |
511 | ec->ec_txframe(ifp, m); | | 515 | ec->ec_txframe(ifp, m); |
512 | ec->ec_state = ECO_SCOUT_SENT; | | 516 | ec->ec_state = ECO_SCOUT_SENT; |
513 | } | | 517 | } |
514 | ifp->if_flags |= IFF_OACTIVE; | | 518 | ifp->if_flags |= IFF_OACTIVE; |
515 | } else { | | 519 | } else { |
516 | log(LOG_ERR, "%s: line jammed\n", ifp->if_xname); | | 520 | log(LOG_ERR, "%s: line jammed\n", ifp->if_xname); |
517 | m_freem(m); | | 521 | m_freem(m); |
518 | } | | 522 | } |
519 | } | | 523 | } |
520 | | | 524 | |
521 | static int | | 525 | static int |
522 | eco_ioctl(struct ifnet *ifp, u_long cmd, void *data) | | 526 | eco_ioctl(struct ifnet *ifp, u_long cmd, void *data) |
523 | { | | 527 | { |
524 | struct ifreq *ifr = (struct ifreq *)data; | | | |
525 | struct ifaddr *ifa = (struct ifaddr *)data; | | 528 | struct ifaddr *ifa = (struct ifaddr *)data; |
526 | int error; | | 529 | int error; |
527 | | | 530 | |
528 | switch (cmd) { | | 531 | switch (cmd) { |
529 | case SIOCINITIFADDR: | | 532 | case SIOCINITIFADDR: |
530 | ifp->if_flags |= IFF_UP; | | 533 | ifp->if_flags |= IFF_UP; |
531 | if ((ifp->if_flags & IFF_RUNNING) == 0 && | | 534 | if ((ifp->if_flags & IFF_RUNNING) == 0 && |
532 | (error = (*ifp->if_init)(ifp)) != 0) | | 535 | (error = (*ifp->if_init)(ifp)) != 0) |
533 | return error; | | 536 | return error; |
534 | switch (ifa->ifa_addr->sa_family) { | | 537 | switch (ifa->ifa_addr->sa_family) { |
535 | #ifdef INET | | 538 | #ifdef INET |
536 | case AF_INET: | | 539 | case AF_INET: |
537 | arp_ifinit(ifp, ifa); | | 540 | arp_ifinit(ifp, ifa); |
538 | break; | | 541 | break; |
539 | #endif | | 542 | #endif |
540 | default: | | 543 | default: |
541 | break; | | 544 | break; |
542 | } | | 545 | } |
543 | return 0; | | 546 | return 0; |
544 | case SIOCSIFMTU: | | 547 | case SIOCSIFMTU: |
545 | if ((error = ifioctl_common(ifp, command, data)) != ENETRESET) | | 548 | if ((error = ifioctl_common(ifp, cmd, data)) != ENETRESET) |
546 | return error; | | 549 | return error; |
547 | else if (ifp->if_flags & IFF_UP) | | 550 | else if (ifp->if_flags & IFF_UP) |
548 | return (*ifp->if_init)(ifp); | | 551 | return (*ifp->if_init)(ifp); |
549 | else | | 552 | else |
550 | return 0; | | 553 | return 0; |
551 | break; | | 554 | break; |
552 | case SIOCSIFFLAGS: | | 555 | case SIOCSIFFLAGS: |
553 | if ((error = ifioctl_common(ifp, cmd, data)) != 0) | | 556 | if ((error = ifioctl_common(ifp, cmd, data)) != 0) |
554 | return error; | | 557 | return error; |
555 | switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { | | 558 | switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { |
556 | case IFF_RUNNING: | | 559 | case IFF_RUNNING: |
557 | /* | | 560 | /* |
558 | * If interface is marked down and it is running, | | 561 | * If interface is marked down and it is running, |
| @@ -729,27 +732,27 @@ eco_immediate(struct ifnet *ifp, struct | | | @@ -729,27 +732,27 @@ eco_immediate(struct ifnet *ifp, struct |
729 | | | 732 | |
730 | eh = mtod(m, struct eco_header *); | | 733 | eh = mtod(m, struct eco_header *); |
731 | switch (eh->eco_control) { | | 734 | switch (eh->eco_control) { |
732 | case ECO_CTL_MACHINEPEEK: | | 735 | case ECO_CTL_MACHINEPEEK: |
733 | MGETHDR(n, M_DONTWAIT, MT_DATA); | | 736 | MGETHDR(n, M_DONTWAIT, MT_DATA); |
734 | if (n == NULL) | | 737 | if (n == NULL) |
735 | goto bad; | | 738 | goto bad; |
736 | n->m_len = n->m_pkthdr.len = ECO_SHDR_LEN + 4; | | 739 | n->m_len = n->m_pkthdr.len = ECO_SHDR_LEN + 4; |
737 | reh = mtod(n, struct eco_header *); | | 740 | reh = mtod(n, struct eco_header *); |
738 | memcpy(reh->eco_dhost, eh->eco_shost, | | 741 | memcpy(reh->eco_dhost, eh->eco_shost, |
739 | ECO_ADDR_LEN); | | 742 | ECO_ADDR_LEN); |
740 | memcpy(reh->eco_shost, CLLADDR(ifp->if_sadl), | | 743 | memcpy(reh->eco_shost, CLLADDR(ifp->if_sadl), |
741 | ECO_ADDR_LEN); | | 744 | ECO_ADDR_LEN); |
742 | memcpy(mtod(n, void *) + ECO_SHDR_LEN, machinepeek_data, | | 745 | memcpy(mtod(n, char *) + ECO_SHDR_LEN, machinepeek_data, |
743 | sizeof(machinepeek_data)); | | 746 | sizeof(machinepeek_data)); |
744 | m_freem(m); | | 747 | m_freem(m); |
745 | return n; | | 748 | return n; |
746 | default: | | 749 | default: |
747 | bad: | | 750 | bad: |
748 | m_freem(m); | | 751 | m_freem(m); |
749 | return NULL; | | 752 | return NULL; |
750 | } | | 753 | } |
751 | } | | 754 | } |
752 | | | 755 | |
753 | /* | | 756 | /* |
754 | * Generate (and return) an acknowledgement for a frame. Doesn't free the | | 757 | * Generate (and return) an acknowledgement for a frame. Doesn't free the |
755 | * original frame, since it's probably needed elsewhere. | | 758 | * original frame, since it's probably needed elsewhere. |