tcpdump mailing list archives
Re: new DLT request
From: Paolo Abeni <altoor () users sourceforge net>
Date: Thu, 20 Sep 2007 10:43:25 +0200
hello, on Thu 9/20/2007 12:18 AM Guy Harris wrote:
Could you re-attach that patch as text? It appears to be in Microsoft's TNEF format;
Sorry for the issue. I'm not sure that the exchange server will preserve
the plain text formatting [ :-) ], so I'm using another mail account...
The patch is down below.
cheers,
Paolo
--
diff -Nrubw --exclude='CVS*' --exclude='.#*' libpcap-vanilla/pcap/bluetooth.h libpcap/pcap/bluetooth.h
--- libpcap-vanilla/pcap/bluetooth.h 1970-01-01 01:00:00.000000000 +0100
+++ libpcap/pcap/bluetooth.h 2007-09-19 09:04:21.000000000 +0200
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2006 Paolo Abeni (Italy)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * bluetooth data struct
+ * By Paolo Abeni <paolo.abeni () email it>
+ *
+ */
+
+#ifndef _PCAP_BLUETOOTH_STRUCTS_H__
+#define _PCAP_BLUETOOTH_STRUCTS_H__
+
+/*
+ * Header prepended libpcap to each bluetooth h:4 frame.
+ * fields are in network byte order
+ */
+typedef struct _pcap_bluetooth_h4_header {
+ u_int32_t direction; /* if first bit is set direction is incoming */
+} pcap_bluetooth_h4_header;
+
+
+#endif
diff -Nrubw --exclude='CVS*' --exclude='.#*' libpcap-vanilla/pcap-bt-linux.c libpcap/pcap-bt-linux.c
--- libpcap-vanilla/pcap-bt-linux.c 2007-08-18 22:54:52.000000000 +0200
+++ libpcap/pcap-bt-linux.c 2007-09-19 08:49:05.000000000 +0200
@@ -11,8 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the Politecnico di Torino, CACE Technologies
- * nor the names of its contributors may be used to endorse or promote
+ * 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
@@ -43,6 +42,7 @@
#include "pcap-int.h"
#include "pcap-bt-linux.h"
+#include "pcap/bluetooth.h"
#ifdef NEED_STRERROR_H
#include "strerror.h"
@@ -55,6 +55,7 @@
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
+#include <arpa/inet.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
@@ -162,9 +163,9 @@
memset(handle, 0, sizeof(*handle));
handle->snapshot = snaplen;
handle->md.timeout = to_ms;
- handle->bufsize = snaplen+BT_CTRL_SIZE;
+ handle->bufsize = snaplen+BT_CTRL_SIZE+sizeof(pcap_bluetooth_h4_header);
handle->offset = BT_CTRL_SIZE;
- handle->linktype = DLT_BLUETOOTH_HCI_H4;
+ handle->linktype = DLT_BLUETOOTH_HCI_H4_WITH_PHDR;
handle->read_op = bt_read_linux;
handle->inject_op = bt_inject_linux;
@@ -186,7 +187,7 @@
return NULL;
}
- handle->buffer = malloc(snaplen+BT_CTRL_SIZE);
+ handle->buffer = malloc(handle->bufsize);
if (!handle->buffer) {
snprintf(errmsg, PCAP_ERRBUF_SIZE, "Can't allocate dump buffer: %s",
pcap_strerror(errno));
@@ -244,8 +245,10 @@
struct msghdr msg;
struct iovec iv;
struct pcap_pkthdr pkth;
+ pcap_bluetooth_h4_header* bthdr;
- iv.iov_base = &handle->buffer[handle->offset];
+ bthdr = (pcap_bluetooth_h4_header*) &handle->buffer[handle->offset];
+ iv.iov_base = &handle->buffer[handle->offset+sizeof(pcap_bluetooth_h4_header)];
iv.iov_len = handle->snapshot;
memset(&msg, 0, sizeof(msg));
@@ -273,8 +276,8 @@
/* get direction and timestamp*/
cmsg = CMSG_FIRSTHDR(&msg);
+ int in=0;
while (cmsg) {
- int in;
switch (cmsg->cmsg_type) {
case HCI_CMSG_DIR:
in = *((int *) CMSG_DATA(cmsg));
@@ -285,8 +288,14 @@
}
cmsg = CMSG_NXTHDR(&msg, cmsg);
}
+ if ((in && (handle->direction == PCAP_D_OUT)) ||
+ ((!in) && (handle->direction == PCAP_D_IN)))
+ return 0;
+
+ bthdr->direction = htonl(in != 0);
+ pkth.caplen+=sizeof(pcap_bluetooth_h4_header);
pkth.len = pkth.caplen;
- callback(user, &pkth, iv.iov_base);
+ callback(user, &pkth, &handle->buffer[handle->offset]);
return 1;
}
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- new DLT request Abeni Paolo (Sep 07)
- Re: new DLT request Guy Harris (Sep 18)
- Re: new DLT request Abeni Paolo (Sep 19)
- Re: new DLT request Guy Harris (Sep 19)
- Re: new DLT request Abeni Paolo (Sep 19)
- <Possible follow-ups>
- Re: new DLT request Paolo Abeni (Sep 20)
- Re: new DLT request Guy Harris (Sep 21)
- Re: new DLT request Paolo Abeni (Sep 20)
- Re: new DLT request Guy Harris (Sep 18)
