diff options
author | AndersBroman <a.broman@bredband.net> | 2014-08-19 23:00:57 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-08-19 21:18:17 +0000 |
commit | 7146999963e0e8baadf5cbe339f71836c43749bc (patch) | |
tree | 0e8163ebc05e4658e808fe274288e4aa7f7ff3f6 /epan/dissectors/packet-e212.c | |
parent | e5e8828d1f0a14ea3bee2b9692e07b8a7078965d (diff) |
Use dissect_e212_imsi() to dissect IMSI
Fix dissection when MCC starts in the high nibble.
Replace deprecated APIs
Change-Id: Ic08a1db9ee7ebb535bf7914191807304e9f88981
Reviewed-on: https://code.wireshark.org/review/3736
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-e212.c')
-rw-r--r-- | epan/dissectors/packet-e212.c | 94 |
1 files changed, 93 insertions, 1 deletions
diff --git a/epan/dissectors/packet-e212.c b/epan/dissectors/packet-e212.c index 30a07aa52a..c23027d362 100644 --- a/epan/dissectors/packet-e212.c +++ b/epan/dissectors/packet-e212.c @@ -2783,6 +2783,94 @@ dissect_e212_mcc_mnc_in_address(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t return 5; } +/* + * MNC of length 2: + * + * 8 7 6 5 4 3 2 1 + * +---+---+---+---+---+---+---+---+ + * | MCC digit 1 | Other data | octet x + * +---------------+---------------+ + * | MNC digit 1 | MCC digit 2 | octet x+1 + * +---------------+---------------+ + * | MNC digit 3 | MNC digit 2 | octet x+2 + * +---------------+---------------+ + * + * MNC of length 3: + * + * 8 7 6 5 4 3 2 1 + * +---+---+---+---+---+---+---+---+ + * | MCC digit 1 | Other data | octet x + * +---------------+---------------+ + * | MCC digit 3 | MCC digit 2 | octet x+1 + * +---------------+---------------+ + * | MNC digit 2 | MNC digit 1 | octet x+2 + * +---------------+---------------+ + * | ..... | MNC digit 3 | octet x+3 + * +---------------+---------------+ + */ +static int +dissect_e212_mcc_mnc_high_nibble(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset) +{ + + guint32 start_offset; + guint8 octet; + guint16 mcc, mnc; + guint8 mcc1, mcc2, mcc3, mnc1, mnc2, mnc3; + proto_item *item; + gboolean long_mnc; + + long_mnc = FALSE; + start_offset = offset; + + /* MCC digits 1 */ + octet = tvb_get_guint8(tvb,offset); + mcc1 = octet >> 4; + offset++; + + /* MCC digits 1 and 2 */ + octet = tvb_get_guint8(tvb,offset); + mcc2 = octet & 0x0f; + mcc3 = octet >> 4; + offset++; + + /* MNC digit 1 and MNC digit 2 */ + octet = tvb_get_guint8(tvb,offset); + mnc1 = octet & 0x0f; + mnc2 = octet >> 4; + offset++; + + /* MNC digits 3 */ + octet = tvb_get_guint8(tvb,offset); + mnc3 = octet & 0x0f; + + mcc = 100 * mcc1 + 10 * mcc2 + mcc3; + mnc = 10 * mnc1 + mnc2; + + /* Try to match the MCC and 2 digits MNC with an entry in our list of operators */ + if (!try_val_to_str_ext(mcc * 1000 + 10 * mnc, &mcc_mnc_codes_ext)) { + mnc = 10 * mnc + mnc3; + long_mnc = TRUE; + } + + item = proto_tree_add_uint(tree, hf_E212_mcc , tvb, start_offset, 2, mcc ); + + if (long_mnc) + item = proto_tree_add_uint_format_value(tree, hf_E212_mnc , tvb, start_offset + 1, 2, mnc, + "%s (%03u)", + val_to_str_ext_const(mcc * 1000 + mnc, &mcc_mnc_codes_ext, "Unknown"), + mnc); + else + item = proto_tree_add_uint_format_value(tree, hf_E212_mnc , tvb, start_offset + 1, 2, mnc, + "%s (%02u)", + val_to_str_ext_const(mcc * 1000 + 10 * mnc, &mcc_mnc_codes_ext, "Unknown"), + mnc); + + if (long_mnc) + return 7; + else + return 5; + +} const gchar * dissect_e212_imsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int length, gboolean skip_first) { @@ -2799,7 +2887,11 @@ dissect_e212_imsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offse subtree = proto_item_add_subtree(item, ett_e212_imsi); - dissect_e212_mcc_mnc_in_address(tvb, pinfo, subtree, offset); + if(skip_first){ + dissect_e212_mcc_mnc_high_nibble(tvb, pinfo, subtree, offset); + }else{ + dissect_e212_mcc_mnc_in_address(tvb, pinfo, subtree, offset); + } return imsi_str; } |