aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-e212.c
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2011-01-04 16:58:07 +0000
committerAnders Broman <anders.broman@ericsson.com>2011-01-04 16:58:07 +0000
commit022b418e40d4780dc9d36437541ca2d905c695e6 (patch)
tree2748b9c81000543776c72e907e365d534901c9c5 /epan/dissectors/packet-e212.c
parent5d7f70bf410349857cedb4b3fdcc9ce22158245c (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 svn path=/trunk/; revision=35360
Diffstat (limited to 'epan/dissectors/packet-e212.c')
-rw-r--r--epan/dissectors/packet-e212.c39
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