Wed Jan 7 20:56:40 2009 UTC ()
Make Econet code compile again.


(bjh21)
diff -r1.9 -r1.10 src/sys/arch/acorn26/ioc/if_eca.c
diff -r1.30 -r1.31 src/sys/net/if_ecosubr.c

cvs diff -r1.9 -r1.10 src/sys/arch/acorn26/ioc/Attic/if_eca.c (expand / switch to unified diff)

--- src/sys/arch/acorn26/ioc/Attic/if_eca.c 2008/12/16 22:35:21 1.9
+++ src/sys/arch/acorn26/ioc/Attic/if_eca.c 2009/01/07 20:56:40 1.10
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_eca.c,v 1.9 2008/12/16 22:35:21 christos Exp $ */ 1/* $NetBSD: if_eca.c,v 1.10 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.
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30#include <sys/param.h> 30#include <sys/param.h>
31 31
32__KERNEL_RCSID(0, "$NetBSD: if_eca.c,v 1.9 2008/12/16 22:35:21 christos Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: if_eca.c,v 1.10 2009/01/07 20:56:40 bjh21 Exp $");
33 33
34#include <sys/device.h> 34#include <sys/device.h>
35#include <sys/malloc.h> 35#include <sys/malloc.h>
36#include <sys/socket.h> 36#include <sys/socket.h>
37#include <sys/syslog.h> 37#include <sys/syslog.h>
38#include <sys/systm.h> 38#include <sys/systm.h>
39 39
40#include <net/if.h> 40#include <net/if.h>
41#include <net/if_dl.h> 41#include <net/if_dl.h>
42#include <net/if_eco.h> 42#include <net/if_eco.h>
43 43
44#include <machine/bus.h> 44#include <machine/bus.h>
45#include <machine/fiq.h> 45#include <machine/fiq.h>
@@ -110,28 +110,28 @@ eca_attach(struct device *parent, struct @@ -110,28 +110,28 @@ eca_attach(struct device *parent, struct
110 printf(", no clock"); 110 printf(", no clock");
111 111
112 /* Initialise ifnet structure. */ 112 /* Initialise ifnet structure. */
113 113
114 strcpy(ifp->if_xname, sc->sc_dev.dv_xname); 114 strcpy(ifp->if_xname, sc->sc_dev.dv_xname);
115 ifp->if_softc = sc; 115 ifp->if_softc = sc;
116 ifp->if_init = eca_init; 116 ifp->if_init = eca_init;
117 ifp->if_stop = eca_stop; 117 ifp->if_stop = eca_stop;
118 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS; 118 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS;
119 IFQ_SET_READY(&ifp->if_snd); 119 IFQ_SET_READY(&ifp->if_snd);
120 sc->sc_ec.ec_claimwire = eca_claimwire; 120 sc->sc_ec.ec_claimwire = eca_claimwire;
121 sc->sc_ec.ec_txframe = eca_txframe; 121 sc->sc_ec.ec_txframe = eca_txframe;
122 122
123 sc->sc_rx_soft = softintr_establish(IPL_SOFTNET, eca_gotframe, sc); 123 sc->sc_rx_soft = softint_establish(IPL_SOFTNET, eca_gotframe, sc);
124 sc->sc_tx_soft = softintr_establish(IPL_SOFTNET, eca_txdone, sc); 124 sc->sc_tx_soft = softint_establish(IPL_SOFTNET, eca_txdone, sc);
125 if (sc->sc_rx_soft == NULL || sc->sc_tx_soft == NULL) { 125 if (sc->sc_rx_soft == NULL || sc->sc_tx_soft == NULL) {
126 printf("\n%s: failed to establish software interrupt\n", 126 printf("\n%s: failed to establish software interrupt\n",
127 sc->sc_dev.dv_xname); 127 sc->sc_dev.dv_xname);
128 return; 128 return;
129 } 129 }
130 130
131 if_attach(ifp); 131 if_attach(ifp);
132 eco_ifattach(ifp, myaddr); 132 eco_ifattach(ifp, myaddr);
133 133
134 sc->sc_fiqhandler.fh_func = eca_fiqhandler; 134 sc->sc_fiqhandler.fh_func = eca_fiqhandler;
135 sc->sc_fiqhandler.fh_size = eca_efiqhandler - eca_fiqhandler; 135 sc->sc_fiqhandler.fh_size = eca_efiqhandler - eca_fiqhandler;
136 sc->sc_fiqhandler.fh_flags = 0; 136 sc->sc_fiqhandler.fh_flags = 0;
137 sc->sc_fiqhandler.fh_regs = &sc->sc_fiqstate.efs_rx_fiqregs; 137 sc->sc_fiqhandler.fh_regs = &sc->sc_fiqstate.efs_rx_fiqregs;
@@ -222,27 +222,27 @@ eca_txframe(struct ifnet *ifp, struct mb @@ -222,27 +222,27 @@ eca_txframe(struct ifnet *ifp, struct mb
222{ 222{
223 struct eca_softc *sc = ifp->if_softc; 223 struct eca_softc *sc = ifp->if_softc;
224 bus_space_tag_t iot = sc->sc_iot; 224 bus_space_tag_t iot = sc->sc_iot;
225 bus_space_handle_t ioh = sc->sc_ioh; 225 bus_space_handle_t ioh = sc->sc_ioh;
226 struct fiqregs fr; 226 struct fiqregs fr;
227 227
228 ioc_fiq_setmask(0); 228 ioc_fiq_setmask(0);
229 /* Start flag-filling while we work out what to do next. */ 229 /* Start flag-filling while we work out what to do next. */
230 sc->sc_cr2 |= MC6854_CR2_RTS | MC6854_CR2_F_M_IDLE; 230 sc->sc_cr2 |= MC6854_CR2_RTS | MC6854_CR2_F_M_IDLE;
231 bus_space_write_1(iot, ioh, MC6854_CR2, sc->sc_cr2); 231 bus_space_write_1(iot, ioh, MC6854_CR2, sc->sc_cr2);
232 sc->sc_fiqstate.efs_fiqhandler = eca_fiqhandler_tx; 232 sc->sc_fiqstate.efs_fiqhandler = eca_fiqhandler_tx;
233 sc->sc_transmitting = 1; 233 sc->sc_transmitting = 1;
234 sc->sc_txmbuf = m; 234 sc->sc_txmbuf = m;
235 fr.fr_r8 = (register_t)sc->sc_ioh.a1; 235 fr.fr_r8 = (register_t)sc->sc_ioh;
236 fr.fr_r9 = (register_t)sc->sc_txmbuf->m_data; 236 fr.fr_r9 = (register_t)sc->sc_txmbuf->m_data;
237 fr.fr_r10 = (register_t)sc->sc_txmbuf->m_len; 237 fr.fr_r10 = (register_t)sc->sc_txmbuf->m_len;
238 fr.fr_r11 = (register_t)&sc->sc_fiqstate; 238 fr.fr_r11 = (register_t)&sc->sc_fiqstate;
239 fiq_setregs(&fr); 239 fiq_setregs(&fr);
240 sc->sc_fiqstate.efs_tx_curmbuf = sc->sc_txmbuf; 240 sc->sc_fiqstate.efs_tx_curmbuf = sc->sc_txmbuf;
241 fiq_downgrade_handler = eca_tx_downgrade; 241 fiq_downgrade_handler = eca_tx_downgrade;
242 /* Read and clear Tx status. */ 242 /* Read and clear Tx status. */
243 bus_space_read_1(iot, ioh, MC6854_SR1); 243 bus_space_read_1(iot, ioh, MC6854_SR1);
244 bus_space_write_1(iot, ioh, MC6854_CR2, 244 bus_space_write_1(iot, ioh, MC6854_CR2,
245 sc->sc_cr2 | MC6854_CR2_CLR_TX_ST); 245 sc->sc_cr2 | MC6854_CR2_CLR_TX_ST);
246 sc->sc_cr1 = MC6854_CR1_TIE; 246 sc->sc_cr1 = MC6854_CR1_TIE;
247 bus_space_write_1(iot, ioh, MC6854_CR1, sc->sc_cr1 | 247 bus_space_write_1(iot, ioh, MC6854_CR1, sc->sc_cr1 |
248 MC6854_CR1_DISCONTINUE); 248 MC6854_CR1_DISCONTINUE);
@@ -279,27 +279,27 @@ eca_tx_downgrade(void) @@ -279,27 +279,27 @@ eca_tx_downgrade(void)
279 bus_space_write_1(iot, ioh, MC6854_CR2, 279 bus_space_write_1(iot, ioh, MC6854_CR2,
280 sc->sc_cr2 | MC6854_CR2_CLR_TX_ST); 280 sc->sc_cr2 | MC6854_CR2_CLR_TX_ST);
281 } 281 }
282 sc->sc_txmbuf = NULL; 282 sc->sc_txmbuf = NULL;
283  283
284 /* Code from eca_init_rx_hard(). */ 284 /* Code from eca_init_rx_hard(). */
285 sc->sc_cr1 = MC6854_CR1_RIE; 285 sc->sc_cr1 = MC6854_CR1_RIE;
286 fiq_downgrade_handler = eca_rx_downgrade; 286 fiq_downgrade_handler = eca_rx_downgrade;
287 sc->sc_transmitting = 0; 287 sc->sc_transmitting = 0;
288 eca_fiqowner = sc; 288 eca_fiqowner = sc;
289 ioc_fiq_setmask(IOC_FIQ_BIT(FIQ_EFIQ)); 289 ioc_fiq_setmask(IOC_FIQ_BIT(FIQ_EFIQ));
290 /* End code from eca_init_rx_hard(). */ 290 /* End code from eca_init_rx_hard(). */
291 291
292 softintr_schedule(sc->sc_tx_soft); 292 softint_schedule(sc->sc_tx_soft);
293} 293}
294 294
295/* 295/*
296 * Low-priority soft interrupt taken after a frame's been transmitted. 296 * Low-priority soft interrupt taken after a frame's been transmitted.
297 */ 297 */
298static void 298static void
299eca_txdone(void *arg) 299eca_txdone(void *arg)
300{ 300{
301 struct eca_softc *sc = arg; 301 struct eca_softc *sc = arg;
302 struct ifnet *ifp = &sc->sc_ec.ec_if; 302 struct ifnet *ifp = &sc->sc_ec.ec_if;
303 303
304 m_freem(sc->sc_txmbuf); 304 m_freem(sc->sc_txmbuf);
305 sc->sc_txmbuf = NULL; 305 sc->sc_txmbuf = NULL;
@@ -348,27 +348,27 @@ eca_init_rxbuf(struct eca_softc *sc, int @@ -348,27 +348,27 @@ eca_init_rxbuf(struct eca_softc *sc, int
348 348
349/* 349/*
350 * Set up the software state necessary for reception, but don't 350 * Set up the software state necessary for reception, but don't
351 * actually start receoption. Pushing the state into the hardware is 351 * actually start receoption. Pushing the state into the hardware is
352 * left to eca_init_rx_hard() the Tx FIQ handler. 352 * left to eca_init_rx_hard() the Tx FIQ handler.
353 */ 353 */
354void 354void
355eca_init_rx_soft(struct eca_softc *sc) 355eca_init_rx_soft(struct eca_softc *sc)
356{ 356{
357 struct ifnet *ifp = &sc->sc_ec.ec_if; 357 struct ifnet *ifp = &sc->sc_ec.ec_if;
358 struct fiqregs *fr = &sc->sc_fiqstate.efs_rx_fiqregs; 358 struct fiqregs *fr = &sc->sc_fiqstate.efs_rx_fiqregs;
359 359
360 memset(fr, 0, sizeof(*fr)); 360 memset(fr, 0, sizeof(*fr));
361 fr->fr_r8 = (register_t)sc->sc_ioh.a1; 361 fr->fr_r8 = (register_t)sc->sc_ioh;
362 fr->fr_r9 = (register_t)sc->sc_rcvmbuf->m_data; 362 fr->fr_r9 = (register_t)sc->sc_rcvmbuf->m_data;
363 fr->fr_r10 = (register_t)ECO_ADDR_LEN; 363 fr->fr_r10 = (register_t)ECO_ADDR_LEN;
364 fr->fr_r11 = (register_t)&sc->sc_fiqstate; 364 fr->fr_r11 = (register_t)&sc->sc_fiqstate;
365 sc->sc_fiqstate.efs_rx_curmbuf = sc->sc_rcvmbuf; 365 sc->sc_fiqstate.efs_rx_curmbuf = sc->sc_rcvmbuf;
366 sc->sc_fiqstate.efs_rx_flags = 0; 366 sc->sc_fiqstate.efs_rx_flags = 0;
367 sc->sc_fiqstate.efs_rx_myaddr = CLLADDR(ifp->if_sadl)[0]; 367 sc->sc_fiqstate.efs_rx_myaddr = CLLADDR(ifp->if_sadl)[0];
368} 368}
369 369
370/* 370/*
371 * Copy state set up by eca_init_rx_soft into the hardware, and reset 371 * Copy state set up by eca_init_rx_soft into the hardware, and reset
372 * the FIQ handler as appropriate. 372 * the FIQ handler as appropriate.
373 * 373 *
374 * This code is functionally duplicated across the Tx FIQ handler and 374 * This code is functionally duplicated across the Tx FIQ handler and
@@ -428,27 +428,27 @@ eca_stop(struct ifnet *ifp, int disable) @@ -428,27 +428,27 @@ eca_stop(struct ifnet *ifp, int disable)
428 } 428 }
429} 429}
430 430
431/* 431/*
432 * This is a FIQ downgrade handler, and as such is entered at IPL_HIGH with 432 * This is a FIQ downgrade handler, and as such is entered at IPL_HIGH with
433 * FIQs disabled (but still owned by us). 433 * FIQs disabled (but still owned by us).
434 */ 434 */
435static void 435static void
436eca_rx_downgrade(void) 436eca_rx_downgrade(void)
437{ 437{
438 struct eca_softc *sc = eca_fiqowner; 438 struct eca_softc *sc = eca_fiqowner;
439 439
440 sc->sc_sr2 = bus_space_read_1(sc->sc_iot, sc->sc_ioh, MC6854_SR2); 440 sc->sc_sr2 = bus_space_read_1(sc->sc_iot, sc->sc_ioh, MC6854_SR2);
441 softintr_schedule(sc->sc_rx_soft); 441 softint_schedule(sc->sc_rx_soft);
442} 442}
443 443
444/* 444/*
445 * eca_gotframe() is called if there's something interesting on 445 * eca_gotframe() is called if there's something interesting on
446 * reception. The receiver is turned off now -- it's up to us to 446 * reception. The receiver is turned off now -- it's up to us to
447 * start it again. 447 * start it again.
448 */ 448 */
449static void 449static void
450eca_gotframe(void *arg) 450eca_gotframe(void *arg)
451{ 451{
452 struct eca_softc *sc = arg; 452 struct eca_softc *sc = arg;
453 struct ifnet *ifp = &sc->sc_ec.ec_if; 453 struct ifnet *ifp = &sc->sc_ec.ec_if;
454 bus_space_tag_t iot = sc->sc_iot; 454 bus_space_tag_t iot = sc->sc_iot;
@@ -463,46 +463,47 @@ eca_gotframe(void *arg) @@ -463,46 +463,47 @@ eca_gotframe(void *arg)
463 /* 1: Is there a valid frame waiting? */ 463 /* 1: Is there a valid frame waiting? */
464 if ((sr2 & MC6854_SR2_FV) && !(sr2 & MC6854_SR2_OVRN) && 464 if ((sr2 & MC6854_SR2_FV) && !(sr2 & MC6854_SR2_OVRN) &&
465 sc->sc_fiqstate.efs_rx_curmbuf != NULL) { 465 sc->sc_fiqstate.efs_rx_curmbuf != NULL) {
466 fiq_getregs(&fr); 466 fiq_getregs(&fr);
467 m = sc->sc_rcvmbuf; 467 m = sc->sc_rcvmbuf;
468 mtail = sc->sc_fiqstate.efs_rx_curmbuf; 468 mtail = sc->sc_fiqstate.efs_rx_curmbuf;
469 /* 469 /*
470 * Before we process this buffer, make sure we can get 470 * Before we process this buffer, make sure we can get
471 * a new one. 471 * a new one.
472 */ 472 */
473 if (eca_init_rxbuf(sc, M_DONTWAIT) == 0) { 473 if (eca_init_rxbuf(sc, M_DONTWAIT) == 0) {
474 ifp->if_ipackets++; /* XXX packet vs frame? */ 474 ifp->if_ipackets++; /* XXX packet vs frame? */
475 /* Trim the tail of the mbuf chain. */ 475 /* Trim the tail of the mbuf chain. */
476 mtail->m_len = (void *)(fr.fr_r9) - mtail->m_data; 476 mtail->m_len =
 477 (char *)(fr.fr_r9) - mtod(mtail, char *);
477 m_freem(mtail->m_next); 478 m_freem(mtail->m_next);
478 mtail->m_next = NULL; 479 mtail->m_next = NULL;
479 /* Set up the header of the chain. */ 480 /* Set up the header of the chain. */
480 m->m_pkthdr.rcvif = ifp; 481 m->m_pkthdr.rcvif = ifp;
481 m->m_pkthdr.len = 0; 482 m->m_pkthdr.len = 0;
482 for (n = m; n != NULL; n = n->m_next) 483 for (n = m; n != NULL; n = n->m_next)
483 m->m_pkthdr.len += n->m_len; 484 m->m_pkthdr.len += n->m_len;
484 reply = eco_inputframe(ifp, m); 485 reply = eco_inputframe(ifp, m);
485 } else 486 } else
486 ifp->if_iqdrops++; 487 ifp->if_iqdrops++;
487 } 488 }
488 489
489 /* 2: Are there any errors waiting? */ 490 /* 2: Are there any errors waiting? */
490 if (sr2 & MC6854_SR2_OVRN) { 491 if (sr2 & MC6854_SR2_OVRN) {
491 fiq_getregs(&fr); 492 fiq_getregs(&fr);
492 mtail = sc->sc_fiqstate.efs_rx_curmbuf; 493 mtail = sc->sc_fiqstate.efs_rx_curmbuf;
493 log(LOG_ERR, "%s: Rx overrun (state = %d, len = %ld)\n", 494 log(LOG_ERR, "%s: Rx overrun (state = %d, len = %ld)\n",
494 sc->sc_dev.dv_xname, sc->sc_ec.ec_state, 495 sc->sc_dev.dv_xname, sc->sc_ec.ec_state,
495 (void *)(fr.fr_r9) - mtail->m_data); 496 (char *)(fr.fr_r9) - mtod(mtail, char *));
496 ifp->if_ierrors++; 497 ifp->if_ierrors++;
497 498
498 /* Discard the rest of the frame. */ 499 /* Discard the rest of the frame. */
499 if (!sc->sc_transmitting) 500 if (!sc->sc_transmitting)
500 bus_space_write_1(iot, ioh, MC6854_CR1, 501 bus_space_write_1(iot, ioh, MC6854_CR1,
501 sc->sc_cr1 | MC6854_CR1_DISCONTINUE); 502 sc->sc_cr1 | MC6854_CR1_DISCONTINUE);
502 } else if (sr2 & MC6854_SR2_RXABT) { 503 } else if (sr2 & MC6854_SR2_RXABT) {
503 log(LOG_NOTICE, "%s: Rx abort\n", sc->sc_dev.dv_xname); 504 log(LOG_NOTICE, "%s: Rx abort\n", sc->sc_dev.dv_xname);
504 ifp->if_ierrors++; 505 ifp->if_ierrors++;
505 } else if (sr2 & MC6854_SR2_ERR) { 506 } else if (sr2 & MC6854_SR2_ERR) {
506 log(LOG_NOTICE, "%s: CRC error\n", sc->sc_dev.dv_xname); 507 log(LOG_NOTICE, "%s: CRC error\n", sc->sc_dev.dv_xname);
507 ifp->if_ierrors++; 508 ifp->if_ierrors++;
508 } 509 }

cvs diff -r1.30 -r1.31 src/sys/net/Attic/if_ecosubr.c (expand / switch to unified diff)

--- src/sys/net/Attic/if_ecosubr.c 2008/12/17 20:51:36 1.30
+++ src/sys/net/Attic/if_ecosubr.c 2009/01/07 20:56:40 1.31
@@ -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
93struct eco_retryparms { 93struct 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 */
99static const uint8_t eco_broadcastaddr[] = { 0xff, 0xff }; 99static const uint8_t eco_broadcastaddr[] = { 0xff, 0xff };
100 100
101static int eco_output(struct ifnet *, struct mbuf *, struct sockaddr *, 101static int eco_output(struct ifnet *, struct mbuf *, const struct sockaddr *,
102 struct rtentry *); 102 struct rtentry *);
103static void eco_input(struct ifnet *, struct mbuf *); 103static void eco_input(struct ifnet *, struct mbuf *);
104static void eco_start(struct ifnet *); 104static void eco_start(struct ifnet *);
105static int eco_ioctl(struct ifnet *, u_long, void *); 105static int eco_ioctl(struct ifnet *, u_long, void *);
106 106
107static int eco_interestingp(struct ifnet *ifp, struct mbuf *m); 107static int eco_interestingp(struct ifnet *ifp, struct mbuf *m);
108static struct mbuf *eco_immediate(struct ifnet *ifp, struct mbuf *m); 108static struct mbuf *eco_immediate(struct ifnet *ifp, struct mbuf *m);
109static struct mbuf *eco_ack(struct ifnet *ifp, struct mbuf *m); 109static struct mbuf *eco_ack(struct ifnet *ifp, struct mbuf *m);
110 110
111static void eco_defer(struct ifnet *, struct mbuf *, int); 111static void eco_defer(struct ifnet *, struct mbuf *, int);
112static void eco_retry_free(struct eco_retry *er); 112static void eco_retry_free(struct eco_retry *er);
113static void eco_retry(void *); 113static 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
160void 158void
161eco_stop(struct ifnet *ifp, int disable) 159eco_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
169static int 167static int
170eco_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, 168eco_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
358static void 359static void
359eco_input(struct ifnet *ifp, struct mbuf *m) 360eco_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
521static int 525static int
522eco_ioctl(struct ifnet *ifp, u_long cmd, void *data) 526eco_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.