* net.c: Dump details for AF_BLUETOOTH sockets

Signed-off-by: Lubomir Rintel <[email protected]>
---
Hi,

this is essentially an updated resend of a patch that I've been using for years 
and apparently has been in review since 2011 [1] :)

[1] http://permalink.gmane.org/gmane.comp.sysutils.strace.devel/2367

Please have a look.

Thank you!
Lubo

 configure.ac         |  1 +
 net.c                | 43 +++++++++++++++++++++++++++++++++++++++++++
 xlat/bt_protocols.h  | 29 +++++++++++++++++++++++++++++
 xlat/bt_protocols.in |  8 ++++++++
 4 files changed, 81 insertions(+)
 create mode 100644 xlat/bt_protocols.h
 create mode 100644 xlat/bt_protocols.in

diff --git a/configure.ac b/configure.ac
index 9caa835..83f16c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -250,6 +250,7 @@ AC_CHECK_HEADERS(m4_normalize([
        sys/reg.h
        sys/uio.h
        sys/vfs.h
+       bluetooth/bluetooth.h
 ]))
 AC_CHECK_HEADERS([linux/icmp.h linux/in6.h linux/netlink.h linux/if_packet.h],
                  [], [], [#include <stddef.h>
diff --git a/net.c b/net.c
index 46c491f..96c5f73 100644
--- a/net.c
+++ b/net.c
@@ -90,6 +90,13 @@
 #if defined(HAVE_LINUX_ICMP_H)
 # include <linux/icmp.h>
 #endif
+#if defined(HAVE_BLUETOOTH_BLUETOOTH_H)
+# include <bluetooth/bluetooth.h>
+# include <bluetooth/rfcomm.h>
+# include <bluetooth/l2cap.h>
+# include <bluetooth/sco.h>
+# include <bluetooth/hci.h>
+#endif
 #ifndef PF_UNSPEC
 # define PF_UNSPEC AF_UNSPEC
 #endif
@@ -110,6 +117,8 @@
 #include "xlat/netlink_protocols.h"
 #endif
 
+#include "xlat/bt_protocols.h"
+
 #include "xlat/msg_flags.h"
 #include "xlat/sockoptions.h"
 
@@ -177,6 +186,12 @@ printsock(struct tcb *tcp, long addr, int addrlen)
 #ifdef AF_NETLINK
                struct sockaddr_nl nl;
 #endif
+#if defined(HAVE_BLUETOOTH_BLUETOOTH_H)
+               struct sockaddr_sco sco;
+               struct sockaddr_rc rc;
+               struct sockaddr_l2 l2;
+               struct sockaddr_hci hci;
+#endif
        } addrbuf;
        char string_addr[100];
 
@@ -291,6 +306,31 @@ printsock(struct tcb *tcp, long addr, int addrlen)
        /* AF_AX25 AF_APPLETALK AF_NETROM AF_BRIDGE AF_AAL5
        AF_X25 AF_ROSE etc. still need to be done */
 
+#if defined(HAVE_BLUETOOTH_BLUETOOTH_H)
+       case AF_BLUETOOTH:
+
+               tprintf("{sco_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X} or ",
+                       addrbuf.sco.sco_bdaddr.b[0], 
addrbuf.sco.sco_bdaddr.b[1],
+                       addrbuf.sco.sco_bdaddr.b[2], 
addrbuf.sco.sco_bdaddr.b[3],
+                       addrbuf.sco.sco_bdaddr.b[4], 
addrbuf.sco.sco_bdaddr.b[5]);
+
+               tprintf("{rc_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X, 
rc_channel=%d} or ",
+                       addrbuf.rc.rc_bdaddr.b[0], addrbuf.rc.rc_bdaddr.b[1],
+                       addrbuf.rc.rc_bdaddr.b[2], addrbuf.rc.rc_bdaddr.b[3],
+                       addrbuf.rc.rc_bdaddr.b[4], addrbuf.rc.rc_bdaddr.b[5],
+                       addrbuf.rc.rc_channel);
+
+               tprintf("{l2_psm=htobs(%d), 
l2_bdaddr=%02X:%02X:%02X:%02X:%02X:%02X, l2_cid=htobs(%d)} or ",
+                       btohs(addrbuf.l2.l2_psm), addrbuf.l2.l2_bdaddr.b[0],
+                       addrbuf.l2.l2_bdaddr.b[1], addrbuf.l2.l2_bdaddr.b[2],
+                       addrbuf.l2.l2_bdaddr.b[3], addrbuf.l2.l2_bdaddr.b[4],
+                       addrbuf.l2.l2_bdaddr.b[5], btohs(addrbuf.l2.l2_cid));
+
+               tprintf("{hci_dev=%d}",  btohs(addrbuf.hci.hci_dev));
+
+               break;
+#endif
+
        default:
                tprints("sa_data=");
                printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
@@ -533,6 +573,9 @@ sys_socket(struct tcb *tcp)
                        printxval(netlink_protocols, tcp->u_arg[2], 
"NETLINK_???");
                        break;
 #endif
+               case PF_BLUETOOTH:
+                       printxval(bt_protocols, tcp->u_arg[2], "IPPROTO_???");
+                       break;
                default:
                        tprintf("%lu", tcp->u_arg[2]);
                        break;
diff --git a/xlat/bt_protocols.h b/xlat/bt_protocols.h
new file mode 100644
index 0000000..0ad983d
--- /dev/null
+++ b/xlat/bt_protocols.h
@@ -0,0 +1,29 @@
+/* Generated by ./xlat/gen.sh from ./xlat/bt_protocols.in; do not edit. */
+
+static const struct xlat bt_protocols[] = {
+#if defined(BTPROTO_L2CAP) || (defined(HAVE_DECL_BTPROTO_L2CAP) && 
HAVE_DECL_BTPROTO_L2CAP)
+       XLAT(BTPROTO_L2CAP),
+#endif
+#if defined(BTPROTO_HCI) || (defined(HAVE_DECL_BTPROTO_HCI) && 
HAVE_DECL_BTPROTO_HCI)
+       XLAT(BTPROTO_HCI),
+#endif
+#if defined(BTPROTO_SCO) || (defined(HAVE_DECL_BTPROTO_SCO) && 
HAVE_DECL_BTPROTO_SCO)
+       XLAT(BTPROTO_SCO),
+#endif
+#if defined(BTPROTO_RFCOMM) || (defined(HAVE_DECL_BTPROTO_RFCOMM) && 
HAVE_DECL_BTPROTO_RFCOMM)
+       XLAT(BTPROTO_RFCOMM),
+#endif
+#if defined(BTPROTO_BNEP) || (defined(HAVE_DECL_BTPROTO_BNEP) && 
HAVE_DECL_BTPROTO_BNEP)
+       XLAT(BTPROTO_BNEP),
+#endif
+#if defined(BTPROTO_CMTP) || (defined(HAVE_DECL_BTPROTO_CMTP) && 
HAVE_DECL_BTPROTO_CMTP)
+       XLAT(BTPROTO_CMTP),
+#endif
+#if defined(BTPROTO_HIDP) || (defined(HAVE_DECL_BTPROTO_HIDP) && 
HAVE_DECL_BTPROTO_HIDP)
+       XLAT(BTPROTO_HIDP),
+#endif
+#if defined(BTPROTO_AVDTP) || (defined(HAVE_DECL_BTPROTO_AVDTP) && 
HAVE_DECL_BTPROTO_AVDTP)
+       XLAT(BTPROTO_AVDTP),
+#endif
+       XLAT_END
+};
diff --git a/xlat/bt_protocols.in b/xlat/bt_protocols.in
new file mode 100644
index 0000000..1f7f348
--- /dev/null
+++ b/xlat/bt_protocols.in
@@ -0,0 +1,8 @@
+BTPROTO_L2CAP
+BTPROTO_HCI
+BTPROTO_SCO
+BTPROTO_RFCOMM
+BTPROTO_BNEP
+BTPROTO_CMTP
+BTPROTO_HIDP
+BTPROTO_AVDTP
-- 
1.9.3


------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Strace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to