[PATCH] Dump details for Bluetooth socket operations
Lubomir Rintel
lkundrak at v3.sk
Sun Nov 20 18:18:51 UTC 2011
* net.c: Dump details for AF_BLUETOOTH sockets
Signed-off-by: Lubomir Rintel <lkundrak at v3.sk>
---
configure.ac | 1 +
net.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 76 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index 789a997..039e206 100644
--- a/configure.ac
+++ b/configure.ac
@@ -269,6 +269,7 @@ AC_CHECK_HEADERS([ \
linux/ptrace.h \
linux/utsname.h \
netinet/sctp.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 025ae9c..0a73473 100644
--- a/net.c
+++ b/net.c
@@ -101,6 +101,14 @@
#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
@@ -450,8 +458,8 @@ static const struct xlat socketlayers[] = {
/* The SOL_* array should remain not NULL-terminated. */
};
/*** WARNING: DANGER WILL ROBINSON: NOTE "socketlayers" array above
- falls into "protocols" array below!!!! This is intended!!! ***/
-static const struct xlat protocols[] = {
+ falls into "inet_protocols" array below!!!! This is intended!!! ***/
+static const struct xlat inet_protocols[] = {
{ IPPROTO_IP, "IPPROTO_IP" },
{ IPPROTO_ICMP, "IPPROTO_ICMP" },
{ IPPROTO_TCP, "IPPROTO_TCP" },
@@ -542,6 +550,33 @@ static const struct xlat protocols[] = {
#endif
{ 0, NULL },
};
+static const struct xlat bt_protocols[] = {
+#ifdef BTPROTO_L2CAP
+ { BTPROTO_L2CAP, "BTPROTO_L2CAP" },
+#endif
+#ifdef BTPROTO_HCI
+ { BTPROTO_HCI, "BTPROTO_HCI" },
+#endif
+#ifdef BTPROTO_SCO
+ { BTPROTO_SCO, "BTPROTO_SCO" },
+#endif
+#ifdef BTPROTO_RFCOMM
+ { BTPROTO_RFCOMM, "BTPROTO_RFCOMM" },
+#endif
+#ifdef BTPROTO_BNEP
+ { BTPROTO_BNEP, "BTPROTO_BNEP" },
+#endif
+#ifdef BTPROTO_CMTP
+ { BTPROTO_CMTP, "BTPROTO_CMTP" },
+#endif
+#ifdef BTPROTO_HIDP
+ { BTPROTO_HIDP, "BTPROTO_HIDP" },
+#endif
+#ifdef BTPROTO_AVDTP
+ { BTPROTO_AVDTP, "BTPROTO_AVDTP" },
+#endif
+ { 0, NULL },
+};
static const struct xlat msg_flags[] = {
{ MSG_OOB, "MSG_OOB" },
#ifdef MSG_DONTROUTE
@@ -1216,6 +1251,12 @@ printsock(struct tcb *tcp, long addr, int addrlen)
#ifdef AF_NETLINK
struct sockaddr_nl nl;
#endif
+#ifdef AF_BLUETOOTH
+ struct sockaddr_sco sco;
+ struct sockaddr_rc rc;
+ struct sockaddr_l2 l2;
+ struct sockaddr_hci hci;
+#endif
} addrbuf;
char string_addr[100];
@@ -1330,6 +1371,30 @@ 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 */
+#ifdef AF_BLUETOOTH
+ 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 /* AF_BLUETOOTH */
default:
tprints("sa_data=");
printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
@@ -1490,7 +1555,7 @@ sys_socket(struct tcb *tcp)
#ifdef PF_INET6
case PF_INET6:
#endif
- printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
+ printxval(inet_protocols, tcp->u_arg[2], "IPPROTO_???");
break;
#ifdef PF_IPX
case PF_IPX:
@@ -1500,6 +1565,9 @@ sys_socket(struct tcb *tcp)
tprints("]");
break;
#endif /* PF_IPX */
+ case PF_BLUETOOTH:
+ printxval(bt_protocols, tcp->u_arg[2], "IPPROTO_???");
+ break;
default:
tprintf("%lu", tcp->u_arg[2]);
break;
@@ -1867,7 +1935,7 @@ sys_socketpair(struct tcb *tcp)
tprints(", ");
switch (tcp->u_arg[0]) {
case PF_INET:
- printxval(protocols, tcp->u_arg[2], "IPPROTO_???");
+ printxval(inet_protocols, tcp->u_arg[2], "IPPROTO_???");
break;
#ifdef PF_IPX
case PF_IPX:
@@ -1877,6 +1945,9 @@ sys_socketpair(struct tcb *tcp)
tprints("]");
break;
#endif /* PF_IPX */
+ case PF_BLUETOOTH:
+ printxval(bt_protocols, tcp->u_arg[2], "IPPROTO_???");
+ break;
default:
tprintf("%lu", tcp->u_arg[2]);
break;
--
1.7.1
More information about the Strace-devel
mailing list