From e0bb1ddea7db6e1ea8018d048ee3a9a614a13cc1 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Mon, 16 Dec 2019 14:50:55 +0200 Subject: TPNCP: Update from downstream * Support little-endian systems * Improve error reporting * Implement some new features in the protocol Change-Id: I73e07a588c4a028fd0c22e1570adb7957ba2d52f Reviewed-on: https://code.wireshark.org/review/35467 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- epan/dissectors/packet-tpncp.c | 850 ++++++++++++++++++++--------------------- epan/prefs.c | 2 + 2 files changed, 407 insertions(+), 445 deletions(-) diff --git a/epan/dissectors/packet-tpncp.c b/epan/dissectors/packet-tpncp.c index 60e1007bad..cc1d45d9f0 100644 --- a/epan/dissectors/packet-tpncp.c +++ b/epan/dissectors/packet-tpncp.c @@ -10,36 +10,38 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ -/*-------------------------------------------------------------------------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ +#define G_LOG_DOMAIN "TPNCP" #include "config.h" #include #include +#include #include -#include #include #include #include #include +#include #include "packet-tcp.h" -/*-------------------------------------------------------------------------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ #define BASE_TPNCP_PORT 2424 +#define HA_PORT_TPNCP_TRUNKPACK 2442 #define TCP_PORT_TPNCP_TRUNKPACK BASE_TPNCP_PORT #define UDP_PORT_TPNCP_TRUNKPACK BASE_TPNCP_PORT #define TCP_PORT_TPNCP_HOST BASE_TPNCP_PORT #define UDP_PORT_TPNCP_HOST BASE_TPNCP_PORT -#define BASE_TPNCP_DATA_LEN 256 -#define MAX_TPNCP_DB_ENTRY_LEN BASE_TPNCP_DATA_LEN +#define MAX_TPNCP_DB_ENTRY_LEN 3000 -#define MAX_TPNCP_DB_SIZE 3000 -#define MAX_ENUMS_NUM 500 -#define MAX_ENUM_ENTRIES 500 +#define MAX_TPNCP_DB_SIZE 5000 +#define MAX_ENUMS_NUM 1000 +#define MAX_ENUM_ENTRIES 1000 -/*-------------------------------------------------------------------------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ void proto_register_tpncp(void); void proto_reg_handoff_tpncp(void); @@ -48,63 +50,53 @@ void proto_reg_handoff_tpncp(void); typedef struct tpncp_data_field_info { gchar *tpncp_data_field_name; - gint tpncp_data_field_descr; - gint tpncp_data_field_sign; - gint tpncp_data_field_size; - gint tpncp_data_field_array_dim; - gint tpncp_data_field_is_ip_addr; + gint tpncp_data_field_descr; + gint tpncp_data_field_sign; + gint tpncp_data_field_size; + gint tpncp_data_field_array_dim; + gint tpncp_data_field_is_ip_addr; struct tpncp_data_field_info *p_next; } tpncp_data_field_info; -/*-------------------------------------------------------------------------------------------------------------------------------------------*/ - -/* Desegmentation of TPNCP over TCP */ +/*--------------------------------------------------------------------------- + * Desegmentation of TPNCP over TCP */ static gboolean tpncp_desegment = TRUE; -/* Database for storing information about all TPNCP events. */ -/* XXX: ToDo: allocate at runtime as needed */ +/* Database for storing information about all TPNCP events. + * XXX: ToDo: allocate at runtime as needed*/ static tpncp_data_field_info tpncp_events_info_db[MAX_TPNCP_DB_SIZE]; -/* Database for storing information about all TPNCP commands. */ -/* XXX: ToDo: allocate at runtime as needed */ +/* Database for storing information about all TPNCP commands. + * XXX: ToDo: allocate at runtime as needed*/ static tpncp_data_field_info tpncp_commands_info_db[MAX_TPNCP_DB_SIZE]; /* Global variables for bitfields representation. */ static gint bits[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80}; -static gint bitindex = 0; /* TPNCP packet header fields. */ static gint proto_tpncp = -1; static gint hf_tpncp_version = -1; static gint hf_tpncp_length = -1; static gint hf_tpncp_seq_number = -1; -/* static gint hf_tpncp_old_event_seq_number = -1; */ +static gint hf_tpncp_length_ext = -1; static gint hf_tpncp_reserved = -1; static gint hf_tpncp_command_id = -1; -/* static gint hf_tpncp_old_command_id = -1; */ static gint hf_tpncp_event_id = -1; static gint hf_tpncp_cid = -1; +static expert_field ei_tpncp_unknown_data = EI_INIT; + /* TPNCP fields defining a subtree. */ static gint ett_tpncp = -1; static gint ett_tpncp_body = -1; -static guint global_tpncp_trunkpack_tcp_port = TCP_PORT_TPNCP_TRUNKPACK; -static guint global_tpncp_trunkpack_udp_port = UDP_PORT_TPNCP_TRUNKPACK; -static guint global_tpncp_host_tcp_port = TCP_PORT_TPNCP_HOST; -static guint global_tpncp_host_udp_port = UDP_PORT_TPNCP_HOST; static gboolean global_tpncp_load_db = FALSE; static dissector_handle_t tpncp_handle; -static guint trunkpack_tcp_port = 0; -static guint trunkpack_udp_port = 0; -static guint host_tcp_port = 0; -static guint host_udp_port = 0; - -/* XXX: ToDo: allocate at runtime as needed */ -/* The following allocates something on the order of 2M of static memory ! */ -/* Also: Runtime value_string_ext arrays should be used */ +/* XXX: ToDo: allocate at runtime as needed + * The following allocates something on the order of 2M of static memory ! + * Also: Runtime value_string_ext arrays should be used*/ static value_string tpncp_commands_id_vals[MAX_TPNCP_DB_SIZE]; static value_string tpncp_events_id_vals[MAX_TPNCP_DB_SIZE]; static value_string tpncp_enums_id_vals[MAX_ENUMS_NUM][MAX_ENUM_ENTRIES]; @@ -114,211 +106,183 @@ static gint hf_size = 1; static gint hf_allocated = 0; static hf_register_info *hf = NULL; -/*-------------------------------------------------------------------------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ -static void dissect_tpncp_data(gint data_id, tvbuff_t *tvb, proto_tree *ltree, - gint *offset, tpncp_data_field_info *data_fields_info) { - proto_item *pi = NULL; - gint32 g_int; - gint16 g_short; - guint16 g_ushort; +static void +dissect_tpncp_data(guint data_id, packet_info *pinfo, tvbuff_t *tvb, proto_tree *ltree, + gint *offset, tpncp_data_field_info *data_fields_info, guint encoding) +{ gint8 g_char; guint8 g_uchar; gint g_str_len, counter, bitshift, bitmask; tpncp_data_field_info *current_tpncp_data_field_info = NULL; + gint bitindex = encoding == ENC_LITTLE_ENDIAN ? 7 : 0; current_tpncp_data_field_info = &data_fields_info[data_id]; while (current_tpncp_data_field_info) { - switch(current_tpncp_data_field_info->tpncp_data_field_size) { - case 1: case 2: case 3: case 4: - case 5: case 6: case 7: case 8: - if ((g_str_len = current_tpncp_data_field_info->tpncp_data_field_array_dim)) { /* add char array */ - g_str_len = MIN(g_str_len, tvb_reported_length_remaining(tvb, *offset)); - proto_tree_add_item(ltree, current_tpncp_data_field_info->tpncp_data_field_descr, - tvb, *offset, g_str_len, ENC_NA|ENC_ASCII); - (*offset) += g_str_len; - } - else { /* add single char */ - g_uchar = tvb_get_guint8(tvb, *offset); - /* bitfields */ - if (current_tpncp_data_field_info->tpncp_data_field_size != 8) { - for (counter = 0, bitmask = 0x0, bitshift = bitindex; - counter < current_tpncp_data_field_info->tpncp_data_field_size; - counter++) - bitmask |= bits[bitindex++]; /* Bitmask of interesting bits. */ - g_uchar &= bitmask; - g_uchar >>= bitshift; + switch (current_tpncp_data_field_info->tpncp_data_field_size) { + case 1: case 2: case 3: case 4: + case 5: case 6: case 7: case 8: + /* add char array */ + if ((g_str_len = current_tpncp_data_field_info->tpncp_data_field_array_dim)) { + g_str_len = MIN(g_str_len, tvb_reported_length_remaining(tvb, *offset)); + proto_tree_add_item(ltree, current_tpncp_data_field_info->tpncp_data_field_descr, + tvb, *offset, g_str_len, ENC_NA | ENC_ASCII); + (*offset) += g_str_len; + } else { /* add single char */ + g_uchar = tvb_get_guint8(tvb, *offset); + + /* bitfields */ + + if (current_tpncp_data_field_info->tpncp_data_field_size != 8) { + for (counter = 0, bitmask = 0x0, bitshift = bitindex; + counter < current_tpncp_data_field_info->tpncp_data_field_size; + counter++) { + bitmask |= bits[bitindex]; /* Bitmask of interesting bits. */ + bitindex += encoding == ENC_LITTLE_ENDIAN ? -1 : 1; } - if (current_tpncp_data_field_info->tpncp_data_field_sign || current_tpncp_data_field_info->tpncp_data_field_size != 8) { - proto_tree_add_uint(ltree, current_tpncp_data_field_info->tpncp_data_field_descr, - tvb, *offset, 1, g_uchar); - } - else { - /* signed*/ - g_char = (gint8)g_uchar; - proto_tree_add_int(ltree, current_tpncp_data_field_info->tpncp_data_field_descr, - tvb, *offset, 1, g_char); - } - if ((bitindex == 0) || (bitindex == 8)) { - (*offset)++; - bitindex = 0; - } - } - break; - case 16: - if (current_tpncp_data_field_info->tpncp_data_field_sign) { - g_ushort = tvb_get_ntohs(tvb, *offset); - proto_tree_add_uint(ltree, current_tpncp_data_field_info->tpncp_data_field_descr, - tvb, *offset, 2, g_ushort); + g_uchar &= bitmask; + g_uchar >>= bitshift; } - else { - g_short = tvb_get_ntohs(tvb, *offset); + if (current_tpncp_data_field_info->tpncp_data_field_sign || + current_tpncp_data_field_info->tpncp_data_field_size != 8) { + proto_tree_add_uint(ltree, + current_tpncp_data_field_info->tpncp_data_field_descr, + tvb, *offset, 1, g_uchar); + } else { + /* signed*/ + g_char = (gint8) g_uchar; proto_tree_add_int(ltree, current_tpncp_data_field_info->tpncp_data_field_descr, - tvb, *offset, 2, g_short); + tvb, *offset, 1, g_char); } - (*offset) += 2; - break; - case 32: - g_int = tvb_get_ntohl(tvb, *offset); - if (current_tpncp_data_field_info->tpncp_data_field_sign) { - pi = proto_tree_add_uint(ltree, current_tpncp_data_field_info->tpncp_data_field_descr, - tvb, *offset, 4, g_int); - } - else { - pi = proto_tree_add_int(ltree, current_tpncp_data_field_info->tpncp_data_field_descr, - tvb, *offset, 4, g_int); - } - /* Add string representation for ip_address's field (if needed). */ - if (current_tpncp_data_field_info->tpncp_data_field_is_ip_addr) { - proto_item_append_text(pi, " (%s)", tvb_ip_to_str(tvb, *offset)); + if (((bitindex == 0 || bitindex == 8) && encoding == ENC_BIG_ENDIAN) || + ((bitindex == -1 || bitindex == 7) && encoding == ENC_LITTLE_ENDIAN)) { + (*offset)++; + bitindex = encoding == ENC_LITTLE_ENDIAN ? 7 : 0; } - (*offset) += 4; - break; - default: - break; - } - current_tpncp_data_field_info = current_tpncp_data_field_info->p_next; - if (tvb_reported_length_remaining(tvb, *offset) <= 0) { + } break; - } - } -} - -/*-------------------------------------------------------------------------------------------------------------------------------------------*/ - -static void dissect_tpncp_event(gint event_id, tvbuff_t *tvb, - proto_tree *tree, gint *offset) { - switch (event_id) { - /* Place non-standard events here. */ - default: - dissect_tpncp_data(event_id, tvb, tree, offset, tpncp_events_info_db); + case 16: + proto_tree_add_item(ltree, current_tpncp_data_field_info->tpncp_data_field_descr, + tvb, *offset, 2, encoding); + (*offset) += 2; + break; + case 32: + proto_tree_add_item(ltree, current_tpncp_data_field_info->tpncp_data_field_descr, + tvb, *offset, 4, encoding); + (*offset) += 4; break; - } -} - -/*-------------------------------------------------------------------------------------------------------------------------------------------*/ - -static void dissect_tpncp_command(gint command_id, tvbuff_t *tvb, - proto_tree *tree, gint *offset) { - switch (command_id) { - /* Place non-standard commands here. */ default: - dissect_tpncp_data(command_id, tvb, tree, offset, tpncp_commands_info_db); break; + } + current_tpncp_data_field_info = current_tpncp_data_field_info->p_next; + if (tvb_reported_length_remaining(tvb, *offset) <= 0 || !current_tpncp_data_field_info) + break; + } + if ((g_str_len = tvb_reported_length_remaining(tvb, *offset)) > 0) { + expert_add_info_format(pinfo, ltree, &ei_tpncp_unknown_data, "TPNCP Unknown Data"); + (*offset) += g_str_len; } } -/*-------------------------------------------------------------------------------------------------------------------------------------------*/ - -static int dissect_tpncp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { +/*---------------------------------------------------------------------------*/ +static int +dissect_tpncp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) +{ proto_item *item = NULL; proto_tree *tpncp_tree = NULL, *event_tree, *command_tree; - gint offset = 0; - guint32 id, cid = 0; - guint16 seq_number, len, ver, reserved; + gint offset = 0, cid = 0; + guint id; + guint seq_number, len, ver; + guint len_ext, reserved; + guint32 fullLength; - ver = tvb_get_ntohs(tvb, 0); - len = tvb_get_ntohs(tvb, 2); - seq_number = tvb_get_ntohs(tvb, 4); - reserved = tvb_get_ntohs(tvb, 6); - id = tvb_get_ntohl(tvb, 8); - - if (pinfo->srcport == UDP_PORT_TPNCP_TRUNKPACK) /* Event */ - cid = tvb_get_ntohl(tvb, 12 ); + guint encoding = tvb_get_ntohs(tvb, 8) == 0 ? ENC_BIG_ENDIAN : ENC_LITTLE_ENDIAN; col_set_str(pinfo->cinfo, COL_PROTOCOL, "TPNCP"); - if (pinfo->srcport == UDP_PORT_TPNCP_TRUNKPACK) { - col_add_fstr(pinfo->cinfo, COL_INFO, - "EvID=%s(%d), SeqNo=%d, ChID=%d, Len=%d, Ver=%d", - val_to_str_const(id, tpncp_events_id_vals, "Unknown"), - id, seq_number, cid, len, ver); - } else { - col_add_fstr(pinfo->cinfo, COL_INFO, - "CmdID=%s(%d), SeqNo=%d, Len=%d, Ver=%d", - val_to_str_const(id, tpncp_commands_id_vals, "Unknown"), - id, seq_number, len, ver); - } - - if (tree) { - item = proto_tree_add_item(tree, proto_tpncp, tvb, 0, -1, ENC_NA); - tpncp_tree = proto_item_add_subtree(item, ett_tpncp); - - proto_tree_add_uint(tpncp_tree, hf_tpncp_version, tvb, 0, 2, ver); - proto_tree_add_uint(tpncp_tree, hf_tpncp_length, tvb, 2, 2, len); - proto_tree_add_uint(tpncp_tree, hf_tpncp_seq_number, tvb, 4, 2, seq_number); - proto_tree_add_uint(tpncp_tree, hf_tpncp_reserved, tvb, 6, 2, reserved); - - if (pinfo->srcport == UDP_PORT_TPNCP_TRUNKPACK) { - if (try_val_to_str(id, tpncp_events_id_vals)) { - proto_tree_add_uint(tpncp_tree, hf_tpncp_event_id, tvb, 8, 4, id); - proto_tree_add_int(tpncp_tree, hf_tpncp_cid, tvb, 12, 4, cid); - offset += 16; - if (tpncp_events_info_db[id].tpncp_data_field_size) { - event_tree = proto_tree_add_subtree_format(tree, tvb, offset, -1, ett_tpncp_body, NULL, "TPNCP Event: %s (%d)", - val_to_str_const(id, tpncp_events_id_vals, "Unknown"), id); - dissect_tpncp_event(id, tvb, event_tree, &offset); - } + item = proto_tree_add_item(tree, proto_tpncp, tvb, 0, -1, ENC_NA); + tpncp_tree = proto_item_add_subtree(item, ett_tpncp); + + proto_tree_add_item_ret_uint(tpncp_tree, hf_tpncp_version, tvb, 0, 2, encoding, &ver); + proto_tree_add_item_ret_uint(tpncp_tree, hf_tpncp_length, tvb, 2, 2, encoding, &len); + proto_tree_add_item_ret_uint(tpncp_tree, hf_tpncp_seq_number, tvb, 4, 2, encoding, &seq_number); + proto_tree_add_item_ret_uint(tpncp_tree, hf_tpncp_length_ext, tvb, 6, 1, encoding, &len_ext); + proto_tree_add_item_ret_uint(tpncp_tree, hf_tpncp_reserved, tvb, 7, 1, encoding, &reserved); + fullLength = 0xffff * len_ext + len; + + id = tvb_get_guint32(tvb, 8, encoding); + cid = tvb_get_gint32(tvb, 12, encoding); + if (pinfo->srcport == UDP_PORT_TPNCP_TRUNKPACK || + pinfo->srcport == HA_PORT_TPNCP_TRUNKPACK) { + if (try_val_to_str(id, tpncp_events_id_vals)) { + proto_tree_add_uint(tpncp_tree, hf_tpncp_event_id, tvb, 8, 4, id); + proto_tree_add_int(tpncp_tree, hf_tpncp_cid, tvb, 12, 4, cid); + offset += 16; + if (tpncp_events_info_db[id].tpncp_data_field_size) { + event_tree = proto_tree_add_subtree_format( + tree, tvb, offset, -1, ett_tpncp_body, NULL, + "TPNCP Event: %s (%d)", + val_to_str_const(id, tpncp_events_id_vals, "Unknown"), id); + dissect_tpncp_data(id, pinfo, tvb, event_tree, &offset, tpncp_events_info_db, + encoding); } } - else { - if (try_val_to_str(id, tpncp_commands_id_vals)) { - proto_tree_add_uint(tpncp_tree, hf_tpncp_command_id, tvb, 8, 4, id); - offset += 12; - if (tpncp_commands_info_db[id].tpncp_data_field_size) { - command_tree = proto_tree_add_subtree_format(tree, tvb, offset, -1, ett_tpncp_body, NULL, "TPNCP Command: %s (%d)", - val_to_str_const(id, tpncp_commands_id_vals, "Unknown"), id); - dissect_tpncp_command(id, tvb, command_tree, &offset); - } - } + } else if (try_val_to_str(id, tpncp_commands_id_vals)) { + proto_tree_add_uint(tpncp_tree, hf_tpncp_command_id, tvb, 8, 4, id); + offset += 12; + if (tpncp_commands_info_db[id].tpncp_data_field_size) { + command_tree = proto_tree_add_subtree_format( + tree, tvb, offset, -1, ett_tpncp_body, NULL, + "TPNCP Command: %s (%d)", + val_to_str_const(id, tpncp_commands_id_vals, "Unknown"), id); + dissect_tpncp_data(id, pinfo, tvb, command_tree, &offset, tpncp_commands_info_db, + encoding); } } + if (pinfo->srcport == UDP_PORT_TPNCP_TRUNKPACK || + pinfo->srcport == HA_PORT_TPNCP_TRUNKPACK) { + col_add_fstr(pinfo->cinfo, COL_INFO, + "EvID=%s(%d), SeqNo=%d, CID=%d, Len=%d, Ver=%d", + val_to_str_const(id, tpncp_events_id_vals, "Unknown"), + id, seq_number, cid, fullLength, ver); + } else { + col_add_fstr(pinfo->cinfo, COL_INFO, + "CmdID=%s(%d), SeqNo=%d, CID=%d, Len=%d, Ver=%d", + val_to_str_const(id, tpncp_commands_id_vals, "Unknown"), + id, seq_number, cid, fullLength, ver); + } + return tvb_reported_length(tvb); } -/*-------------------------------------------------------------------------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ -static guint get_tpncp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, - int offset, void *data _U_) +static guint +get_tpncp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_) { - guint16 plen; + guint32 plen; + + /* Get the length of the TPNCP packet. */ + plen = tvb_get_ntohs(tvb, offset + 2) + 0xffff * tvb_get_guint8(tvb, offset + 6); - /* Get the length of the DNS packet. */ - plen = tvb_get_ntohs(tvb, offset + 2); - /* Length does not include the version+length field. */ - plen += 4; + /* Length does not include the version+length field. */ + plen += 4; - return plen; + return plen; } -/*-------------------------------------------------------------------------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ -static int dissect_tpncp_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) { +static int +dissect_tpncp_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) +{ if (pinfo->can_desegment) /* If desegmentation is enabled (TCP preferences) use the desegmentation API. */ - tcp_dissect_pdus(tvb, pinfo, tree, tpncp_desegment, 4, get_tpncp_pdu_len, dissect_tpncp, data); + tcp_dissect_pdus(tvb, pinfo, tree, tpncp_desegment, 4, get_tpncp_pdu_len, + dissect_tpncp, data); else /* Otherwise use the regular dissector (might not give correct dissection). */ dissect_tpncp(tvb, pinfo, tree, data); @@ -326,30 +290,41 @@ static int dissect_tpncp_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree return tvb_reported_length(tvb); } -/*-------------------------------------------------------------------------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ -static gint fill_tpncp_id_vals(value_string string[], FILE *file) { +static gboolean +fgetline(gchar *buffer, int size, FILE *file) +{ + if (!fgets(buffer, size, file)) + return 0; + size_t last = strlen(buffer); + if (buffer[last - 1] == '\n') + buffer[last - 1] = 0; + return 1; +} + +static gint +fill_tpncp_id_vals(value_string string[], FILE *file) +{ gint i = 0, tpncp_id = 0; gchar *tpncp_name, *line_in_file; - line_in_file = (gchar *)g_malloc(MAX_TPNCP_DB_ENTRY_LEN); + if (file == NULL) return -1; + + line_in_file = (gchar *) g_malloc(MAX_TPNCP_DB_ENTRY_LEN); line_in_file[0] = 0; - tpncp_name = (gchar *)g_malloc(MAX_TPNCP_DB_ENTRY_LEN); + tpncp_name = (gchar *) g_malloc(MAX_TPNCP_DB_ENTRY_LEN); tpncp_name[0] = 0; - while (fgets(line_in_file, MAX_TPNCP_DB_ENTRY_LEN, file) != NULL) { - if (!strncmp(line_in_file, "#####", 5)) { + while (fgetline(line_in_file, MAX_TPNCP_DB_ENTRY_LEN, file) && !feof(file)) { + if (!strncmp(line_in_file, "#####", 5)) break; - } if (sscanf(line_in_file, "%255s %d", tpncp_name, &tpncp_id) == 2) { - string[i].strptr = g_strdup(tpncp_name); - string[i].value = tpncp_id; - if (i < (MAX_TPNCP_DB_SIZE-1)) { - i++; - } - else { + string[i].strptr = wmem_strdup(wmem_epan_scope(), tpncp_name); + string[i].value = (guint32) tpncp_id; + if (i >= MAX_TPNCP_DB_SIZE - 1) break; - } + i++; } } @@ -359,64 +334,51 @@ static gint fill_tpncp_id_vals(value_string string[], FILE *file) { return 0; } -/*-------------------------------------------------------------------------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ -static gint fill_enums_id_vals(FILE *file) { +static gint +fill_enums_id_vals(FILE *file) +{ gint i = 0, enum_id = 0, enum_val = 0; gboolean first_entry = TRUE; - gchar *line_in_file = NULL, *enum_name = NULL, - *enum_type = NULL, *enum_str = NULL; + gchar *line_in_file = NULL, *enum_name = NULL, *enum_type = NULL, *enum_str = NULL; - line_in_file = (gchar *)g_malloc(MAX_TPNCP_DB_ENTRY_LEN); - line_in_file[0] = 0; - enum_name = (gchar *)g_malloc(MAX_TPNCP_DB_ENTRY_LEN); - enum_name[0] = 0; - enum_type = (gchar *)g_malloc(MAX_TPNCP_DB_ENTRY_LEN); - enum_type[0] = 0; - enum_str = (gchar *)g_malloc(MAX_TPNCP_DB_ENTRY_LEN); - enum_str[0] = 0; - - while (fgets(line_in_file, MAX_TPNCP_DB_ENTRY_LEN, file) != NULL) { - if (!strncmp(line_in_file, "#####", 5)) { + line_in_file = (gchar *) g_malloc(MAX_TPNCP_DB_ENTRY_LEN); + enum_name = (gchar *) g_malloc(MAX_TPNCP_DB_ENTRY_LEN); + enum_type = (gchar *) g_malloc(MAX_TPNCP_DB_ENTRY_LEN); + enum_str = (gchar *) g_malloc(MAX_TPNCP_DB_ENTRY_LEN); + + *line_in_file = *enum_name = *enum_type = *enum_str = 0; + while (fgetline(line_in_file, MAX_TPNCP_DB_ENTRY_LEN, file)) { + if (!strncmp(line_in_file, "#####", 5)) break; - } if (sscanf(line_in_file, "%255s %255s %d", enum_name, enum_str, &enum_id) == 3) { if (strcmp(enum_type, enum_name)) { if (!first_entry) { tpncp_enums_id_vals[enum_val][i].strptr = NULL; tpncp_enums_id_vals[enum_val][i].value = 0; - if (enum_val < (MAX_ENUMS_NUM-1)) { + if (enum_val < (MAX_ENUMS_NUM - 2)) { enum_val++; i = 0; - } - else { + } else { break; } - } - else + } else { first_entry = FALSE; - tpncp_enums_name_vals[enum_val] = g_strdup(enum_name); + } + tpncp_enums_name_vals[enum_val] = wmem_strdup(wmem_epan_scope(), enum_name); g_strlcpy(enum_type, enum_name, MAX_TPNCP_DB_ENTRY_LEN); } - tpncp_enums_id_vals[enum_val][i].strptr = g_strdup(enum_str); + tpncp_enums_id_vals[enum_val][i].strptr = wmem_strdup(wmem_epan_scope(), enum_str); tpncp_enums_id_vals[enum_val][i].value = enum_id; - if (i < (MAX_ENUM_ENTRIES-1)) { + if (i < (MAX_ENUM_ENTRIES - 1)) { i++; - } - else { + } else { break; } } } - /* make sure the last entry in the array is null but - * don't overflow if we've filled the entire thing (in which case - * we have to drop an entry) */ - if (enum_val + 1 >= MAX_ENUMS_NUM) { - g_free(tpncp_enums_name_vals[enum_val]); - tpncp_enums_name_vals[enum_val] = NULL; - } - else { - tpncp_enums_name_vals[enum_val+1] = NULL; - } + + tpncp_enums_name_vals[enum_val + 1] = NULL; g_free(line_in_file); g_free(enum_name); @@ -426,9 +388,11 @@ static gint fill_enums_id_vals(FILE *file) { return 0; } -/*-------------------------------------------------------------------------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ -static gint get_enum_name_val(gchar *enum_name) { +static gint +get_enum_name_val(const gchar *enum_name) +{ gint enum_val = 0; while (tpncp_enums_name_vals[enum_val]) { @@ -440,17 +404,21 @@ static gint get_enum_name_val(gchar *enum_name) { return -1; } -/*-------------------------------------------------------------------------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ -static gint init_tpncp_data_fields_info(tpncp_data_field_info *data_fields_info, FILE *file) { +static gint +init_tpncp_data_fields_info(tpncp_data_field_info *data_fields_info, FILE *file) +{ static gboolean was_registered = FALSE; - gchar *tpncp_db_entry = NULL, *tpncp_data_field_name = NULL, *tmp = NULL; - gint enum_val, data_id, current_data_id = -1, - tpncp_data_field_sign, tpncp_data_field_size, + gchar tpncp_db_entry[MAX_TPNCP_DB_ENTRY_LEN]; + gchar entry_copy[MAX_TPNCP_DB_ENTRY_LEN]; + const gchar *tpncp_data_field_name = NULL, *tmp = NULL; + gint enum_val, data_id, current_data_id = -1, tpncp_data_field_sign, tpncp_data_field_size, tpncp_data_field_array_dim, tpncp_data_field_is_ip_addr; guint idx; tpncp_data_field_info *current_tpncp_data_field_info = NULL; hf_register_info hf_entr; + gboolean registered_struct_ids[MAX_TPNCP_DB_SIZE]; static hf_register_info hf_tpncp[] = { { @@ -489,26 +457,24 @@ static gint init_tpncp_data_fields_info(tpncp_data_field_info *data_fields_info, NULL, HFILL } }, -#if 0 { - &hf_tpncp_old_event_seq_number, + &hf_tpncp_length_ext, { - "Sequence number", - "tpncp.old_event_seq_number", - FT_UINT32, + "Length Extension", + "tpncp.lengthextention", + FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } }, -#endif { &hf_tpncp_reserved, { "Reserved", "tpncp.reserved", - FT_UINT16, + FT_UINT8, BASE_DEC, NULL, 0x0, @@ -527,20 +493,6 @@ static gint init_tpncp_data_fields_info(tpncp_data_field_info *data_fields_info, NULL, HFILL } }, -#if 0 - { - &hf_tpncp_old_command_id, - { - "Command ID", - "tpncp.old_command_id", - FT_UINT16, - BASE_DEC, - VALS(tpncp_commands_id_vals), - 0x0, - NULL, HFILL - } - }, -#endif { &hf_tpncp_event_id, { @@ -567,35 +519,35 @@ static gint init_tpncp_data_fields_info(tpncp_data_field_info *data_fields_info, } }; + memset(registered_struct_ids, 0, sizeof (registered_struct_ids)); + /* Register common fields of hf_register_info structure. */ - hf_entr.hfinfo.type = FT_NONE; - hf_entr.hfinfo.strings = NULL; - hf_entr.hfinfo.bitmask = 0x0; - hf_entr.hfinfo.blurb = NULL; + hf_entr.hfinfo.type = FT_NONE; + hf_entr.hfinfo.strings = NULL; + hf_entr.hfinfo.bitmask = 0x0; + hf_entr.hfinfo.blurb = NULL; HFILL_INIT(hf_entr); if (!was_registered) { + void *newbuf; + /* Register non-standard data should be done only once. */ - hf_allocated = hf_size+(int)array_length(hf_tpncp)-1; - if ((hf = (hf_register_info *)g_realloc(hf, hf_allocated * sizeof(hf_register_info))) == NULL) { - /* XXX realloc returning NULL does not free the original memory, - * is this a leak? */ - return (-1); - } + hf_allocated = hf_size + (int) array_length(hf_tpncp) - 1; + newbuf = wmem_realloc(wmem_epan_scope(), hf, hf_allocated * sizeof (hf_register_info)); + if (!newbuf) + return -1; + hf = (hf_register_info *) newbuf; for (idx = 0; idx < array_length(hf_tpncp); idx++) { - memcpy(hf + (hf_size - 1), hf_tpncp + idx, sizeof(hf_register_info)); + memcpy(hf + (hf_size - 1), hf_tpncp + idx, sizeof (hf_register_info)); hf_size++; } was_registered = TRUE; - } - else + } else hf_size++; /* Register standard data. */ - tpncp_db_entry = (gchar *)g_malloc(MAX_TPNCP_DB_ENTRY_LEN); - tpncp_db_entry[0] = 0; - - while (fgets(tpncp_db_entry, MAX_TPNCP_DB_ENTRY_LEN, file) != NULL) { + while (fgetline(tpncp_db_entry, MAX_TPNCP_DB_ENTRY_LEN, file)) { + g_snprintf(entry_copy, MAX_TPNCP_DB_ENTRY_LEN, "%s", tpncp_db_entry); if (!strncmp(tpncp_db_entry, "#####", 5)) { hf_size--; break; @@ -603,93 +555,131 @@ static gint init_tpncp_data_fields_info(tpncp_data_field_info *data_fields_info, /* Default to decimal display type */ hf_entr.hfinfo.display = BASE_DEC; - - if ((tmp = strtok(tpncp_db_entry, " ")) == NULL) - continue; /* Badly formed data base entry - skip corresponding field's registration. */ - if (!ws_strtou32(tmp, NULL, &data_id)) + if ((tmp = strtok(tpncp_db_entry, " ")) == NULL) { + report_failure( + "ERROR! Badly formed data base entry: %s - corresponding field's registration is skipped.", + entry_copy); + continue; + } + data_id = (gint) g_ascii_strtoll(tmp, NULL, 10); + if ((tpncp_data_field_name = strtok(NULL, " ")) == NULL) { + report_failure( + "ERROR! Badly formed data base entry: %s - corresponding field's registration is skipped.", + entry_copy); continue; - if ((tpncp_data_field_name = strtok(NULL, " ")) == NULL) - continue; /* Badly formed data base entry - skip corresponding field's registration. */ - if ((tmp = strtok(NULL, " ")) == NULL) - continue; /* Badly formed data base entry - skip corresponding field's registration. */ - if (!ws_strtou32(tmp, NULL, &tpncp_data_field_sign)) + } + + /* We happen to have a line without a name (57 0 32 0 0 primitive). Consider unnamed. */ + if (g_ascii_isdigit(*tpncp_data_field_name)) { + tmp = tpncp_data_field_name; + tpncp_data_field_name = "unnamed"; + } else { + if ((tmp = strtok(NULL, " ")) == NULL) { + report_failure( + "ERROR! Badly formed data base entry: %s - corresponding field's registration is skipped.", + entry_copy); + continue; + } + } + tpncp_data_field_sign = (gint) g_ascii_strtoll(tmp, NULL, 10); + if ((tmp = strtok(NULL, " ")) == NULL) { + report_failure( + "ERROR! Badly formed data base entry: %s - corresponding field's registration is skipped.", + entry_copy); continue; - if ((tmp = strtok(NULL, " ")) == NULL) - continue; /* Badly formed data base entry - skip corresponding field's registration. */ - if (!ws_strtou32(tmp, NULL, &tpncp_data_field_size)) + } + tpncp_data_field_size = (gint) g_ascii_strtoll(tmp, NULL, 10); + if ((tmp = strtok(NULL, " ")) == NULL) { + report_failure( + "ERROR! Badly formed data base entry: %s - corresponding field's registration is skipped.", + entry_copy); continue; - if ((tmp = strtok(NULL, " ")) == NULL) - continue; /* Badly formed data base entry - skip corresponding field's registration. */ - if (!ws_strtou32(tmp, NULL, &tpncp_data_field_array_dim)) + } + tpncp_data_field_array_dim = (gint) g_ascii_strtoll(tmp, NULL, 10); + if ((tmp = strtok(NULL, " ")) == NULL) { + report_failure( + "ERROR! Badly formed data base entry: %s - corresponding field's registration is skipped.", + entry_copy); continue; - if ((tmp = strtok(NULL, " ")) == NULL) - continue; /* Badly formed data base entry - skip corresponding field's registration. */ - if (!ws_strtou32(tmp, NULL, &tpncp_data_field_is_ip_addr)) + } + tpncp_data_field_is_ip_addr = tpncp_data_field_sign && g_ascii_strtoll(tmp, NULL, 10); + if ((tmp = strtok(NULL, "\n")) == NULL) { + report_failure( + "ERROR! Badly formed data base entry: %s - corresponding field's registration is skipped.", + entry_copy); continue; - if ((tmp = strtok(NULL, "\n")) == NULL) - continue; /* Badly formed data base entry - skip corresponding field's registration. */ + } if (current_data_id != data_id) { /* new data */ + if (registered_struct_ids[data_id] == TRUE) { + report_failure( + "ERROR! The data_id %d already registered. Cannot register two identical events/command", + data_id); + continue; + } + registered_struct_ids[data_id] = TRUE; current_tpncp_data_field_info = &data_fields_info[data_id]; current_data_id = data_id; - } - else { - if ((current_tpncp_data_field_info->p_next = - (tpncp_data_field_info *)g_malloc0(sizeof(tpncp_data_field_info))) - == NULL) { - g_free(tpncp_db_entry); + } else { + current_tpncp_data_field_info->p_next = (tpncp_data_field_info *) wmem_alloc( + wmem_epan_scope(), sizeof (tpncp_data_field_info)); + if (!current_tpncp_data_field_info->p_next) return (-1); - } current_tpncp_data_field_info = current_tpncp_data_field_info->p_next; + current_tpncp_data_field_info->p_next = NULL; } + /* Register specific fields of hf_register_info struture. */ if (strcmp(tmp, "primitive")) { enum_val = get_enum_name_val(tmp); - if (enum_val == -1) { + if (enum_val == -1) hf_entr.hfinfo.strings = NULL; - } - else { + else hf_entr.hfinfo.strings = VALS(tpncp_enums_id_vals[enum_val]); - } - } - else { + } else { hf_entr.hfinfo.strings = NULL; } current_tpncp_data_field_info->tpncp_data_field_descr = -1; hf_entr.p_id = ¤t_tpncp_data_field_info->tpncp_data_field_descr; - current_tpncp_data_field_info->tpncp_data_field_name = g_strdup_printf("tpncp.%s", tpncp_data_field_name); + current_tpncp_data_field_info->tpncp_data_field_name = + wmem_strdup_printf(wmem_epan_scope(), "tpncp.%s", tpncp_data_field_name); hf_entr.hfinfo.name = current_tpncp_data_field_info->tpncp_data_field_name; hf_entr.hfinfo.abbrev = current_tpncp_data_field_info->tpncp_data_field_name; switch (tpncp_data_field_size) { - case 1: case 2: case 3: case 4: - case 5: case 6: case 7: case 8: - if (tpncp_data_field_array_dim) { - hf_entr.hfinfo.type = FT_STRING; - hf_entr.hfinfo.display = BASE_NONE; - } - else - hf_entr.hfinfo.type = (tpncp_data_field_sign)?FT_UINT8:FT_INT8; - break; - case 16: - hf_entr.hfinfo.type = (tpncp_data_field_sign)?FT_UINT16:FT_INT16; - break; - case 32: - hf_entr.hfinfo.type = (tpncp_data_field_sign)?FT_UINT32:FT_INT32; - break; - default: - break; + case 1: case 2: case 3: case 4: + case 5: case 6: case 7: case 8: + if (tpncp_data_field_array_dim) { + hf_entr.hfinfo.type = FT_STRING; + hf_entr.hfinfo.display = BASE_NONE; + } else { + hf_entr.hfinfo.type = (tpncp_data_field_sign) ? FT_UINT8 : FT_INT8; + } + break; + case 16: + hf_entr.hfinfo.type = (tpncp_data_field_sign) ? FT_UINT16 : FT_INT16; + break; + case 32: + if (tpncp_data_field_is_ip_addr) { + hf_entr.hfinfo.display = BASE_NONE; + hf_entr.hfinfo.type = FT_IPv4; + } else { + hf_entr.hfinfo.type = (tpncp_data_field_sign) ? FT_UINT32 : FT_INT32; + } + break; + default: + break; } + /* Register initialized hf_register_info in global database. */ if (hf_size > hf_allocated) { + void *newbuf; hf_allocated += 1024; - if ((hf = (hf_register_info *)g_realloc(hf, hf_allocated * sizeof(hf_register_info))) == NULL) { - /* XXX realloc returning NULL does not free the original memory, - * is this a leak? */ - g_free(tpncp_db_entry); - return (-1); - } + newbuf = wmem_realloc(wmem_epan_scope(), hf, hf_allocated * sizeof (hf_register_info)); + if (!newbuf) + return -1; + hf = (hf_register_info *) newbuf; } - memcpy(hf + hf_size - 1, &hf_entr, sizeof(hf_register_info)); + memcpy(hf + hf_size - 1, &hf_entr, sizeof (hf_register_info)); hf_size++; current_tpncp_data_field_info->tpncp_data_field_sign = tpncp_data_field_sign; current_tpncp_data_field_info->tpncp_data_field_size = tpncp_data_field_size; @@ -697,132 +687,107 @@ static gint init_tpncp_data_fields_info(tpncp_data_field_info *data_fields_info, current_tpncp_data_field_info->tpncp_data_field_is_ip_addr = tpncp_data_field_is_ip_addr; } - g_free(tpncp_db_entry); - return 0; } -/*-------------------------------------------------------------------------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ -static gint init_tpncp_db(void) { - gchar *tpncp_dat_file_path; - gint ret; +static gint +init_tpncp_db(void) +{ + gchar tpncp_dat_file_path[MAX_TPNCP_DB_ENTRY_LEN]; FILE *file; - tpncp_dat_file_path = g_strdup_printf("%s" G_DIR_SEPARATOR_S"tpncp" G_DIR_SEPARATOR_S "tpncp.dat", get_datafile_dir()); + g_snprintf(tpncp_dat_file_path, MAX_TPNCP_DB_ENTRY_LEN, + "%s" G_DIR_SEPARATOR_S "tpncp" G_DIR_SEPARATOR_S "tpncp.dat", get_datafile_dir()); /* Open file with TPNCP data. */ - if ((file = ws_fopen(tpncp_dat_file_path, "r")) == NULL) { - g_free(tpncp_dat_file_path); + if ((file = ws_fopen(tpncp_dat_file_path, "r")) == NULL) return (-1); - } - - g_free(tpncp_dat_file_path); - - ret = fill_tpncp_id_vals(tpncp_events_id_vals, file); - if (ret != 0) - goto done; + fill_tpncp_id_vals(tpncp_events_id_vals, file); + fill_tpncp_id_vals(tpncp_commands_id_vals, file); + fill_enums_id_vals(file); + init_tpncp_data_fields_info(tpncp_events_info_db, file); + init_tpncp_data_fields_info(tpncp_commands_info_db, file); - ret = fill_tpncp_id_vals(tpncp_commands_id_vals, file); - if (ret != 0) - goto done; - - ret = fill_enums_id_vals(file); - if (ret != 0) - goto done; - - ret = init_tpncp_data_fields_info(tpncp_events_info_db, file); - if (ret != 0) - goto done; - - ret = init_tpncp_data_fields_info(tpncp_commands_info_db, file); - -done: fclose(file); - - return ret; + return 0; } -/*-------------------------------------------------------------------------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ -void proto_reg_handoff_tpncp(void) { - static gint tpncp_prefs_initialized = FALSE; - static dissector_handle_t tpncp_tcp_handle; +void +proto_reg_handoff_tpncp(void) +{ + dissector_handle_t tpncp_udp_handle, tpncp_tcp_handle; gint idx; + static gboolean initialized = FALSE; + + if (proto_tpncp == -1) return; /* If we weren't able to load the database (and thus the hf_ entries) * do not attach to any ports (if we did then we'd get a "dissector bug" * assertions every time a packet is handed to us and we tried to use the * hf_ entry). */ - if (proto_tpncp == -1) + if (!global_tpncp_load_db) return; - if (!tpncp_prefs_initialized) { - tpncp_tcp_handle = create_dissector_handle(dissect_tpncp_tcp, proto_tpncp); - - tpncp_prefs_initialized = TRUE; - } - else { - dissector_delete_uint("tcp.port", trunkpack_tcp_port, tpncp_tcp_handle); - dissector_delete_uint("udp.port", trunkpack_udp_port, tpncp_handle); - dissector_delete_uint("tcp.port", host_tcp_port, tpncp_tcp_handle); - dissector_delete_uint("udp.port", host_udp_port, tpncp_handle); + if (hf_allocated == 0 && init_tpncp_db() == -1) { + report_failure("tpncp: Could not load tpncp.dat file, tpncp dissector will not work"); + return; } - if(global_tpncp_load_db){ - if (hf_allocated == 0) { - if (init_tpncp_db() == -1) { - report_failure("tpncp: Could not load tpncp.dat file, tpncp dissector will not work"); - return; - } - - /* Rather than duplicating large quantities of code from - * proto_register_field_array() and friends to sanitize the tpncp.dat file - * when we read it, just catch any exceptions we get while registering and - * take them as a hint that the file is corrupt. Then move on, so that at - * least the rest of the protocol dissectors will still work. - */ - TRY { - /* The function proto_register_field_array does not work with dynamic - * arrays, so pass dynamic array elements one-by-one in the loop. - */ - for(idx = 0; idx < hf_size; idx++) { - proto_register_field_array(proto_tpncp, &hf[idx], 1); - } - } - - CATCH_ALL { - report_failure("Corrupt tpncp.dat file, tpncp dissector will not work."); - } + tpncp_udp_handle = create_dissector_handle(dissect_tpncp, proto_tpncp); + tpncp_tcp_handle = create_dissector_handle(dissect_tpncp_tcp, proto_tpncp); + dissector_add_uint_with_preference("udp.port", UDP_PORT_TPNCP_TRUNKPACK, tpncp_udp_handle); + dissector_add_uint_with_preference("tcp.port", TCP_PORT_TPNCP_TRUNKPACK, tpncp_tcp_handle); - ENDTRY; - } - - trunkpack_tcp_port = global_tpncp_trunkpack_tcp_port; - trunkpack_udp_port = global_tpncp_trunkpack_udp_port; + if (initialized) + return; - host_tcp_port = global_tpncp_host_tcp_port; - host_udp_port = global_tpncp_host_udp_port; + /* Rather than duplicating large quantities of code from + * proto_register_field_array() and friends to sanitize the tpncp.dat file + * when we read it, just catch any exceptions we get while registering and + * take them as a hint that the file is corrupt. Then move on, so that at + * least the rest of the protocol dissectors will still work. + */ + TRY { + /* The function proto_register_field_array does not work with dynamic + * arrays, so pass dynamic array elements one-by-one in the loop. + */ + for (idx = 0; idx < hf_size; idx++) + proto_register_field_array(proto_tpncp, &hf[idx], 1); + } - dissector_add_uint("tcp.port", global_tpncp_trunkpack_tcp_port, tpncp_tcp_handle); - dissector_add_uint("udp.port", global_tpncp_trunkpack_udp_port, tpncp_handle); + CATCH_ALL { + report_failure("Corrupt tpncp.dat file, tpncp dissector will not work."); } + + ENDTRY; + initialized = TRUE; } -/*-------------------------------------------------------------------------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ -void proto_register_tpncp(void) { +void +proto_register_tpncp(void) +{ module_t *tpncp_module; + expert_module_t* expert_tpncp; static gint *ett[] = { &ett_tpncp, &ett_tpncp_body }; + static ei_register_info ei[] = { + { &ei_tpncp_unknown_data, { "tpncp.unknown_data", PI_UNDECODED, PI_WARN, "Unknown data", EXPFILL } }, + }; + /* this dissector reads hf entries from a database - a boolean preference defines whether the database is loaded or not - we initialize the hf array in the handoff function when we have - access to the preference's value */ + * a boolean preference defines whether the database is loaded or not + * we initialize the hf array in the handoff function when we have + * access to the preference's value */ proto_tpncp = proto_register_protocol("AudioCodes TPNCP (TrunkPack Network Control Protocol)", "TPNCP", "tpncp"); @@ -833,6 +798,9 @@ void proto_register_tpncp(void) { proto_register_subtree_array(ett, array_length(ett)); + expert_tpncp = expert_register_protocol(proto_tpncp); + expert_register_field_array(expert_tpncp, ei, array_length(ei)); + /* See https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9569 for some discussion on this as well */ prefs_register_bool_preference(tpncp_module, "load_db", "Whether to load DB or not; if DB not loaded dissector is passive", @@ -840,14 +808,6 @@ void proto_register_tpncp(void) { " disables the protocol; Wireshark has to be restarted for the" " setting to take effect.", &global_tpncp_load_db); - - prefs_register_uint_preference(tpncp_module, "tcp.trunkpack_port", - "TPNCP \"well-known\" TrunkPack TCP Port", - "", 10, &global_tpncp_trunkpack_tcp_port); - - prefs_register_uint_preference(tpncp_module, "udp.trunkpack_port", - "TPNCP \"well-known\" TrunkPack UDP Port", - "", 10, &global_tpncp_trunkpack_udp_port); } /* diff --git a/epan/prefs.c b/epan/prefs.c index cf5333d834..dccc912e87 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -5160,6 +5160,7 @@ deprecated_port_pref(gchar *pref_name, const gchar *value) {"vnc.alternate_port", "VNC", "tcp.port", 10}, {"scop.port", "SCoP", "tcp.port", 10}, {"scop.port_secure", "SCoP", "tcp.port", 10}, + {"tcp.trunkpack_port", "TPNCP", "tcp.port", 10}, /* UDP */ {"h248.udp_port", "H248", "udp.port", 10}, {"actrace.udp_port", "ACtrace", "udp.port", 10}, @@ -5191,6 +5192,7 @@ deprecated_port_pref(gchar *pref_name, const gchar *value) {"uaudp.port4", "UAUDP", "udp.port", 10}, {"uhd.dissector_port", "UHD", "udp.port", 10}, {"vrt.dissector_port", "vrt", "udp.port", 10}, + {"udp.trunkpack_port", "TPNCP", "udp.port", 10}, }; struct port_pref_name port_range_prefs[] = { -- cgit v1.2.3