From 264c79359eeedd8a67c38212e12f187303e5db04 Mon Sep 17 00:00:00 2001 From: plunky Date: Mon, 11 Sep 2006 22:12:39 +0000 Subject: [PATCH] Endian issues: hci_event.c: - Convert memo->response.clock_offset to host-endian. hci_ioctl.c: - printf format tweak (size_t) hci_link.c: - Convert memo->response.clock_offset from host-endian. - Tweak a DIAGNOSTIC message. l2cap_signal.c: - In l2cap_recv_config_req(), rp->scid is little-endian so make sure we convert from host-endian. from scw@ --- sys/netbt/hci_event.c | 7 +++++-- sys/netbt/hci_ioctl.c | 8 ++++---- sys/netbt/hci_link.c | 9 +++++---- sys/netbt/l2cap_signal.c | 6 +++--- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/sys/netbt/hci_event.c b/sys/netbt/hci_event.c index 4f2603fe1e58..c0e8a9c69302 100644 --- a/sys/netbt/hci_event.c +++ b/sys/netbt/hci_event.c @@ -1,4 +1,4 @@ -/* $NetBSD: hci_event.c,v 1.1 2006/06/19 15:44:45 gdamore Exp $ */ +/* $NetBSD: hci_event.c,v 1.2 2006/09/11 22:12:39 plunky Exp $ */ /*- * Copyright (c) 2005 Iain Hibbert. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hci_event.c,v 1.1 2006/06/19 15:44:45 gdamore Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hci_event.c,v 1.2 2006/09/11 22:12:39 plunky Exp $"); #include #include @@ -422,6 +422,9 @@ hci_event_inquiry_result(struct hci_unit *unit, struct mbuf *m) m_copydata(m, 0, sizeof(hci_inquiry_response), (caddr_t)&memo->response); m_adj(m, sizeof(hci_inquiry_response)); + + memo->response.clock_offset = + le16toh(memo->response.clock_offset); } } diff --git a/sys/netbt/hci_ioctl.c b/sys/netbt/hci_ioctl.c index 271d1447f1fd..2371f2bbe575 100644 --- a/sys/netbt/hci_ioctl.c +++ b/sys/netbt/hci_ioctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: hci_ioctl.c,v 1.3 2006/08/27 11:41:58 plunky Exp $ */ +/* $NetBSD: hci_ioctl.c,v 1.4 2006/09/11 22:12:39 plunky Exp $ */ /*- * Copyright (c) 2005 Iain Hibbert. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hci_ioctl.c,v 1.3 2006/08/27 11:41:58 plunky Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hci_ioctl.c,v 1.4 2006/09/11 22:12:39 plunky Exp $"); #include #include @@ -107,11 +107,11 @@ hci_dump(void) BDADDR(chan->lc_raddr.bt_bdaddr)); LIST_FOREACH(dlc, &rs->rs_dlcs, rd_next) { printf("+DLC channel=%d, dlci=%d, " - "state=%d, flags=0x%4.4x, rxcred=%d, rxsize=%d, " + "state=%d, flags=0x%4.4x, rxcred=%d, rxsize=%ld, " "txcred=%d, pending=%d, txqlen=%d\n", dlc->rd_raddr.bt_channel, dlc->rd_dlci, dlc->rd_state, dlc->rd_flags, - dlc->rd_rxcred, dlc->rd_rxsize, + dlc->rd_rxcred, (unsigned long)dlc->rd_rxsize, dlc->rd_txcred, dlc->rd_pending, (dlc->rd_txbuf ? dlc->rd_txbuf->m_pkthdr.len : 0)); } diff --git a/sys/netbt/hci_link.c b/sys/netbt/hci_link.c index 4012417a2dae..034554a43298 100644 --- a/sys/netbt/hci_link.c +++ b/sys/netbt/hci_link.c @@ -1,4 +1,4 @@ -/* $NetBSD: hci_link.c,v 1.4 2006/09/11 22:08:38 plunky Exp $ */ +/* $NetBSD: hci_link.c,v 1.5 2006/09/11 22:12:39 plunky Exp $ */ /*- * Copyright (c) 2005 Iain Hibbert. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hci_link.c,v 1.4 2006/09/11 22:08:38 plunky Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hci_link.c,v 1.5 2006/09/11 22:12:39 plunky Exp $"); #include #include @@ -98,7 +98,7 @@ hci_acl_open(struct hci_unit *unit, bdaddr_t *bdaddr) if (memo != NULL) { cp.page_scan_rep_mode = memo->response.page_scan_rep_mode; cp.page_scan_mode = memo->response.page_scan_mode; - cp.clock_offset = memo->response.clock_offset; + cp.clock_offset = htole16(memo->response.clock_offset); } if (unit->hci_link_policy & HCI_LINK_POLICY_ENABLE_ROLE_SWITCH) @@ -261,7 +261,8 @@ hci_acl_recv(struct mbuf *m, struct hci_unit *unit) } if (m->m_pkthdr.len != le16toh(hdr.length)) { - printf("%s: bad ACL packet length\n", unit->hci_devname); + printf("%s: bad ACL packet length (%d != %d)\n", + unit->hci_devname, m->m_pkthdr.len, le16toh(hdr.length)); goto bad; } #endif diff --git a/sys/netbt/l2cap_signal.c b/sys/netbt/l2cap_signal.c index 7804d1c18b3e..4ea3f2f7e503 100644 --- a/sys/netbt/l2cap_signal.c +++ b/sys/netbt/l2cap_signal.c @@ -1,4 +1,4 @@ -/* $NetBSD: l2cap_signal.c,v 1.1 2006/06/19 15:44:45 gdamore Exp $ */ +/* $NetBSD: l2cap_signal.c,v 1.2 2006/09/11 22:12:39 plunky Exp $ */ /*- * Copyright (c) 2005 Iain Hibbert. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: l2cap_signal.c,v 1.1 2006/06/19 15:44:45 gdamore Exp $"); +__KERNEL_RCSID(0, "$NetBSD: l2cap_signal.c,v 1.2 2006/09/11 22:12:39 plunky Exp $"); #include #include @@ -412,7 +412,7 @@ l2cap_recv_config_req(struct mbuf *m, struct hci_link *link) /* ready our response packet */ rp = (l2cap_cfg_rsp_cp *)buf; - rp->scid = chan->lc_rcid; + rp->scid = htole16(chan->lc_rcid); rp->flags = 0; /* "No Continuation" */ rp->result = L2CAP_SUCCESS; len = sizeof(*rp);