Hi, On Fri, Oct 03, 2014 at 11:40:28AM +0200, Lubomir Rintel wrote: > * 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 > ]))
We keep this list of headers sorted.
> 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"
All constants referenced by this new file are defined in
bluetooth/bluetooth.h, so a check for HAVE_BLUETOOTH_BLUETOOTH_H
is needed here and ...
> @@ -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;
... here. To be on the safe side, I'd also add a check for PF_BLUETOOTH.
Finally, "IPPROTO_???" is not quite appropriate here,
lets replace it with "BTPROTO_???".
> +
> #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:
I'd also add a check for AF_BLUETOOTH here.
> +
> + 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));
I'd probably merged these tprintf calls into a single call,
but it's a matter of taste.
> +
> + break;
> +#endif
> +
> default:
> tprints("sa_data=");
> printstr(tcp, (long) &((struct sockaddr *) addr)->sa_data,
> 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. */
All xlat/*.h files are generated, we do not add them to the repository.
> 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
--
ldv
pgp393svOMH5m.pgp
Description: PGP signature
------------------------------------------------------------------------------
_______________________________________________ Strace-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/strace-devel
