From: Marcel Holtmann <marcel@holtmann.org>
To: Guy Harris <guy@alum.mit.edu>
Cc: Paul Ionescu <paul@acorp.ro>,
BlueZ Mailing List <bluez-devel@lists.sourceforge.net>,
ethereal-dev@ethereal.com
Subject: Re: [Ethereal-dev] Re: [Bluez-devel] bluetooth ethereal dissector
Date: 30 Oct 2003 12:39:46 +0100 [thread overview]
Message-ID: <1067513580.18114.20.camel@pegasus> (raw)
In-Reply-To: <FBDCA88C-0A86-11D8-B1BA-000A958097E4@alum.mit.edu>
[-- Attachment #1: Type: text/plain, Size: 831 bytes --]
Hi Guy,
> > here is my patch that adds a Wiretap module for reading files created
> > with "hcidump -w".
>
> Checked in, with wiretap/Makefile.nmake updated to build it, with the
> __attribute((packed))__ stuff removed (not all compilers used to build
> Wiretap support it, and there are no fields in there that would require
> padding), and with the byte swapping done with "g_ntohs()" and
> "g_ntohl()" so it doesn't have to include headers not found on all
> platforms.
sorry for the nmake stuff, but I always forget them :(
Attached is another patch against CVS, which re-introduces the byte
swapping, because the ntohs/ntohl are not working in this case. I used
the GLIB macros and so it should be portable now. I also use the macro
_U_ for __attribute((packed))__ and this should be portable, too.
Regards
Marcel
[-- Attachment #2: patch-ethereal-hcidump-2 --]
[-- Type: text/x-patch, Size: 1722 bytes --]
diff -urN ethereal/wiretap/hcidump.c ethereal-mh/wiretap/hcidump.c
--- ethereal/wiretap/hcidump.c Thu Oct 30 04:11:02 2003
+++ ethereal-mh/wiretap/hcidump.c Thu Oct 30 12:16:17 2003
@@ -28,13 +28,27 @@
#include "buffer.h"
#include "hcidump.h"
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define htobs(val) (val)
+#define htobl(val) (val)
+#define btohs(val) (val)
+#define btohl(val) (val)
+#elif G_BYTE_ORDER == G_BIG_ENDIAN
+#define htobs(val) GUINT16_SWAP_LE_BE(val)
+#define htobl(val) GUINT32_SWAP_LE_BE(val)
+#define btohs(val) GUINT16_SWAP_LE_BE(val)
+#define btohl(val) GUINT32_SWAP_LE_BE(val)
+#else
+#error unknown ENDIAN type
+#endif
+
struct dump_hdr {
guint16 len;
guint8 in;
guint8 pad;
guint32 ts_sec;
guint32 ts_usec;
-};
+} _U_;
#define DUMP_HDR_SIZE (sizeof(struct dump_hdr))
@@ -55,7 +69,7 @@
}
wth->data_offset += DUMP_HDR_SIZE;
- packet_size = g_ntohs(dh.len);
+ packet_size = btohs(dh.len);
if (packet_size > WTAP_MAX_PACKET_SIZE) {
/*
* Probably a corrupt capture file; don't blow up trying
@@ -79,8 +93,8 @@
}
wth->data_offset += packet_size;
- wth->phdr.ts.tv_sec = g_ntohl(dh.ts_sec);
- wth->phdr.ts.tv_usec = g_ntohl(dh.ts_usec);
+ wth->phdr.ts.tv_sec = btohl(dh.ts_sec);
+ wth->phdr.ts.tv_usec = btohl(dh.ts_usec);
wth->phdr.caplen = packet_size;
wth->phdr.len = packet_size;
wth->phdr.pkt_encap = WTAP_ENCAP_BLUETOOTH_H4;
@@ -131,7 +145,7 @@
return (*err != 0) ? -1 : 0;
}
- if (dh.in != 0 && dh.in != 1 && dh.pad != 0 && g_ntohs(dh.len) < 1)
+ if (dh.in != 0 && dh.in != 1 && dh.pad != 0 && btohs(dh.len) < 1)
return 0;
bytes_read = file_read(&type, 1, 1, wth->fh);
next prev parent reply other threads:[~2003-10-30 11:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-28 22:11 [Bluez-devel] bluetooth ethereal dissector Paul Ionescu
2003-10-29 8:54 ` James Courtier-Dutton
2003-10-29 11:17 ` Marcel Holtmann
2003-10-29 20:16 ` [Ethereal-dev] " Guy Harris
2003-10-29 11:07 ` Marcel Holtmann
2003-10-29 19:26 ` [Ethereal-dev] " Guy Harris
2003-10-30 2:50 ` Marcel Holtmann
2003-10-30 3:13 ` Guy Harris
2003-10-30 11:39 ` Marcel Holtmann [this message]
2003-10-30 11:54 ` Guy Harris
2003-10-30 12:49 ` Marcel Holtmann
2003-10-30 6:22 ` Guy Harris
2003-10-30 12:22 ` Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1067513580.18114.20.camel@pegasus \
--to=marcel@holtmann.org \
--cc=bluez-devel@lists.sourceforge.net \
--cc=ethereal-dev@ethereal.com \
--cc=guy@alum.mit.edu \
--cc=paul@acorp.ro \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox