aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-gsm_sim.c
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2021-08-27 12:25:37 +0200
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2021-08-30 08:49:38 +0000
commit3efb3cab62c64fbda2e15b528e87fc7c1c515af4 (patch)
tree6aca53ac2a27b23528b01642e40b8f0c4a9df933 /epan/dissectors/packet-gsm_sim.c
parent28dbab369d5a6790b4657ddf012c9a73526a8789 (diff)
gsm_sim: Fix MANAGE CHANNEL
Use correct offset for P1 and P2 when showing channel operation and channel number. According to TS 102 221 V14.2.0 the Open channel operation is using P2 for channel, and let UICC assign when this is 0. Show P3 as Le. Make P3 optional because it's not present in at least Close channel operation. Change text in Info column to avoid "Channel Channel: x".
Diffstat (limited to 'epan/dissectors/packet-gsm_sim.c')
-rw-r--r--epan/dissectors/packet-gsm_sim.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/epan/dissectors/packet-gsm_sim.c b/epan/dissectors/packet-gsm_sim.c
index dab908b26c..07650a4b40 100644
--- a/epan/dissectors/packet-gsm_sim.c
+++ b/epan/dissectors/packet-gsm_sim.c
@@ -1247,7 +1247,6 @@ static int
dissect_gsm_apdu(guint8 ins, guint8 p1, guint8 p2, guint8 p3, tvbuff_t *tvb,
int offset, packet_info *pinfo, proto_tree *tree, gboolean isSIMtrace)
{
- guint8 g8;
guint16 g16;
tvbuff_t *subtvb;
int i, start_offset;
@@ -1403,21 +1402,18 @@ dissect_gsm_apdu(guint8 ins, guint8 p1, guint8 p2, guint8 p3, tvbuff_t *tvb,
call_dissector_with_data(sub_handle_cap, subtvb, pinfo, tree, GUINT_TO_POINTER(0x14));
break;
case 0x70: /* MANAGE CHANNEL */
- proto_tree_add_item(tree, hf_chan_op, tvb, offset-3, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, hf_chan_op, tvb, offset+P1_OFFS, 1, ENC_BIG_ENDIAN);
col_append_fstr(pinfo->cinfo, COL_INFO, "Operation=%s ",
val_to_str(p1, chan_op_vals, "%02x"));
- switch (p1) {
- case 0x00: /* OPEN */
- /* Logical channels are assigned by the card, so in 'open' they are
- * in the DATA, whereas in close their number is in P2 */
- proto_tree_add_item(tree, hf_chan_nr, tvb, offset+DATA_OFFS, 1, ENC_BIG_ENDIAN);
- g8 = tvb_get_guint8(tvb, offset+DATA_OFFS);
- col_append_fstr(pinfo->cinfo, COL_INFO, "Channel=%d ", g8);
- break;
- case 0x80: /* CLOSE */
- proto_tree_add_item(tree, hf_chan_nr, tvb, offset-2, 1, ENC_BIG_ENDIAN);
- col_append_fstr(pinfo->cinfo, COL_INFO, "Channel=%d ", p2);
- break;
+ proto_tree_add_item(tree, hf_chan_nr, tvb, offset+P2_OFFS, 1, ENC_BIG_ENDIAN);
+ if (p1 == 0) { /* OPEN */
+ proto_tree_add_item(tree, hf_le, tvb, offset+P3_OFFS, 1, ENC_BIG_ENDIAN);
+ }
+ if (p1 == 0 && p2 == 0) {
+ /* Logical channels are assigned by the card when P2 is 0. */
+ col_append_fstr(pinfo->cinfo, COL_INFO, "(assign channel) ");
+ } else {
+ col_append_fstr(pinfo->cinfo, COL_INFO, "(channel: %d) ", p2);
}
break;
case 0x78: /* GET IDENTITY */
@@ -1500,7 +1496,13 @@ dissect_cmd_apdu_tvb(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree
ins = tvb_get_guint8(tvb, offset+1);
p1 = tvb_get_guint8(tvb, offset+2);
p2 = tvb_get_guint8(tvb, offset+3);
- p3 = tvb_get_guint8(tvb, offset+4);
+
+ if (tvb_reported_length_remaining(tvb, offset+3) > 1) {
+ p3 = tvb_get_guint8(tvb, offset+4);
+ } else {
+ /* Parameter 3 not present. */
+ p3 = 0;
+ }
if (tree) {
ti = proto_tree_add_item(tree, proto_gsm_sim, tvb, 0, -1, ENC_NA);