aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-e212.c
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss.ws@gmail.com>2014-08-19 22:50:17 -0400
committerJeff Morriss <jeff.morriss.ws@gmail.com>2014-08-20 02:55:09 +0000
commitb9a94f009eb0bdecca27caf3e892cc58932c9eab (patch)
treedf111ab01376ae9eaa7add7ff9e996a00d64e31e /epan/dissectors/packet-e212.c
parent9d7784dfeb053cc468290e76eff0efaacf04b9b5 (diff)
Add a routine to dissect an UTF8-encoded IMSI (as you'd find in Diameter) and use it to decode the User-Name AVP of S6a/S6d messages.
Also clean up some white space/formatting. Change-Id: Idf2d4cad2af1826b24de7d59407ffeb36100c19b Reviewed-on: https://code.wireshark.org/review/3742 Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-e212.c')
-rw-r--r--epan/dissectors/packet-e212.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/epan/dissectors/packet-e212.c b/epan/dissectors/packet-e212.c
index c83ae56dea..77a23d7f93 100644
--- a/epan/dissectors/packet-e212.c
+++ b/epan/dissectors/packet-e212.c
@@ -32,6 +32,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/wmem/wmem.h>
+#include <stdlib.h>
#include "packet-e212.h"
#include "expert.h"
@@ -2868,7 +2869,40 @@ dissect_e212_mcc_mnc_high_nibble(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr
return 7;
else
return 5;
+}
+
+static int
+dissect_e212_mcc_mnc_in_utf8_address(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
+{
+ guint16 mcc, mnc;
+ gboolean long_mnc = FALSE;
+
+ mcc = atoi(tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 3, ENC_UTF_8));
+ mnc = atoi(tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 3, 2, ENC_UTF_8));
+
+ /* 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 = atoi(tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 3, 3, ENC_UTF_8));
+ long_mnc = TRUE;
+ }
+ proto_tree_add_uint(tree, hf_E212_mcc, tvb, offset, 3, mcc );
+
+ if (long_mnc)
+ proto_tree_add_uint_format_value(tree, hf_E212_mnc, tvb, offset + 3, 3, mnc,
+ "%s (%03u)",
+ val_to_str_ext_const(mcc * 1000 + mnc, &mcc_mnc_codes_ext, "Unknown1"),
+ mnc);
+ else
+ proto_tree_add_uint_format_value(tree, hf_E212_mnc, tvb, offset + 3, 2, mnc,
+ "%s (%02u)",
+ val_to_str_ext_const(mcc * 1000 + 10 * mnc, &mcc_mnc_codes_ext, "Unknown2"),
+ mnc);
+
+ if (long_mnc)
+ return 6;
+ else
+ return 5;
}
const gchar *
@@ -2895,6 +2929,25 @@ dissect_e212_imsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offse
return imsi_str;
}
+
+const gchar *
+dissect_e212_utf8_imsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int length)
+{
+ proto_item *item;
+ proto_tree *subtree;
+ const gchar *imsi_str;
+
+ /* Fetch the UTF8-encoded IMSI */
+ imsi_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_UTF_8);
+ item = proto_tree_add_string(tree, hf_E212_imsi, tvb, offset, length, imsi_str);
+
+ subtree = proto_item_add_subtree(item, ett_e212_imsi);
+
+ dissect_e212_mcc_mnc_in_utf8_address(tvb, pinfo, subtree, offset);
+
+ return imsi_str;
+}
+
/*
* Register the protocol with Wireshark.
*