diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:14:53 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:14:53 +0000 |
commit | a86c5f7cae7ec9a3398300555a0b644689d946a1 (patch) | |
tree | 39fe4b107c71174fd1e8a8ceb9a4d2aa14116248 /epan/dissectors/packet-netperfmeter.c | |
parent | Releasing progress-linux version 4.2.6-1~progress7.99u1. (diff) | |
download | wireshark-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-netperfmeter.c')
-rw-r--r-- | epan/dissectors/packet-netperfmeter.c | 245 |
1 files changed, 124 insertions, 121 deletions
diff --git a/epan/dissectors/packet-netperfmeter.c b/epan/dissectors/packet-netperfmeter.c index 9e5349ab..543703b3 100644 --- a/epan/dissectors/packet-netperfmeter.c +++ b/epan/dissectors/packet-netperfmeter.c @@ -19,24 +19,27 @@ #include <epan/packet.h> #include <epan/sctpppids.h> #include <epan/stat_tap_ui.h> +#include <epan/tfs.h> + +#include <wsutil/array.h> void proto_register_npm(void); void proto_reg_handoff_npm(void); static dissector_handle_t npm_handle; -static int proto_npm = -1; +static int proto_npm; static int tap_npm = -1; -static int ett_npm = -1; -static int ett_addflow_flags = -1; -static int ett_identifyflow_flags = -1; -static int ett_start_flags = -1; -static int ett_data_flags = -1; -static int ett_results_flags = -1; -static int ett_onoffarray = -1; +static int ett_npm; +static int ett_addflow_flags; +static int ett_identifyflow_flags; +static int ett_start_flags; +static int ett_data_flags; +static int ett_results_flags; +static int ett_onoffarray; -static guint64 npm_total_msgs = 0; -static guint64 npm_total_bytes = 0; +static uint64_t npm_total_msgs; +static uint64_t npm_total_bytes; #define PPID_NETPERFMETER_CONTROL_LEGACY 0x29097605 @@ -66,83 +69,83 @@ static const value_string message_type_values[] = { { 0, NULL } }; -static int hf_message_type = -1; -static int hf_message_flags = -1; -static int hf_message_length = -1; - -static int hf_acknowledge_flowid = -1; -static int hf_acknowledge_measurementid = -1; -static int hf_acknowledge_streamid = -1; -// static int hf_acknowledge_padding = -1; -static int hf_acknowledge_status = -1; - -static int hf_addflow_flag_debug = -1; -static int hf_addflow_flag_nodelay = -1; -static int hf_addflow_flag_repeatonoff = -1; -static int hf_addflow_flowid = -1; -static int hf_addflow_measurementid = -1; -static int hf_addflow_streamid = -1; -static int hf_addflow_protocol = -1; -static int hf_addflow_flags = -1; -static int hf_addflow_description = -1; -static int hf_addflow_ordered = -1; -static int hf_addflow_reliable = -1; -static int hf_addflow_retranstrials = -1; -static int hf_addflow_framerate1 = -1; -static int hf_addflow_framerate2 = -1; -static int hf_addflow_framerate3 = -1; -static int hf_addflow_framerate4 = -1; -static int hf_addflow_framesize1 = -1; -static int hf_addflow_framesize2 = -1; -static int hf_addflow_framesize3 = -1; -static int hf_addflow_framesize4 = -1; -static int hf_addflow_frameraterng = -1; -static int hf_addflow_framesizerng = -1; -static int hf_addflow_rcvbuffersize = -1; -static int hf_addflow_sndbuffersize = -1; -static int hf_addflow_maxmsgsize = -1; -static int hf_addflow_cmt = -1; -static int hf_addflow_ccid = -1; -static int hf_addflow_onoffevents = -1; -static int hf_addflow_onoffeventarray = -1; - -static int hf_removeflow_flowid = -1; -static int hf_removeflow_measurementid = -1; -static int hf_removeflow_streamid = -1; - -static int hf_identifyflow_flag_compress_vectors = -1; -static int hf_identifyflow_flag_no_vectors = -1; -static int hf_identifyflow_flowid = -1; -static int hf_identifyflow_magicnumber = -1; -static int hf_identifyflow_measurementid = -1; -static int hf_identifyflow_streamid = -1; +static int hf_message_type; +static int hf_message_flags; +static int hf_message_length; + +static int hf_acknowledge_flowid; +static int hf_acknowledge_measurementid; +static int hf_acknowledge_streamid; +// static int hf_acknowledge_padding; +static int hf_acknowledge_status; + +static int hf_addflow_flag_debug; +static int hf_addflow_flag_nodelay; +static int hf_addflow_flag_repeatonoff; +static int hf_addflow_flowid; +static int hf_addflow_measurementid; +static int hf_addflow_streamid; +static int hf_addflow_protocol; +static int hf_addflow_flags; +static int hf_addflow_description; +static int hf_addflow_ordered; +static int hf_addflow_reliable; +static int hf_addflow_retranstrials; +static int hf_addflow_framerate1; +static int hf_addflow_framerate2; +static int hf_addflow_framerate3; +static int hf_addflow_framerate4; +static int hf_addflow_framesize1; +static int hf_addflow_framesize2; +static int hf_addflow_framesize3; +static int hf_addflow_framesize4; +static int hf_addflow_frameraterng; +static int hf_addflow_framesizerng; +static int hf_addflow_rcvbuffersize; +static int hf_addflow_sndbuffersize; +static int hf_addflow_maxmsgsize; +static int hf_addflow_cmt; +static int hf_addflow_ccid; +static int hf_addflow_onoffevents; +static int hf_addflow_onoffeventarray; + +static int hf_removeflow_flowid; +static int hf_removeflow_measurementid; +static int hf_removeflow_streamid; + +static int hf_identifyflow_flag_compress_vectors; +static int hf_identifyflow_flag_no_vectors; +static int hf_identifyflow_flowid; +static int hf_identifyflow_magicnumber; +static int hf_identifyflow_measurementid; +static int hf_identifyflow_streamid; #define NETPERFMETER_IDENTIFY_FLOW_MAGIC_NUMBER 0x4bcdf3aa303c6774ULL -static int hf_data_flag_frame_begin = -1; -static int hf_data_flag_frame_end = -1; -static int hf_data_flowid = -1; -static int hf_data_measurementid = -1; -static int hf_data_streamid = -1; -static int hf_data_padding = -1; -static int hf_data_frameid = -1; -static int hf_data_packetseqnumber = -1; -static int hf_data_byteseqnumber = -1; -static int hf_data_timestamp = -1; -static int hf_data_payload = -1; +static int hf_data_flag_frame_begin; +static int hf_data_flag_frame_end; +static int hf_data_flowid; +static int hf_data_measurementid; +static int hf_data_streamid; +static int hf_data_padding; +static int hf_data_frameid; +static int hf_data_packetseqnumber; +static int hf_data_byteseqnumber; +static int hf_data_timestamp; +static int hf_data_payload; -static int hf_start_flag_compress_vectors = -1; -static int hf_start_flag_compress_scalars = -1; -static int hf_start_flag_no_vectors = -1; -static int hf_start_flag_no_scalars = -1; -// static int hf_start_padding = -1; -static int hf_start_measurementid = -1; +static int hf_start_flag_compress_vectors; +static int hf_start_flag_compress_scalars; +static int hf_start_flag_no_vectors; +static int hf_start_flag_no_scalars; +// static int hf_start_padding; +static int hf_start_measurementid; -// static int hf_stop_padding = -1; -static int hf_stop_measurementid = -1; +// static int hf_stop_padding; +static int hf_stop_measurementid; -static int hf_results_flag_eof = -1; -static int hf_results_data = -1; +static int hf_results_flag_eof; +static int hf_results_data; /* Setup list of Transport Layer protocol types */ @@ -279,8 +282,8 @@ static hf_register_info hf[] = { typedef struct _tap_npm_rec_t { - guint8 type; - guint16 size; + uint8_t type; + uint16_t size; const char* type_string; } tap_npm_rec_t; @@ -299,12 +302,12 @@ dissect_npm_acknowledge_message(tvbuff_t *message_tvb, proto_tree *message_tree) static void dissect_npm_add_flow_message(tvbuff_t *message_tvb, proto_tree *message_tree, proto_item *flags_item) { - guint32 retranstrials; + uint32_t retranstrials; proto_item* onoffitem; proto_tree* onofftree; proto_tree* flags_tree; - guint16 onoffevents; - guint32 onoffvalue; + uint16_t onoffevents; + uint32_t onoffvalue; unsigned int i; flags_tree = proto_item_add_subtree(flags_item, ett_addflow_flags); @@ -353,9 +356,9 @@ dissect_npm_add_flow_message(tvbuff_t *message_tvb, proto_tree *message_tree, pr if (onoffevents > 0) { onofftree = proto_item_add_subtree(onoffitem, ett_onoffarray); for(i = 0;i < onoffevents;i++) { - onoffvalue = tvb_get_ntohl(message_tvb, 144 + (int)(sizeof(guint32) * i)); + onoffvalue = tvb_get_ntohl(message_tvb, 144 + (int)(sizeof(uint32_t) * i)); proto_tree_add_uint_format(onofftree, hf_addflow_onoffeventarray, message_tvb, - 144 + (int)(sizeof(guint32) * i), (int)sizeof(guint32), + 144 + (int)(sizeof(uint32_t) * i), (int)sizeof(uint32_t), onoffvalue, "%1.3f s: set to %s", onoffvalue / 1000.0, (i & 1) ? "OFF" : "ON"); } } @@ -391,8 +394,8 @@ static void dissect_npm_data_message(tvbuff_t *message_tvb, proto_tree *message_tree, proto_item *flags_item) { proto_tree* flags_tree; - const guint16 message_length = tvb_get_ntohs(message_tvb, 2); - guint64 timestamp; + const uint16_t message_length = tvb_get_ntohs(message_tvb, 2); + uint64_t timestamp; nstime_t t; flags_tree = proto_item_add_subtree(flags_item, ett_data_flags); @@ -449,7 +452,7 @@ dissect_npm_results_message(tvbuff_t *message_tvb, proto_tree *message_tree, pro flags_tree = proto_item_add_subtree(flags_item, ett_data_flags); proto_tree_add_item(flags_tree, hf_results_flag_eof, message_tvb, 1, 1, ENC_BIG_ENDIAN); - const guint16 message_length = tvb_get_ntohs(message_tvb, 2); + const uint16_t message_length = tvb_get_ntohs(message_tvb, 2); if (message_length > 4) { proto_tree_add_item(message_tree, hf_results_data, message_tvb, 4, message_length - 4, ENC_NA); } @@ -462,7 +465,7 @@ dissect_npm_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *npm_t proto_tree* flags_tree; tap_npm_rec_t* tap_rec = wmem_new0(pinfo->pool, tap_npm_rec_t); - tap_rec->type = tvb_get_guint8(message_tvb, 0); + tap_rec->type = tvb_get_uint8(message_tvb, 0); tap_rec->size = tvb_get_ntohs(message_tvb, 2); tap_rec->type_string = val_to_str_const(tap_rec->type, message_type_values, "Unknown NetPerfMeter message type"); tap_queue_packet(tap_npm, pinfo, tap_rec); @@ -520,46 +523,46 @@ dissect_npm(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree, void *d }; /* dissect the message */ dissect_npm_message(message_tvb, pinfo, npm_tree); - return TRUE; + return true; } -static int -heur_dissect_npm(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) +static bool +dissect_npm_heur(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - const guint length = tvb_captured_length(message_tvb); + const unsigned length = tvb_captured_length(message_tvb); if (length < 4) - return FALSE; + return false; /* For TCP, UDP or DCCP: Type must either be NETPERFMETER_DATA or NETPERFMETER_IDENTIFY_FLOW */ - const guint8 type = tvb_get_guint8(message_tvb, 0); + const uint8_t type = tvb_get_uint8(message_tvb, 0); switch(type) { case NETPERFMETER_DATA: if (length < 48 + 8) - return FALSE; + return false; /* Identify NetPerfMeter flow by payload pattern */ for(int i = 0; i < 8; i++) { - guint8 d = tvb_get_guint8(message_tvb, 48 + i); + uint8_t d = tvb_get_uint8(message_tvb, 48 + i); if( (d != 30 + i) && (d != 127 - i) ) - return FALSE; + return false; } break; case NETPERFMETER_IDENTIFY_FLOW: if (length < 24 + 2) - return FALSE; + return false; if (tvb_get_ntoh64(message_tvb, 8) != NETPERFMETER_IDENTIFY_FLOW_MAGIC_NUMBER) { /* Identify NetPerfMeter flow by NETPERFMETER_IDENTIFY_FLOW_MAGIC_NUMBER */ - return FALSE; + return false; } break; default: /* Not a NetPerfMeter packet */ - return FALSE; + return false; break; } - - return dissect_npm(message_tvb, pinfo, tree, data); + dissect_npm(message_tvb, pinfo, tree, data); + return true; } @@ -594,10 +597,10 @@ static stat_tap_table_item npm_stat_fields[] = { static void npm_stat_init(stat_tap_table_ui* new_stat) { const char *table_name = "NetPerfMeter Statistics"; - int num_fields = sizeof(npm_stat_fields)/sizeof(stat_tap_table_item); + int num_fields = array_length(npm_stat_fields); stat_tap_table *table; int i = 0; - stat_tap_table_item_type items[sizeof(npm_stat_fields)/sizeof(stat_tap_table_item)]; + stat_tap_table_item_type items[array_length(npm_stat_fields)]; table = stat_tap_find_table(new_stat, table_name); if (table) { @@ -645,9 +648,9 @@ npm_stat_packet(void* tapdata, packet_info* pinfo _U_, epan_dissect_t* edt _U_, const tap_npm_rec_t* tap_rec = (const tap_npm_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; @@ -675,9 +678,9 @@ npm_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; @@ -735,7 +738,7 @@ npm_stat_packet(void* tapdata, packet_info* pinfo _U_, epan_dissect_t* edt _U_, static void npm_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++) { @@ -792,7 +795,7 @@ void proto_register_npm(void) { /* Setup protocol subtree array */ - static gint *ett[] = { + static int *ett[] = { &ett_npm, &ett_addflow_flags, &ett_identifyflow_flags, @@ -803,7 +806,7 @@ proto_register_npm(void) }; static tap_param npm_stat_params[] = { - { PARAM_FILTER, "filter", "Filter", NULL, TRUE } + { PARAM_FILTER, "filter", "Filter", NULL, true } }; static stat_tap_table_ui npm_stat_table = { @@ -816,8 +819,8 @@ proto_register_npm(void) npm_stat_reset, NULL, NULL, - sizeof(npm_stat_fields)/sizeof(stat_tap_table_item), npm_stat_fields, - sizeof(npm_stat_params)/sizeof(tap_param), npm_stat_params, + array_length(npm_stat_fields), npm_stat_fields, + array_length(npm_stat_params), npm_stat_params, NULL, 0 }; @@ -847,9 +850,9 @@ proto_reg_handoff_npm(void) dissector_add_uint("sctp.ppi", NPMP_DATA_PAYLOAD_PROTOCOL_ID, npm_handle); /* Heuristic dissector for TCP, UDP and DCCP */ - heur_dissector_add("tcp", heur_dissect_npm, "NetPerfMeter over TCP", "netperfmeter_tcp", proto_npm, HEURISTIC_ENABLE); - heur_dissector_add("udp", heur_dissect_npm, "NetPerfMeter over UDP", "netperfmeter_udp", proto_npm, HEURISTIC_ENABLE); - heur_dissector_add("dccp", heur_dissect_npm, "NetPerfMeter over DCCP", "netperfmeter_dccp", proto_npm, HEURISTIC_ENABLE); + heur_dissector_add("tcp", dissect_npm_heur, "NetPerfMeter over TCP", "netperfmeter_tcp", proto_npm, HEURISTIC_ENABLE); + heur_dissector_add("udp", dissect_npm_heur, "NetPerfMeter over UDP", "netperfmeter_udp", proto_npm, HEURISTIC_ENABLE); + heur_dissector_add("dccp", dissect_npm_heur, "NetPerfMeter over DCCP", "netperfmeter_dccp", proto_npm, HEURISTIC_ENABLE); } /* |