Commit b9a94f00 authored by Jeff Morriss's avatar Jeff Morriss

Add a routine to dissect an UTF8-encoded IMSI (as you'd find in Diameter) and...

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/3742Reviewed-by: default avatarJeff Morriss <jeff.morriss.ws@gmail.com>
parent 9d7784df
This diff is collapsed.
......@@ -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.
*
......
......@@ -42,14 +42,26 @@ int dissect_e212_mcc_mnc_in_address(tvbuff_t *tvb, packet_info *pinfo, proto_tre
* Given a tvbuff, an offset into the tvbuff, and a length that starts
* at that offset, fetch BCD encoded digits from a tvbuff starting from either
* the low or high half byte, formatting the digits according to a digit
* set of 0-9 returning "?" for overdecadic digits create a string in the tree and a corresponding filter
* set of 0-9 returning "?" for overdecadic digits and then
* create a string in the tree and a corresponding filter
*
* Note a tvbuff content of 0xf is considered a 'filler' and will end the
* conversion.
* the wmem allocated string will be returned.
* A wmem allocated string will be returned.
*/
WS_DLL_PUBLIC
const gchar * dissect_e212_imsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int length, gboolean skip_first);
/**
*
* Given a tvbuff, an offset into the tvbuff, and a length that starts
* at that offset, fetch UTF8-encoded digits from the tvbuff and then
* create a string in the tree and a corresponding filter.
*
* The wmem allocated string will be returned.
*/
WS_DLL_PUBLIC
const gchar * dissect_e212_utf8_imsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int length);
#endif /* __PACKET_E212_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment