diff options
-rw-r--r-- | AUTHORS | 6 | ||||
-rw-r--r-- | epan/dissectors/Makefile.common | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-bthci_acl.c | 1 | ||||
-rw-r--r-- | epan/dissectors/packet-bthci_cmd.c | 1 | ||||
-rw-r--r-- | epan/dissectors/packet-bthci_evt.c | 1 | ||||
-rw-r--r-- | epan/dissectors/packet-bthci_sco.c | 1 | ||||
-rw-r--r-- | epan/dissectors/packet-btsdp.c | 1 | ||||
-rw-r--r-- | epan/dissectors/packet-frame.c | 5 | ||||
-rw-r--r-- | epan/dissectors/packet-hci_h1.c | 134 | ||||
-rw-r--r-- | epan/dissectors/packet-hci_h1.h | 27 | ||||
-rw-r--r-- | wiretap/Makefile.common | 1 | ||||
-rw-r--r-- | wiretap/btsnoop.c | 303 | ||||
-rw-r--r-- | wiretap/btsnoop.h | 30 | ||||
-rw-r--r-- | wiretap/file_access.c | 8 | ||||
-rw-r--r-- | wiretap/wtap.h | 13 |
15 files changed, 530 insertions, 4 deletions
@@ -2691,10 +2691,14 @@ Fulko Hew <fulko.hew [AT] gmail.com> { Link Control) WAN protocol dissection } -Andy Chu <chu.dev [AT] gmail.com> { +Andy Chu <chu.dev [AT] gmail.com> { China Mobile Point to Point } +Shane Kearns <shane.kearns [AT] symbian.com> { + Support Symbian OS btsnoop +} + and by: Pavel Roskin <proski [AT] gnu.org> diff --git a/epan/dissectors/Makefile.common b/epan/dissectors/Makefile.common index 4c1609b087..1208573139 100644 --- a/epan/dissectors/Makefile.common +++ b/epan/dissectors/Makefile.common @@ -431,6 +431,7 @@ CLEAN_DISSECTOR_SRC = \ packet-h261.c \ packet-h263.c \ packet-h264.c \ + packet-hci_h1.c \ packet-hci_h4.c \ packet-hclnfsd.c \ packet-homeplug.c \ @@ -909,6 +910,7 @@ DISSECTOR_INCLUDES = \ packet-h264.h \ packet-h323.h \ packet-h450-ros.h \ + packet-hci_h1.h \ packet-hci_h4.h \ packet-hclnfsd.h \ packet-hpext.h \ diff --git a/epan/dissectors/packet-bthci_acl.c b/epan/dissectors/packet-bthci_acl.c index 348bf130e9..28d9795789 100644 --- a/epan/dissectors/packet-bthci_acl.c +++ b/epan/dissectors/packet-bthci_acl.c @@ -290,6 +290,7 @@ proto_reg_handoff_btacl(void) bthci_acl_handle = find_dissector("bthci_acl"); dissector_add("hci_h4.type", HCI_H4_TYPE_ACL, bthci_acl_handle); + dissector_add("hci_h1.type", BTHCI_CHANNEL_ACL, bthci_acl_handle); btl2cap_handle = find_dissector("btl2cap"); diff --git a/epan/dissectors/packet-bthci_cmd.c b/epan/dissectors/packet-bthci_cmd.c index 4f0c2bf83e..246c390cc6 100644 --- a/epan/dissectors/packet-bthci_cmd.c +++ b/epan/dissectors/packet-bthci_cmd.c @@ -2916,5 +2916,6 @@ proto_reg_handoff_bthci_cmd(void) dissector_handle_t bthci_cmd_handle; bthci_cmd_handle = find_dissector("bthci_cmd"); dissector_add("hci_h4.type", HCI_H4_TYPE_CMD, bthci_cmd_handle); + dissector_add("hci_h1.type", BTHCI_CHANNEL_COMMAND, bthci_cmd_handle); } diff --git a/epan/dissectors/packet-bthci_evt.c b/epan/dissectors/packet-bthci_evt.c index 4fb5785671..ef9f70508f 100644 --- a/epan/dissectors/packet-bthci_evt.c +++ b/epan/dissectors/packet-bthci_evt.c @@ -3538,6 +3538,7 @@ proto_reg_handoff_bthci_evt(void) bthci_evt_handle = find_dissector("bthci_evt"); dissector_add("hci_h4.type", HCI_H4_TYPE_EVT, bthci_evt_handle); + dissector_add("hci_h1.type", BTHCI_CHANNEL_EVENT, bthci_evt_handle); bthci_com_handle = find_dissector("bthci_cmd"); } diff --git a/epan/dissectors/packet-bthci_sco.c b/epan/dissectors/packet-bthci_sco.c index f72475ad97..fc31f33bff 100644 --- a/epan/dissectors/packet-bthci_sco.c +++ b/epan/dissectors/packet-bthci_sco.c @@ -110,6 +110,7 @@ proto_reg_handoff_btsco(void) bthci_sco_handle = find_dissector("bthci_sco"); dissector_add("hci_h4.type", HCI_H4_TYPE_SCO, bthci_sco_handle); + dissector_add("hci_h1.type", BTHCI_CHANNEL_SCO, bthci_sco_handle); } diff --git a/epan/dissectors/packet-btsdp.c b/epan/dissectors/packet-btsdp.c index 8088f835fd..77018896d3 100644 --- a/epan/dissectors/packet-btsdp.c +++ b/epan/dissectors/packet-btsdp.c @@ -676,7 +676,6 @@ dissect_sdp_service_search_response(proto_tree *t, tvbuff_t *tvb, int offset) ti = proto_tree_add_text(t, tvb, offset, curr_count * 4, "ServiceRecordHandleList"); st = proto_item_add_subtree(ti, ett_btsdp_ssr); - offset+=4; while(curr_count>0){ proto_tree_add_text(st, tvb, offset, 4, "0x%x", tvb_get_ntohl(tvb, offset)); diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c index af69c16935..0dccd64a38 100644 --- a/epan/dissectors/packet-frame.c +++ b/epan/dissectors/packet-frame.c @@ -135,6 +135,11 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) P2P_DIR_SENT : P2P_DIR_RECV; break; + case WTAP_ENCAP_BLUETOOTH_HCI: + pinfo->p2p_dir = pinfo->pseudo_header->bthci.sent ? + P2P_DIR_SENT : P2P_DIR_RECV; + break; + case WTAP_ENCAP_LAPB: case WTAP_ENCAP_FRELAY_WITH_PHDR: pinfo->p2p_dir = diff --git a/epan/dissectors/packet-hci_h1.c b/epan/dissectors/packet-hci_h1.c new file mode 100644 index 0000000000..66aea2dcea --- /dev/null +++ b/epan/dissectors/packet-hci_h1.c @@ -0,0 +1,134 @@ +/* packet-hci_h1.c + * Routines for the Bluetooth HCI h1 dissection + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <epan/packet.h> + +#include "packet-hci_h1.h" + + +static int proto_hci_h1 = -1; +static int hf_hci_h1_type = -1; +static int hf_hci_h1_direction = -1; + +static gint ett_hci_h1 = -1; + +static dissector_table_t hci_h1_table; +static dissector_handle_t data_handle; + + +static const value_string hci_h1_type_vals[] = { + {BTHCI_CHANNEL_COMMAND, "HCI Command"}, + {BTHCI_CHANNEL_ACL, "ACL Data"}, + {BTHCI_CHANNEL_SCO, "SCO Data"}, + {BTHCI_CHANNEL_EVENT, "HCI Event"}, + {0, NULL } +}; +static const value_string hci_h1_direction_vals[] = { + {0, "Sent"}, + {1, "Rcvd"}, + {0, NULL} +}; + +static void +dissect_hci_h1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + guint8 type; + tvbuff_t *next_tvb; + proto_item *ti=NULL; + proto_tree *hci_h1_tree=NULL; + + if(check_col(pinfo->cinfo, COL_PROTOCOL)) + col_set_str(pinfo->cinfo, COL_PROTOCOL, "HCI"); + + if(check_col(pinfo->cinfo, COL_INFO)) + col_clear(pinfo->cinfo, COL_INFO); + + type = pinfo->pseudo_header->bthci.channel; + + if(tree){ + ti = proto_tree_add_item(tree, proto_hci_h1, tvb, 0, 1, FALSE); + hci_h1_tree = proto_item_add_subtree(ti, ett_hci_h1); + } + + if(check_col(pinfo->cinfo, COL_INFO)){ + col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",pinfo->p2p_dir==P2P_DIR_SENT?"Sent":"Rcvd",val_to_str(type, hci_h1_type_vals, "Unknown 0x%02x")); + } + ti=proto_tree_add_uint(hci_h1_tree, hf_hci_h1_direction, tvb, 0, 0, pinfo->p2p_dir); + PROTO_ITEM_SET_GENERATED(ti); + proto_item_append_text(hci_h1_tree, " %s %s", val_to_str(pinfo->p2p_dir, hci_h1_direction_vals, "0x%02x"), val_to_str(type, hci_h1_type_vals, "Unknown 0x%02x")); + + next_tvb = tvb_new_subset(tvb, 0, -1, -1); + if(!dissector_try_port(hci_h1_table, type, next_tvb, pinfo, tree)) { + call_dissector(data_handle, next_tvb, pinfo, tree); + } +} + + +void +proto_register_hci_h1(void) +{ + static hf_register_info hf[] = { + { &hf_hci_h1_type, + { "HCI Packet Type", "hci_h1.type", + FT_UINT8, BASE_HEX, VALS(hci_h1_type_vals), 0x0, + "HCI Packet Type", HFILL }}, + + { &hf_hci_h1_direction, + { "Direction", "hci_h1.direction", + FT_UINT8, BASE_HEX, VALS(hci_h1_direction_vals), 0x0, + "HCI Packet Direction Sent/Rcvd", HFILL }}, + + }; + + static gint *ett[] = { + &ett_hci_h1, + }; + + proto_hci_h1 = proto_register_protocol("Bluetooth HCI", + "HCI_H1", "hci_h1"); + + register_dissector("hci_h1", dissect_hci_h1, proto_hci_h1); + + proto_register_field_array(proto_hci_h1, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + + hci_h1_table = register_dissector_table("hci_h1.type", + "HCI h1 pdu type", FT_UINT8, BASE_HEX); +} + +void +proto_reg_handoff_hci_h1(void) +{ + dissector_handle_t hci_h1_handle; + + data_handle = find_dissector("data"); + hci_h1_handle = find_dissector("hci_h1"); + dissector_add("wtap_encap", WTAP_ENCAP_BLUETOOTH_HCI, hci_h1_handle); +} + + diff --git a/epan/dissectors/packet-hci_h1.h b/epan/dissectors/packet-hci_h1.h new file mode 100644 index 0000000000..37aa136ac0 --- /dev/null +++ b/epan/dissectors/packet-hci_h1.h @@ -0,0 +1,27 @@ +/* packet-hci_h1.h + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __PACKET_HCI_H1_H__ +#define __PACKET_HCI_H1_H__ + +#endif diff --git a/wiretap/Makefile.common b/wiretap/Makefile.common index 57d276acae..af2ac2158b 100644 --- a/wiretap/Makefile.common +++ b/wiretap/Makefile.common @@ -34,6 +34,7 @@ NONGENERATED_C_FILES = \ ascend.c \ atm.c \ ber.c \ + btsnoop.c \ buffer.c \ catapult_dct2000.c \ commview.c \ diff --git a/wiretap/btsnoop.c b/wiretap/btsnoop.c new file mode 100644 index 0000000000..7cfad9f842 --- /dev/null +++ b/wiretap/btsnoop.c @@ -0,0 +1,303 @@ +/* btsnoop.c + * + * $Id$ + * + * Wiretap Library + * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include <errno.h> +#include <string.h> +#include "wtap-int.h" +#include "file_wrappers.h" +#include "buffer.h" +#include "atm.h" +#include "btsnoop.h" +/* See RFC 1761 for a description of the "snoop" file format. */ + +/* Magic number in "btsnoop" files. */ +static const char btsnoop_magic[] = { + 'b', 't', 's', 'n', 'o', 'o', 'p', '\0' +}; + +/* "snoop" file header (minus magic number). */ +struct btsnoop_hdr { + guint32 version; /* version number (should be 1) */ + guint32 datalink; /* datalink type */ +}; + +/* "snoop" record header. */ +struct btsnooprec_hdr { + guint32 orig_len; /* actual length of packet */ + guint32 incl_len; /* number of octets captured in file */ + guint32 flags; /* packet flags */ + guint32 cum_drops; /* cumulative number of dropped packets */ + gint64 ts_usec; /* timestamp microseconds */ +}; + +/* H1 is unframed data with the packet type encoded in the flags field of capture header */ +/* It can be used for any datalink by placing logging above the datalink layer of HCI */ +#define KHciLoggerDatalinkTypeH1 1001 +/* H4 is the serial HCI with packet type encoded in the first byte of each packet */ +#define KHciLoggerDatalinkTypeH4 1002 +/* CSR's PPP derived bluecore serial protocol - in practice we log in H1 format after deframing */ +#define KHciLoggerDatalinkTypeBCSP 1003 +/* H5 is the official three wire serial protocol derived from BCSP*/ +#define KHciLoggerDatalinkTypeH5 1004 + +#define KHciLoggerHostToController 0 +#define KHciLoggerControllerToHost 0x00000001 +#define KHciLoggerACLDataFrame 0 +#define KHciLoggerCommandOrEvent 0x00000002 + +const gint64 KUnixTimeBase = G_GINT64_CONSTANT(0x00dcddb30f2f8000); /* offset from symbian - unix time */ + +static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info, + gint64 *data_offset); +static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off, + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info); +static gboolean snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err); + +int btsnoop_open(wtap *wth, int *err, gchar **err_info _U_) +{ + int bytes_read; + char magic[sizeof btsnoop_magic]; + struct btsnoop_hdr hdr; + + int file_encap=WTAP_ENCAP_UNKNOWN; + + /* Read in the string that should be at the start of a "snoop" file */ + errno = WTAP_ERR_CANT_READ; + bytes_read = file_read(magic, 1, sizeof magic, wth->fh); + if (bytes_read != sizeof magic) { + *err = file_error(wth->fh); + if (*err != 0) + return -1; + return 0; + } + wth->data_offset += sizeof magic; + + if (memcmp(magic, btsnoop_magic, sizeof btsnoop_magic) != 0) { + return 0; + } + + /* Read the rest of the header. */ + errno = WTAP_ERR_CANT_READ; + bytes_read = file_read(&hdr, 1, sizeof hdr, wth->fh); + if (bytes_read != sizeof hdr) { + *err = file_error(wth->fh); + if (*err != 0) + return -1; + return 0; + } + wth->data_offset += sizeof hdr; + + /* + * Make sure it's a version we support. + */ + hdr.version = g_ntohl(hdr.version); + if (hdr.version != 1) { + *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("btsnoop: version %u unsupported", hdr.version); + return -1; + } + + hdr.datalink = g_ntohl(hdr.datalink); + switch (hdr.datalink) { + case KHciLoggerDatalinkTypeH1: + file_encap=WTAP_ENCAP_BLUETOOTH_HCI; + break; + case KHciLoggerDatalinkTypeBCSP: + case KHciLoggerDatalinkTypeH5: + *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("btsnoop: BCSP/H5 capture logs %u unsupported", hdr.version); + return -1; + case KHciLoggerDatalinkTypeH4: + file_encap=WTAP_ENCAP_BLUETOOTH_H4; + break; + default: + *err = WTAP_ERR_UNSUPPORTED; + *err_info = g_strdup_printf("btsnoop: datalink %u unsupported", hdr.version); + return -1; + } + + wth->subtype_read = btsnoop_read; + wth->subtype_seek_read = btsnoop_seek_read; + wth->file_encap = file_encap; + wth->snapshot_length = 0; /* not available in header */ + wth->tsprecision = WTAP_FILE_TSPREC_USEC; + wth->file_type = WTAP_FILE_BTSNOOP; + return 1; +} + +static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info, + gint64 *data_offset) +{ + guint32 packet_size; + guint32 flags; + guint32 orig_size; + int bytes_read; + struct btsnooprec_hdr hdr; + gint64 ts; + + /* As the send/receive flag is stored in the middle of the capture header + but needs to go in the pseudo header for wiretap, the header needs to be reread + in the seek_read function*/ + *data_offset = wth->data_offset; + + /* Read record header. */ + errno = WTAP_ERR_CANT_READ; + bytes_read = file_read(&hdr, 1, sizeof hdr, wth->fh); + if (bytes_read != sizeof hdr) { + *err = file_error(wth->fh); + if (*err == 0 && bytes_read != 0) + *err = WTAP_ERR_SHORT_READ; + return FALSE; + } + wth->data_offset += sizeof hdr; + if(sizeof hdr!=24) + { + *err_info="wrong header size"; + return FALSE; + } + + packet_size = g_ntohl(hdr.incl_len); + orig_size = g_ntohl(hdr.orig_len); + flags = g_ntohl(hdr.flags); + if (packet_size > WTAP_MAX_PACKET_SIZE) { + /* + * Probably a corrupt capture file; don't blow up trying + * to allocate space for an immensely-large packet. + */ + *err = WTAP_ERR_BAD_RECORD; + *err_info = g_strdup_printf("snoop: File has %u-byte packet, bigger than maximum of %u", + packet_size, WTAP_MAX_PACKET_SIZE); + return FALSE; + } + + buffer_assure_space(wth->frame_buffer, packet_size); + if (!snoop_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer), + packet_size, err)) { + return FALSE; /* Read error */ + } + wth->data_offset += packet_size; + + ts = GINT64_FROM_BE(hdr.ts_usec); + ts -= KUnixTimeBase; + + wth->phdr.ts.secs = (guint)(ts / 1000000); + wth->phdr.ts.nsecs = (guint)((ts % 1000000) * 1000); + wth->phdr.caplen = packet_size; + wth->phdr.len = orig_size; + if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_H4) + { + wth->pseudo_header.p2p.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE; + } + else if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_HCI) + { + wth->pseudo_header.bthci.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE; + if(flags & KHciLoggerCommandOrEvent) + { + if(wth->pseudo_header.bthci.sent) + { + wth->pseudo_header.bthci.channel = BTHCI_CHANNEL_COMMAND; + } + else + { + wth->pseudo_header.bthci.channel = BTHCI_CHANNEL_EVENT; + } + } + else + { + wth->pseudo_header.bthci.channel = BTHCI_CHANNEL_ACL; + } + } + return TRUE; +} + +static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off, + union wtap_pseudo_header *pseudo_header, guchar *pd, int length, + int *err, gchar **err_info _U_) { + int bytes_read; + struct btsnooprec_hdr hdr; + guint32 flags; + if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) + return FALSE; + + /* Read record header. */ + errno = WTAP_ERR_CANT_READ; + bytes_read = file_read(&hdr, 1, sizeof hdr, wth->random_fh); + if (bytes_read != sizeof hdr) { + *err = file_error(wth->random_fh); + if (*err == 0 && bytes_read != 0) + *err = WTAP_ERR_SHORT_READ; + return FALSE; + } + flags = g_ntohl(hdr.flags); + + /* + * Read the packet data. + */ + if (!snoop_read_rec_data(wth->random_fh, pd, length, err)) + return FALSE; /* failed */ + + if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_H4) + { + pseudo_header->p2p.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE; + } + else if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_HCI) + { + pseudo_header->bthci.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE; + if(flags & KHciLoggerCommandOrEvent) + { + if(pseudo_header->bthci.sent) + { + pseudo_header->bthci.channel = BTHCI_CHANNEL_COMMAND; + } + else + { + pseudo_header->bthci.channel = BTHCI_CHANNEL_EVENT; + } + } + else + { + pseudo_header->bthci.channel = BTHCI_CHANNEL_ACL; + } + } + return TRUE; +} + +static gboolean +snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err) +{ + int bytes_read; + + errno = WTAP_ERR_CANT_READ; + bytes_read = file_read(pd, 1, length, fh); + + if (bytes_read != length) { + *err = file_error(fh); + if (*err == 0) + *err = WTAP_ERR_SHORT_READ; + return FALSE; + } + return TRUE; +} diff --git a/wiretap/btsnoop.h b/wiretap/btsnoop.h new file mode 100644 index 0000000000..3255688602 --- /dev/null +++ b/wiretap/btsnoop.h @@ -0,0 +1,30 @@ +/* btsnoop.h + * + * $Id$ + * + * Wiretap Library + * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __W_BTSNOOP_H__ +#define __W_BTSNOOP_H__ + +int btsnoop_open(wtap *wth, int *err, gchar **err_info); +gboolean btsnoop_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err); +int btsnoop_dump_can_write_encap(int encap); + +#endif diff --git a/wiretap/file_access.c b/wiretap/file_access.c index 9ba0c7584b..902bba589a 100644 --- a/wiretap/file_access.c +++ b/wiretap/file_access.c @@ -76,7 +76,7 @@ #include "netscreen.h" #include "commview.h" #include "pcapng.h" - +#include "btsnoop.h" /* The open_file_* routines should return: @@ -120,6 +120,7 @@ static wtap_open_routine_t open_routines_base[] = { ber_open, mpeg_open, pcapng_open, + btsnoop_open, /* Files that don't have magic bytes at a fixed location, * but that instead require a heuristic of some sort to * identify them. This includes the ASCII trace files that @@ -578,7 +579,10 @@ static const struct file_type_info dump_open_table_base[] = { /* WTAP_FILE_PCAPNG */ { "Wireshark - pcapng (experimental)", "pcapng", "*.pcapng", NULL, FALSE, - pcapng_dump_can_write_encap, pcapng_dump_open } + pcapng_dump_can_write_encap, pcapng_dump_open }, + + /* WTAP_FILE_BTSNOOP */ + { "Symbian OS btsnoop", "btsnoop", "*.log", NULL, FALSE, NULL, NULL } }; gint wtap_num_file_types = sizeof(dump_open_table_base) / sizeof(struct file_type_info); diff --git a/wiretap/wtap.h b/wiretap/wtap.h index bebaf40f14..7d25897be6 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -196,6 +196,7 @@ extern "C" { #define WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR 99 #define WTAP_ENCAP_SITA 100 #define WTAP_ENCAP_SCCP 101 +#define WTAP_ENCAP_BLUETOOTH_HCI 102 /*raw packets without a transport layer header e.g. H4*/ #define WTAP_NUM_ENCAP_TYPES wtap_get_num_encap_types() @@ -254,6 +255,7 @@ extern "C" { #define WTAP_FILE_NETSCREEN 48 #define WTAP_FILE_COMMVIEW 49 #define WTAP_FILE_PCAPNG 50 +#define WTAP_FILE_BTSNOOP 51 #define WTAP_NUM_FILE_TYPES wtap_get_num_file_types() @@ -710,6 +712,16 @@ struct sita_phdr { guint8 proto; }; +/*pseudo header for Bluetooth HCI*/ +struct bthci_phdr { + gboolean sent; + guint8 channel; +}; + +#define BTHCI_CHANNEL_COMMAND 1 +#define BTHCI_CHANNEL_ACL 2 +#define BTHCI_CHANNEL_SCO 3 +#define BTHCI_CHANNEL_EVENT 4 union wtap_pseudo_header { struct eth_phdr eth; @@ -729,6 +741,7 @@ union wtap_pseudo_header { struct linux_usb_phdr linux_usb; struct erf_mc_phdr erf; struct sita_phdr sita; + struct bthci_phdr bthci; }; struct wtap_nstime { |