diff options
author | etxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-01-04 16:58:07 +0000 |
---|---|---|
committer | etxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-01-04 16:58:07 +0000 |
commit | 8095dd7f15da9e579298e5fcca90c0c4134a5b96 (patch) | |
tree | 2748b9c81000543776c72e907e365d534901c9c5 /epan/dissectors/packet-e212.c | |
parent | f08b8501324054264c1150a8585a09da1afcea60 (diff) |
Introduce dissect_e212_mcc_mnc_ep_str()
Which can be useful to make nice lables like:
+ Serving Network : MCC 311 United States of America, MNC 28
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35360 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-e212.c')
-rw-r--r-- | epan/dissectors/packet-e212.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/epan/dissectors/packet-e212.c b/epan/dissectors/packet-e212.c index 5c7a78a3c5..c6d7909148 100644 --- a/epan/dissectors/packet-e212.c +++ b/epan/dissectors/packet-e212.c @@ -2216,14 +2216,20 @@ static int hf_E212_msin = -1; * | MNC digit 3 | MNC digit 2 | octet x+2 * +---------------+---------------+ */ -int -dissect_e212_mcc_mnc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, gboolean little_endian){ + +/* + * Return MCC MNC in a ep allocated string that can be used in labels. + */ +gchar * +dissect_e212_mcc_mnc_ep_str(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, gboolean little_endian) +{ int start_offset; guint8 octet; guint16 mcc, mnc; guint8 mcc1, mcc2, mcc3, mnc1, mnc2, mnc3; proto_item *item; + gchar *mcc_mnc_str; start_offset = offset; /* Mobile country code MCC */ @@ -2252,24 +2258,47 @@ dissect_e212_mcc_mnc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int of if ((mcc1 > 9) || (mcc2 > 9) || (mcc3 > 9)) expert_add_info_format(pinfo, item, PI_MALFORMED, PI_WARN, "MCC contains non-decimal digits"); - if(mnc3 != 0x0f) + if(mnc3 != 0x0f){ item = proto_tree_add_uint_format(tree, hf_E212_mnc , tvb, start_offset + 1, 2, mnc, "Mobile Network Code (MNC): %s (%03u)", val_to_str_ext_const(mcc * 1000 + mnc, &mcc_mnc_codes_ext, "Unknown"), mnc); - else + /* Preapre a string with the MCC and MNC including the country and Operator if + * known, do NOT print unknown. + */ + mcc_mnc_str = ep_strdup_printf("MCC %u %s, MNC %03u %s", + mcc, + val_to_str_ext_const(mcc,&E212_codes_ext,""), + mnc, + val_to_str_ext_const(mcc * 1000 + mnc, &mcc_mnc_codes_ext, "")); + }else{ item = proto_tree_add_uint_format(tree, hf_E212_mnc , tvb, start_offset + 1, 2, mnc, "Mobile Network Code (MNC): %s (%02u)", val_to_str_ext_const(mcc * 1000 + 10 * mnc, &mcc_mnc_codes_ext, "Unknown"), mnc); + /* Preapre a string with the MCC and MNC including the country and Operator if + * known, do NOT print unknown. + */ + mcc_mnc_str = ep_strdup_printf("MCC %u %s, MNC %02u %s", + mcc, + val_to_str_ext_const(mcc,&E212_codes_ext,""), + mnc, + val_to_str_ext_const(mcc * 1000 + mnc, &mcc_mnc_codes_ext, "")); + } if ((mnc1 > 9) || (mnc2 > 9) || ((mnc3 > 9) && (mnc3 != 0x0f))) expert_add_info_format(pinfo, item, PI_MALFORMED, PI_WARN, "MNC contains non-decimal digits"); offset++; - return offset; + return mcc_mnc_str; } +int +dissect_e212_mcc_mnc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, gboolean little_endian) +{ + dissect_e212_mcc_mnc_ep_str(tvb, pinfo, tree, offset, little_endian); + return offset +3; +} /* * When we want to decode the MCC/MNC pair in an address that is encoded according to E.212 |