hello,

The attached patch is my first attempt to add support to tcpdump for a
'new' DLT (exists in libpcap head, but is currently unknown to
tcpdump). 
It print some basic information (hci frame direction) regarding
bluetooth capture. 
Any comments are very welcome!

cheers,

Paolo
--------------------------------------------------------------------

CONFIDENTIALITY NOTICE

This message and its attachments are addressed solely to the persons above and 
may contain confidential information. If you have received the message in 
error, be informed that any use of the content hereof is prohibited. Please 
return it immediately to the sender and delete the message. Should you have any 
questions, please contact us by replying to [EMAIL PROTECTED]

        Thank you

                                        www.telecomitalia.it

--------------------------------------------------------------------
                        
diff -Nrubw --exclude='CVS*' --exclude='.#*' tcpdump-vanilla/interface.h tcpdump/interface.h
--- tcpdump-vanilla/interface.h	2007-08-29 14:31:00.000000000 +0200
+++ tcpdump/interface.h	2007-09-11 10:12:34.000000000 +0200
@@ -328,6 +328,7 @@
 extern void bfd_print(const u_char *, u_int, u_int);
 extern void sip_print(const u_char *, u_int);
 extern void syslog_print(const u_char *, u_int);
+extern u_int bt_if_print(const struct pcap_pkthdr *, const u_char *);
 
 #ifdef INET6
 extern void ip6_print(const u_char *, u_int);
diff -Nrubw --exclude='CVS*' --exclude='.#*' tcpdump-vanilla/Makefile.in tcpdump/Makefile.in
--- tcpdump-vanilla/Makefile.in	2007-09-12 21:36:18.000000000 +0200
+++ tcpdump/Makefile.in	2007-09-13 09:17:39.000000000 +0200
@@ -88,7 +88,8 @@
 	print-symantec.c print-syslog.c print-tcp.c print-telnet.c print-tftp.c \
 	print-timed.c print-token.c print-udld.c print-udp.c \
 	print-vjc.c print-vqp.c print-vrrp.c print-vtp.c \
-	print-wb.c print-zephyr.c setsignal.c tcpdump.c util.c
+	print-wb.c print-zephyr.c setsignal.c tcpdump.c util.c \
+	print-bt.c
 
 LIBNETDISSECT_SRC=print-isakmp.c
 LIBNETDISSECT_OBJ=$(LIBNETDISSECT_SRC:.c=.o)
diff -Nrubw --exclude='CVS*' --exclude='.#*' tcpdump-vanilla/print-bt.c tcpdump/print-bt.c
--- tcpdump-vanilla/print-bt.c	1970-01-01 01:00:00.000000000 +0100
+++ tcpdump/print-bt.c	2007-09-19 08:52:57.000000000 +0200
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2007
+ *	[EMAIL PROTECTED]  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by Paolo Abeni.'' 
+ * The name of author may not be used to endorse or promote products derived 
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static const char rcsid[] _U_ =
+    "@(#) $Header: /tcpdump/master/tcpdump/print-bt.c $";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include <pcap.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+
+#ifdef DLT_BLUETOOTH_HCI_H4_WITH_PHDR
+#include <pcap/bluetooth.h>
+
+#define	BT_HDRLEN sizeof(pcap_bluetooth_h4_header)
+/*
+ * This is the top level routine of the printer.  'p' points
+ * to the bluetooth header of the packet, 'h->ts' is the timestamp,
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * is the number of bytes actually captured.
+ */
+u_int
+bt_if_print(const struct pcap_pkthdr *h, const u_char *p)
+{
+	u_int length = h->len;
+	u_int caplen = h->caplen;
+	const pcap_bluetooth_h4_header* hdr = (const pcap_bluetooth_h4_header*)p;
+
+	if (caplen < BT_HDRLEN) {
+		printf("[|bt]");
+		return (BT_HDRLEN);
+	}
+	caplen -= BT_HDRLEN;
+	length -= BT_HDRLEN;
+	p += BT_HDRLEN;
+	if (eflag)
+		(void)printf("hci length %d, direction %s, ", length, (ntohl(hdr->direction)&0x1)?"in":"out");
+
+	if (!suppress_default_print)
+		default_print(p, caplen);
+
+	return (BT_HDRLEN);
+}
+#endif
+
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
Binary files tcpdump-vanilla/print-isakmp.o and tcpdump/print-isakmp.o differ
diff -Nrubw --exclude='CVS*' --exclude='.#*' tcpdump-vanilla/tcpdump.c tcpdump/tcpdump.c
--- tcpdump-vanilla/tcpdump.c	2007-09-12 21:36:18.000000000 +0200
+++ tcpdump/tcpdump.c	2007-09-24 09:32:46.000000000 +0200
@@ -269,6 +269,9 @@
 #ifdef DLT_MFR
 	{ mfr_if_print, DLT_MFR },
 #endif
+#ifdef DLT_BLUETOOTH_HCI_H4_WITH_PHDR
+	{ bt_if_print, DLT_BLUETOOTH_HCI_H4_WITH_PHDR},
+#endif
 	{ NULL,			0 },
 };
 
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.

Reply via email to