Custom bluetooth transport implementation

asked 2021-08-26 09:14:47 +0000

kasjer gravatar image

Hi

I work with device that implements HCI interface over vendor specific USB protocol. I would be able to create dissector plugin if function:

static bluetooth_data_t *
dissect_bluetooth_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)

...was not private to packet-bluetooth.c.

Currently supported transports are coupled with bluetooth protocol inside function proto_reg_handoff_bluetooth() (and some static functions called inside) and use disset_bluetooth_common() that I would also like to use.

I wander if exporting function dissect_bluetooth_common() would be a problem or there is other recommended way to create data of type bluetooth_data_t needed later for actual HCI command/event dissectors?

Or maybe I need to integrate some strange protocol into packet-bluetooth.c?

Thanks for advise.

edit retag flag offensive close merge delete

Comments

I'm not very familiar with bluetooth so might be missing the point as to where your protocol fits in, but the bluetooth dissector creates a number of tables that subdissectors can register with to be called when the common routine locates a packet of interest, e.g. the HCI Vendor table "bluetooth.vendor", do any of these fit your needs? Hint, look for register_dissector_table() calls to see the tables available.

grahamb gravatar imagegrahamb ( 2021-08-26 09:30:37 +0000 )edit

Various bluetooth dissectors expect that void *data passed to them is of type bluetooth_data_t * the only function that actually creates this is dissect_bluetooth_common(). Protocol that I'm working with can register itself but at some point it wants to call bluetooth dissectors like this call_dissector_with_data(bthci_cmd_handle, next_tvb, pinfo, tree, bluetooth_data); first argument I can get using find_dissector_add_dependency() without need to modify packet-bluetooth.h but the last one bluetooth_data is only created in one file for various transports see functions dissect_bluetooth()dissect_bluetooth_bthci()dissect_bluetooth_btmon()dissect_bluetooth_usb()dissect_bluetooth_ubertooth() So I would like to pass data down to correct dissector but required data is not created so I guess I can't find it in any table.

kasjer gravatar imagekasjer ( 2021-08-26 10:21:13 +0000 )edit

Sorry for being an idiot, but I don't follow the protocol stack you have. Are you saying you have something like:

your protocol
  bluetooth
    bluetooth sub dissector

If not, can you explain the protocol stack?

grahamb gravatar imagegrahamb ( 2021-08-26 10:35:51 +0000 )edit

its like this

usb protocol
    my protocol
        bluetooth

it is very similar to what usb_hci does

usb protocol
    usb_hci
        bluetooth

So basically it replaces Bluetooth standardized USB transport. Bleutooth over USB normally uses some set of USB endpoints for various purposes while this custom transport uses different endpoints configuration and also handled some non-bluetooth traffic. Wireshark handles usb_hci in in packet-hci_usb.c and packet-bluetooth.c.

kasjer gravatar imagekasjer ( 2021-08-26 10:58:09 +0000 )edit

Given the stack you describe, why can't your dissector call the bluetooth top-level dissector (dissect_bluetooth) which calls the internal function dissect_bluetooth_common? Maybe because that isn't registered via a call to register_dissector. <br\&gt;<br/> The dissector is registered in the wtap_encap table (and the usb.product and usb.protocol tables for the dissect_bluetooth_usb function) for various tabel values so could be located there and then called.

grahamb gravatar imagegrahamb ( 2021-08-26 11:18:11 +0000 )edit