aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorAndersBroman <anders.broman@ericsson.com>2016-03-29 17:59:27 +0200
committerAnders Broman <a.broman58@gmail.com>2016-03-29 21:25:39 +0000
commit7b406ea3ea4667eb06437954d388125983135835 (patch)
tree925bd86821703eb1e2291cf489dc638728724335 /epan
parent6128ca02ebea4c49ed379c5c6007dab7439367a1 (diff)
[Exported PDU] Add the abillity to use dissector tables from the file.
Change-Id: I51ac8ce56641cf6eeda18c2a3f6d6952d3126415 Reviewed-on: https://code.wireshark.org/review/14693 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-exported_pdu.c91
-rw-r--r--epan/exported_pdu.h13
2 files changed, 84 insertions, 20 deletions
diff --git a/epan/dissectors/packet-exported_pdu.c b/epan/dissectors/packet-exported_pdu.c
index 19b88db765..dad7dc98b0 100644
--- a/epan/dissectors/packet-exported_pdu.c
+++ b/epan/dissectors/packet-exported_pdu.c
@@ -36,9 +36,10 @@ void proto_reg_handoff_exported_pdu(void);
static int proto_exported_pdu = -1;
static int hf_exported_pdu_tag = -1;
static int hf_exported_pdu_tag_len = -1;
-static int hf_exported_pdu_unknown_tag = -1;
+static int hf_exported_pdu_unknown_tag_val = -1;
static int hf_exported_pdu_prot_name = -1;
static int hf_exported_pdu_heur_prot_name = -1;
+static int hf_exported_pdu_dis_table_name = -1;
static int hf_exported_pdu_ipv4_src = -1;
static int hf_exported_pdu_ipv4_dst = -1;
static int hf_exported_pdu_ipv6_src = -1;
@@ -52,6 +53,8 @@ static int hf_exported_pdu_ss7_dpc = -1;
static int hf_exported_pdu_orig_fno = -1;
static int hf_exported_pdu_dvbci_evt = -1;
static int hf_exported_pdu_exported_pdu = -1;
+static int hf_exported_pdu_dis_table_val = -1;
+static int hf_exported_pdu_col_proto_str = -1;
/* Initialize the subtree pointers */
static gint ett_exported_pdu = -1;
@@ -59,30 +62,35 @@ static gint ett_exported_pdu_tag = -1;
#define EXPORTED_PDU_NEXT_PROTO_STR 0
#define EXPORTED_PDU_NEXT_HEUR_PROTO_STR 1
+#define EXPORTED_PDU_NEXT_DIS_TABLE_STR 2
+
static const value_string exported_pdu_tag_vals[] = {
{ EXP_PDU_TAG_END_OF_OPT, "End-of-options" },
/* 1 - 9 reserved */
- { EXP_PDU_TAG_OPTIONS_LENGTH, "Total length of the options excluding this TLV" },
- { EXP_PDU_TAG_LINKTYPE, "Linktype value" },
- { EXP_PDU_TAG_PROTO_NAME, "PDU content protocol name" },
- { EXP_PDU_TAG_HEUR_PROTO_NAME, "PDU content heuristic protocol name" },
- /* Add protocol type related tags here */
+ { EXP_PDU_TAG_OPTIONS_LENGTH, "Total length of the options excluding this TLV" },
+ { EXP_PDU_TAG_LINKTYPE, "Linktype value" },
+ { EXP_PDU_TAG_PROTO_NAME, "PDU content protocol name" },
+ { EXP_PDU_TAG_HEUR_PROTO_NAME, "PDU content heuristic protocol name" },
+ { EXP_PDU_TAG_DISSECTOR_TABLE_NAME, "PDU content dissector table name" },
+ /* Add protocol type related tags here */
/* 14 - 19 reserved */
- { EXP_PDU_TAG_IPV4_SRC, "IPv4 Source Address" },
- { EXP_PDU_TAG_IPV4_DST, "IPv4 Destination Address" },
- { EXP_PDU_TAG_IPV6_SRC, "IPv6 Source Address" },
- { EXP_PDU_TAG_IPV6_DST, "IPv6 Destination Address" },
+ { EXP_PDU_TAG_IPV4_SRC, "IPv4 Source Address" },
+ { EXP_PDU_TAG_IPV4_DST, "IPv4 Destination Address" },
+ { EXP_PDU_TAG_IPV6_SRC, "IPv6 Source Address" },
+ { EXP_PDU_TAG_IPV6_DST, "IPv6 Destination Address" },
- { EXP_PDU_TAG_PORT_TYPE, "Port Type" },
- { EXP_PDU_TAG_SRC_PORT, "Source Port" },
- { EXP_PDU_TAG_DST_PORT, "Destination Port" },
+ { EXP_PDU_TAG_PORT_TYPE, "Port Type" },
+ { EXP_PDU_TAG_SRC_PORT, "Source Port" },
+ { EXP_PDU_TAG_DST_PORT, "Destination Port" },
- { EXP_PDU_TAG_SS7_OPC, "SS7 OPC" },
- { EXP_PDU_TAG_SS7_DPC, "SS7 DPC" },
+ { EXP_PDU_TAG_SS7_OPC, "SS7 OPC" },
+ { EXP_PDU_TAG_SS7_DPC, "SS7 DPC" },
- { EXP_PDU_TAG_ORIG_FNO, "Original Frame number" },
+ { EXP_PDU_TAG_ORIG_FNO, "Original Frame number" },
- { EXP_PDU_TAG_DVBCI_EVT, "DVB-CI event" },
+ { EXP_PDU_TAG_DVBCI_EVT, "DVB-CI event" },
+ { EXP_PDU_TAG_DISSECTOR_TABLE_NAME_NUM_VAL, "Dissector table value" },
+ { EXP_PDU_TAG_COL_PROT_TEXT, "Column Protocol String" },
{ 0, NULL }
};
@@ -99,9 +107,13 @@ dissect_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void*
int tag_len;
int next_proto_type = -1;
char *proto_name = NULL;
+ char *dissector_table = NULL;
+ char *col_proto_str = NULL;
dissector_handle_t proto_handle;
mtp3_addr_pc_t *mtp3_addr;
guint8 dvb_ci_dir;
+ guint32 dissector_table_val=0;
+ dissector_table_t dis_tbl;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Exported PDU");
@@ -129,6 +141,11 @@ dissect_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void*
proto_name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tag_len, ENC_UTF_8|ENC_NA);
proto_tree_add_item(tag_tree, hf_exported_pdu_heur_prot_name, tvb, offset, tag_len, ENC_UTF_8|ENC_NA);
break;
+ case EXP_PDU_TAG_DISSECTOR_TABLE_NAME:
+ next_proto_type = EXPORTED_PDU_NEXT_DIS_TABLE_STR;
+ dissector_table = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tag_len, ENC_UTF_8 | ENC_NA);
+ proto_tree_add_item(tag_tree, hf_exported_pdu_dis_table_name, tvb, offset, tag_len, ENC_UTF_8 | ENC_NA);
+ break;
case EXP_PDU_TAG_IPV4_SRC:
proto_tree_add_item(tag_tree, hf_exported_pdu_ipv4_src, tvb, offset, 4, ENC_BIG_ENDIAN);
set_address_tvb(&pinfo->net_src, AT_IPv4, 4, tvb, offset);
@@ -187,10 +204,18 @@ dissect_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void*
tvb, offset, 1, ENC_BIG_ENDIAN);
dvbci_set_addrs(dvb_ci_dir, pinfo);
break;
+ case EXP_PDU_TAG_DISSECTOR_TABLE_NAME_NUM_VAL:
+ dissector_table_val = tvb_get_ntohl(tvb, offset);
+ proto_tree_add_item(tag_tree, hf_exported_pdu_dis_table_val, tvb, offset, 4, ENC_BIG_ENDIAN);
+ break;
+ case EXP_PDU_TAG_COL_PROT_TEXT:
+ col_proto_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tag_len, ENC_UTF_8 | ENC_NA);
+ proto_tree_add_item(tag_tree, hf_exported_pdu_col_proto_str, tvb, offset, tag_len, ENC_UTF_8 | ENC_NA);
+ break;
case EXP_PDU_TAG_END_OF_OPT:
break;
default:
- proto_tree_add_item(tag_tree, hf_exported_pdu_unknown_tag, tvb, offset, tag_len, ENC_NA);
+ proto_tree_add_item(tag_tree, hf_exported_pdu_unknown_tag_val, tvb, offset, tag_len, ENC_NA);
/* Add an expert item too? */
break;
}
@@ -218,6 +243,17 @@ dissect_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void*
}
break;
}
+ case EXPORTED_PDU_NEXT_DIS_TABLE_STR:
+ {
+ dis_tbl = find_dissector_table(dissector_table);
+ if (dis_tbl) {
+ col_clear(pinfo->cinfo, COL_PROTOCOL);
+ if (col_proto_str) {
+ col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "%s",col_proto_str);
+ }
+ dissector_try_uint_new(dis_tbl, dissector_table_val, payload_tvb, pinfo, tree, FALSE, NULL);
+ }
+ }
default:
break;
}
@@ -245,8 +281,8 @@ proto_register_exported_pdu(void)
FT_UINT16, BASE_DEC, NULL, 0,
NULL, HFILL }
},
- { &hf_exported_pdu_unknown_tag,
- { "Unknown tag", "exported_pdu.unknown_tag",
+ { &hf_exported_pdu_unknown_tag_val,
+ { "Unknown tags value", "exported_pdu.unknown_tag.val",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }
},
@@ -260,6 +296,11 @@ proto_register_exported_pdu(void)
FT_STRING, BASE_NONE, NULL, 0,
NULL, HFILL }
},
+ { &hf_exported_pdu_dis_table_name,
+ { "Dissector Table Name", "exported_pdu.dis_table_name",
+ FT_STRING, BASE_NONE, NULL, 0,
+ NULL, HFILL }
+ },
{ &hf_exported_pdu_ipv4_src,
{ "IPv4 Src", "exported_pdu.ipv4_src",
FT_IPv4, BASE_NONE, NULL, 0,
@@ -327,6 +368,16 @@ proto_register_exported_pdu(void)
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }
},
+ { &hf_exported_pdu_dis_table_val,
+ { "Value to use when calling disector table", "exported_pdu.dis_table_val",
+ FT_UINT32, BASE_DEC, NULL, 0,
+ NULL, HFILL }
+ },
+ { &hf_exported_pdu_col_proto_str,
+ { "Column protocol string", "exported_pdu.col_proto_str",
+ FT_STRING, BASE_NONE, NULL, 0,
+ NULL, HFILL }
+ },
};
/* Setup protocol subtree array */
diff --git a/epan/exported_pdu.h b/epan/exported_pdu.h
index 087c91ec8a..0fb19d41e7 100644
--- a/epan/exported_pdu.h
+++ b/epan/exported_pdu.h
@@ -93,6 +93,12 @@ WS_DLL_PUBLIC GSList *get_export_pdu_tap_list(void);
* during registration, e.g "sip_udp"
* Will be used to call the next dissector.
*/
+#define EXP_PDU_TAG_DISSECTOR_TABLE_NAME 14 /**< The value part should be an ASCII non NULL terminated string
+ * containing the dissector table name given
+ * during registration, e.g "gsm_map.v3.arg.opcode"
+ * Will be used to call the next dissector.
+ */
+
/* Add protocol type related tags here.
* NOTE Only one protocol type tag may be present in a packet, the first one
* found will be used*/
@@ -113,6 +119,13 @@ WS_DLL_PUBLIC GSList *get_export_pdu_tap_list(void);
#define EXP_PDU_TAG_DVBCI_EVT 31
+#define EXP_PDU_TAG_DISSECTOR_TABLE_NAME_NUM_VAL 32 /**< value part is the numeric value to be used calling the dissector table
+ * given with tag EXP_PDU_TAG_DISSECTOR_TABLE_NAME, must follow emediatly after the table tag.
+ */
+
+#define EXP_PDU_TAG_COL_PROT_TEXT 33 /**< Text string to put in COL_PROTOCOL, one use case is in conjunction with dissector tables where
+ * COL_PROTOCOL might not be filled in.
+ */
typedef struct _exp_pdu_data_t {
guint tlv_buffer_len;