forked from osmocom/wireshark
MBIM: fix dissection of control packets when capturing with usbmon
Change-Id: Ie20fcb8d393a85d47ba78f6cb70de77fedda2587 Reviewed-on: https://code.wireshark.org/review/829 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
This commit is contained in:
parent
843054ce96
commit
38b5efd5cf
|
@ -1,6 +1,6 @@
|
|||
/* packet-mbim.c
|
||||
* Routines for MBIM dissection
|
||||
* Copyright 2013, Pascal Quantin <pascal.quantin@gmail.com>
|
||||
* Copyright 2013-2014, Pascal Quantin <pascal.quantin@gmail.com>
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
|
@ -3492,7 +3492,7 @@ mbim_dissect_muticarrier_current_cid_list_info(tvbuff_t *tvb, packet_info *pinfo
|
|||
}
|
||||
|
||||
static int
|
||||
dissect_mbim_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
|
||||
dissect_mbim_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
||||
{
|
||||
proto_item *ti;
|
||||
proto_tree *mbim_tree, *header_tree, *subtree;
|
||||
|
@ -3503,7 +3503,15 @@ dissect_mbim_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
|
|||
struct mbim_conv_info *mbim_conv;
|
||||
struct mbim_info *mbim_info = NULL;
|
||||
|
||||
if (mbim_control_decode_unknown_itf && (tvb_reported_length(tvb) < 12)) {
|
||||
if (data) {
|
||||
usb_trans_info_t *usb_trans_info = ((usb_conv_info_t *)data)->usb_trans_info;
|
||||
if ((usb_trans_info->setup.request == 0x00) && (usb_trans_info->header_info & USB_HEADER_IS_LINUX)) {
|
||||
/* Skip Send Encapsulated Command header */
|
||||
offset += 7;
|
||||
}
|
||||
}
|
||||
|
||||
if (mbim_control_decode_unknown_itf && (tvb_reported_length_remaining(tvb, offset) < 12)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3522,9 +3530,9 @@ dissect_mbim_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
|
|||
conversation_add_proto_data(conversation, proto_mbim, mbim_conv);
|
||||
}
|
||||
|
||||
ti = proto_tree_add_item(tree, proto_mbim, tvb, 0, -1, ENC_NA);
|
||||
ti = proto_tree_add_item(tree, proto_mbim, tvb, offset, -1, ENC_NA);
|
||||
mbim_tree = proto_item_add_subtree(ti, ett_mbim);
|
||||
ti = proto_tree_add_item(mbim_tree, hf_mbim_control, tvb, 0, 0, ENC_NA);
|
||||
ti = proto_tree_add_item(mbim_tree, hf_mbim_control, tvb, offset, 0, ENC_NA);
|
||||
PROTO_ITEM_SET_HIDDEN(ti);
|
||||
|
||||
ti = proto_tree_add_text(mbim_tree, tvb, offset, 12, "Message Header");
|
||||
|
|
|
@ -464,9 +464,15 @@ dissect_usb_com_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
|
|||
switch (usb_trans_info->setup.request)
|
||||
{
|
||||
case SEND_ENCAPSULATED_COMMAND:
|
||||
if ((usb_conv_info->interfaceSubclass == COM_SUBCLASS_MBIM) &&
|
||||
(usb_trans_info->header_info & USB_HEADER_IS_LINUX)) {
|
||||
offset = call_dissector_only(mbim_control_handle, tvb, pinfo, tree, usb_conv_info);
|
||||
break;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
case GET_ENCAPSULATED_RESPONSE:
|
||||
if (!is_request && (usb_conv_info->interfaceSubclass == COM_SUBCLASS_MBIM)) {
|
||||
offset = call_dissector_only(mbim_control_handle, tvb, pinfo, tree, NULL);
|
||||
if ((usb_conv_info->interfaceSubclass == COM_SUBCLASS_MBIM) && !is_request) {
|
||||
offset = call_dissector_only(mbim_control_handle, tvb, pinfo, tree, usb_conv_info);
|
||||
}
|
||||
break;
|
||||
case GET_NTB_PARAMETERS:
|
||||
|
|
|
@ -1851,7 +1851,7 @@ dissect_usb_vid_get_set(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb,
|
|||
offset += 2;
|
||||
|
||||
/* If there is an extended pseudo header, skip over it to reach the payload */
|
||||
if ((usb_trans_info->setup.request == USB_SETUP_SET_CUR) && usb_trans_info->header_len_64)
|
||||
if ((usb_trans_info->setup.request == USB_SETUP_SET_CUR) && (usb_trans_info->header_info & USB_HEADER_IS_64_BYTES))
|
||||
offset += 16;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -41,11 +41,6 @@
|
|||
#include "packet-usb.h"
|
||||
#include "packet-usb-hid.h"
|
||||
|
||||
/* internal header flags */
|
||||
#define USB_HEADER_IS_LINUX (1 << 0)
|
||||
#define USB_HEADER_IS_64_BYTES (1 << 1)
|
||||
#define USB_HEADER_IS_USBPCAP (1 << 2)
|
||||
|
||||
/* protocols and header fields */
|
||||
static int proto_usb = -1;
|
||||
|
||||
|
@ -2867,10 +2862,10 @@ dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent,
|
|||
/* this is a request */
|
||||
usb_trans_info = (usb_trans_info_t *)wmem_tree_lookup32(usb_conv_info->transactions, pinfo->fd->num);
|
||||
if (!usb_trans_info) {
|
||||
usb_trans_info = wmem_new0(wmem_file_scope(), usb_trans_info_t);
|
||||
usb_trans_info->request_in = pinfo->fd->num;
|
||||
usb_trans_info->req_time = pinfo->fd->abs_ts;
|
||||
usb_trans_info->header_len_64 = (header_info & USB_HEADER_IS_64_BYTES) ? TRUE : FALSE;
|
||||
usb_trans_info = wmem_new0(wmem_file_scope(), usb_trans_info_t);
|
||||
usb_trans_info->request_in = pinfo->fd->num;
|
||||
usb_trans_info->req_time = pinfo->fd->abs_ts;
|
||||
usb_trans_info->header_info = header_info;
|
||||
|
||||
wmem_tree_insert32(usb_conv_info->transactions, pinfo->fd->num, usb_trans_info);
|
||||
}
|
||||
|
|
|
@ -39,12 +39,17 @@ typedef struct _usb_address_t {
|
|||
|
||||
typedef struct _usb_conv_info_t usb_conv_info_t;
|
||||
|
||||
/* header flags */
|
||||
#define USB_HEADER_IS_LINUX (1 << 0)
|
||||
#define USB_HEADER_IS_64_BYTES (1 << 1)
|
||||
#define USB_HEADER_IS_USBPCAP (1 << 2)
|
||||
|
||||
/* there is one such structure for each request/response */
|
||||
typedef struct _usb_trans_info_t {
|
||||
guint32 request_in;
|
||||
guint32 response_in;
|
||||
nstime_t req_time;
|
||||
gboolean header_len_64;
|
||||
guint8 header_info;
|
||||
|
||||
/* Valid only for SETUP transactions */
|
||||
struct _usb_setup {
|
||||
|
|
Loading…
Reference in New Issue