summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-log3gpp.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-log3gpp.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-log3gpp.c')
-rw-r--r--epan/dissectors/packet-log3gpp.c84
1 files changed, 41 insertions, 43 deletions
diff --git a/epan/dissectors/packet-log3gpp.c b/epan/dissectors/packet-log3gpp.c
index 995c509f..bf6311f0 100644
--- a/epan/dissectors/packet-log3gpp.c
+++ b/epan/dissectors/packet-log3gpp.c
@@ -11,13 +11,12 @@
#include "config.h"
-#include <stdlib.h>
-
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/proto_data.h>
#include <wiretap/wtap.h>
#include <wsutil/strtoi.h>
+#include <wsutil/array.h>
#include "packet-mac-lte.h"
#include "packet-pdcp-lte.h"
@@ -30,18 +29,18 @@ void proto_register_log3gpp(void);
void proto_reg_handoff_log3gpp(void);
/* Protocol and registered fields. */
-static int proto_log3gpp = -1;
+static int proto_log3gpp;
-static int hf_log3gpp_timestamp = -1;
-static int hf_log3gpp_protocol = -1;
-static int hf_log3gpp_direction = -1;
-static int hf_log3gpp_dissector_option = -1;
-static int hf_log3gpp_unparsed_data = -1;
-static int hf_log3gpp_dissected_length = -1;
+static int hf_log3gpp_timestamp;
+static int hf_log3gpp_protocol;
+static int hf_log3gpp_direction;
+static int hf_log3gpp_dissector_option;
+static int hf_log3gpp_unparsed_data;
+static int hf_log3gpp_dissected_length;
/* Protocol subtree. */
-static int ett_log3gpp = -1;
+static int ett_log3gpp;
/* Variables used to select a version for RRC and NAS */
static int lte_rrc_prot_version = REL8;
@@ -71,11 +70,11 @@ static const value_string direction_vals[] = {
{ 0, NULL },
};
/* Pseudo header functions*/
-typedef gboolean (*pseudo_hdr_func_ptr_t) (char *, packet_info *pinfo, guint16, packet_direction_t);
+typedef bool (*pseudo_hdr_func_ptr_t) (char *, packet_info *pinfo, uint16_t, packet_direction_t);
-static gboolean lte_mac_pseudo_hdr(char *, packet_info *pinfo, guint16, packet_direction_t);
-static gboolean lte_rlc_pseudo_hdr(char *, packet_info *pinfo, guint16, packet_direction_t);
-static gboolean lte_pdcp_pseudo_hdr(char *, packet_info *pinfo, guint16, packet_direction_t);
+static bool lte_mac_pseudo_hdr(char *, packet_info *pinfo, uint16_t, packet_direction_t);
+static bool lte_rlc_pseudo_hdr(char *, packet_info *pinfo, uint16_t, packet_direction_t);
+static bool lte_pdcp_pseudo_hdr(char *, packet_info *pinfo, uint16_t, packet_direction_t);
typedef struct
{
@@ -176,8 +175,8 @@ look_for_dissector(char* protocol_name, packet_direction_t direction, pseudo_hdr
element_ptr = (lookup_dissector_element_t*)bsearch((void*)protocol_name,
(void*)dissector_lookup_table,
- sizeof(dissector_lookup_table) / sizeof(lookup_dissector_element_t),
- sizeof(lookup_dissector_element_t),
+ array_length(dissector_lookup_table),
+ sizeof dissector_lookup_table[0],
dissector_element_compare);
if (element_ptr != NULL) {
if (direction == UPLINK)
@@ -209,8 +208,8 @@ update_dissector_name(const char* protocol_name, packet_direction_t direction, c
element_ptr = (lookup_dissector_element_t*)bsearch((void*)protocol_name,
(void*)dissector_lookup_table,
- sizeof(dissector_lookup_table) / sizeof(lookup_dissector_element_t),
- sizeof(lookup_dissector_element_t),
+ array_length(dissector_lookup_table),
+ sizeof dissector_lookup_table[0],
dissector_element_compare);
if (element_ptr != NULL) {
if (direction == UPLINK)
@@ -237,8 +236,8 @@ update_dissector_name(const char* protocol_name, packet_direction_t direction, c
* RNTI type (M): "NO_RNTI" or "P_RNTI" or "RA_RNTI" or "C_RNTI" or "SI_RNT" followed by rnti value in decimal format
* subframe number (M): "SFN" followed by the subframe number in decimal format
*/
-static gboolean
-lte_mac_pseudo_hdr(char* option_str, packet_info* pinfo, guint16 length, packet_direction_t direction)
+static bool
+lte_mac_pseudo_hdr(char* option_str, packet_info* pinfo, uint16_t length, packet_direction_t direction)
{
struct mac_lte_info* p_mac_lte_info;
char* par_opt_field;
@@ -354,8 +353,8 @@ lte_mac_pseudo_hdr(char* option_str, packet_info* pinfo, guint16 length, packet_
* UM Sequence nb length (O): "SN_5b" or "SN_10b"
*/
-static gboolean
-lte_rlc_pseudo_hdr(char* option_str, packet_info* pinfo, guint16 length, packet_direction_t direction)
+static bool
+lte_rlc_pseudo_hdr(char* option_str, packet_info* pinfo, uint16_t length, packet_direction_t direction)
{
struct rlc_lte_info* p_rlc_lte_info;
char* par_opt_field;
@@ -452,15 +451,15 @@ lte_rlc_pseudo_hdr(char* option_str, packet_info* pinfo, guint16 length, packet_
/* Store info in packet */
p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc_lte, 0, p_rlc_lte_info);
- return (1);
+ return 1;
}
/* In the optional string, PDCP info should be set as follow (M = mandatory, O = optional):
* Plane: "SRB" or "DRB"
* Sequence number length: "SN_7b" or "SN_12b"
*/
-static gboolean
-lte_pdcp_pseudo_hdr(char* option_str, packet_info* pinfo, guint16 length _U_, packet_direction_t direction)
+static bool
+lte_pdcp_pseudo_hdr(char* option_str, packet_info* pinfo, uint16_t length _U_, packet_direction_t direction)
{
struct pdcp_lte_info* p_pdcp_lte_info;
char* par_opt_field;
@@ -526,7 +525,7 @@ lte_pdcp_pseudo_hdr(char* option_str, packet_info* pinfo, guint16 length _U_, pa
/* Store info in packet */
p_add_proto_data(wmem_file_scope(), pinfo, proto_pdcp_lte, 0, p_pdcp_lte_info);
- return (1);
+ return 1;
}
@@ -538,20 +537,20 @@ dissect_log3gpp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data
{
proto_tree* prot3gpp_tree = NULL;
proto_item* ti = NULL;
- gint offset = 0;
- gint protocol_name_start;
- gint protocol_name_length;
- gint protocol_option_start;
- gint protocol_option_length;
- gint timestamp_start;
- gint timestamp_length;
+ int offset = 0;
+ int protocol_name_start;
+ int protocol_name_length;
+ int protocol_option_start;
+ int protocol_option_length;
+ int timestamp_start;
+ int timestamp_length;
packet_direction_t direction;
tvbuff_t* next_tvb;
dissector_handle_t protocol_handle = 0;
int sub_dissector_result = 0;
char* protocol_name;
char* protocol_option;
- gboolean is_hex_data;
+ bool is_hex_data;
/* Clear Info */
col_clear(pinfo->cinfo, COL_INFO);
@@ -585,7 +584,7 @@ dissect_log3gpp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data
offset += protocol_name_length;
/* Direction */
- direction = (packet_direction_t)tvb_get_guint8(tvb, offset);
+ direction = (packet_direction_t)tvb_get_uint8(tvb, offset);
if (prot3gpp_tree) {
proto_tree_add_item(prot3gpp_tree, hf_log3gpp_direction, tvb, offset, 1, ENC_BIG_ENDIAN);
}
@@ -660,8 +659,7 @@ dissect_log3gpp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data
if (!is_hex_data)
{
- col_add_fstr(pinfo->cinfo, COL_INFO,
- "%s",
+ col_add_str(pinfo->cinfo, COL_INFO,
tvb_get_string_enc(pinfo->pool, tvb, offset, tvb_reported_length(tvb) - offset, ENC_UTF_8 | ENC_NA));
}
else
@@ -689,15 +687,15 @@ dissect_log3gpp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data
/******************************************************************************/
void proto_reg_handoff_log3gpp(void)
{
- static gboolean init = FALSE;
+ static bool init = false;
- if (init == FALSE)
+ if (init == false)
{
dissector_handle_t log3gpp_handle;
log3gpp_handle = find_dissector("prot3gpp");
dissector_add_uint("wtap_encap", WTAP_ENCAP_LOG_3GPP, log3gpp_handle);
- init = TRUE;
+ init = true;
}
if (lte_rrc_prot_version == REL8)
{
@@ -783,7 +781,7 @@ void proto_register_log3gpp(void)
},
};
- static gint *ett[] =
+ static int *ett[] =
{
&ett_log3gpp
};
@@ -803,7 +801,7 @@ void proto_register_log3gpp(void)
"If they are present they should be listed here.",
&lte_rrc_prot_version,
lte_rrc_dissector_version,
- FALSE);
+ false);
prefs_register_enum_preference(log3gpp_module,
"nas_eps_release_version",
@@ -812,7 +810,7 @@ void proto_register_log3gpp(void)
"If they are present they should be listed here.",
&nas_eps_prot_version,
nas_eps_dissector_version,
- FALSE);
+ false);
/* Allow dissector to find be found by name. */
register_dissector("prot3gpp", dissect_log3gpp, proto_log3gpp);