summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-enrp.c
diff options
context:
space:
mode:
Diffstat (limited to 'epan/dissectors/packet-enrp.c')
-rw-r--r--epan/dissectors/packet-enrp.c181
1 files changed, 92 insertions, 89 deletions
diff --git a/epan/dissectors/packet-enrp.c b/epan/dissectors/packet-enrp.c
index 70114dcc..156f283c 100644
--- a/epan/dissectors/packet-enrp.c
+++ b/epan/dissectors/packet-enrp.c
@@ -26,9 +26,12 @@
#include <epan/stat_tap_ui.h>
#include <epan/expert.h>
#include <epan/proto_data.h>
+#include <epan/tfs.h>
+#include <epan/unit_strings.h>
#include <wsutil/str_util.h>
#include <wsutil/ws_roundup.h>
+#include <wsutil/array.h>
#include "packet-asap+enrp-common.h"
@@ -38,71 +41,71 @@ void proto_reg_handoff_enrp(void);
static dissector_handle_t enrp_handle;
/* Initialize the protocol and registered fields */
-static int enrp_tap = -1;
-static int proto_enrp = -1;
-static int hf_cause_code = -1;
-static int hf_cause_length = -1;
-static int hf_cause_info = -1;
-static int hf_cause_padding = -1;
-static int hf_message_type = -1;
-static int hf_message_flags = -1;
-static int hf_message_length = -1;
-static int hf_message_value = -1;
-static int hf_parameter_type = -1;
-static int hf_parameter_length = -1;
-static int hf_parameter_value = -1;
-static int hf_parameter_padding = -1;
-static int hf_parameter_ipv4_address = -1;
-static int hf_parameter_ipv6_address = -1;
-static int hf_dccp_port = -1;
-static int hf_dccp_reserved = -1;
-static int hf_dccp_service_code = -1;
-static int hf_sctp_port = -1;
-static int hf_transport_use = -1;
-static int hf_tcp_port = -1;
-static int hf_udp_port = -1;
-static int hf_udp_reserved = -1;
-static int hf_udp_lite_port = -1;
-static int hf_udp_lite_reserved = -1;
-static int hf_policy_type = -1;
-static int hf_policy_value = -1;
-static int hf_policy_weight = -1;
-static int hf_policy_priority = -1;
-static int hf_policy_load = -1;
-static int hf_policy_degradation = -1;
-static int hf_policy_loaddpf = -1;
-static int hf_policy_weightdpf = -1;
-static int hf_policy_distance = -1;
-static int hf_pool_handle = -1;
-static int hf_pe_pe_identifier = -1;
-static int hf_home_enrp_id = -1;
-static int hf_reg_life = -1;
-static int hf_server_identifier = -1;
-static int hf_cookie = -1;
-static int hf_pe_identifier = -1;
-static int hf_pe_checksum = -1;
-static int hf_sender_servers_id = -1;
-static int hf_receiver_servers_id = -1;
-static int hf_target_servers_id = -1;
-static int hf_update_action = -1;
-static int hf_pmu_reserved = -1;
-static int hf_reply_required_bit = -1;
-static int hf_own_children_only_bit = -1;
-static int hf_more_to_send_bit = -1;
-static int hf_reject_bit = -1;
-static int hf_tos_bit = -1;
+static int enrp_tap;
+static int proto_enrp;
+static int hf_cause_code;
+static int hf_cause_length;
+static int hf_cause_info;
+static int hf_cause_padding;
+static int hf_message_type;
+static int hf_message_flags;
+static int hf_message_length;
+static int hf_message_value;
+static int hf_parameter_type;
+static int hf_parameter_length;
+static int hf_parameter_value;
+static int hf_parameter_padding;
+static int hf_parameter_ipv4_address;
+static int hf_parameter_ipv6_address;
+static int hf_dccp_port;
+static int hf_dccp_reserved;
+static int hf_dccp_service_code;
+static int hf_sctp_port;
+static int hf_transport_use;
+static int hf_tcp_port;
+static int hf_udp_port;
+static int hf_udp_reserved;
+static int hf_udp_lite_port;
+static int hf_udp_lite_reserved;
+static int hf_policy_type;
+static int hf_policy_value;
+static int hf_policy_weight;
+static int hf_policy_priority;
+static int hf_policy_load;
+static int hf_policy_degradation;
+static int hf_policy_loaddpf;
+static int hf_policy_weightdpf;
+static int hf_policy_distance;
+static int hf_pool_handle;
+static int hf_pe_pe_identifier;
+static int hf_home_enrp_id;
+static int hf_reg_life;
+static int hf_server_identifier;
+static int hf_cookie;
+static int hf_pe_identifier;
+static int hf_pe_checksum;
+static int hf_sender_servers_id;
+static int hf_receiver_servers_id;
+static int hf_target_servers_id;
+static int hf_update_action;
+static int hf_pmu_reserved;
+static int hf_reply_required_bit;
+static int hf_own_children_only_bit;
+static int hf_more_to_send_bit;
+static int hf_reject_bit;
+static int hf_tos_bit;
/* Initialize the subtree pointers */
-static gint ett_enrp = -1;
-static gint ett_enrp_parameter = -1;
-static gint ett_enrp_cause = -1;
-static gint ett_enrp_flags = -1;
+static int ett_enrp;
+static int ett_enrp_parameter;
+static int ett_enrp_cause;
+static int ett_enrp_flags;
-static guint64 enrp_total_msgs = 0;
-static guint64 enrp_total_bytes = 0;
+static uint64_t enrp_total_msgs;
+static uint64_t enrp_total_bytes;
-static expert_field ei_enrp_max_recursion_depth_reached = EI_INIT;
-static expert_field ei_enrp_invalid_length = EI_INIT;
+static expert_field ei_enrp_max_recursion_depth_reached;
+static expert_field ei_enrp_invalid_length;
static void
dissect_parameters(tvbuff_t *, packet_info *, proto_tree *);
@@ -118,8 +121,8 @@ dissect_enrp(tvbuff_t *, packet_info *, proto_tree *, void*);
#define ENRP_MAX_RECURSION_DEPTH 10
typedef struct _enrp_tap_rec_t {
- guint8 type;
- guint16 size;
+ uint8_t type;
+ uint16_t size;
const char* type_string;
} enrp_tap_rec_t;
@@ -128,7 +131,7 @@ typedef struct _enrp_tap_rec_t {
static void
dissect_unknown_cause(tvbuff_t *cause_tvb, proto_tree *cause_tree, proto_item *cause_item)
{
- guint16 code, length, cause_info_length;
+ uint16_t code, length, cause_info_length;
code = tvb_get_ntohs(cause_tvb, CAUSE_CODE_OFFSET);
length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET);
@@ -142,7 +145,7 @@ static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_error_cause(tvbuff_t *cause_tvb, packet_info *pinfo, proto_tree *parameter_tree)
{
- guint16 code, length, padding_length;
+ uint16_t code, length, padding_length;
proto_item *cause_item;
proto_tree *cause_tree;
tvbuff_t *parameter_tvb, *message_tvb;
@@ -200,8 +203,8 @@ static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_error_causes(tvbuff_t *error_causes_tvb, packet_info *pinfo, proto_tree *parameter_tree)
{
- guint16 length, total_length;
- gint offset;
+ uint16_t length, total_length;
+ int offset;
tvbuff_t *error_cause_tvb;
offset = 0;
@@ -305,8 +308,8 @@ dissect_udp_lite_transport_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo
static void
dissect_pool_member_selection_policy_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree)
{
- guint32 type;
- guint length;
+ uint32_t type;
+ unsigned length;
proto_tree_add_item(parameter_tree, hf_policy_type, parameter_tvb, POLICY_TYPE_OFFSET, POLICY_TYPE_LENGTH, ENC_BIG_ENDIAN);
type = tvb_get_ntohl(parameter_tvb, POLICY_TYPE_OFFSET);
@@ -364,7 +367,7 @@ dissect_pool_member_selection_policy_parameter(tvbuff_t *parameter_tvb, proto_tr
static void
dissect_pool_handle_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *parameter_tree)
{
- guint16 handle_length;
+ uint16_t handle_length;
proto_item* pi;
handle_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
@@ -413,7 +416,7 @@ dissect_operation_error_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, p
static void
dissect_cookie_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
- guint16 cookie_length;
+ uint16_t cookie_length;
cookie_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
if (cookie_length > 0)
@@ -438,7 +441,7 @@ dissect_pe_checksum_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tre
static void
dissect_unknown_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
- guint16 type, parameter_value_length;
+ uint16_t type, parameter_value_length;
type = tvb_get_ntohs(parameter_tvb, PARAMETER_TYPE_OFFSET);
parameter_value_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
@@ -453,7 +456,7 @@ static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *enrp_tree)
{
- guint16 type, length, padding_length;
+ uint16_t type, length, padding_length;
proto_tree *parameter_item;
proto_tree *parameter_tree;
@@ -540,7 +543,7 @@ static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_parameters(tvbuff_t *parameters_tvb, packet_info *pinfo, proto_tree *tree)
{
- gint offset, length, total_length, remaining_length;
+ int offset, length, total_length, remaining_length;
tvbuff_t *parameter_tvb;
offset = 0;
@@ -769,9 +772,9 @@ dissect_enrp_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *enrp
enrp_tap_rec_t *tap_rec;
proto_item *flags_item;
proto_tree *flags_tree;
- guint8 type;
+ uint8_t type;
- type = tvb_get_guint8(message_tvb, MESSAGE_TYPE_OFFSET);
+ type = tvb_get_uint8(message_tvb, MESSAGE_TYPE_OFFSET);
if (p_get_proto_depth(pinfo, proto_enrp) == 1) {
tap_rec = wmem_new0(pinfo->pool, enrp_tap_rec_t);
tap_rec->type = type;
@@ -888,10 +891,10 @@ static stat_tap_table_item enrp_stat_fields[] = {
static void enrp_stat_init(stat_tap_table_ui* new_stat)
{
const char *table_name = "NetPerfMeter Statistics";
- int num_fields = sizeof(enrp_stat_fields)/sizeof(stat_tap_table_item);
+ int num_fields = array_length(enrp_stat_fields);
stat_tap_table *table;
int i = 0;
- stat_tap_table_item_type items[sizeof(enrp_stat_fields)/sizeof(stat_tap_table_item)];
+ stat_tap_table_item_type items[array_length(enrp_stat_fields)];
table = stat_tap_find_table(new_stat, table_name);
if (table) {
@@ -939,9 +942,9 @@ enrp_stat_packet(void* tapdata, packet_info* pinfo _U_, epan_dissect_t* edt _U_,
const enrp_tap_rec_t* tap_rec = (const enrp_tap_rec_t*)data;
stat_tap_table* table;
stat_tap_table_item_type* msg_data;
- gint idx;
- guint64 messages;
- guint64 bytes;
+ int idx;
+ uint64_t messages;
+ uint64_t bytes;
int i = 0;
double firstSeen = -1.0;
double lastSeen = -1.0;
@@ -969,9 +972,9 @@ enrp_stat_packet(void* tapdata, packet_info* pinfo _U_, epan_dissect_t* edt _U_,
/* Update messages and bytes share */
while (message_type_values[i].strptr) {
msg_data = stat_tap_get_field_data(table, i, MESSAGES_COLUMN);
- const guint m = msg_data->value.uint_value;
+ const unsigned m = msg_data->value.uint_value;
msg_data = stat_tap_get_field_data(table, i, BYTES_COLUMN);
- const guint b = msg_data->value.uint_value;
+ const unsigned b = msg_data->value.uint_value;
msg_data = stat_tap_get_field_data(table, i, MESSAGES_SHARE_COLUMN);
msg_data->type = TABLE_ITEM_FLOAT;
@@ -1029,7 +1032,7 @@ enrp_stat_packet(void* tapdata, packet_info* pinfo _U_, epan_dissect_t* edt _U_,
static void
enrp_stat_reset(stat_tap_table* table)
{
- guint element;
+ unsigned element;
stat_tap_table_item_type* item_data;
for (element = 0; element < table->num_elements; element++) {
@@ -1123,7 +1126,7 @@ proto_register_enrp(void)
{ &hf_pool_handle, { "Pool Handle", "enrp.pool_handle_pool_handle", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_pe_pe_identifier, { "PE Identifier", "enrp.pool_element_pe_identifier", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_home_enrp_id, { "Home ENRP Server Identifier", "enrp.pool_element_home_enrp_server_identifier", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
- { &hf_reg_life, { "Registration Life", "enrp.pool_element_registration_life", FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0, NULL, HFILL } },
+ { &hf_reg_life, { "Registration Life", "enrp.pool_element_registration_life", FT_INT32, BASE_DEC|BASE_UNIT_STRING, UNS(&units_milliseconds), 0x0, NULL, HFILL } },
{ &hf_server_identifier, { "Server Identifier", "enrp.server_information_server_identifier", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_cookie, { "Cookie", "enrp.cookie", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_pe_identifier, { "PE Identifier", "enrp.pe_identifier", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
@@ -1141,7 +1144,7 @@ proto_register_enrp(void)
};
/* Setup protocol subtree array */
- static gint *ett[] = {
+ static int *ett[] = {
&ett_enrp,
&ett_enrp_parameter,
&ett_enrp_cause,
@@ -1158,7 +1161,7 @@ proto_register_enrp(void)
};
static tap_param enrp_stat_params[] = {
- { PARAM_FILTER, "filter", "Filter", NULL, TRUE }
+ { PARAM_FILTER, "filter", "Filter", NULL, true }
};
static stat_tap_table_ui enrp_stat_table = {
@@ -1171,8 +1174,8 @@ proto_register_enrp(void)
enrp_stat_reset,
NULL,
NULL,
- sizeof(enrp_stat_fields)/sizeof(stat_tap_table_item), enrp_stat_fields,
- sizeof(enrp_stat_params)/sizeof(tap_param), enrp_stat_params,
+ array_length(enrp_stat_fields), enrp_stat_fields,
+ array_length(enrp_stat_params), enrp_stat_params,
NULL,
0
};