aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2014-10-04 21:52:50 +0200
committerAnders Broman <a.broman58@gmail.com>2014-10-05 07:07:59 +0000
commitdbcd94d33a7977aa22cf8d68e9e7109dc7b2c00a (patch)
tree76fb66d4e0c0bde321c233b09f6ee0383674c074
parente731bc77072fddfbfe189d2da3271931e230fc98 (diff)
DLT User: add ability to export PDUs
It can be really useful to share hand crafted captures without the need to configure the DLT User table Change-Id: Iefab00b741f95b1f3a3247cb28ed01a367fa4ff4 Reviewed-on: https://code.wireshark.org/review/4469 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--epan/dissectors/packet-user_encap.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/epan/dissectors/packet-user_encap.c b/epan/dissectors/packet-user_encap.c
index b220278841..45fc90488b 100644
--- a/epan/dissectors/packet-user_encap.c
+++ b/epan/dissectors/packet-user_encap.c
@@ -31,6 +31,8 @@
#include <epan/prefs.h>
#include <epan/uat.h>
#include <epan/wmem/wmem.h>
+#include <epan/exported_pdu.h>
+#include <epan/tap.h>
#include <wiretap/wtap.h>
#ifdef _MSC_VER
@@ -82,11 +84,28 @@ static guint num_encaps = 0;
static uat_t* encaps_uat;
static dissector_handle_t data_handle;
+static gint exported_pdu_tap = -1;
+
/*
* Use this for DLT_USER2 if we don't have an encapsulation for it.
*/
static user_encap_t user2_encap;
+static void export_pdu(tvbuff_t *tvb, packet_info* pinfo, char *proto_name)
+{
+ if (have_tap_listener(exported_pdu_tap)) {
+ exp_pdu_data_t *exp_pdu_data;
+ guint8 exp_pdu_data_tag;
+
+ exp_pdu_data_tag = EXP_PDU_TAG_ORIG_FNO_BIT;
+ exp_pdu_data = load_export_pdu_tags(pinfo, proto_name, -1, &exp_pdu_data_tag, 1);
+ exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb);
+ exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
+ exp_pdu_data->pdu_tvb = tvb;
+ tap_queue_packet(exported_pdu_tap, pinfo, exp_pdu_data);
+ }
+}
+
static void dissect_user(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) {
user_encap_t* encap = NULL;
tvbuff_t* payload_tvb;
@@ -138,6 +157,7 @@ static void dissect_user(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) {
if (encap->header_size) {
tvbuff_t* hdr_tvb = tvb_new_subset_length(tvb, 0, encap->header_size);
+ export_pdu(hdr_tvb, pinfo, encap->header_proto_name);
call_dissector(encap->header_proto, hdr_tvb, pinfo, tree);
if (encap->header_proto_name) {
const char *proto_name = dissector_handle_get_long_name(find_dissector(encap->header_proto_name));
@@ -147,10 +167,11 @@ static void dissect_user(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) {
}
}
- len = tvb_length(tvb) - (encap->header_size + encap->trailer_size);
+ len = tvb_captured_length(tvb) - (encap->header_size + encap->trailer_size);
reported_len = tvb_reported_length(tvb) - (encap->header_size + encap->trailer_size);
payload_tvb = tvb_new_subset(tvb, encap->header_size, len, reported_len);
+ export_pdu(payload_tvb, pinfo, encap->payload_proto_name);
call_dissector(encap->payload_proto, payload_tvb, pinfo, tree);
if (encap->payload_proto_name) {
const char *proto_name = dissector_handle_get_long_name(find_dissector(encap->payload_proto_name));
@@ -161,6 +182,7 @@ static void dissect_user(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) {
if (encap->trailer_size) {
tvbuff_t* trailer_tvb = tvb_new_subset_length(tvb, encap->header_size + len, encap->trailer_size);
+ export_pdu(trailer_tvb, pinfo, encap->trailer_proto_name);
call_dissector(encap->trailer_proto, trailer_tvb, pinfo, tree);
if (encap->trailer_proto_name) {
const char *proto_name = dissector_handle_get_long_name(find_dissector(encap->trailer_proto_name));
@@ -282,6 +304,8 @@ void proto_register_user_encap(void)
prefs_register_protocol_obsolete(proto_register_protocol("DLT User C","DLT_USER_C","user_dlt_c"));
prefs_register_protocol_obsolete(proto_register_protocol("DLT User D","DLT_USER_D","user_dlt_d"));
*/
+
+ exported_pdu_tap = register_export_pdu_tap("DLT User");
}
/*