summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ber.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:53 +0000
commita86c5f7cae7ec9a3398300555a0b644689d946a1 (patch)
tree39fe4b107c71174fd1e8a8ceb9a4d2aa14116248 /epan/dissectors/packet-ber.c
parentReleasing progress-linux version 4.2.6-1~progress7.99u1. (diff)
downloadwireshark-a86c5f7cae7ec9a3398300555a0b644689d946a1.tar.xz
wireshark-a86c5f7cae7ec9a3398300555a0b644689d946a1.zip
Merging upstream version 4.4.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'epan/dissectors/packet-ber.c')
-rw-r--r--epan/dissectors/packet-ber.c1022
1 files changed, 526 insertions, 496 deletions
diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c
index 5d01d055..b6715b03 100644
--- a/epan/dissectors/packet-ber.c
+++ b/epan/dissectors/packet-ber.c
@@ -52,6 +52,7 @@
#include <epan/expert.h>
#include <epan/uat.h>
#include <epan/decode_as.h>
+#include <epan/tfs.h>
#include <wiretap/wtap.h>
#ifdef DEBUG_BER
#include <epan/ws_printf.h>
@@ -71,137 +72,137 @@
void proto_register_ber(void);
void proto_reg_handoff_ber(void);
-static gint proto_ber = -1;
-static gint hf_ber_id_class = -1;
-static gint hf_ber_id_pc = -1;
-static gint hf_ber_id_uni_tag = -1;
-static gint hf_ber_id_uni_tag_ext = -1;
-static gint hf_ber_id_tag = -1;
-static gint hf_ber_id_tag_ext = -1;
-static gint hf_ber_length = -1;
-static gint hf_ber_length_octets = -1;
-static gint hf_ber_bitstring_padding = -1;
-static gint hf_ber_bitstring_empty = -1;
-static gint hf_ber_unknown_OID = -1;
-static gint hf_ber_unknown_relative_OID = -1;
-static gint hf_ber_unknown_BOOLEAN = -1;
-static gint hf_ber_unknown_OCTETSTRING = -1;
-static gint hf_ber_unknown_BER_OCTETSTRING = -1;
-static gint hf_ber_unknown_BER_primitive = -1;
-static gint hf_ber_unknown_GraphicString = -1;
-static gint hf_ber_unknown_NumericString = -1;
-static gint hf_ber_unknown_PrintableString = -1;
-static gint hf_ber_unknown_TeletexString = -1;
-static gint hf_ber_unknown_VisibleString = -1;
-static gint hf_ber_unknown_GeneralString = -1;
-static gint hf_ber_unknown_UniversalString = -1;
-static gint hf_ber_unknown_BMPString = -1;
-static gint hf_ber_unknown_IA5String = -1;
-static gint hf_ber_unknown_UTCTime = -1;
-static gint hf_ber_unknown_UTF8String = -1;
-static gint hf_ber_unknown_GeneralizedTime = -1;
-static gint hf_ber_unknown_INTEGER = -1;
-static gint hf_ber_unknown_REAL = -1;
-static gint hf_ber_unknown_BITSTRING = -1;
-static gint hf_ber_unknown_ENUMERATED = -1;
-static gint hf_ber_direct_reference = -1; /* OBJECT_IDENTIFIER */
-static gint hf_ber_indirect_reference = -1; /* INTEGER */
-static gint hf_ber_data_value_descriptor = -1; /* ObjectDescriptor */
-static gint hf_ber_encoding = -1; /* T_encoding */
-static gint hf_ber_single_ASN1_type = -1; /* T_single_ASN1_type */
-static gint hf_ber_octet_aligned = -1; /* OCTET_STRING */
-static gint hf_ber_arbitrary = -1; /* BIT_STRING */
-static gint hf_ber_extra_data = -1;
-static gint hf_ber_encoding_boiler_plate = -1;
+static int proto_ber;
+static int hf_ber_id_class;
+static int hf_ber_id_pc;
+static int hf_ber_id_uni_tag;
+static int hf_ber_id_uni_tag_ext;
+static int hf_ber_id_tag;
+static int hf_ber_id_tag_ext;
+static int hf_ber_length;
+static int hf_ber_length_octets;
+static int hf_ber_bitstring_padding;
+static int hf_ber_bitstring_empty;
+static int hf_ber_unknown_OID;
+static int hf_ber_unknown_relative_OID;
+static int hf_ber_unknown_BOOLEAN;
+static int hf_ber_unknown_OCTETSTRING;
+static int hf_ber_unknown_BER_OCTETSTRING;
+static int hf_ber_unknown_BER_primitive;
+static int hf_ber_unknown_GraphicString;
+static int hf_ber_unknown_NumericString;
+static int hf_ber_unknown_PrintableString;
+static int hf_ber_unknown_TeletexString;
+static int hf_ber_unknown_VisibleString;
+static int hf_ber_unknown_GeneralString;
+static int hf_ber_unknown_UniversalString;
+static int hf_ber_unknown_BMPString;
+static int hf_ber_unknown_IA5String;
+static int hf_ber_unknown_UTCTime;
+static int hf_ber_unknown_UTF8String;
+static int hf_ber_unknown_GeneralizedTime;
+static int hf_ber_unknown_INTEGER;
+static int hf_ber_unknown_REAL;
+static int hf_ber_unknown_BITSTRING;
+static int hf_ber_unknown_ENUMERATED;
+static int hf_ber_direct_reference; /* OBJECT_IDENTIFIER */
+static int hf_ber_indirect_reference; /* INTEGER */
+static int hf_ber_data_value_descriptor; /* ObjectDescriptor */
+static int hf_ber_encoding; /* T_encoding */
+static int hf_ber_single_ASN1_type; /* T_single_ASN1_type */
+static int hf_ber_octet_aligned; /* OCTET_STRING */
+static int hf_ber_arbitrary; /* BIT_STRING */
+static int hf_ber_extra_data;
+static int hf_ber_encoding_boiler_plate;
/* Generated from convert_proto_tree_add_text.pl */
-static int hf_ber_seq_of_eoc = -1;
-static int hf_ber_64bit_uint_as_bytes = -1;
-static int hf_ber_choice_eoc = -1;
-static int hf_ber_seq_field_eoc = -1;
-static int hf_ber_seq_eoc = -1;
-static int hf_ber_set_field_eoc = -1;
-static int hf_ber_set_eoc = -1;
-static int hf_ber_null_tag = -1;
-static int hf_ber_unknown_octetstring = -1;
-static int hf_ber_unknown_data = -1;
-
-static int hf_ber_fragments = -1;
-static int hf_ber_fragment = -1;
-static int hf_ber_fragment_overlap = -1;
-static int hf_ber_fragment_overlap_conflicts = -1;
-static int hf_ber_fragment_multiple_tails = -1;
-static int hf_ber_fragment_too_long_fragment = -1;
-static int hf_ber_fragment_error = -1;
-static int hf_ber_fragment_count = -1;
-static int hf_ber_reassembled_in = -1;
-static int hf_ber_reassembled_length = -1;
-
-static gint ett_ber_octet_string = -1;
-static gint ett_ber_reassembled_octet_string = -1;
-static gint ett_ber_primitive = -1;
-static gint ett_ber_unknown = -1;
-static gint ett_ber_SEQUENCE = -1;
-static gint ett_ber_EXTERNAL = -1;
-static gint ett_ber_T_encoding = -1;
-static gint ett_ber_fragment = -1;
-static gint ett_ber_fragments = -1;
-
-static expert_field ei_ber_size_constraint_string = EI_INIT;
-static expert_field ei_ber_size_constraint_value = EI_INIT;
-static expert_field ei_ber_size_constraint_items = EI_INIT;
-static expert_field ei_ber_sequence_field_wrong = EI_INIT;
-static expert_field ei_ber_expected_octet_string = EI_INIT;
-static expert_field ei_ber_expected_null = EI_INIT;
-static expert_field ei_ber_expected_null_zero_length = EI_INIT;
-static expert_field ei_ber_expected_sequence = EI_INIT;
-static expert_field ei_ber_expected_set = EI_INIT;
-static expert_field ei_ber_expected_string = EI_INIT;
-static expert_field ei_ber_expected_object_identifier = EI_INIT;
-static expert_field ei_ber_expected_generalized_time = EI_INIT;
-static expert_field ei_ber_expected_utc_time = EI_INIT;
-static expert_field ei_ber_expected_bitstring = EI_INIT;
-static expert_field ei_ber_error_length = EI_INIT;
-static expert_field ei_ber_wrong_tag_in_tagged_type = EI_INIT;
-static expert_field ei_ber_universal_tag_unknown = EI_INIT;
-static expert_field ei_ber_no_oid = EI_INIT;
-static expert_field ei_ber_syntax_not_implemented = EI_INIT;
-static expert_field ei_ber_oid_not_implemented = EI_INIT;
-static expert_field ei_ber_value_too_many_bytes = EI_INIT;
-static expert_field ei_ber_unknown_field_sequence = EI_INIT;
-static expert_field ei_ber_unknown_field_set = EI_INIT;
-static expert_field ei_ber_missing_field_set = EI_INIT;
-static expert_field ei_ber_empty_choice = EI_INIT;
-static expert_field ei_ber_choice_not_found = EI_INIT;
-static expert_field ei_ber_bits_unknown = EI_INIT;
-static expert_field ei_ber_bits_set_padded = EI_INIT;
-static expert_field ei_ber_illegal_padding = EI_INIT;
-static expert_field ei_ber_invalid_format_generalized_time = EI_INIT;
-static expert_field ei_ber_invalid_format_utctime = EI_INIT;
-static expert_field ei_hf_field_not_integer_type = EI_INIT;
-static expert_field ei_ber_constr_bitstr = EI_INIT;
-static expert_field ei_ber_real_not_primitive = EI_INIT;
+static int hf_ber_seq_of_eoc;
+static int hf_ber_64bit_uint_as_bytes;
+static int hf_ber_choice_eoc;
+static int hf_ber_seq_field_eoc;
+static int hf_ber_seq_eoc;
+static int hf_ber_set_field_eoc;
+static int hf_ber_set_eoc;
+static int hf_ber_null_tag;
+static int hf_ber_unknown_octetstring;
+static int hf_ber_unknown_data;
+
+static int hf_ber_fragments;
+static int hf_ber_fragment;
+static int hf_ber_fragment_overlap;
+static int hf_ber_fragment_overlap_conflicts;
+static int hf_ber_fragment_multiple_tails;
+static int hf_ber_fragment_too_long_fragment;
+static int hf_ber_fragment_error;
+static int hf_ber_fragment_count;
+static int hf_ber_reassembled_in;
+static int hf_ber_reassembled_length;
+
+static int ett_ber_octet_string;
+static int ett_ber_reassembled_octet_string;
+static int ett_ber_primitive;
+static int ett_ber_unknown;
+static int ett_ber_SEQUENCE;
+static int ett_ber_EXTERNAL;
+static int ett_ber_T_encoding;
+static int ett_ber_fragment;
+static int ett_ber_fragments;
+
+static expert_field ei_ber_size_constraint_string;
+static expert_field ei_ber_size_constraint_value;
+static expert_field ei_ber_size_constraint_items;
+static expert_field ei_ber_sequence_field_wrong;
+static expert_field ei_ber_expected_octet_string;
+static expert_field ei_ber_expected_null;
+static expert_field ei_ber_expected_null_zero_length;
+static expert_field ei_ber_expected_sequence;
+static expert_field ei_ber_expected_set;
+static expert_field ei_ber_expected_string;
+static expert_field ei_ber_expected_object_identifier;
+static expert_field ei_ber_expected_generalized_time;
+static expert_field ei_ber_expected_utc_time;
+static expert_field ei_ber_expected_bitstring;
+static expert_field ei_ber_error_length;
+static expert_field ei_ber_wrong_tag_in_tagged_type;
+static expert_field ei_ber_universal_tag_unknown;
+static expert_field ei_ber_no_oid;
+static expert_field ei_ber_syntax_not_implemented;
+static expert_field ei_ber_oid_not_implemented;
+static expert_field ei_ber_value_too_many_bytes;
+static expert_field ei_ber_unknown_field_sequence;
+static expert_field ei_ber_unknown_field_set;
+static expert_field ei_ber_missing_field_set;
+static expert_field ei_ber_empty_choice;
+static expert_field ei_ber_choice_not_found;
+static expert_field ei_ber_bits_unknown;
+static expert_field ei_ber_bits_set_padded;
+static expert_field ei_ber_illegal_padding;
+static expert_field ei_ber_invalid_format_generalized_time;
+static expert_field ei_ber_invalid_format_utctime;
+static expert_field ei_hf_field_not_integer_type;
+static expert_field ei_ber_constr_bitstr;
+static expert_field ei_ber_real_not_primitive;
static dissector_handle_t ber_handle;
static dissector_handle_t ber_file_handle;
-static gboolean show_internal_ber_fields = FALSE;
-static gboolean decode_octetstring_as_ber = FALSE;
-static gboolean decode_primitive_as_ber = FALSE;
-static gboolean decode_unexpected = FALSE;
-static gboolean decode_warning_leading_zero_bits = FALSE;
+static bool show_internal_ber_fields;
+static bool decode_octetstring_as_ber;
+static bool decode_primitive_as_ber;
+static bool decode_unexpected;
+static bool decode_warning_leading_zero_bits;
-static gchar *decode_as_syntax = NULL;
+static char *decode_as_syntax;
-static dissector_table_t ber_oid_dissector_table = NULL;
-static dissector_table_t ber_syntax_dissector_table = NULL;
+static dissector_table_t ber_oid_dissector_table;
+static dissector_table_t ber_syntax_dissector_table;
-static GHashTable *syntax_table = NULL;
+static GHashTable *syntax_table;
-static gint8 last_class;
+static int8_t last_class;
static bool last_pc;
-static gint32 last_tag;
-static guint32 last_length;
+static int32_t last_tag;
+static uint32_t last_length;
static tvbuff_t *last_length_tvb;
static int last_length_offset;
static int last_length_len;
@@ -277,7 +278,7 @@ static const true_false_string ber_real_decimal_vals = {
typedef struct _da_data {
GHFunc func;
- gpointer user_data;
+ void *user_data;
} da_data;
typedef struct _oid_user_t {
@@ -291,7 +292,7 @@ UAT_CSTRING_CB_DEF(oid_users, name, oid_user_t)
UAT_VS_CSTRING_DEF(oid_users, syntax, oid_user_t, 0, "")
static oid_user_t *oid_users;
-static guint num_oid_users;
+static unsigned num_oid_users;
#define MAX_SYNTAX_NAMES 128
/* Define non_const_value_string as a hack to prevent chackAPIs.pl from complaining */
@@ -373,12 +374,12 @@ static uat_field_t users_flds[] = {
};
-static void ber_prompt(packet_info *pinfo _U_, gchar* result)
+static void ber_prompt(packet_info *pinfo _U_, char* result)
{
snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Decode ASN.1 file as");
}
-static gpointer ber_value(packet_info *pinfo _U_)
+static void *ber_value(packet_info *pinfo _U_)
{
/* Not used */
return NULL;
@@ -387,17 +388,18 @@ static gpointer ber_value(packet_info *pinfo _U_)
struct ber_decode_as_populate
{
decode_as_add_to_list_func add_to_list;
- gpointer ui_element;
+ void *ui_element;
};
static void
-decode_ber_add_to_list(gpointer key, gpointer value, gpointer user_data)
+decode_ber_add_to_list(void *key, void *value, void *user_data)
{
struct ber_decode_as_populate* populate = (struct ber_decode_as_populate*)user_data;
- populate->add_to_list("ASN.1", (gchar *)key, value, populate->ui_element);
+ dtbl_entry_t *dtbl_entry = (dtbl_entry_t*)value;
+ populate->add_to_list("ASN.1", (char *)key, dtbl_entry_get_initial_handle(dtbl_entry), populate->ui_element);
}
-static void ber_populate_list(const gchar *table_name _U_, decode_as_add_to_list_func add_to_list, gpointer ui_element)
+static void ber_populate_list(const char *table_name _U_, decode_as_add_to_list_func add_to_list, void *ui_element)
{
struct ber_decode_as_populate populate;
@@ -407,18 +409,18 @@ static void ber_populate_list(const gchar *table_name _U_, decode_as_add_to_list
ber_decode_as_foreach(decode_ber_add_to_list, &populate);
}
-static gboolean ber_decode_as_reset(const char *name _U_, gconstpointer pattern _U_)
+static bool ber_decode_as_reset(const char *name _U_, const void *pattern _U_)
{
g_free(decode_as_syntax);
decode_as_syntax = NULL;
- return FALSE;
+ return false;
}
-static gboolean ber_decode_as_change(const char *name _U_, gconstpointer pattern _U_, gconstpointer handle _U_, const gchar* list_name)
+static bool ber_decode_as_change(const char *name _U_, const void *pattern _U_, const void *handle _U_, const char* list_name)
{
g_free(decode_as_syntax);
decode_as_syntax = g_strdup(list_name);
- return FALSE;
+ return false;
}
int
@@ -450,7 +452,7 @@ register_ber_syntax_dissector(const char *syntax, int proto, dissector_t dissect
{
dissector_handle_t dissector_handle;
- dissector_handle = create_dissector_handle(dissector, proto);
+ dissector_handle = create_dissector_handle_with_name_and_description(dissector, proto, NULL, syntax);
dissector_add_string("ber.syntax", syntax, dissector_handle);
}
@@ -460,7 +462,7 @@ register_ber_oid_syntax(const char *oid, const char *name, const char *syntax)
{
if (syntax && *syntax)
- g_hash_table_insert(syntax_table, (gpointer)g_strdup(oid), (gpointer)g_strdup(syntax));
+ g_hash_table_insert(syntax_table, (void *)g_strdup(oid), (void *)g_strdup(syntax));
if (name && *name)
register_ber_oid_name(oid, name);
@@ -474,13 +476,13 @@ register_ber_oid_name(const char *oid, const char *name)
}
static void
-ber_add_syntax_name(gpointer key, gpointer value _U_, gpointer user_data)
+ber_add_syntax_name(void *key, void *value _U_, void *user_data)
{
- guint *i = (guint*)user_data;
+ unsigned *i = (unsigned*)user_data;
if (*i < MAX_SYNTAX_NAMES) {
syntax_names[*i].value = *i;
- syntax_names[*i].strptr = (const gchar*)key;
+ syntax_names[*i].strptr = (const char*)key;
(*i)++;
}
@@ -488,7 +490,7 @@ ber_add_syntax_name(gpointer key, gpointer value _U_, gpointer user_data)
}
static void
-ber_decode_as_dt(const gchar *table_name _U_, ftenum_t selector_type _U_, gpointer key, gpointer value, gpointer user_data)
+ber_decode_as_dt(const char *table_name _U_, ftenum_t selector_type _U_, void *key, void *value, void *user_data)
{
da_data *decode_as_data;
@@ -498,7 +500,7 @@ ber_decode_as_dt(const gchar *table_name _U_, ftenum_t selector_type _U_, gpoint
}
void
-ber_decode_as_foreach(GHFunc func, gpointer user_data)
+ber_decode_as_foreach(GHFunc func, void *user_data)
{
da_data decode_as_data;
@@ -510,7 +512,7 @@ ber_decode_as_foreach(GHFunc func, gpointer user_data)
}
/* Get oid syntax from hash table to get translation in proto dissection(packet-per.c) */
-static const gchar *
+static const char *
get_ber_oid_syntax(const char *oid)
{
return (const char *)g_hash_table_lookup(syntax_table, oid);
@@ -519,21 +521,21 @@ get_ber_oid_syntax(const char *oid)
static void
ber_update_oids(void)
{
- guint i;
+ unsigned i;
for (i = 0; i < num_oid_users; i++)
register_ber_oid_syntax(oid_users[i].oid, oid_users[i].name, oid_users[i].syntax);
}
static void
-ber_check_length (guint32 length, gint32 min_len, gint32 max_len, asn1_ctx_t *actx, proto_item *item, bool bit)
+ber_check_length (uint32_t length, int32_t min_len, int32_t max_len, asn1_ctx_t *actx, proto_item *item, bool bit)
{
- if ((min_len != -1) && (length < (guint32)min_len)) {
+ if ((min_len != -1) && (length < (uint32_t)min_len)) {
expert_add_info_format(
actx->pinfo, item, &ei_ber_size_constraint_string,
"Size constraint: %sstring too short: %d (%d .. %d)",
bit ? "bit " : "", length, min_len, max_len);
- } else if ((max_len != -1) && (length > (guint32)max_len)) {
+ } else if ((max_len != -1) && (length > (uint32_t)max_len)) {
expert_add_info_format(
actx->pinfo, item, &ei_ber_size_constraint_string,
"Size constraint: %sstring too long: %d (%d .. %d)",
@@ -542,7 +544,7 @@ ber_check_length (guint32 length, gint32 min_len, gint32 max_len, asn1_ctx_t *ac
}
static void
-ber_check_value64 (gint64 value, gint64 min_len, gint64 max_len, asn1_ctx_t *actx, proto_item *item)
+ber_check_value64 (int64_t value, int64_t min_len, int64_t max_len, asn1_ctx_t *actx, proto_item *item)
{
if ((min_len != -1) && (value < min_len)) {
expert_add_info_format(
@@ -558,14 +560,14 @@ ber_check_value64 (gint64 value, gint64 min_len, gint64 max_len, asn1_ctx_t *act
}
static void
-ber_check_value (guint32 value, gint32 min_len, gint32 max_len, asn1_ctx_t *actx, proto_item *item)
+ber_check_value (uint32_t value, int32_t min_len, int32_t max_len, asn1_ctx_t *actx, proto_item *item)
{
- if ((min_len != -1) && (value < (guint32)min_len)) {
+ if ((min_len != -1) && (value < (uint32_t)min_len)) {
expert_add_info_format(
actx->pinfo, item, &ei_ber_size_constraint_value,
"Size constraint: value too small: %d (%d .. %d)",
value, min_len, max_len);
- } else if ((max_len != -1) && (value > (guint32)max_len)) {
+ } else if ((max_len != -1) && (value > (uint32_t)max_len)) {
expert_add_info_format(
actx->pinfo, item, &ei_ber_size_constraint_value,
"Size constraint: value too big: %d (%d .. %d)",
@@ -574,7 +576,7 @@ ber_check_value (guint32 value, gint32 min_len, gint32 max_len, asn1_ctx_t *actx
}
static void
-ber_check_items (int cnt, gint32 min_len, gint32 max_len, asn1_ctx_t *actx, proto_item *item)
+ber_check_items (int cnt, int32_t min_len, int32_t max_len, asn1_ctx_t *actx, proto_item *item)
{
if ((min_len != -1) && (cnt < min_len)) {
expert_add_info_format(
@@ -597,36 +599,36 @@ ber_check_items (int cnt, gint32 min_len, gint32 max_len, asn1_ctx_t *actx, prot
* unreassembled tvbuff.
*/
static tvbuff_t *
-ber_tvb_new_subset_length(tvbuff_t *tvb, const gint backing_offset, const gint backing_length)
+ber_tvb_new_subset_length(tvbuff_t *tvb, const int backing_offset, const int backing_length)
{
- gint length_remaining;
+ int length_remaining;
length_remaining = tvb_reported_length_remaining(tvb, backing_offset);
return tvb_new_subset_length(tvb, backing_offset, (length_remaining > backing_length) ? backing_length : length_remaining);
}
int
-dissect_ber_tagged_type(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, gint8 tag_cls, gint32 tag_tag, bool tag_impl, ber_type_fn type)
+dissect_ber_tagged_type(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, int8_t tag_cls, int32_t tag_tag, bool tag_impl, ber_type_fn type)
{
- gint8 tmp_cls;
- gint32 tmp_tag;
+ int8_t tmp_cls;
+ int32_t tmp_tag;
int identifier_offset;
int identifier_len;
- guint32 tmp_len;
+ uint32_t tmp_len;
tvbuff_t *next_tvb = tvb;
#ifdef DEBUG_BER
{
const char *name;
header_field_info *hfinfo;
-if (hf_id >= 0) {
+if (hf_id > 0) {
hfinfo = proto_registrar_get_nth(hf_id);
name = hfinfo->name;
} else {
name = "unnamed";
}
if (tvb_reported_length_remaining(tvb, offset) > 3) {
-proto_tree_add_debug_text(tree, "dissect_ber_tagged_type(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2));
+proto_tree_add_debug_text(tree, "dissect_ber_tagged_type(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_uint8(tvb, offset), tvb_get_uint8(tvb, offset+1), tvb_get_uint8(tvb, offset+2));
} else {
proto_tree_add_debug_text(tree, "dissect_ber_tagged_type(%s) entered\n", name);
}
@@ -673,8 +675,8 @@ proto_tree_add_debug_text(tree, "dissect_ber_tagged_type(%s) entered\n", name);
*/
static proto_item *
ber_add_bad_length_error(packet_info *pinfo, proto_tree *tree,
- const char *name, tvbuff_t *tvb, const gint start,
- gint length)
+ const char *name, tvbuff_t *tvb, const int start,
+ int length)
{
proto_item *ti;
@@ -691,7 +693,7 @@ ber_add_bad_length_error(packet_info *pinfo, proto_tree *tree,
static void
ber_add_large_length_error(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb,
int offset, int length, tvbuff_t *len_tvb,
- const gint len_offset, const guint32 len_length)
+ const int len_offset, const uint32_t len_length)
{
proto_tree_add_expert_format(
tree, pinfo, &ei_ber_error_length, len_tvb, len_offset, len_length,
@@ -719,12 +721,13 @@ ber_add_large_length_error(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb,
*/
static proto_item *
ber_proto_tree_add_item(packet_info *pinfo, proto_tree *tree,
- const int hfindex, tvbuff_t *tvb, const gint start,
- gint length, const guint encoding)
+ const int hfindex, tvbuff_t *tvb, const int start,
+ int length, const unsigned encoding)
{
header_field_info *hfinfo;
+ proto_item* ti;
- hfinfo = proto_registrar_get_nth((guint)hfindex);
+ hfinfo = proto_registrar_get_nth((unsigned)hfindex);
if (hfinfo != NULL) {
switch (hfinfo->type) {
@@ -791,7 +794,13 @@ ber_proto_tree_add_item(packet_info *pinfo, proto_tree *tree,
return ber_add_bad_length_error(pinfo, tree,
hfinfo->name, tvb, start, length);
break;
-
+ case FT_STRING:
+ if (length == 0) {
+ ti = proto_tree_add_item(tree, hfindex, tvb, start, length, encoding);
+ proto_item_append_text(ti, "<MISSING>");
+ return ti;
+ }
+ break;
default:
break;
}
@@ -800,22 +809,23 @@ ber_proto_tree_add_item(packet_info *pinfo, proto_tree *tree,
}
static int
-try_dissect_unknown_ber(packet_info *pinfo, tvbuff_t *tvb, volatile int offset, proto_tree *tree, gint nest_level)
+// NOLINTNEXTLINE(misc-no-recursion)
+try_dissect_unknown_ber(packet_info *pinfo, tvbuff_t *tvb, volatile int offset, proto_tree *tree, int nest_level)
{
int start_offset;
- gint8 ber_class;
- bool pc, ind;
- gint32 tag;
+ int8_t ber_class;
+ bool pc, ind;
+ int32_t tag;
int identifier_offset;
int identifier_len;
- guint32 len;
+ uint32_t len;
int len_offset;
int len_len;
int hdr_len;
proto_item *item = NULL;
proto_tree *next_tree = NULL;
- guint8 c;
- guint32 i;
+ uint8_t c;
+ uint32_t i;
bool is_printable;
volatile bool is_decoded_as;
proto_item *pi;
@@ -827,14 +837,14 @@ try_dissect_unknown_ber(packet_info *pinfo, tvbuff_t *tvb, volatile int offset,
}
start_offset = offset;
- asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
+ asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
offset = get_ber_identifier(tvb, offset, &ber_class, &pc, &tag);
len_offset = offset;
offset = get_ber_length(tvb, offset, &len, &ind);
len_len = offset - len_offset;
- if (len > (guint32)tvb_reported_length_remaining(tvb, offset)) {
+ if (len > (uint32_t)tvb_reported_length_remaining(tvb, offset)) {
/* hmm maybe something bad happened or the frame is short;
since these are not vital outputs just return instead of
throwing an exception.
@@ -848,7 +858,7 @@ try_dissect_unknown_ber(packet_info *pinfo, tvbuff_t *tvb, volatile int offset,
return tvb_reported_length(tvb);
}
/* we don't care about the class only on the constructor flag */
- if (pc != TRUE) {
+ if (pc != true) {
/* this is not constructed */
@@ -859,25 +869,25 @@ try_dissect_unknown_ber(packet_info *pinfo, tvbuff_t *tvb, volatile int offset,
/* XXX: shouldn't really get here */
break;
case BER_UNI_TAG_INTEGER:
- offset = dissect_ber_integer(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_INTEGER, NULL);
+ offset = dissect_ber_integer(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_INTEGER, NULL);
break;
case BER_UNI_TAG_REAL:
- offset = dissect_ber_real(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_REAL, NULL);
+ offset = dissect_ber_real(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_REAL, NULL);
break;
case BER_UNI_TAG_BITSTRING:
- offset = dissect_ber_bitstring(FALSE, &asn1_ctx, tree, tvb, start_offset, NULL, 0, hf_ber_unknown_BITSTRING, -1, NULL);
+ offset = dissect_ber_bitstring(false, &asn1_ctx, tree, tvb, start_offset, NULL, 0, hf_ber_unknown_BITSTRING, -1, NULL);
break;
case BER_UNI_TAG_ENUMERATED:
- offset = dissect_ber_integer(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_ENUMERATED, NULL);
+ offset = dissect_ber_integer(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_ENUMERATED, NULL);
break;
case BER_UNI_TAG_GraphicString:
- offset = dissect_ber_octet_string(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_GraphicString, NULL);
+ offset = dissect_ber_octet_string(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_GraphicString, NULL);
break;
case BER_UNI_TAG_OCTETSTRING:
- is_decoded_as = FALSE;
+ is_decoded_as = false;
if (decode_octetstring_as_ber && (len >= 2)) {
volatile int ber_offset = 0;
- guint32 ber_len = 0;
+ uint32_t ber_len = 0;
TRY{
ber_offset = get_ber_identifier(tvb, offset, NULL, &pc, NULL);
ber_offset = get_ber_length(tvb, ber_offset, &ber_len, NULL);
@@ -888,7 +898,7 @@ try_dissect_unknown_ber(packet_info *pinfo, tvbuff_t *tvb, volatile int offset,
/* Decoded a constructed ASN.1 tag with a length indicating this
* could be BER encoded data. Try dissecting as unknown BER.
*/
- is_decoded_as = TRUE;
+ is_decoded_as = true;
if (show_internal_ber_fields) {
offset = dissect_ber_identifier(pinfo, tree, tvb, start_offset, NULL, NULL, NULL);
offset = dissect_ber_length(pinfo, tree, tvb, offset, NULL, NULL);
@@ -899,53 +909,53 @@ try_dissect_unknown_ber(packet_info *pinfo, tvbuff_t *tvb, volatile int offset,
}
}
if (!is_decoded_as) {
- offset = dissect_ber_octet_string(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_OCTETSTRING, NULL);
+ offset = dissect_ber_octet_string(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_OCTETSTRING, NULL);
}
break;
case BER_UNI_TAG_OID:
- offset = dissect_ber_object_identifier_str(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_OID, NULL);
+ offset = dissect_ber_object_identifier_str(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_OID, NULL);
break;
case BER_UNI_TAG_RELATIVE_OID:
- offset = dissect_ber_relative_oid_str(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_relative_OID, NULL);
+ offset = dissect_ber_relative_oid_str(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_relative_OID, NULL);
break;
case BER_UNI_TAG_NumericString:
- offset = dissect_ber_octet_string(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_NumericString, NULL);
+ offset = dissect_ber_octet_string(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_NumericString, NULL);
break;
case BER_UNI_TAG_PrintableString:
- offset = dissect_ber_octet_string(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_PrintableString, NULL);
+ offset = dissect_ber_octet_string(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_PrintableString, NULL);
break;
case BER_UNI_TAG_TeletexString:
- offset = dissect_ber_octet_string(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_TeletexString, NULL);
+ offset = dissect_ber_octet_string(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_TeletexString, NULL);
break;
case BER_UNI_TAG_VisibleString:
- offset = dissect_ber_octet_string(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_VisibleString, NULL);
+ offset = dissect_ber_octet_string(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_VisibleString, NULL);
break;
case BER_UNI_TAG_GeneralString:
offset = dissect_ber_GeneralString(&asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_GeneralString, NULL, 0);
break;
case BER_UNI_TAG_BMPString:
- offset = dissect_ber_octet_string(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_BMPString, NULL);
+ offset = dissect_ber_octet_string(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_BMPString, NULL);
break;
case BER_UNI_TAG_UniversalString:
- offset = dissect_ber_octet_string(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_UniversalString, NULL);
+ offset = dissect_ber_octet_string(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_UniversalString, NULL);
break;
case BER_UNI_TAG_IA5String:
- offset = dissect_ber_octet_string(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_IA5String, NULL);
+ offset = dissect_ber_octet_string(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_IA5String, NULL);
break;
case BER_UNI_TAG_UTCTime:
- offset = dissect_ber_octet_string(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_UTCTime, NULL);
+ offset = dissect_ber_octet_string(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_UTCTime, NULL);
break;
case BER_UNI_TAG_NULL:
proto_tree_add_item(tree, hf_ber_null_tag, tvb, offset, len, ENC_NA);
break;
case BER_UNI_TAG_UTF8String:
- offset = dissect_ber_octet_string(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_UTF8String, NULL);
+ offset = dissect_ber_octet_string(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_UTF8String, NULL);
break;
case BER_UNI_TAG_GeneralizedTime:
- offset = dissect_ber_octet_string(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_GeneralizedTime, NULL);
+ offset = dissect_ber_octet_string(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_GeneralizedTime, NULL);
break;
case BER_UNI_TAG_BOOLEAN:
- offset = dissect_ber_boolean(FALSE, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_BOOLEAN, NULL);
+ offset = dissect_ber_boolean(false, &asn1_ctx, tree, tvb, start_offset, hf_ber_unknown_BOOLEAN, NULL);
break;
default:
identifier_offset = start_offset;
@@ -974,10 +984,10 @@ try_dissect_unknown_ber(packet_info *pinfo, tvbuff_t *tvb, volatile int offset,
pi = proto_tree_add_none_format(tree, hf_ber_unknown_BER_primitive, tvb, offset, len,
"[%s %d] ", val_to_str_const(ber_class, ber_class_codes, "Unknown"), tag);
- is_decoded_as = FALSE;
+ is_decoded_as = false;
if (decode_primitive_as_ber && (len >= 2)) {
volatile int ber_offset = 0;
- guint32 ber_len = 0;
+ uint32_t ber_len = 0;
TRY{
ber_offset = get_ber_identifier(tvb, offset, NULL, &pc, NULL);
ber_offset = get_ber_length(tvb, ber_offset, &ber_len, NULL);
@@ -988,7 +998,7 @@ try_dissect_unknown_ber(packet_info *pinfo, tvbuff_t *tvb, volatile int offset,
/* Decoded a constructed ASN.1 tag with a length indicating this
* could be BER encoded data. Try dissecting as unknown BER.
*/
- is_decoded_as = TRUE;
+ is_decoded_as = true;
proto_item_append_text(pi, "[BER encoded]");
next_tree = proto_item_add_subtree(pi, ett_ber_primitive);
offset = try_dissect_unknown_ber(pinfo, tvb, offset, next_tree, nest_level + 1);
@@ -997,12 +1007,12 @@ try_dissect_unknown_ber(packet_info *pinfo, tvbuff_t *tvb, volatile int offset,
if (!is_decoded_as && len) {
/* we may want to do better and show the bytes */
- is_printable = TRUE;
+ is_printable = true;
for (i = 0; i < len; i++) {
- c = tvb_get_guint8(tvb, offset + i);
+ c = tvb_get_uint8(tvb, offset + i);
if (is_printable && !g_ascii_isprint(c))
- is_printable = FALSE;
+ is_printable = false;
proto_item_append_text(pi, "%02x", c);
}
@@ -1010,7 +1020,7 @@ try_dissect_unknown_ber(packet_info *pinfo, tvbuff_t *tvb, volatile int offset,
if (is_printable) { /* give a nicer representation if it looks like a string */
proto_item_append_text(pi, " (");
for (i = 0; i < len; i++) {
- proto_item_append_text(pi, "%c", tvb_get_guint8(tvb, offset + i));
+ proto_item_append_text(pi, "%c", tvb_get_uint8(tvb, offset + i));
}
proto_item_append_text(pi, ")");
}
@@ -1054,6 +1064,7 @@ try_dissect_unknown_ber(packet_info *pinfo, tvbuff_t *tvb, volatile int offset,
}
int
+// NOLINTNEXTLINE(misc-no-recursion)
dissect_unknown_ber(packet_info *pinfo, tvbuff_t *tvb, int offset, proto_tree *tree)
{
return try_dissect_unknown_ber(pinfo, tvb, offset, tree, 1);
@@ -1080,7 +1091,7 @@ call_ber_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *p
{
proto_item *item = NULL;
proto_tree *next_tree = NULL;
- gint length_remaining;
+ int length_remaining;
/* XXX we should probably use get_ber_length() here */
length_remaining = tvb_reported_length_remaining(tvb, offset);
@@ -1102,7 +1113,7 @@ call_ber_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *p
}
if (decode_unexpected) {
int ber_offset;
- gint32 ber_len;
+ int32_t ber_len;
if (item) {
next_tree = proto_item_add_subtree(item, ett_ber_unknown);
@@ -1166,13 +1177,13 @@ call_ber_syntax_callback(const char *syntax, tvbuff_t *tvb, int offset, packet_i
/* 8.1.2 Identifier octets */
int
-get_ber_identifier(tvbuff_t *tvb, int offset, gint8 *ber_class, bool *pc, gint32 *tag) {
- guint8 id, t;
- gint8 tmp_class;
+get_ber_identifier(tvbuff_t *tvb, int offset, int8_t *ber_class, bool *pc, int32_t *tag) {
+ uint8_t id, t;
+ int8_t tmp_class;
bool tmp_pc;
- gint32 tmp_tag;
+ int32_t tmp_tag;
- id = tvb_get_guint8(tvb, offset);
+ id = tvb_get_uint8(tvb, offset);
offset += 1;
#ifdef DEBUG_BER
ws_debug_printf("BER ID=%02x", id);
@@ -1185,7 +1196,7 @@ ws_debug_printf("BER ID=%02x", id);
if (tmp_tag == 0x1F) {
tmp_tag = 0;
while (tvb_reported_length_remaining(tvb, offset) > 0) {
- t = tvb_get_guint8(tvb, offset);
+ t = tvb_get_uint8(tvb, offset);
#ifdef DEBUG_BER
ws_debug_printf(" %02x", t);
#endif
@@ -1215,7 +1226,7 @@ ws_debug_printf("\n");
}
static void
-get_last_ber_identifier(gint8 *ber_class, bool *pc, gint32 *tag)
+get_last_ber_identifier(int8_t *ber_class, bool *pc, int32_t *tag)
{
if (ber_class)
*ber_class = last_class;
@@ -1227,12 +1238,12 @@ get_last_ber_identifier(gint8 *ber_class, bool *pc, gint32 *tag)
}
int
-dissect_ber_identifier(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, gint8 *ber_class, bool *pc, gint32 *tag)
+dissect_ber_identifier(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, int8_t *ber_class, bool *pc, int32_t *tag)
{
int old_offset = offset;
- gint8 tmp_class;
+ int8_t tmp_class;
bool tmp_pc;
- gint32 tmp_tag;
+ int32_t tmp_tag;
offset = get_ber_identifier(tvb, offset, &tmp_class, &tmp_pc, &tmp_tag);
@@ -1267,31 +1278,32 @@ dissect_ber_identifier(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb,
/** Try to get the length octets of the BER TLV.
* Only (TAGs and) LENGTHs that fit inside 32 bit integers are supported.
*
- * @return TRUE if we have the entire length, FALSE if we're in the middle of
+ * @return true if we have the entire length, false if we're in the middle of
* an indefinite length and haven't reached EOC.
*/
/* 8.1.3 Length octets */
static int
-try_get_ber_length(tvbuff_t *tvb, int offset, guint32 *length, bool *ind, gint nest_level) {
- guint8 oct, len;
- guint32 indef_len;
- guint32 tmp_length;
- bool tmp_ind;
+// NOLINTNEXTLINE(misc-no-recursion)
+try_get_ber_length(tvbuff_t *tvb, int offset, uint32_t *length, bool *ind, int nest_level) {
+ uint8_t oct, len;
+ uint32_t indef_len;
+ uint32_t tmp_length;
+ bool tmp_ind;
int tmp_offset, s_offset;
- gint8 tclass;
+ int8_t tclass;
bool tpc;
- gint32 ttag;
+ int32_t ttag;
tmp_length = 0;
- tmp_ind = FALSE;
+ tmp_ind = false;
if (nest_level > BER_MAX_NESTING) {
/* Assume that we have a malformed packet. */
THROW(ReportedBoundsError);
}
- oct = tvb_get_guint8(tvb, offset);
+ oct = tvb_get_uint8(tvb, offset);
offset += 1;
if (!(oct & 0x80)) {
@@ -1302,7 +1314,7 @@ try_get_ber_length(tvbuff_t *tvb, int offset, guint32 *length, bool *ind, gint n
if (len) {
/* 8.1.3.5 */
while (len--) {
- oct = tvb_get_guint8(tvb, offset);
+ oct = tvb_get_uint8(tvb, offset);
offset++;
tmp_length = (tmp_length<<8) + oct;
}
@@ -1313,7 +1325,7 @@ try_get_ber_length(tvbuff_t *tvb, int offset, guint32 *length, bool *ind, gint n
/* ok in here we can traverse the BER to find the length, this will fix most indefinite length issues */
/* Assumption here is that indefinite length is always used on constructed types*/
/* check for EOC */
- while (tvb_get_guint8(tvb, offset) || tvb_get_guint8(tvb, offset+1)) {
+ while (tvb_get_uint8(tvb, offset) || tvb_get_uint8(tvb, offset+1)) {
/* not an EOC at offset */
s_offset = offset;
offset= get_ber_identifier(tvb, offset, &tclass, &tpc, &ttag);
@@ -1325,15 +1337,15 @@ try_get_ber_length(tvbuff_t *tvb, int offset, guint32 *length, bool *ind, gint n
THROW(ReportedBoundsError);
}
tmp_length += 2;
- tmp_ind = TRUE;
+ tmp_ind = true;
offset = tmp_offset;
}
}
/* Several users treat the length as signed value, clamp the value to avoid
* an overflow to negative values. */
- if (tmp_length > (guint32)G_MAXINT32)
- tmp_length = (guint32)G_MAXINT32;
+ if (tmp_length > (uint32_t)INT32_MAX)
+ tmp_length = (uint32_t)INT32_MAX;
if (length)
*length = tmp_length;
@@ -1348,13 +1360,13 @@ ws_debug_printf("get BER length %d, offset %d (remaining %d)\n", tmp_length, off
}
int
-get_ber_length(tvbuff_t *tvb, int offset, guint32 *length, bool *ind)
+get_ber_length(tvbuff_t *tvb, int offset, uint32_t *length, bool *ind)
{
return try_get_ber_length(tvb, offset, length, ind, 1);
}
static void
-get_last_ber_length(guint32 *length, bool *ind, tvbuff_t **len_tvb, int *len_offset, int *len_len)
+get_last_ber_length(uint32_t *length, bool *ind, tvbuff_t **len_tvb, int *len_offset, int *len_len)
{
if (length)
*length = last_length;
@@ -1372,10 +1384,10 @@ get_last_ber_length(guint32 *length, bool *ind, tvbuff_t **len_tvb, int *len_off
* We only handle (TAGs and) LENGTHs that fit inside 32 bit integers.
*/
int
-dissect_ber_length(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, guint32 *length, bool *ind)
+dissect_ber_length(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, uint32_t *length, bool *ind)
{
int old_offset = offset;
- guint32 tmp_length;
+ uint32_t tmp_length;
bool tmp_ind;
offset = get_ber_length(tvb, offset, &tmp_length, &tmp_ind);
@@ -1385,7 +1397,7 @@ dissect_ber_length(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int
proto_tree_add_uint_format_value(tree, hf_ber_length, tvb, old_offset, 1, tmp_length, "Indefinite length %d", tmp_length);
} else {
if ((offset - old_offset) > 1) {
- proto_tree_add_uint(tree, hf_ber_length_octets, tvb, old_offset, 1, (tvb_get_guint8(tvb, old_offset) & 0x7f));
+ proto_tree_add_uint(tree, hf_ber_length_octets, tvb, old_offset, 1, (tvb_get_uint8(tvb, old_offset) & 0x7f));
proto_tree_add_uint(tree, hf_ber_length, tvb, old_offset+1, offset - (old_offset+1), tmp_length);
} else {
proto_tree_add_uint(tree, hf_ber_length, tvb, old_offset, offset - old_offset, tmp_length);
@@ -1413,18 +1425,19 @@ proto_tree_add_debug_text(tree, "dissect BER length %d, offset %d (remaining %d)
static reassembly_table octet_segment_reassembly_table;
static int
-dissect_ber_constrained_octet_string_impl(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint32 min_len, gint32 max_len, gint hf_id, tvbuff_t **out_tvb, guint nest_level, guint encoding);
+dissect_ber_constrained_octet_string_impl(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int32_t min_len, int32_t max_len, int hf_id, tvbuff_t **out_tvb, unsigned nest_level, unsigned encoding);
static int
-reassemble_octet_string(asn1_ctx_t *actx, proto_tree *tree, gint hf_id, tvbuff_t *tvb, int offset, guint32 con_len, bool ind, tvbuff_t **out_tvb, guint nest_level)
+// NOLINTNEXTLINE(misc-no-recursion)
+reassemble_octet_string(asn1_ctx_t *actx, proto_tree *tree, int hf_id, tvbuff_t *tvb, int offset, uint32_t con_len, bool ind, tvbuff_t **out_tvb, unsigned nest_level)
{
fragment_head *fd_head = NULL;
tvbuff_t *next_tvb = NULL;
tvbuff_t *reassembled_tvb = NULL;
- guint16 dst_ref = 0;
+ uint16_t dst_ref = 0;
int start_offset = offset;
- bool fragment = TRUE;
- bool firstFragment = TRUE;
+ bool fragment = true;
+ bool firstFragment = true;
if (nest_level > BER_MAX_NESTING) {
/* Assume that we have a malformed packet. */
@@ -1440,11 +1453,11 @@ reassemble_octet_string(asn1_ctx_t *actx, proto_tree *tree, gint hf_id, tvbuff_t
return offset;
/* not sure we need this */
- actx->pinfo->fragmented = TRUE;
+ actx->pinfo->fragmented = true;
while(!fd_head) {
- offset = dissect_ber_constrained_octet_string_impl(FALSE, actx, NULL,
+ offset = dissect_ber_constrained_octet_string_impl(false, actx, NULL,
tvb, offset, NO_BOUND, NO_BOUND, hf_id, &next_tvb, nest_level + 1, 0);
if (next_tvb == NULL) {
@@ -1455,15 +1468,15 @@ reassemble_octet_string(asn1_ctx_t *actx, proto_tree *tree, gint hf_id, tvbuff_t
if (ind) {
/* this was indefinite length - so check for EOC */
- if ((tvb_get_guint8(tvb, offset) == 0) && (tvb_get_guint8(tvb, offset+1) == 0)) {
- fragment = FALSE;
+ if ((tvb_get_uint8(tvb, offset) == 0) && (tvb_get_uint8(tvb, offset+1) == 0)) {
+ fragment = false;
/* skip past EOC */
offset +=2;
}
} else {
- if ((guint32)(offset - start_offset) >= con_len)
- fragment = FALSE;
+ if ((uint32_t)(offset - start_offset) >= con_len)
+ fragment = false;
}
if (!fragment && firstFragment) {
@@ -1473,7 +1486,7 @@ reassemble_octet_string(asn1_ctx_t *actx, proto_tree *tree, gint hf_id, tvbuff_t
get_ber_identifier(tvb, start_offset, NULL, &pc, NULL);
if (!pc && tree) {
/* Only display here if not constructed */
- dissect_ber_octet_string(FALSE, actx, tree, tvb, start_offset, hf_id, NULL);
+ dissect_ber_octet_string(false, actx, tree, tvb, start_offset, hf_id, NULL);
}
reassembled_tvb = next_tvb;
break;
@@ -1490,7 +1503,7 @@ reassemble_octet_string(asn1_ctx_t *actx, proto_tree *tree, gint hf_id, tvbuff_t
tvb_reported_length(next_tvb),
fragment);
- firstFragment = FALSE;
+ firstFragment = false;
}
if (fd_head) {
@@ -1513,7 +1526,7 @@ reassemble_octet_string(asn1_ctx_t *actx, proto_tree *tree, gint hf_id, tvbuff_t
*out_tvb = reassembled_tvb;
/* again - not sure we need this */
- actx->pinfo->fragmented = FALSE;
+ actx->pinfo->fragmented = false;
return offset;
@@ -1521,38 +1534,40 @@ reassemble_octet_string(asn1_ctx_t *actx, proto_tree *tree, gint hf_id, tvbuff_t
/* 8.7 Encoding of an octetstring value */
int
-dissect_ber_constrained_octet_string(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint32 min_len, gint32 max_len, gint hf_id, tvbuff_t **out_tvb) {
+// NOLINTNEXTLINE(misc-no-recursion)
+dissect_ber_constrained_octet_string(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int32_t min_len, int32_t max_len, int hf_id, tvbuff_t **out_tvb) {
return dissect_ber_constrained_octet_string_impl(implicit_tag, actx, tree, tvb, offset, min_len, max_len, hf_id, out_tvb, 0, 0);
}
static int
-dissect_ber_constrained_octet_string_impl(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint32 min_len, gint32 max_len, gint hf_id, tvbuff_t **out_tvb, guint nest_level, guint encoding) {
- gint8 ber_class;
- bool pc, ind;
- gint32 tag;
+// NOLINTNEXTLINE(misc-no-recursion)
+dissect_ber_constrained_octet_string_impl(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int32_t min_len, int32_t max_len, int hf_id, tvbuff_t **out_tvb, unsigned nest_level, unsigned encoding) {
+ int8_t ber_class;
+ bool pc, ind;
+ int32_t tag;
int identifier_offset;
int identifier_len;
- guint32 len;
+ uint32_t len;
tvbuff_t *len_tvb;
int len_offset;
int len_len;
int hoffset;
int end_offset;
proto_item *it, *cause;
- guint32 len_remain;
+ uint32_t len_remain;
#ifdef DEBUG_BER
{
const char *name;
header_field_info *hfinfo;
-if (hf_id >= 0) {
+if (hf_id > 0) {
hfinfo = proto_registrar_get_nth(hf_id);
name = hfinfo->name;
} else {
name = "unnamed";
}
if (tvb_reported_length_remaining(tvb, offset) > 3) {
-proto_tree_add_debug_text(tree, "OCTET STRING dissect_ber_octet string(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2));
+proto_tree_add_debug_text(tree, "OCTET STRING dissect_ber_octet string(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_uint8(tvb, offset), tvb_get_uint8(tvb, offset+1), tvb_get_uint8(tvb, offset+2));
} else {
proto_tree_add_debug_text(tree, "OCTET STRING dissect_ber_octet_string(%s) entered\n", name);
}
@@ -1600,12 +1615,12 @@ proto_tree_add_debug_text(tree, "OCTET STRING dissect_ber_octet_string(%s) enter
end_offset = offset+len;
/* caller may have created new buffer for indefinite length data Verify via length */
- len_remain = (guint32)tvb_reported_length_remaining(tvb, offset);
+ len_remain = (uint32_t)tvb_reported_length_remaining(tvb, offset);
if (ind && (len_remain == (len - 2))) {
/* new buffer received so adjust length and indefinite flag */
len -= 2;
end_offset -= 2;
- ind = FALSE;
+ ind = false;
} else if (len_remain < len) {
/*
* error - short frame, or this item runs past the
@@ -1624,7 +1639,7 @@ proto_tree_add_debug_text(tree, "OCTET STRING dissect_ber_octet_string(%s) enter
end_offset = reassemble_octet_string(actx, tree, hf_id, tvb, offset, len, ind, out_tvb, nest_level);
} else {
/* primitive */
- gint length_remaining;
+ int length_remaining;
length_remaining = tvb_reported_length_remaining(tvb, offset);
#if 0
@@ -1633,10 +1648,10 @@ proto_tree_add_debug_text(tree, "OCTET STRING dissect_ber_octet_string(%s) enter
}
#endif
- if (len <= (guint32)length_remaining) {
+ if (len <= (uint32_t)length_remaining) {
length_remaining = len;
}
- if (hf_id >= 0) {
+ if (hf_id > 0) {
/*
* Strings are special. See X.680 section 41 "Definition of
* restricted character string types" and X.690 section 8.20
@@ -1754,7 +1769,7 @@ proto_tree_add_debug_text(tree, "OCTET STRING dissect_ber_octet_string(%s) enter
}
it = ber_proto_tree_add_item(actx->pinfo, tree, hf_id, tvb, offset, length_remaining, encoding);
actx->created_item = it;
- ber_check_length(length_remaining, min_len, max_len, actx, it, FALSE);
+ ber_check_length(length_remaining, min_len, max_len, actx, it, false);
} else {
proto_tree_add_item(tree, hf_ber_unknown_octetstring, tvb, offset, len, ENC_NA);
@@ -1768,39 +1783,40 @@ proto_tree_add_debug_text(tree, "OCTET STRING dissect_ber_octet_string(%s) enter
}
int
-dissect_ber_octet_string(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, tvbuff_t **out_tvb) {
+// NOLINTNEXTLINE(misc-no-recursion)
+dissect_ber_octet_string(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, tvbuff_t **out_tvb) {
return dissect_ber_constrained_octet_string_impl(implicit_tag, actx, tree, tvb, offset, NO_BOUND, NO_BOUND, hf_id, out_tvb, 0, 0);
}
int
-dissect_ber_octet_string_with_encoding(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, tvbuff_t **out_tvb, guint encoding) {
+dissect_ber_octet_string_with_encoding(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, tvbuff_t **out_tvb, unsigned encoding) {
return dissect_ber_constrained_octet_string_impl(implicit_tag, actx, tree, tvb, offset, NO_BOUND, NO_BOUND, hf_id, out_tvb, 0, encoding);
}
int
-dissect_ber_octet_string_wcb(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, ber_callback func)
+dissect_ber_octet_string_wcb(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, ber_callback func)
{
tvbuff_t *out_tvb = NULL;
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_id, (func) ? &out_tvb : NULL);
if (func && out_tvb && (tvb_reported_length(out_tvb) > 0)) {
- if (hf_id >= 0)
+ if (hf_id > 0)
tree = proto_item_add_subtree(actx->created_item, ett_ber_octet_string);
- /* TODO Should hf_id2 be pased as last parameter???*/
- func(FALSE, out_tvb, 0, actx, tree, -1);
+ /* TODO Should hf_id2 be passed as last parameter???*/
+ func(false, out_tvb, 0, actx, tree, -1);
}
return offset;
}
/* 8.8 Encoding of a null value */
int
-dissect_ber_null(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id) {
- gint8 ber_class;
+dissect_ber_null(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id) {
+ int8_t ber_class;
bool pc;
- gint32 tag;
+ int32_t tag;
int identifier_offset;
int identifier_len;
- guint32 len;
+ uint32_t len;
int len_offset;
int len_len;
@@ -1833,34 +1849,34 @@ dissect_ber_null(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t
offset += len;
}
}
- if (hf_id >= 0)
+ if (hf_id > 0)
proto_tree_add_item(tree, hf_id, tvb, offset, 0, ENC_BIG_ENDIAN);
return offset;
}
int
-dissect_ber_integer64(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, gint64 *value)
+dissect_ber_integer64(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, int64_t *value)
{
- gint8 ber_class;
+ int8_t ber_class;
bool pc;
- gint32 tag;
- guint32 len;
- gint64 val;
- guint32 i;
- bool used_too_many_bytes = FALSE;
- guint8 first = 0;
+ int32_t tag;
+ uint32_t len;
+ int64_t val;
+ uint32_t i;
+ bool used_too_many_bytes = false;
+ uint8_t first = 0;
#ifdef DEBUG_BER
{
const char *name;
header_field_info *hfinfo;
-if (hf_id >= 0) {
+if (hf_id > 0) {
hfinfo = proto_registrar_get_nth(hf_id);
name = hfinfo->name;
} else {
name = "unnamed";
}
if (tvb_reported_length_remaining(tvb, offset) > 3) {
-proto_tree_add_debug_text(tree, "INTEGERnew dissect_ber_integer(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2));
+proto_tree_add_debug_text(tree, "INTEGERnew dissect_ber_integer(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_uint8(tvb, offset), tvb_get_uint8(tvb, offset+1), tvb_get_uint8(tvb, offset+2));
} else {
proto_tree_add_debug_text(tree, "INTEGERnew dissect_ber_integer(%s) entered implicit_tag:%d \n", name, implicit_tag);
}
@@ -1876,18 +1892,18 @@ proto_tree_add_debug_text(tree, "INTEGERnew dissect_ber_integer(%s) entered impl
offset = dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &ber_class, &pc, &tag);
offset = dissect_ber_length(actx->pinfo, tree, tvb, offset, &len, NULL);
} else {
- gint32 remaining = tvb_reported_length_remaining(tvb, offset);
+ int32_t remaining = tvb_reported_length_remaining(tvb, offset);
len = remaining>0 ? remaining : 0;
}
val = 0;
if (len > 0) {
- first = tvb_get_guint8(tvb, offset);
+ first = tvb_get_uint8(tvb, offset);
/* we can't handle integers > 64 bits */
/* take into account the use case of a 64bits unsigned integer: you will have a 9th byte set to 0 */
if ((len > 9) || ((len == 9) && (first != 0))) {
- if (hf_id >= 0) {
+ if (hf_id > 0) {
header_field_info *hfinfo = proto_registrar_get_nth(hf_id);
/* use the original field only if it is suitable for bytes */
@@ -1895,7 +1911,7 @@ proto_tree_add_debug_text(tree, "INTEGERnew dissect_ber_integer(%s) entered impl
hf_id = hf_ber_64bit_uint_as_bytes;
proto_tree_add_bytes_format(tree, hf_id, tvb, offset, len, NULL,
- "%s: 0x%s", hfinfo->name, tvb_bytes_to_str(wmem_packet_scope(), tvb, offset, len));
+ "%s: 0x%s", hfinfo->name, tvb_bytes_to_str(actx->pinfo->pool, tvb, offset, len));
}
offset += len;
@@ -1903,28 +1919,28 @@ proto_tree_add_debug_text(tree, "INTEGERnew dissect_ber_integer(%s) entered impl
}
/* extend sign bit for signed fields */
enum ftenum type = FT_INT32; /* Default to signed, is this correct? */
- if (hf_id >= 0) {
+ if (hf_id > 0) {
type = proto_registrar_get_ftype(hf_id);
}
if (first & 0x80 && FT_IS_INT(type)) {
val = -1;
}
if ((len > 1) && decode_warning_leading_zero_bits) {
- guint8 second = tvb_get_guint8(tvb, offset+1);
+ uint8_t second = tvb_get_uint8(tvb, offset+1);
if (((first == 0x00) && ((second & 0x80) == 0)) ||
((first == 0xff) && ((second & 0x80) != 0))) {
- used_too_many_bytes = TRUE;
+ used_too_many_bytes = true;
}
}
for (i=0; i<len; i++) {
- val = ((guint64)val<<8) | tvb_get_guint8(tvb, offset);
+ val = ((uint64_t)val<<8) | tvb_get_uint8(tvb, offset);
offset++;
}
}
actx->created_item = NULL;
- if (hf_id >= 0) {
+ if (hf_id > 0) {
/* */
header_field_info* hfi;
@@ -1939,19 +1955,19 @@ proto_tree_add_debug_text(tree, "INTEGERnew dissect_ber_integer(%s) entered impl
case FT_UINT16:
case FT_UINT24:
case FT_UINT32:
- actx->created_item = proto_tree_add_uint(tree, hf_id, tvb, offset-len, len, (guint32)val);
+ actx->created_item = proto_tree_add_uint(tree, hf_id, tvb, offset-len, len, (uint32_t)val);
break;
case FT_INT8:
case FT_INT16:
case FT_INT24:
case FT_INT32:
- actx->created_item = proto_tree_add_int(tree, hf_id, tvb, offset-len, len, (gint32)val);
+ actx->created_item = proto_tree_add_int(tree, hf_id, tvb, offset-len, len, (int32_t)val);
break;
case FT_INT64:
actx->created_item = proto_tree_add_int64(tree, hf_id, tvb, offset-len, len, val);
break;
case FT_UINT64:
- actx->created_item = proto_tree_add_uint64(tree, hf_id, tvb, offset-len, len, (guint64)val);
+ actx->created_item = proto_tree_add_uint64(tree, hf_id, tvb, offset-len, len, (uint64_t)val);
break;
case FT_BYTES:
/*
@@ -1961,7 +1977,7 @@ proto_tree_add_debug_text(tree, "INTEGERnew dissect_ber_integer(%s) entered impl
* values are handled here.
*/
actx->created_item = proto_tree_add_bytes_format(tree, hf_id, tvb, offset-len, len, NULL,
- "%s: 0x%s", hfi->name, tvb_bytes_to_str(wmem_packet_scope(), tvb, offset-len, len));
+ "%s: 0x%s", hfi->name, tvb_bytes_to_str(actx->pinfo->pool, tvb, offset-len, len));
break;
default:
DISSECTOR_ASSERT_NOT_REACHED();
@@ -1984,9 +2000,9 @@ proto_tree_add_debug_text(tree, "INTEGERnew dissect_ber_integer(%s) entered impl
}
int
-dissect_ber_constrained_integer64(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint64 min_len, gint64 max_len, gint hf_id, gint64 *value)
+dissect_ber_constrained_integer64(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int64_t min_len, int64_t max_len, int hf_id, int64_t *value)
{
- gint64 val;
+ int64_t val;
offset = dissect_ber_integer64(implicit_tag, actx, tree, tvb, offset, hf_id, &val);
if (value) {
@@ -1999,41 +2015,41 @@ dissect_ber_constrained_integer64(bool implicit_tag, asn1_ctx_t *actx, proto_tre
}
int
-dissect_ber_integer(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, guint32 *value)
+dissect_ber_integer(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, uint32_t *value)
{
- gint64 val;
+ int64_t val;
offset = dissect_ber_integer64(implicit_tag, actx, tree, tvb, offset, hf_id, &val);
if (value) {
- *value = (guint32)val;
+ *value = (uint32_t)val;
}
return offset;
}
int
-dissect_ber_constrained_integer(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint32 min_len, gint32 max_len, gint hf_id, guint32 *value)
+dissect_ber_constrained_integer(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int32_t min_len, int32_t max_len, int hf_id, uint32_t *value)
{
- gint64 val;
+ int64_t val;
offset = dissect_ber_integer64(implicit_tag, actx, tree, tvb, offset, hf_id, &val);
if (value) {
- *value = (guint32)val;
+ *value = (uint32_t)val;
}
- ber_check_value ((guint32)val, min_len, max_len, actx, actx->created_item);
+ ber_check_value ((uint32_t)val, min_len, max_len, actx, actx->created_item);
return offset;
}
int
-dissect_ber_boolean(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, bool *value)
+dissect_ber_boolean(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, bool *value)
{
- gint8 ber_class;
+ int8_t ber_class;
bool pc;
- gint32 tag;
- guint32 len;
- guint8 val;
+ int32_t tag;
+ uint32_t len;
+ uint8_t val;
header_field_info *hfi;
if (!implicit_tag) {
@@ -2041,18 +2057,18 @@ dissect_ber_boolean(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuf
offset = dissect_ber_length(actx->pinfo, tree, tvb, offset, &len, NULL);
/*if (ber_class != BER_CLASS_UNI)*/
} else {
- gint32 remaining = tvb_reported_length_remaining(tvb, offset);
+ int32_t remaining = tvb_reported_length_remaining(tvb, offset);
len = remaining > 0 ? remaining : 0;
}
if (len == 1)
{
- val = tvb_get_guint8(tvb, offset);
+ val = tvb_get_uint8(tvb, offset);
offset += 1;
actx->created_item = NULL;
- if (hf_id >= 0) {
+ if (hf_id > 0) {
hfi = proto_registrar_get_nth(hf_id);
if (hfi->type == FT_BOOLEAN)
actx->created_item = proto_tree_add_boolean(tree, hf_id, tvb, offset-1, 1, val);
@@ -2063,7 +2079,7 @@ dissect_ber_boolean(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuf
val = 0;
actx->created_item = NULL;
- if (hf_id >= 0) {
+ if (hf_id > 0) {
hfi = proto_registrar_get_nth(hf_id);
proto_tree_add_expert_format(
tree, actx->pinfo, &ei_ber_error_length, tvb, offset, len,
@@ -2072,7 +2088,7 @@ dissect_ber_boolean(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuf
}
if (value) {
- *value = (val ? TRUE : FALSE);
+ *value = (val ? true : false);
}
return offset;
@@ -2082,12 +2098,12 @@ dissect_ber_boolean(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuf
/* 8.5 Encoding of a real value */
/* Somewhat tested */
int
-dissect_ber_real(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, double *value)
+dissect_ber_real(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, double *value)
{
- gint8 ber_class;
+ int8_t ber_class;
bool pc;
- gint32 tag;
- guint32 val_length = 0, len_remain, end_offset;
+ int32_t tag;
+ uint32_t val_length = 0, len_remain, end_offset;
tvbuff_t *len_tvb;
int len_offset;
int len_len;
@@ -2106,7 +2122,7 @@ dissect_ber_real(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t
end_offset = offset + val_length;
/* Check is buffer has (at least) the expected length */
- len_remain = (guint32)tvb_reported_length_remaining(tvb, offset);
+ len_remain = (uint32_t)tvb_reported_length_remaining(tvb, offset);
if (len_remain < val_length) {
/* error - this item runs past the end of the item containing it */
ber_add_large_length_error(actx->pinfo, tree, tvb, offset, val_length, len_tvb, len_offset, len_len);
@@ -2132,13 +2148,13 @@ dissect_ber_real(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t
/* this function dissects a BER sequence
*/
int
-dissect_ber_sequence(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, const ber_sequence_t *seq, gint hf_id, gint ett_id) {
- gint8 classx;
- bool pcx, ind = 0, ind_field, imp_tag = FALSE;
- gint32 tagx;
+dissect_ber_sequence(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, const ber_sequence_t *seq, int hf_id, int ett_id) {
+ int8_t classx;
+ bool pcx, ind = 0, ind_field, imp_tag = false;
+ int32_t tagx;
int identifier_offset;
int identifier_len;
- guint32 lenx;
+ uint32_t lenx;
proto_tree *tree = parent_tree;
proto_item *item = NULL;
proto_item *cause;
@@ -2150,14 +2166,14 @@ dissect_ber_sequence(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tre
{
const char *name;
header_field_info *hfinfo;
-if (hf_id >= 0) {
+if (hf_id > 0) {
hfinfo = proto_registrar_get_nth(hf_id);
name = hfinfo->name;
} else {
name = "unnamed";
}
if (tvb_reported_length_remaining(tvb, offset) > 3) {
-proto_tree_add_debug_text(tree, "SEQUENCE dissect_ber_sequence(%s) entered offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2));
+proto_tree_add_debug_text(tree, "SEQUENCE dissect_ber_sequence(%s) entered offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_uint8(tvb, offset), tvb_get_uint8(tvb, offset+1), tvb_get_uint8(tvb, offset+2));
} else {
proto_tree_add_debug_text(tree, "SEQUENCE dissect_ber_sequence(%s) entered\n", name);
}
@@ -2173,7 +2189,7 @@ proto_tree_add_debug_text(tree, "SEQUENCE dissect_ber_sequence(%s) entered\n", n
end_offset = offset+lenx;
}
/* create subtree */
- if (hf_id >= 0) {
+ if (hf_id > 0) {
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_id, tvb, hoffset, lenx + offset - hoffset, ENC_BIG_ENDIAN);
tree = proto_item_add_subtree(item, ett_id);
@@ -2221,15 +2237,15 @@ proto_tree_add_debug_text(tree, "SEQUENCE dissect_ber_sequence(%s) entered\n", n
}
/* loop over all entries until we reach the end of the sequence */
while (offset < end_offset) {
- gint8 ber_class;
+ int8_t ber_class;
bool pc;
- gint32 tag;
- guint32 len;
+ int32_t tag;
+ uint32_t len;
int eoffset, count;
/*if (ind) { this sequence was of indefinite length, if this is implicit indefinite impossible maybe
but ber dissector uses this to eat the tag length then pass into here... EOC still on there...*/
- if ((tvb_get_guint8(tvb, offset) == 0) && (tvb_get_guint8(tvb, offset+1) == 0)) {
+ if ((tvb_get_uint8(tvb, offset) == 0) && (tvb_get_uint8(tvb, offset+1) == 0)) {
/* If the first bytes is 00 00 of a indefenert length field it's a zero length field*/
offset = dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &ber_class, &pc, &tag);
dissect_ber_length(actx->pinfo, tree, tvb, offset, &len, &ind);
@@ -2393,7 +2409,7 @@ ber_sequence_try_again:
} else {
hoffset = dissect_ber_identifier(actx->pinfo, tree, tvb, hoffset, NULL, NULL, NULL);
hoffset = dissect_ber_length(actx->pinfo, tree, tvb, hoffset, NULL, NULL);
- next_tvb = ber_tvb_new_subset_length(tvb, hoffset, eoffset - hoffset - (2 * ind_field));
+ next_tvb = ber_tvb_new_subset_length(tvb, hoffset, eoffset - hoffset - (ind_field ? 2 : 0));
}
} else {
next_tvb = ber_tvb_new_subset_length(tvb, hoffset, eoffset - hoffset);
@@ -2416,14 +2432,14 @@ ber_sequence_try_again:
{
const char *name;
header_field_info *hfinfo;
-if (hf_id >= 0) {
+if (hf_id > 0) {
hfinfo = proto_registrar_get_nth(hf_id);
name = hfinfo->name;
} else {
name = "unnamed";
}
if (tvb_reported_length_remaining(next_tvb, 0) > 3) {
-proto_tree_add_debug_text(tree, "SEQUENCE dissect_ber_sequence(%s) calling subdissector offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(next_tvb, 0), tvb_get_guint8(next_tvb, 0), tvb_get_guint8(next_tvb, 1), tvb_get_guint8(next_tvb, 2));
+proto_tree_add_debug_text(tree, "SEQUENCE dissect_ber_sequence(%s) calling subdissector offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(next_tvb, 0), tvb_get_uint8(next_tvb, 0), tvb_get_uint8(next_tvb, 1), tvb_get_uint8(next_tvb, 2));
} else {
proto_tree_add_debug_text(tree, "SEQUENCE dissect_ber_sequence(%s) calling subdissector\n", name);
}
@@ -2433,9 +2449,9 @@ proto_tree_add_debug_text(tree, "SEQUENCE dissect_ber_sequence(%s) calling subdi
/* Assume that we have a malformed packet. */
THROW(ReportedBoundsError);
}
- imp_tag = FALSE;
+ imp_tag = false;
if (seq->flags & BER_FLAGS_IMPLTAG) {
- imp_tag = TRUE;
+ imp_tag = true;
}
count = seq->func(imp_tag, next_tvb, 0, actx, tree, *seq->p_id);
@@ -2444,7 +2460,7 @@ proto_tree_add_debug_text(tree, "SEQUENCE dissect_ber_sequence(%s) calling subdi
{
const char *name;
header_field_info *hfinfo;
-if (hf_id >= 0) {
+if (hf_id > 0) {
hfinfo = proto_registrar_get_nth(hf_id);
name = hfinfo->name;
} else {
@@ -2498,13 +2514,13 @@ proto_tree_add_debug_text(tree, "SEQUENCE dissect_ber_sequence(%s) subdissector
/* This function dissects a BER set
*/
int
-dissect_ber_set(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, const ber_sequence_t *set, gint hf_id, gint ett_id) {
- gint8 classx;
+dissect_ber_set(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, const ber_sequence_t *set, int hf_id, int ett_id) {
+ int8_t classx;
bool pcx, ind = 0, ind_field, imp_tag;
- gint32 tagx;
+ int32_t tagx;
int identifier_offset;
int identifier_len;
- guint32 lenx;
+ uint32_t lenx;
int len_offset;
int len_len;
proto_tree *tree = parent_tree;
@@ -2513,9 +2529,9 @@ dissect_ber_set(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tv
int end_offset, s_offset;
int hoffset;
tvbuff_t *next_tvb;
- guint32 mandatory_fields = 0;
- guint8 set_idx;
- bool first_pass;
+ uint32_t mandatory_fields = 0;
+ uint8_t set_idx;
+ bool first_pass;
const ber_sequence_t *cset = NULL;
#define MAX_SET_ELEMENTS 32
@@ -2526,14 +2542,14 @@ dissect_ber_set(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tv
{
const char *name;
header_field_info *hfinfo;
-if (hf_id >= 0) {
+if (hf_id > 0) {
hfinfo = proto_registrar_get_nth(hf_id);
name = hfinfo->name;
} else {
name = "unnamed";
}
if (tvb_reported_length_remaining(tvb, offset) > 3) {
-proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) entered offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2));
+proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) entered offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_uint8(tvb, offset), tvb_get_uint8(tvb, offset+1), tvb_get_uint8(tvb, offset+2));
} else {
proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) entered\n", name);
}
@@ -2584,7 +2600,7 @@ proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) entered\n", name);
}
/* create subtree */
- if (hf_id >= 0) {
+ if (hf_id > 0) {
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_id, tvb, offset, lenx, ENC_BIG_ENDIAN);
tree = proto_item_add_subtree(item, ett_id);
@@ -2602,16 +2618,16 @@ proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) entered\n", name);
/* loop over all entries until we reach the end of the set */
while (offset < end_offset) {
- gint8 ber_class;
+ int8_t ber_class;
bool pc;
- gint32 tag;
- guint32 len;
+ int32_t tag;
+ uint32_t len;
int eoffset, count;
/*if (ind) { this sequence was of indefinite length, if this is implicit indefinite impossible maybe
but ber dissector uses this to eat the tag length then pass into here... EOC still on there...*/
- if ((tvb_get_guint8(tvb, offset) == 0) && (tvb_get_guint8(tvb, offset+1) == 0)) {
+ if ((tvb_get_uint8(tvb, offset) == 0) && (tvb_get_uint8(tvb, offset+1) == 0)) {
if (show_internal_ber_fields) {
proto_tree_add_item(tree, hf_ber_seq_eoc, tvb, s_offset, offset+2, ENC_NA);
}
@@ -2628,7 +2644,7 @@ proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) entered\n", name);
len_len = offset - len_offset;
eoffset = offset + len;
- if (len > (guint32)(end_offset - offset) || len > (guint32) tvb_reported_length_remaining(tvb, offset)) {
+ if (len > (uint32_t)(end_offset - offset) || len > (uint32_t) tvb_reported_length_remaining(tvb, offset)) {
ber_add_large_length_error(actx->pinfo, tree, tvb, offset, len, tvb, len_offset, len_len);
return end_offset;
}
@@ -2639,11 +2655,11 @@ proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) entered\n", name);
* of if NOCHKTAG is set
*/
- for (first_pass = TRUE, cset = set, set_idx = 0; cset->func || first_pass; cset++, set_idx++) {
+ for (first_pass = true, cset = set, set_idx = 0; cset->func || first_pass; cset++, set_idx++) {
/* we reset for a second pass when we will look for choices */
if (!cset->func) {
- first_pass = FALSE;
+ first_pass = false;
cset = set; /* reset to the beginning */
set_idx = 0;
@@ -2660,7 +2676,7 @@ proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) entered\n", name);
/* dissect header and len for field */
hoffset = dissect_ber_identifier(actx->pinfo, tree, tvb, hoffset, NULL, NULL, NULL);
hoffset = dissect_ber_length(actx->pinfo, tree, tvb, hoffset, NULL, NULL);
- next_tvb = ber_tvb_new_subset_length(tvb, hoffset, eoffset - hoffset - (2 * ind_field));
+ next_tvb = ber_tvb_new_subset_length(tvb, hoffset, eoffset - hoffset - (ind_field ? 2 : 0));
} else {
next_tvb = ber_tvb_new_subset_length(tvb, hoffset, eoffset - hoffset);
}
@@ -2683,14 +2699,14 @@ proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) entered\n", name);
{
const char *name;
header_field_info *hfinfo;
-if (hf_id >= 0) {
+if (hf_id > 0) {
hfinfo = proto_registrar_get_nth(hf_id);
name = hfinfo->name;
} else {
name = "unnamed";
}
if (tvb_reported_length_remaining(next_tvb, 0) > 3) {
-proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) calling subdissector offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(next_tvb, 0), tvb_get_guint8(next_tvb, 0), tvb_get_guint8(next_tvb, 1), tvb_get_guint8(next_tvb, 2));
+proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) calling subdissector offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(next_tvb, 0), tvb_get_uint8(next_tvb, 0), tvb_get_uint8(next_tvb, 1), tvb_get_uint8(next_tvb, 2));
} else {
proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) calling subdissector\n", name);
}
@@ -2700,9 +2716,9 @@ proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) calling subdissector\n"
/* Assume that we have a malformed packet. */
THROW(ReportedBoundsError);
}
- imp_tag = FALSE;
+ imp_tag = false;
if ((cset->flags & BER_FLAGS_IMPLTAG))
- imp_tag = TRUE;
+ imp_tag = true;
count = cset->func(imp_tag, next_tvb, 0, actx, tree, *cset->p_id);
/* if we consumed some bytes,
@@ -2791,35 +2807,35 @@ proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) calling subdissector\n"
#endif
int
-dissect_ber_choice(asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, const ber_choice_t *choice, gint hf_id, gint ett_id, gint *branch_taken)
+dissect_ber_choice(asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, const ber_choice_t *choice, int hf_id, int ett_id, int *branch_taken)
{
- gint8 ber_class;
- bool pc, ind, imp_tag = FALSE;
- gint32 tag;
+ int8_t ber_class;
+ bool pc, ind, imp_tag = false;
+ int32_t tag;
int identifier_offset;
int identifier_len;
- guint32 len;
+ uint32_t len;
proto_tree *tree = parent_tree;
proto_item *item = NULL;
int end_offset, start_offset, count;
int hoffset = offset;
- gint length;
+ int length;
tvbuff_t *next_tvb;
- bool first_pass;
+ bool first_pass;
header_field_info *hfinfo;
const ber_choice_t *ch;
#ifdef DEBUG_BER_CHOICE
{
const char *name;
-if (hf_id >= 0) {
+if (hf_id > 0) {
hfinfo = proto_registrar_get_nth(hf_id);
name = hfinfo->name;
} else {
name = "unnamed";
}
if (tvb_reported_length_remaining(tvb, offset) > 3) {
-proto_tree_add_debug_text(tree, "CHOICE dissect_ber_choice(%s) entered offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2));
+proto_tree_add_debug_text(tree, "CHOICE dissect_ber_choice(%s) entered offset:%d len:%d %02x:%02x:%02x\n", name, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_uint8(tvb, offset), tvb_get_uint8(tvb, offset+1), tvb_get_uint8(tvb, offset+2));
} else {
proto_tree_add_debug_text(tree, "CHOICE dissect_ber_choice(%s) entered len:%d\n", name, tvb_reported_length_remaining(tvb, offset));
}
@@ -2848,7 +2864,7 @@ proto_tree_add_debug_text(tree, "CHOICE dissect_ber_choice(%s) entered len:%d\n"
/* Some sanity checks.
* The hf field passed to us MUST be an integer type
*/
- if (hf_id >= 0) {
+ if (hf_id > 0) {
hfinfo = proto_registrar_get_nth(hf_id);
switch (hfinfo->type) {
case FT_UINT8:
@@ -2869,14 +2885,14 @@ proto_tree_add_debug_text(tree, "CHOICE dissect_ber_choice(%s) entered len:%d\n"
/* loop over all entries until we find the right choice or
run out of entries */
ch = choice;
- first_pass = TRUE;
+ first_pass = true;
while (ch->func || first_pass) {
if (branch_taken) {
(*branch_taken)++;
}
/* we reset for a second pass when we will look for choices */
if (!ch->func) {
- first_pass = FALSE;
+ first_pass = false;
ch = choice; /* reset to the beginning */
if (branch_taken) {
*branch_taken = -1;
@@ -2906,7 +2922,7 @@ proto_tree_add_debug_text(tree, "CHOICE testing potential subdissector class[%p]
length = end_offset- hoffset;
}
/* create subtree */
- if (hf_id >= 0) {
+ if (hf_id > 0) {
if (parent_tree) {
item = proto_tree_add_uint(parent_tree, hf_id, tvb, hoffset, end_offset - hoffset, ch->value);
tree = proto_item_add_subtree(item, ett_id);
@@ -2933,14 +2949,14 @@ proto_tree_add_debug_text(tree, "CHOICE testing potential subdissector class[%p]
#ifdef DEBUG_BER_CHOICE
{
const char *name;
-if (hf_id >= 0) {
+if (hf_id > 0) {
hfinfo = proto_registrar_get_nth(hf_id);
name = hfinfo->name;
} else {
name = "unnamed";
}
if (tvb_reported_length_remaining(next_tvb, 0) > 3) {
-proto_tree_add_debug_text(tree, "CHOICE dissect_ber_choice(%s) calling subdissector start_offset:%d offset:%d len:%d %02x:%02x:%02x\n", name, start_offset, offset, tvb_reported_length_remaining(next_tvb, 0), tvb_get_guint8(next_tvb, 0), tvb_get_guint8(next_tvb, 1), tvb_get_guint8(next_tvb, 2));
+proto_tree_add_debug_text(tree, "CHOICE dissect_ber_choice(%s) calling subdissector start_offset:%d offset:%d len:%d %02x:%02x:%02x\n", name, start_offset, offset, tvb_reported_length_remaining(next_tvb, 0), tvb_get_uint8(next_tvb, 0), tvb_get_uint8(next_tvb, 1), tvb_get_uint8(next_tvb, 2));
} else {
proto_tree_add_debug_text(tree, "CHOICE dissect_ber_choice(%s) calling subdissector len:%d\n", name, tvb_reported_length(next_tvb));
}
@@ -2950,14 +2966,14 @@ proto_tree_add_debug_text(tree, "CHOICE dissect_ber_choice(%s) calling subdissec
/* Assume that we have a malformed packet. */
THROW(ReportedBoundsError);
}
- imp_tag = FALSE;
+ imp_tag = false;
if ((ch->flags & BER_FLAGS_IMPLTAG))
- imp_tag = TRUE;
+ imp_tag = true;
count = ch->func(imp_tag, next_tvb, 0, actx, tree, *ch->p_id);
#ifdef DEBUG_BER_CHOICE
{
const char *name;
-if (hf_id >= 0) {
+if (hf_id > 0) {
hfinfo = proto_registrar_get_nth(hf_id);
name = hfinfo->name;
} else {
@@ -2972,7 +2988,7 @@ proto_tree_add_debug_text(tree, "CHOICE dissect_ber_choice(%s) subdissector ate
#ifdef DEBUG_BER_CHOICE
{
const char *name;
-if (hf_id >= 0) {
+if (hf_id > 0) {
hfinfo = proto_registrar_get_nth(hf_id);
name = hfinfo->name;
} else {
@@ -3021,18 +3037,18 @@ proto_tree_add_debug_text(tree, "CHOICE dissect_ber_choice(%s) trying again\n",
/* this function dissects a BER GeneralString
*/
int
-dissect_ber_GeneralString(asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, char *name_string, int name_len)
+dissect_ber_GeneralString(asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, char *name_string, int name_len)
{
- gint8 ber_class;
+ int8_t ber_class;
bool pc;
- gint32 tag;
+ int32_t tag;
int identifier_offset;
int identifier_len;
- guint32 len;
+ uint32_t len;
int end_offset;
int hoffset;
char str_arr[256];
- guint32 max_len;
+ uint32_t max_len;
char *str;
proto_item *cause;
@@ -3076,7 +3092,7 @@ dissect_ber_GeneralString(asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int
tvb_memcpy(tvb, str, offset, len);
str[len]=0;
- if (hf_id >= 0) {
+ if (hf_id > 0) {
proto_tree_add_string(tree, hf_id, tvb, offset, len, str);
}
@@ -3085,13 +3101,14 @@ dissect_ber_GeneralString(asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int
#endif
int
-dissect_ber_constrained_restricted_string(bool implicit_tag, gint32 type, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint32 min_len, gint32 max_len, gint hf_id, tvbuff_t **out_tvb) {
- gint8 ber_class;
+// NOLINTNEXTLINE(misc-no-recursion)
+dissect_ber_constrained_restricted_string(bool implicit_tag, int32_t type, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int32_t min_len, int32_t max_len, int hf_id, tvbuff_t **out_tvb) {
+ int8_t ber_class;
bool pc;
- gint32 tag;
+ int32_t tag;
int identifier_offset;
int identifier_len;
- guint32 len;
+ uint32_t len;
int eoffset;
int hoffset = offset;
proto_item *cause;
@@ -3100,14 +3117,14 @@ dissect_ber_constrained_restricted_string(bool implicit_tag, gint32 type, asn1_
{
const char *name;
header_field_info *hfinfo;
-if (hf_id >= 0) {
+if (hf_id > 0) {
hfinfo = proto_registrar_get_nth(hf_id);
name = hfinfo->name;
} else {
name = "unnamed";
}
if (tvb_reported_length_remaining(tvb, offset) > 3) {
-proto_tree_add_debug_text(tree, "RESTRICTED STRING dissect_ber_octet string(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2));
+proto_tree_add_debug_text(tree, "RESTRICTED STRING dissect_ber_octet string(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_uint8(tvb, offset), tvb_get_uint8(tvb, offset+1), tvb_get_uint8(tvb, offset+2));
} else {
proto_tree_add_debug_text(tree, "RESTRICTED STRING dissect_ber_octet_string(%s) entered\n", name);
}
@@ -3145,18 +3162,20 @@ proto_tree_add_debug_text(tree, "RESTRICTED STRING dissect_ber_octet_string(%s)
return dissect_ber_constrained_octet_string(implicit_tag, actx, tree, tvb, hoffset, min_len, max_len, hf_id, out_tvb);
}
-int dissect_ber_restricted_string(bool implicit_tag, gint32 type, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, tvbuff_t **out_tvb)
+// NOLINTNEXTLINE(misc-no-recursion)
+int dissect_ber_restricted_string(bool implicit_tag, int32_t type, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, tvbuff_t **out_tvb)
{
return dissect_ber_constrained_restricted_string(implicit_tag, type, actx, tree, tvb, offset, NO_BOUND, NO_BOUND, hf_id, out_tvb);
}
int
-dissect_ber_GeneralString(asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, char *name_string, guint name_len)
+// NOLINTNEXTLINE(misc-no-recursion)
+dissect_ber_GeneralString(asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, char *name_string, unsigned name_len)
{
tvbuff_t *out_tvb = NULL;
- gint tvb_len;
+ int tvb_len;
- offset = dissect_ber_restricted_string(FALSE, BER_UNI_TAG_GeneralString, actx, tree, tvb, offset, hf_id, (name_string) ? &out_tvb : NULL);
+ offset = dissect_ber_restricted_string(false, BER_UNI_TAG_GeneralString, actx, tree, tvb, offset, hf_id, (name_string) ? &out_tvb : NULL);
if (name_string) {
/*
@@ -3166,11 +3185,11 @@ dissect_ber_GeneralString(asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int
*/
if (out_tvb) {
tvb_len = tvb_reported_length(out_tvb);
- if ((guint)tvb_len >= name_len) {
- tvb_memcpy(out_tvb, (guint8*)name_string, 0, name_len-1);
+ if ((unsigned)tvb_len >= name_len) {
+ tvb_memcpy(out_tvb, (uint8_t*)name_string, 0, name_len-1);
name_string[name_len-1] = '\0';
} else {
- tvb_memcpy(out_tvb, (guint8*)name_string, 0, tvb_len);
+ tvb_memcpy(out_tvb, (uint8_t*)name_string, 0, tvb_len);
name_string[tvb_len] = '\0';
}
}
@@ -3182,32 +3201,33 @@ dissect_ber_GeneralString(asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int
/* 8.19 Encoding of a relative or absolute object identifier value.
*/
static int
-dissect_ber_any_oid(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, tvbuff_t **value_tvb, bool is_absolute)
+// NOLINTNEXTLINE(misc-no-recursion)
+dissect_ber_any_oid(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, tvbuff_t **value_tvb, bool is_absolute)
{
- gint8 ber_class;
+ int8_t ber_class;
bool pc;
- gint32 tag;
+ int32_t tag;
int identifier_offset;
int identifier_len;
- guint32 len;
+ uint32_t len;
int eoffset;
int hoffset;
const char *str;
proto_item *cause;
- const gchar *name;
+ const char *name;
header_field_info *hfi;
#ifdef DEBUG_BER
{
header_field_info *hfinfo;
-if (hf_id >= 0) {
+if (hf_id > 0) {
hfinfo = proto_registrar_get_nth(hf_id);
name = hfinfo->name;
} else {
name = "unnamed";
}
if (tvb_reported_length_remaining(tvb, offset) > 3) {
-proto_tree_add_debug_text(tree, "OBJECT IDENTIFIER dissect_ber_any_oid(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2));
+proto_tree_add_debug_text(tree, "OBJECT IDENTIFIER dissect_ber_any_oid(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_uint8(tvb, offset), tvb_get_uint8(tvb, offset+1), tvb_get_uint8(tvb, offset+2));
} else {
proto_tree_add_debug_text(tree, "OBJECT IDENTIFIER dissect_ber_any_oid(%s) entered\n", name);
}
@@ -3250,11 +3270,11 @@ proto_tree_add_debug_text(tree, "OBJECT IDENTIFIER dissect_ber_any_oid(%s) enter
if ((is_absolute && hfi->type == FT_OID) || (!is_absolute && hfi->type == FT_REL_OID)) {
actx->created_item = proto_tree_add_item(tree, hf_id, tvb, offset, len, ENC_BIG_ENDIAN);
} else if (FT_IS_STRING(hfi->type)) {
- str = oid_encoded2string(wmem_packet_scope(), tvb_get_ptr(tvb, offset, len), len);
+ str = oid_encoded2string(actx->pinfo->pool, tvb_get_ptr(tvb, offset, len), len);
actx->created_item = proto_tree_add_string(tree, hf_id, tvb, offset, len, str);
if (actx->created_item) {
/* see if we know the name of this oid */
- name = oid_resolved_from_encoded(wmem_packet_scope(), tvb_get_ptr(tvb, offset, len), len);
+ name = oid_resolved_from_encoded(actx->pinfo->pool, tvb_get_ptr(tvb, offset, len), len);
if (name) {
proto_item_append_text(actx->created_item, " (%s)", name);
}
@@ -3270,16 +3290,17 @@ proto_tree_add_debug_text(tree, "OBJECT IDENTIFIER dissect_ber_any_oid(%s) enter
}
static int
-dissect_ber_any_oid_str(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, const char **value_stringx, bool is_absolute)
+// NOLINTNEXTLINE(misc-no-recursion)
+dissect_ber_any_oid_str(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, const char **value_stringx, bool is_absolute)
{
tvbuff_t *value_tvb = NULL;
- guint length;
+ unsigned length;
offset = dissect_ber_any_oid(implicit_tag, actx, tree, tvb, offset, hf_id, (value_stringx) ? &value_tvb : NULL, is_absolute);
if (value_stringx) {
if (value_tvb && (length = tvb_reported_length(value_tvb))) {
- *value_stringx = oid_encoded2string(wmem_packet_scope(), tvb_get_ptr(value_tvb, 0, length), length);
+ *value_stringx = oid_encoded2string(actx->pinfo->pool, tvb_get_ptr(value_tvb, 0, length), length);
} else {
*value_stringx = "";
}
@@ -3291,29 +3312,33 @@ dissect_ber_any_oid_str(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, t
/* 8.19 Encoding of a relative object identifier value.
*/
int
-dissect_ber_relative_oid(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, tvbuff_t **value_tvb)
+// NOLINTNEXTLINE(misc-no-recursion)
+dissect_ber_relative_oid(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, tvbuff_t **value_tvb)
{
- return dissect_ber_any_oid(implicit_tag, actx, tree, tvb, offset, hf_id, value_tvb, FALSE);
+ return dissect_ber_any_oid(implicit_tag, actx, tree, tvb, offset, hf_id, value_tvb, false);
}
int
-dissect_ber_relative_oid_str(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, const char **value_stringx)
+// NOLINTNEXTLINE(misc-no-recursion)
+dissect_ber_relative_oid_str(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, const char **value_stringx)
{
- return dissect_ber_any_oid_str(implicit_tag, actx, tree, tvb, offset, hf_id, value_stringx, FALSE);
+ return dissect_ber_any_oid_str(implicit_tag, actx, tree, tvb, offset, hf_id, value_stringx, false);
}
/* 8.19 Encoding of an object identifier value.
*/
int
-dissect_ber_object_identifier(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, tvbuff_t **value_tvb)
+// NOLINTNEXTLINE(misc-no-recursion)
+dissect_ber_object_identifier(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, tvbuff_t **value_tvb)
{
- return dissect_ber_any_oid(implicit_tag, actx, tree, tvb, offset, hf_id, value_tvb, TRUE);
+ return dissect_ber_any_oid(implicit_tag, actx, tree, tvb, offset, hf_id, value_tvb, true);
}
int
-dissect_ber_object_identifier_str(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, const char **value_stringx)
+// NOLINTNEXTLINE(misc-no-recursion)
+dissect_ber_object_identifier_str(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, const char **value_stringx)
{
- return dissect_ber_any_oid_str(implicit_tag, actx, tree, tvb, offset, hf_id, value_stringx, TRUE);
+ return dissect_ber_any_oid_str(implicit_tag, actx, tree, tvb, offset, hf_id, value_stringx, true);
}
#ifdef DEBUG_BER
@@ -3321,19 +3346,19 @@ dissect_ber_object_identifier_str(bool implicit_tag, asn1_ctx_t *actx, proto_tre
#endif
static int
-dissect_ber_sq_of(bool implicit_tag, gint32 type, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, gint32 min_len, gint32 max_len, const ber_sequence_t *seq, gint hf_id, gint ett_id) {
- gint8 classx;
- bool pcx, ind = FALSE, ind_field;
- gint32 tagx;
+dissect_ber_sq_of(bool implicit_tag, int32_t type, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, int32_t min_len, int32_t max_len, const ber_sequence_t *seq, int hf_id, int ett_id) {
+ int8_t classx;
+ bool pcx, ind = false, ind_field;
+ int32_t tagx;
int identifier_offset;
int identifier_len;
- guint32 lenx;
+ uint32_t lenx;
proto_tree *tree = parent_tree;
proto_item *item = NULL;
proto_item *causex;
int cnt, hoffsetx, end_offset;
- bool have_cnt;
+ bool have_cnt;
header_field_info *hfi;
tvbuff_t *next_tvb;
@@ -3341,14 +3366,14 @@ dissect_ber_sq_of(bool implicit_tag, gint32 type, asn1_ctx_t *actx, proto_tree *
{
const char *name;
header_field_info *hfinfo;
-if (hf_id >= 0) {
+if (hf_id > 0) {
hfinfo = proto_registrar_get_nth(hf_id);
name = hfinfo->name;
} else {
name = "unnamed";
}
if (tvb_reported_length_remaining(tvb,offset) > 3) {
-proto_tree_add_debug_text(tree, "SQ OF dissect_ber_sq_of(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_guint8(tvb, offset), tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2));
+proto_tree_add_debug_text(tree, "SQ OF dissect_ber_sq_of(%s) entered implicit_tag:%d offset:%d len:%d %02x:%02x:%02x\n", name, implicit_tag, offset, tvb_reported_length_remaining(tvb, offset), tvb_get_uint8(tvb, offset), tvb_get_uint8(tvb, offset+1), tvb_get_uint8(tvb, offset+2));
} else {
proto_tree_add_debug_text(tree, "SQ OF dissect_ber_sq_of(%s) entered\n", name);
}
@@ -3394,7 +3419,7 @@ proto_tree_add_debug_text(tree, "SQ OF dissect_ber_sq_of(%s) entered\n", name);
/* count number of items */
cnt = 0;
- have_cnt = FALSE;
+ have_cnt = false;
hoffsetx = offset;
/* only count the number of items IFF we have the full blob,
* else this will just generate a [short frame] before we even start
@@ -3402,16 +3427,16 @@ proto_tree_add_debug_text(tree, "SQ OF dissect_ber_sq_of(%s) entered\n", name);
*/
/* XXX Do we really need to count them at all ? ronnie */
if (tvb_captured_length_remaining(tvb, offset) == tvb_reported_length_remaining(tvb, offset)) {
- have_cnt = TRUE;
+ have_cnt = true;
while (offset < end_offset) {
- guint32 len;
- gint s_offset;
+ uint32_t len;
+ int s_offset;
s_offset = offset;
/*if (ind) { this sequence of was of indefinite length, if this is implicit indefinite impossible maybe
but ber dissector uses this to eat the tag length then pass into here... EOC still on there...*/
- if ((tvb_get_guint8(tvb, offset) == 0) && (tvb_get_guint8(tvb, offset+1) == 0)) {
+ if ((tvb_get_uint8(tvb, offset) == 0) && (tvb_get_uint8(tvb, offset+1) == 0)) {
break;
}
/* } */
@@ -3427,7 +3452,7 @@ proto_tree_add_debug_text(tree, "SQ OF dissect_ber_sq_of(%s) entered\n", name);
/* Underflow - give up; this can happen with a very large
* length.
*/
- have_cnt = FALSE;
+ have_cnt = false;
cnt = 0;
break;
}
@@ -3436,7 +3461,7 @@ proto_tree_add_debug_text(tree, "SQ OF dissect_ber_sq_of(%s) entered\n", name);
offset = hoffsetx;
/* create subtree */
- if (hf_id >= 0) {
+ if (hf_id > 0) {
hfi = proto_registrar_get_nth(hf_id);
if (parent_tree) {
if (hfi->type == FT_NONE) {
@@ -3456,10 +3481,10 @@ proto_tree_add_debug_text(tree, "SQ OF dissect_ber_sq_of(%s) entered\n", name);
/* loop over all entries until we reach the end of the sequence */
while (offset < end_offset) {
- gint8 ber_class;
+ int8_t ber_class;
bool pc;
- gint32 tag;
- guint32 len;
+ int32_t tag;
+ uint32_t len;
int eoffset;
int hoffset;
proto_item *cause;
@@ -3468,7 +3493,7 @@ proto_tree_add_debug_text(tree, "SQ OF dissect_ber_sq_of(%s) entered\n", name);
hoffset = offset;
/*if (ind) { this sequence was of indefinite length, if this is implicit indefinite impossible maybe
but ber dissector uses this to eat the tag length then pass into here... EOC still on there...*/
- if ((tvb_get_guint8(tvb, offset) == 0) && (tvb_get_guint8(tvb, offset+1) == 0)) {
+ if ((tvb_get_uint8(tvb, offset) == 0) && (tvb_get_uint8(tvb, offset+1) == 0)) {
if (show_internal_ber_fields) {
proto_tree_add_item(tree, hf_ber_seq_of_eoc, tvb, hoffset, end_offset-hoffset, ENC_NA);
}
@@ -3546,9 +3571,9 @@ proto_tree_add_debug_text(tree, "SQ OF dissect_ber_sq_of(%s) entered\n", name);
next_tvb = ber_tvb_new_subset_length(tvb, hoffset, eoffset-hoffset);
- imp_tag = FALSE;
+ imp_tag = false;
if (seq->flags == BER_FLAGS_IMPLTAG)
- imp_tag = TRUE;
+ imp_tag = true;
/* call the dissector for this field */
seq->func(imp_tag, next_tvb, 0, actx, tree, *seq->p_id);
/* hold on if we are implicit and the result is zero, i.e. the item in the sequence of
@@ -3572,36 +3597,36 @@ proto_tree_add_debug_text(tree, "SQ OF dissect_ber_sq_of(%s) entered\n", name);
}
int
-dissect_ber_constrained_sequence_of(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, gint32 min_len, gint32 max_len, const ber_sequence_t *seq, gint hf_id, gint ett_id) {
+dissect_ber_constrained_sequence_of(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, int32_t min_len, int32_t max_len, const ber_sequence_t *seq, int hf_id, int ett_id) {
return dissect_ber_sq_of(implicit_tag, BER_UNI_TAG_SEQUENCE, actx, parent_tree, tvb, offset, min_len, max_len, seq, hf_id, ett_id);
}
int
-dissect_ber_sequence_of(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, const ber_sequence_t *seq, gint hf_id, gint ett_id) {
+dissect_ber_sequence_of(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, const ber_sequence_t *seq, int hf_id, int ett_id) {
return dissect_ber_sq_of(implicit_tag, BER_UNI_TAG_SEQUENCE, actx, parent_tree, tvb, offset, NO_BOUND, NO_BOUND, seq, hf_id, ett_id);
}
int
-dissect_ber_constrained_set_of(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, gint32 min_len, gint32 max_len, const ber_sequence_t *seq, gint hf_id, gint ett_id) {
+dissect_ber_constrained_set_of(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, int32_t min_len, int32_t max_len, const ber_sequence_t *seq, int hf_id, int ett_id) {
return dissect_ber_sq_of(implicit_tag, BER_UNI_TAG_SET, actx, parent_tree, tvb, offset, min_len, max_len, seq, hf_id, ett_id);
}
int
-dissect_ber_set_of(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, const ber_sequence_t *seq, gint hf_id, gint ett_id) {
+dissect_ber_set_of(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, const ber_sequence_t *seq, int hf_id, int ett_id) {
return dissect_ber_sq_of(implicit_tag, BER_UNI_TAG_SET, actx, parent_tree, tvb, offset, NO_BOUND, NO_BOUND, seq, hf_id, ett_id);
}
int
-dissect_ber_GeneralizedTime(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id)
+dissect_ber_GeneralizedTime(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id)
{
nstime_t ts;
- const guint8 *tmpstr;
- gint8 ber_class;
+ const uint8_t *tmpstr;
+ int8_t ber_class;
bool pc;
- gint32 tag;
+ int32_t tag;
int identifier_offset;
int identifier_len;
- guint32 len;
+ uint32_t len;
int len_offset;
int len_len;
int end_offset;
@@ -3681,7 +3706,7 @@ dissect_ber_GeneralizedTime(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tre
return end_offset;
}
- tmpstr = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_ASCII);
+ tmpstr = tvb_get_string_enc(actx->pinfo->pool, tvb, offset, len, ENC_ASCII);
if (!iso8601_to_nstime(&ts, tmpstr, ISO8601_DATETIME_BASIC)) {
cause = proto_tree_add_expert_format(
tree, actx->pinfo, &ei_ber_invalid_format_generalized_time,
@@ -3695,7 +3720,7 @@ dissect_ber_GeneralizedTime(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tre
return end_offset;
}
- if (hf_id >= 0) {
+ if (hf_id > 0) {
proto_tree_add_time(tree, hf_id, tvb, offset, len, &ts);
}
@@ -3708,22 +3733,22 @@ dissect_ber_GeneralizedTime(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tre
* tvblen: if not NULL return consumed packet bytes
*/
int
-dissect_ber_UTCTime(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, char **datestrptr, guint32 *tvblen)
+dissect_ber_UTCTime(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id, char **datestrptr, uint32_t *tvblen)
{
char *outstr, *outstrptr;
- const guint8 *instr;
- gint8 ber_class;
+ const uint8_t *instr;
+ int8_t ber_class;
bool pc;
- gint32 tag;
+ int32_t tag;
int identifier_offset;
int identifier_len;
- guint32 len, i, n;
+ uint32_t len, i, n;
int hoffset;
proto_item *cause;
proto_tree *error_tree;
- const gchar *error_str = NULL;
+ const char *error_str = NULL;
- outstrptr = outstr = (char *)wmem_alloc(wmem_packet_scope(), 29);
+ outstrptr = outstr = (char *)wmem_alloc(actx->pinfo->pool, 29);
if (datestrptr) *datestrptr = NULL; /* mark invalid */
if (tvblen) *tvblen = 0;
@@ -3757,12 +3782,12 @@ dissect_ber_UTCTime(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuf
}
if ((len < 10) || (len > 19)) {
- error_str = wmem_strdup_printf(wmem_packet_scope(), "BER Error: UTCTime invalid length: %u", len);
- instr = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len > 19 ? 19 : len, ENC_ASCII);
+ error_str = wmem_strdup_printf(actx->pinfo->pool, "BER Error: UTCTime invalid length: %u", len);
+ instr = tvb_get_string_enc(actx->pinfo->pool, tvb, offset, len > 19 ? 19 : len, ENC_ASCII);
goto malformed;
}
- instr = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_ASCII);
+ instr = tvb_get_string_enc(actx->pinfo->pool, tvb, offset, len, ENC_ASCII);
/* YYMMDDhhmm */
for (i=0; i<10; i++) {
@@ -3821,7 +3846,7 @@ dissect_ber_UTCTime(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuf
i+=5;
break;
default:
- error_str = wmem_strdup_printf(wmem_packet_scope(),
+ error_str = wmem_strdup_printf(actx->pinfo->pool,
"BER Error: malformed UTCTime encoding, "
"unexpected character in %dth octet, "
"must be \'Z\', \'+\' or \'-\'", i+1);
@@ -3830,7 +3855,7 @@ dissect_ber_UTCTime(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuf
}
if (len != i) {
- error_str = wmem_strdup_printf(wmem_packet_scope(),
+ error_str = wmem_strdup_printf(actx->pinfo->pool,
"BER Error: malformed UTCTime encoding, %d unexpected character%s after %dth octet",
len - i,
(len == (i - 1) ? "s" : ""),
@@ -3841,7 +3866,7 @@ dissect_ber_UTCTime(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuf
if (datestrptr) {
*datestrptr = outstr; /* mark as valid */
} else {
- if (hf_id >= 0) {
+ if (hf_id > 0) {
proto_tree_add_string(tree, hf_id, tvb, offset, len, outstr);
}
}
@@ -3849,7 +3874,7 @@ dissect_ber_UTCTime(bool implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuf
return offset+len;
malformed:
- if (hf_id >= 0) {
+ if (hf_id > 0) {
cause = proto_tree_add_string(tree, hf_id, tvb, offset, len, instr);
error_tree = proto_item_add_subtree(cause, ett_ber_unknown);
} else {
@@ -3870,15 +3895,16 @@ malformed:
/* 8.6 Encoding of a bitstring value */
int
-dissect_ber_constrained_bitstring(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, gint32 min_len, gint32 max_len, int * const *named_bits, int num_named_bits, gint hf_id, gint ett_id, tvbuff_t **out_tvb)
+// NOLINTNEXTLINE(misc-no-recursion)
+dissect_ber_constrained_bitstring(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, int32_t min_len, int32_t max_len, int * const *named_bits, int num_named_bits, int hf_id, int ett_id, tvbuff_t **out_tvb)
{
- gint8 ber_class;
+ int8_t ber_class;
bool pc, ind;
- gint32 tag;
+ int32_t tag;
int identifier_offset;
int identifier_len;
- gint len;
- guint8 pad = 0;
+ int len;
+ uint8_t pad = 0;
int end_offset;
int hoffset;
proto_item *item = NULL;
@@ -3899,7 +3925,7 @@ dissect_ber_constrained_bitstring(bool implicit_tag, asn1_ctx_t *actx, proto_tre
/* sanity check: we only handle Universal BitStrings */
/* for an IMPLICIT APPLICATION tag asn2wrs seems to call this
- function with implicit_tag = FALSE. BER_FLAGS_NOOWNTAG was
+ function with implicit_tag = false. BER_FLAGS_NOOWNTAG was
set so the APPLICATION tag was still present.
So here we relax it for APPLICATION tags. CONTEXT tags may
still cause a problem. */
@@ -3941,7 +3967,7 @@ dissect_ber_constrained_bitstring(bool implicit_tag, asn1_ctx_t *actx, proto_tre
/* TO DO */
} else {
/* primitive */
- pad = tvb_get_guint8(tvb, offset);
+ pad = tvb_get_uint8(tvb, offset);
/* 8.6.2.4 If a bitstring value has no 1 bits, then an encoder (as a sender's option)
* may encode the value with a length of 1 and with an initial octet set to 0
* or may encode it as a bit string with one or more 0 bits following the initial octet.
@@ -3954,7 +3980,7 @@ dissect_ber_constrained_bitstring(bool implicit_tag, asn1_ctx_t *actx, proto_tre
if (out_tvb) {
*out_tvb = ber_tvb_new_subset_length(tvb, offset, len);
}
- ber_check_length(8 * len - pad, min_len, max_len, actx, item, TRUE);
+ ber_check_length(8 * len - pad, min_len, max_len, actx, item, true);
return end_offset;
} else {
/* padding */
@@ -3967,19 +3993,19 @@ dissect_ber_constrained_bitstring(bool implicit_tag, asn1_ctx_t *actx, proto_tre
}
offset++;
len--;
- if (hf_id >= 0) {
+ if (hf_id > 0) {
item = proto_tree_add_item(parent_tree, hf_id, tvb, offset, len, ENC_NA);
actx->created_item = item;
if (named_bits) {
- guint8 *bitstring = (guint8 *)tvb_memdup(wmem_packet_scope(), tvb, offset, len);
+ uint8_t *bitstring = (uint8_t *)tvb_memdup(actx->pinfo->pool, tvb, offset, len);
const int named_bits_bytelen = (num_named_bits + 7) / 8;
if (show_internal_ber_fields) {
if (len < named_bits_bytelen) {
- guint zero_bits_omitted = num_named_bits - ((len * 8) - pad);
+ unsigned zero_bits_omitted = num_named_bits - ((len * 8) - pad);
proto_item_append_text(item, " [%u zero bits not encoded, but displayed]", zero_bits_omitted);
}
}
- if (ett_id != -1) {
+ if (ett_id > 0) {
tree = proto_item_add_subtree(item, ett_id);
}
for (int i = 0; i < named_bits_bytelen; i++) {
@@ -3996,7 +4022,7 @@ dissect_ber_constrained_bitstring(bool implicit_tag, asn1_ctx_t *actx, proto_tre
// If less data is available than the number of named bits, then
// the trailing (right) bits are assumed to be 0.
- guint64 value = 0;
+ uint64_t value = 0;
if (i < len) {
value = bitstring[i];
if (num_named_bits - bit_offset > 7) {
@@ -4016,7 +4042,7 @@ dissect_ber_constrained_bitstring(bool implicit_tag, asn1_ctx_t *actx, proto_tre
for (int i = 0; i < len; i++) {
if (bitstring[i]) {
expert_add_info_format(actx->pinfo, item, &ei_ber_bits_unknown, "Unknown bit(s): 0x%s",
- bytes_to_str(wmem_packet_scope(), bitstring, len));
+ bytes_to_str(actx->pinfo->pool, bitstring, len));
break;
}
}
@@ -4029,7 +4055,7 @@ dissect_ber_constrained_bitstring(bool implicit_tag, asn1_ctx_t *actx, proto_tre
if ((pad > 0) && (pad < 8) && (len > 0)) {
- guint8 bits_in_pad = tvb_get_guint8(tvb, offset + len - 1) & (0xFF >> (8 - pad));
+ uint8_t bits_in_pad = tvb_get_uint8(tvb, offset + len - 1) & (0xFF >> (8 - pad));
if (bits_in_pad) {
expert_add_info_format(
actx->pinfo, item, &ei_ber_bits_set_padded,
@@ -4037,14 +4063,15 @@ dissect_ber_constrained_bitstring(bool implicit_tag, asn1_ctx_t *actx, proto_tre
}
}
- ber_check_length(8 * len - pad, min_len, max_len, actx, item, TRUE);
+ ber_check_length(8 * len - pad, min_len, max_len, actx, item, true);
return end_offset;
}
int
-dissect_ber_bitstring(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, int * const *named_bits, gint num_named_bits, gint hf_id, gint ett_id, tvbuff_t **out_tvb)
+// NOLINTNEXTLINE(misc-no-recursion)
+dissect_ber_bitstring(bool implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, int * const *named_bits, int num_named_bits, int hf_id, int ett_id, tvbuff_t **out_tvb)
{
return dissect_ber_constrained_bitstring(implicit_tag, actx, parent_tree, tvb, offset, -1, -1, named_bits, num_named_bits, hf_id, ett_id, out_tvb);
}
@@ -4070,7 +4097,7 @@ static int
dissect_ber_INTEGER(bool implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
&actx->external.indirect_reference);
- actx->external.indirect_ref_present = TRUE;
+ actx->external.indirect_ref_present = true;
return offset;
}
@@ -4079,7 +4106,7 @@ static int
dissect_ber_T_octet_aligned(bool implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index)
{
if (actx->external.u.ber.ber_callback) {
- offset = actx->external.u.ber.ber_callback(FALSE, tvb, offset, actx, tree, hf_index);
+ offset = actx->external.u.ber.ber_callback(false, tvb, offset, actx, tree, hf_index);
} else if (actx->external.direct_ref_present &&
dissector_get_string_handle(ber_oid_dissector_table, actx->external.direct_reference)) {
offset = call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, tree, NULL);
@@ -4094,7 +4121,7 @@ dissect_ber_OBJECT_IDENTIFIER(bool implicit_tag, tvbuff_t *tvb, int offset, asn1
{
DISSECTOR_ASSERT(actx);
offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &actx->external.direct_reference);
- actx->external.direct_ref_present = TRUE;
+ actx->external.direct_ref_present = true;
return offset;
}
@@ -4114,7 +4141,7 @@ static int
dissect_ber_T_single_ASN1_type(bool implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index)
{
if (actx->external.u.ber.ber_callback) {
- offset = actx->external.u.ber.ber_callback(FALSE, tvb, offset, actx, tree, hf_index);
+ offset = actx->external.u.ber.ber_callback(false, tvb, offset, actx, tree, hf_index);
} else {
offset = call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, tree, NULL);
}
@@ -4126,7 +4153,7 @@ static int
dissect_ber_T_arbitrary(bool implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index)
{
if (actx->external.u.ber.ber_callback) {
- offset = actx->external.u.ber.ber_callback(FALSE, tvb, offset, actx, tree, hf_index);
+ offset = actx->external.u.ber.ber_callback(false, tvb, offset, actx, tree, hf_index);
} else {
offset = dissect_ber_bitstring(implicit_tag, actx, tree, tvb, offset,
NULL, 0, hf_index, -1, &actx->external.arbitrary);
@@ -4179,12 +4206,12 @@ dissect_ber_external_U(bool implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t
}
int
-dissect_ber_external_type(bool implicit_tag, proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, gint hf_id, ber_callback func) {
+dissect_ber_external_type(bool implicit_tag, proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, int hf_id, ber_callback func) {
actx->external.u.ber.ber_callback = func;
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
- hf_id, BER_CLASS_UNI, BER_UNI_TAG_EXTERNAL, TRUE, dissect_ber_external_U);
+ hf_id, BER_CLASS_UNI, BER_UNI_TAG_EXTERNAL, true, dissect_ber_external_U);
asn1_ctx_clean_external(actx);
@@ -4192,11 +4219,11 @@ dissect_ber_external_type(bool implicit_tag, proto_tree *tree, tvbuff_t *tvb, in
}
/* Experimental */
int
-dissect_ber_EmbeddedPDV_Type(bool implicit_tag, proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, gint hf_id, ber_callback func _U_) {
+dissect_ber_EmbeddedPDV_Type(bool implicit_tag, proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, int hf_id, ber_callback func _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
- hf_id, BER_CLASS_UNI, BER_UNI_TAG_EMBEDDED_PDV, TRUE, dissect_ber_external_U);
+ hf_id, BER_CLASS_UNI, BER_UNI_TAG_EMBEDDED_PDV, true, dissect_ber_external_U);
return offset;
}
@@ -4256,7 +4283,7 @@ dissect_ber_file(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
bool
oid_has_dissector(const char *oid) {
- return(dissector_get_string_handle(ber_oid_dissector_table, oid) != NULL);
+ return (dissector_get_string_handle(ber_oid_dissector_table, oid) != NULL);
}
static void
@@ -4447,7 +4474,7 @@ proto_register_ber(void)
{ &hf_ber_encoding_boiler_plate, { "BER encoded protocol, to see BER internal fields set protocol BER preferences", "ber.encoding_boiler_plate", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
};
- static gint *ett[] = {
+ static int *ett[] = {
&ett_ber_octet_string,
&ett_ber_reassembled_octet_string,
&ett_ber_primitive,
@@ -4506,7 +4533,7 @@ proto_register_ber(void)
uat_t* users_uat = uat_new("OID Tables",
sizeof(oid_user_t),
"oid",
- FALSE,
+ false,
&oid_users,
&num_oid_users,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
@@ -4578,7 +4605,7 @@ proto_register_ber(void)
void
proto_reg_handoff_ber(void)
{
- guint i = 1;
+ unsigned i = 1;
oid_add_from_string("asn1", "2.1");
oid_add_from_string("basic-encoding", "2.1.1");
@@ -4598,6 +4625,9 @@ proto_reg_handoff_ber(void)
ber_update_oids();
dissector_add_uint("wtap_encap", WTAP_ENCAP_BER, ber_file_handle);
+
+ dissector_add_string("media_type.suffix", "ber", ber_handle); /* RFC 6839 */
+ dissector_add_string("media_type.suffix", "der", ber_handle); /* RFC 6839 */
}
/*