aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/dissectors/packet-ansi_a.c125
-rw-r--r--epan/dissectors/packet-gsm_a_common.c64
-rw-r--r--epan/dissectors/packet-gsm_a_common.h6
-rw-r--r--epan/dissectors/packet-gsm_a_dtap.c12
4 files changed, 33 insertions, 174 deletions
diff --git a/epan/dissectors/packet-ansi_a.c b/epan/dissectors/packet-ansi_a.c
index 958530cc5f..cff18d7436 100644
--- a/epan/dissectors/packet-ansi_a.c
+++ b/epan/dissectors/packet-ansi_a.c
@@ -1460,51 +1460,6 @@ static ansi_a_dgt_set_t Dgt_dtmf = {
/* FUNCTIONS */
-/*
- * Unpack BCD input pattern into output ASCII pattern
- *
- * Input Pattern is supplied using the same format as the digits
- *
- * Returns: length of unpacked pattern
- */
-static int
-my_dgt_tbcd_unpack(
- char *out, /* ASCII pattern out */
- guchar *in, /* packed pattern in */
- int num_octs, /* Number of octets to unpack */
- ansi_a_dgt_set_t *dgt /* Digit definitions */
- )
-{
- int cnt = 0;
- unsigned char i;
-
- while (num_octs)
- {
- /*
- * unpack first value in byte
- */
- i = *in++;
- *out++ = dgt->out[i & 0x0f];
- cnt++;
-
- /*
- * unpack second value in byte
- */
- i >>= 4;
-
- if ((num_octs == 1) && (i == 0x0f)) /* odd number bytes - hit filler */
- break;
-
- *out++ = dgt->out[i];
- cnt++;
- num_octs--;
- }
-
- *out = '\0';
-
- return(cnt);
-}
-
static const value_string ansi_a_so_str_vals[] = {
{ 1, "Basic Variable Rate Voice Service (8 kbps)" },
{ 2, "Mobile Station Loopback (8 kbps)" },
@@ -2438,7 +2393,6 @@ static guint8
elem_mid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset, guint len, ansi_a_shared_data_t *data_p)
{
guint8 oct;
- guint8 *poctets;
guint32 value;
guint32 curr_offset;
const gchar *str;
@@ -2453,23 +2407,16 @@ elem_mid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset, gu
proto_tree_add_item(tree, hf_ansi_a_meid_mid_digit_1, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_ansi_a_mid_odd_even_ind, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_ansi_a_mid_type_of_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
-
- a_bigbuf[0] = Dgt_meid.out[(oct & 0xf0) >> 4];
curr_offset++;
- poctets = (guint8 *)tvb_memdup(wmem_packet_scope(), tvb, curr_offset, len - (curr_offset - offset));
+ if (curr_offset - offset >= len) /* Sanity check */
+ return (curr_offset - offset);
- my_dgt_tbcd_unpack(&a_bigbuf[1], poctets, len - (curr_offset - offset),
- &Dgt_meid);
+ str = tvb_bcd_dig_to_wmem_packet_str(tvb, curr_offset, len - (curr_offset - offset), NULL, FALSE);
+ proto_tree_add_string(tree, hf_ansi_a_meid, tvb, curr_offset, len - (curr_offset - offset), str);
+ proto_item_append_text(data_p->elem_item, " - MEID (%s)", str);
curr_offset += len - (curr_offset - offset);
-
- proto_tree_add_string_format_value(tree, hf_ansi_a_meid, tvb, offset + 1, len - 1,
- a_bigbuf,
- "%s",
- a_bigbuf);
-
- proto_item_append_text(data_p->elem_item, " - MEID (%s)", a_bigbuf);
break;
case 2: /* Broadcast Address */
@@ -2542,28 +2489,23 @@ elem_mid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset, gu
proto_tree_add_item(tree, hf_ansi_a_mid_odd_even_ind, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_ansi_a_mid_type_of_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
-
- a_bigbuf[0] = Dgt_msid.out[(oct & 0xf0) >> 4];
curr_offset++;
- poctets = (guint8 *)tvb_memdup(wmem_packet_scope(), tvb, curr_offset, len - (curr_offset - offset));
-
- my_dgt_tbcd_unpack(&a_bigbuf[1], poctets, len - (curr_offset - offset),
- &Dgt_msid);
+ if (curr_offset - offset >= len) /* Sanity check */
+ return (curr_offset - offset);
- proto_tree_add_string_format(tree, hf_ansi_a_imsi, tvb, curr_offset - 1, len - (curr_offset - 1 - offset),
- a_bigbuf,
- "BCD Digits: %s",
- a_bigbuf);
+ str = tvb_bcd_dig_to_wmem_packet_str(tvb, curr_offset, len - (curr_offset - offset), NULL, FALSE);
+ proto_tree_add_string_format(tree, hf_ansi_a_imsi, tvb, curr_offset, len - (curr_offset - offset),
+ str, "BCD Digits: %s", str);
- proto_item_append_text(data_p->elem_item, " - IMSI (%s)", a_bigbuf);
+ proto_item_append_text(data_p->elem_item, " - IMSI (%s)", str);
if (data_p->message_item)
{
- proto_item_append_text(data_p->message_item, " MID=%s", a_bigbuf);
+ proto_item_append_text(data_p->message_item, " MID=%s", str);
}
if (global_a_info_display)
{
- col_append_fstr(pinfo->cinfo, COL_INFO, "MID=%s ", a_bigbuf);
+ col_append_fstr(pinfo->cinfo, COL_INFO, "MID=%s ", str);
}
curr_offset += len - (curr_offset - offset);
@@ -4111,8 +4053,8 @@ static const value_string ansi_a_cld_party_bcd_num_plan_vals[] = {
static guint8
elem_cld_party_bcd_num(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint32 offset, guint len, ansi_a_shared_data_t *data_p)
{
- guint8 *poctets;
guint32 curr_offset;
+ const char *str;
curr_offset = offset;
@@ -4122,12 +4064,13 @@ elem_cld_party_bcd_num(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
curr_offset++;
- poctets = (guint8 *)tvb_memdup(wmem_packet_scope(), tvb, curr_offset, len - (curr_offset - offset));
+ if (curr_offset - offset >= len) /* Sanity check */
+ return (curr_offset - offset);
- my_dgt_tbcd_unpack(a_bigbuf, poctets, len - (curr_offset - offset), &Dgt_tbcd);
- proto_tree_add_string(tree, hf_ansi_a_cld_party_bcd_num, tvb, curr_offset, len - (curr_offset - offset), a_bigbuf);
+ str = tvb_bcd_dig_to_wmem_packet_str(tvb, curr_offset, len - (curr_offset - offset), NULL, FALSE);
+ proto_tree_add_string(tree, hf_ansi_a_cld_party_bcd_num, tvb, curr_offset, len - (curr_offset - offset), str);
- proto_item_append_text(data_p->elem_item, " - (%s)", a_bigbuf);
+ proto_item_append_text(data_p->elem_item, " - (%s)", str);
curr_offset += len - (curr_offset - offset);
@@ -7063,39 +7006,23 @@ elem_bdtmf_trans_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, g
static guint8
elem_dtmf_chars(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint32 offset, guint len, ansi_a_shared_data_t *data_p)
{
- guint8 oct;
guint32 curr_offset;
guint8 packed_len;
- guint8 *poctets;
+ const char *str;
curr_offset = offset;
proto_tree_add_item(tree, hf_ansi_a_bdtmf_chars_num_chars, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
-
- oct = tvb_get_guint8(tvb, curr_offset);
-
curr_offset++;
- packed_len = len - (curr_offset - offset);
-
- poctets = (guint8 *)tvb_memdup(wmem_packet_scope(), tvb, curr_offset, packed_len);
+ if (curr_offset - offset >= len) /* Sanity check */
+ return (curr_offset - offset);
- /*
- * the packed DTMF digits are not "terminated" with a '0xF' for an odd
- * number of digits but the unpack routine expects it
- */
- if (oct & 0x01)
- {
- poctets[packed_len-1] |= 0xF0;
- }
-
- my_dgt_tbcd_unpack(a_bigbuf, poctets, packed_len,
- &Dgt_dtmf);
-
- proto_tree_add_string(tree, hf_ansi_a_bdtmf_chars_digits, tvb, curr_offset, packed_len,
- a_bigbuf);
+ packed_len = len - (curr_offset - offset);
+ str = tvb_bcd_dig_to_wmem_packet_str(tvb, curr_offset, packed_len, NULL, FALSE);
- proto_item_append_text(data_p->elem_item, " - (%s)", a_bigbuf);
+ proto_tree_add_string(tree, hf_ansi_a_bdtmf_chars_digits, tvb, curr_offset, packed_len, str);
+ proto_item_append_text(data_p->elem_item, " - (%s)", str);
curr_offset += packed_len;
diff --git a/epan/dissectors/packet-gsm_a_common.c b/epan/dissectors/packet-gsm_a_common.c
index 30123fb17f..5a0d7e6a0a 100644
--- a/epan/dissectors/packet-gsm_a_common.c
+++ b/epan/dissectors/packet-gsm_a_common.c
@@ -758,9 +758,6 @@ static expert_field ei_gsm_a_no_element_dissector = EI_INIT;
static expert_field ei_gsm_a_format_not_supported = EI_INIT;
static expert_field ei_gsm_a_mobile_identity_type = EI_INIT;
-
-static char a_bigbuf[1024];
-
sccp_assoc_info_t* sccp_assoc;
#define NUM_GSM_COMMON_ELEM (sizeof(gsm_common_elem_strings)/sizeof(value_string))
@@ -1935,51 +1932,6 @@ static dgt_set_t Dgt1_9_bcd = {
/* FUNCTIONS */
/*
- * Unpack BCD input pattern into output ASCII pattern
- *
- * Input Pattern is supplied using the same format as the digits
- *
- * Returns: length of unpacked pattern
- */
-int
-my_dgt_tbcd_unpack(
- char *out, /* ASCII pattern out */
- guchar *in, /* packed pattern in */
- int num_octs, /* Number of octets to unpack */
- dgt_set_t *dgt /* Digit definitions */
- )
-{
- int cnt = 0;
- unsigned char i;
-
- while (num_octs)
- {
- /*
- * unpack first value in byte
- */
- i = *in++;
- *out++ = dgt->out[i & 0x0f];
- cnt++;
-
- /*
- * unpack second value in byte
- */
- i >>= 4;
-
- if (i == 0x0f) /* odd number bytes - hit filler */
- break;
-
- *out++ = dgt->out[i & 0xf]; /* ( '& 0xf' added to keep VS Code Analysis happy ) */
- cnt++;
- num_octs--;
- }
-
- *out = '\0';
-
- return cnt;
-}
-
-/*
* Decode the MCC/MNC from 3 octets in 'octs'
*/
static void
@@ -2183,7 +2135,6 @@ de_mid(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guin
{
guint8 oct;
guint32 curr_offset;
- guint8 *poctets;
guint32 value;
gboolean odd;
const gchar *digit_str;
@@ -2260,25 +2211,22 @@ de_mid(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guin
proto_tree_add_item(tree, hf_gsm_a_odd_even_ind, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_gsm_a_mobile_identity_type, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
-
- /* XXX - dynamically allocate a_bigbuf since the only use is now here */
- a_bigbuf[0] = Dgt1_9_bcd.out[(oct & 0xf0) >> 4];
curr_offset++;
- poctets = (guint8 *)tvb_memdup(wmem_packet_scope(), tvb, curr_offset, len - (curr_offset - offset));
+ if (curr_offset - offset >= len) /* Sanity check */
+ return (curr_offset - offset);
- my_dgt_tbcd_unpack(&a_bigbuf[1], poctets, len - (curr_offset - offset),
- &Dgt1_9_bcd);
+ digit_str = tvb_bcd_dig_to_wmem_packet_str(tvb, curr_offset, len - (curr_offset - offset), NULL, FALSE);
proto_tree_add_string_format(tree,
hf_gsm_a_imei,
tvb, curr_offset, len - (curr_offset - offset),
- a_bigbuf,
+ digit_str,
"BCD Digits: %s",
- a_bigbuf);
+ digit_str);
if (add_string)
- g_snprintf(add_string, string_len, " - IMEI (%s)", a_bigbuf);
+ g_snprintf(add_string, string_len, " - IMEI (%s)", digit_str);
curr_offset += len - (curr_offset - offset);
break;
diff --git a/epan/dissectors/packet-gsm_a_common.h b/epan/dissectors/packet-gsm_a_common.h
index 1cdea3e351..29a4def89d 100644
--- a/epan/dissectors/packet-gsm_a_common.h
+++ b/epan/dissectors/packet-gsm_a_common.h
@@ -71,12 +71,6 @@
/* PROTOTYPES/FORWARDS */
typedef guint16 (*elem_fcn)(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string, int string_len);
typedef void (*msg_fcn)(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len);
-int my_dgt_tbcd_unpack(
- char *out, /* ASCII pattern out */
- guchar *in, /* packed pattern in */
- int num_octs, /* Number of octets to unpack */
- dgt_set_t *dgt /* Digit definitions */
- );
/* globals needed as a result of spltting the packet-gsm_a.c into several files
* until further restructuring can take place to make them more modular
diff --git a/epan/dissectors/packet-gsm_a_dtap.c b/epan/dissectors/packet-gsm_a_dtap.c
index 43e6cb9120..00da104fb1 100644
--- a/epan/dissectors/packet-gsm_a_dtap.c
+++ b/epan/dissectors/packet-gsm_a_dtap.c
@@ -2243,7 +2243,6 @@ const value_string gsm_a_dtap_screening_ind_values[] = {
static guint16
de_bcd_num(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, int header_field, gboolean *address_extracted)
{
- guint8 *poctets;
guint8 extension;
guint32 curr_offset, num_string_len;
proto_item *item;
@@ -2270,19 +2269,10 @@ de_bcd_num(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset,
NO_MORE_DATA_CHECK(len);
num_string_len = len - (curr_offset - offset);
- poctets = (guint8 *)tvb_memdup(wmem_packet_scope(), tvb, curr_offset, num_string_len);
-
*address_extracted = TRUE;
- my_dgt_tbcd_unpack(a_bigbuf, poctets, num_string_len,
- &Dgt_mbcd);
digit_str = tvb_bcd_dig_to_wmem_packet_str(tvb, curr_offset, num_string_len, NULL, FALSE);
- proto_tree_add_string(tree, header_field, tvb, curr_offset, num_string_len, digit_str);
- item = proto_tree_add_string_format(tree, header_field,
- tvb, curr_offset, num_string_len,
- a_bigbuf,
- "BCD Digits: %s",
- a_bigbuf);
+ item = proto_tree_add_string(tree, header_field, tvb, curr_offset, num_string_len, digit_str);
/* Check for overdicadic digits, we used the standard digit map from tvbuff.c
* 0 1 2 3 4 5 6 7 8 9 a b c d e f