Wireshark-bugs: [Wireshark-bugs] [Bug 7715] Bluetooth: Add SAP dissector

Date: Sat, 6 Oct 2012 15:27:13 -0700 (PDT)
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7715

--- Comment #26 from Pascal Quantin <pascal.quantin@xxxxxxxxx> 2012-10-06 15:27:12 PDT ---
(In reply to comment #24)
> Created attachment 9229 [details]
> [PATCH] gsm-sim: Fixes required by Bluetooth SAP
> 
> Changelog: 
> fix issue from comment #20, thanks. Now should be ok, without some malformed
> GSM-SIM packets, is that bug in GSM-SIM or I miss something?

I did a quick test and as expected the osmocom decoding was broken due to the
hunk I indicated in comment #25.

Replacing the hunk:
        if (rc == -1 && sim_tree) {
            /* default dissector */
            proto_tree_add_item(sim_tree, hf_apdu_p1, tvb, offset+0, 1,
ENC_BIG_ENDIAN);
            proto_tree_add_item(sim_tree, hf_apdu_p2, tvb, offset+1, 1,
ENC_BIG_ENDIAN);
            proto_tree_add_item(sim_tree, hf_apdu_p3, tvb, offset+2, 1,
ENC_BIG_ENDIAN);
        }
        offset += 3;
    }

    if (tvb_len > 2) {
        proto_tree_add_item(sim_tree, hf_apdu_data, tvb, offset, tvb_len - 2,
ENC_NA);
        offset = tvb_len - 2;
    }

    if (osmocom_mode || !cond) {

        /* obtain status word */
        sw = tvb_get_ntohs(tvb, offset);
        /* proto_tree_add_item(sim_tree, hf_apdu_sw, tvb, tvb_len-2, 2,
ENC_BIG_ENDIAN); */
        proto_tree_add_uint_format(sim_tree, hf_apdu_sw, tvb, offset, 2, sw,
                                "Status Word: %04x %s", sw, get_sw_string(sw));
        offset += 2;

by:
        if (rc == -1 && sim_tree) {
            /* default dissector */
            proto_tree_add_item(sim_tree, hf_apdu_p1, tvb, offset+0, 1,
ENC_BIG_ENDIAN);
            proto_tree_add_item(sim_tree, hf_apdu_p2, tvb, offset+1, 1,
ENC_BIG_ENDIAN);
            proto_tree_add_item(sim_tree, hf_apdu_p3, tvb, offset+2, 1,
ENC_BIG_ENDIAN);
            proto_tree_add_item(sim_tree, hf_apdu_data, tvb, offset+3, p3,
ENC_NA);
        }
        offset += 3;
    } else if (tvb_len > 2) {
        proto_tree_add_item(sim_tree, hf_apdu_data, tvb, offset, tvb_len - 2,
ENC_NA);
    }
    offset = tvb_len - 2;

    if (osmocom_mode || !cond) {

        /* obtain status word */
        sw = tvb_get_ntohs(tvb, offset);
        /* proto_tree_add_item(sim_tree, hf_apdu_sw, tvb, offset, 2,
ENC_BIG_ENDIAN); */
        proto_tree_add_uint_format(sim_tree, hf_apdu_sw, tvb, offset, 2, sw,
                                "Status Word: %04x %s", sw, get_sw_string(sw));
        offset += 2;

fixes the issue.

Concerning the use of the call_dissector_with_data, until we decide how to use
it exactly I would prefer instead to introduce another dissector using the
"standard" 3GPP mode.
I would happy to add two new subdissectors "gsm_sim.command" and
"gsm_sim.response" mapping the 3GPP requirements and keeping "gsm_sim"
dissector for the the specific format of the osmocom simtrace module. Moreover
it would deserve my own needs ;) Michal, would you be OK with this? Is your
"Direction of stream" really needed? Could it be moved in packet-btsap.c?

-- 
Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.