diff options
| author | kiyohara <kiyohara@NetBSD.org> | 2007-10-14 18:13:49 +0000 |
|---|---|---|
| committer | kiyohara <kiyohara@NetBSD.org> | 2007-10-14 18:13:49 +0000 |
| commit | eb89d5dad9883ab15fe2dc043748cfdc047ad4e1 (patch) | |
| tree | 8517269f536116376efd3cc7a9c5a42830534dc0 /sys/dev/bluetooth | |
| parent | 2d2dc93ca416d57c152330e0d9c4fbd7e8d84bcd (diff) | |
+ Add #ifdef DPRINTF{,N} before #undef.
+ Initialize m_pkthdr.len, and increment if not escape charactor.
+ Call bcsp_start() if there is no transmitted packet.
+ Call m_adj() after debug print.
+ Reset the values of the Sequencing layer if link reset it.
Diffstat (limited to 'sys/dev/bluetooth')
| -rw-r--r-- | sys/dev/bluetooth/bcsp.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/sys/dev/bluetooth/bcsp.c b/sys/dev/bluetooth/bcsp.c index f864681cdbf..261508a8062 100644 --- a/sys/dev/bluetooth/bcsp.c +++ b/sys/dev/bluetooth/bcsp.c @@ -1,4 +1,4 @@ -/* $NetBSD: bcsp.c,v 1.2 2007/10/04 14:43:06 kiyohara Exp $ */ +/* $NetBSD: bcsp.c,v 1.3 2007/10/14 18:13:49 kiyohara Exp $ */ /* * Copyright (c) 2007 KIYOHARA Takashi * All rights reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.2 2007/10/04 14:43:06 kiyohara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.3 2007/10/14 18:13:49 kiyohara Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -54,8 +54,12 @@ __KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.2 2007/10/04 14:43:06 kiyohara Exp $"); #include "ioconf.h" #ifdef BCSP_DEBUG +#ifdef DPRINTF #undef DPRINTF +#endif +#ifdef DPRINTFN #undef DPRINTFN +#endif #define DPRINTF(x) printf x #define DPRINTFN(n, x) do { if (bcsp_debug > (n)) printf x; } while (0) @@ -588,7 +592,7 @@ bcsp_slip_receive(int c, struct tty *tp) } m = m->m_next; - m->m_len = 0; + m->m_pkthdr.len = m->m_len = 0; } } else if (c != BCSP_SLIP_PKTSTART) { @@ -677,13 +681,13 @@ bcsp_slip_receive(int c, struct tty *tp) default: mtod(m, uint8_t *)[m->m_len++] = c; } + sc->sc_rxp->m_pkthdr.len++; } if (discard) { discarded: DPRINTFN(4, ("%s: receives unexpected byte 0x%02x: %s\n", sc->sc_dev.dv_xname, c, errstr)); - } else - sc->sc_rxp->m_pkthdr.len++; + } sc->sc_unit.hci_stats.byte_rx++; return 0; @@ -890,6 +894,7 @@ bcsp_mux_transmit(struct bcsp_softc *sc) hdrp->flags |= BCSP_FLAGS_PROTOCOL_REL; /* Reliable */ goto transmit; } + bcsp_start(unit); if (sc->sc_mux_send_ack == true) { m = bcsp_create_ackpkt(); if (m != NULL) @@ -1005,11 +1010,6 @@ bcsp_sequencing_receive(struct bcsp_softc *sc, struct mbuf *m) m_copydata(m, 0, sizeof(bcsp_hdr_t), &hdr); rxseq = BCSP_FLAGS_SEQ(hdr.flags); - /* - * We remove the header of BCSP and add the 'uint8_t type' of - * hci_*_hdr_t to the head. - */ - m_adj(m, sizeof(bcsp_hdr_t) - sizeof(uint8_t)); DPRINTFN(1, ("%s: seq receive: rxseq=%d, expected %d\n", sc->sc_dev.dv_xname, rxseq, sc->sc_seq_expected_rxseq)); @@ -1018,6 +1018,12 @@ bcsp_sequencing_receive(struct bcsp_softc *sc, struct mbuf *m) bcsp_packet_print(m); #endif + /* + * We remove the header of BCSP and add the 'uint8_t type' of + * hci_*_hdr_t to the head. + */ + m_adj(m, sizeof(bcsp_hdr_t) - sizeof(uint8_t)); + if (rxseq != sc->sc_seq_expected_rxseq) { m_freem(m); @@ -1228,6 +1234,7 @@ bcsp_timer_timeout(void *arg) printf("%s: reached the retry limit." " restart the link-establishment\n", sc->sc_dev.dv_xname); + bcsp_sequencing_reset(sc); bcsp_start_le(&sc->sc_unit); return; } @@ -1509,6 +1516,8 @@ bcsp_input_le(struct hci_unit *unit, struct mbuf *m) printf("%s: received sync!! peer to reset?\n", sc->sc_dev.dv_xname); + bcsp_sequencing_reset(sc); + rplypkt = sync; sc->sc_le_state = le_state_shy; } else printf("%s: received unknown packet at garrulous\n", |
