Exported PDU: add support for data length on the wire
authorPascal Quantin <pascal.quantin@gmail.com>
Tue, 18 Mar 2014 22:01:22 +0000 (23:01 +0100)
committerAnders Broman <a.broman58@gmail.com>
Wed, 19 Mar 2014 05:13:30 +0000 (05:13 +0000)
Change-Id: Iff14ec4d0297ec85f3597b33871fb0ab5256a597
Reviewed-on: https://code.wireshark.org/review/728
Reviewed-by: Anders Broman <a.broman58@gmail.com>
13 files changed:
asn1/credssp/packet-credssp-template.c
epan/dissectors/packet-credssp.c
epan/dissectors/packet-diameter.c
epan/dissectors/packet-dtls.c
epan/dissectors/packet-dvbci.c
epan/dissectors/packet-ipsec.c
epan/dissectors/packet-logcat.c
epan/dissectors/packet-reload-framing.c
epan/dissectors/packet-sctp.c
epan/dissectors/packet-sip.c
epan/dissectors/packet-ssl.c
epan/exported_pdu.h
ui/tap_export_pdu.c

index abfd986275527b1bcfd729aedb92dff0ae70c484..31457f28dd372e895adcc1c8b9fc4d40c20abf58 100644 (file)
@@ -111,7 +111,8 @@ dissect_credssp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
                                                   (EXP_PDU_TAG_IP_SRC_BIT | EXP_PDU_TAG_IP_DST_BIT | EXP_PDU_TAG_SRC_PORT_BIT |
                                                    EXP_PDU_TAG_DST_PORT_BIT | EXP_PDU_TAG_ORIG_FNO_BIT));
 
-              exp_pdu_data->tvb_length = tvb_length(tvb);
+              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);
index 240e0c56cc54e54d89b26faa82aa65710e6413f3..2f01b59e80e3e71e055ed3ca3e7c6de7cc4b2e56 100644 (file)
@@ -383,7 +383,8 @@ dissect_credssp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
                                                   (EXP_PDU_TAG_IP_SRC_BIT | EXP_PDU_TAG_IP_DST_BIT | EXP_PDU_TAG_SRC_PORT_BIT |
                                                    EXP_PDU_TAG_DST_PORT_BIT | EXP_PDU_TAG_ORIG_FNO_BIT));
 
-              exp_pdu_data->tvb_length = tvb_length(tvb);
+              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);
@@ -506,7 +507,7 @@ void proto_register_credssp(void) {
         "OCTET_STRING", HFILL }},
 
 /*--- End of included file: packet-credssp-hfarr.c ---*/
-#line 149 "../../asn1/credssp/packet-credssp-template.c"
+#line 150 "../../asn1/credssp/packet-credssp-template.c"
   };
 
   /* List of subtrees */
@@ -524,7 +525,7 @@ void proto_register_credssp(void) {
     &ett_credssp_TSRequest,
 
 /*--- End of included file: packet-credssp-ettarr.c ---*/
-#line 155 "../../asn1/credssp/packet-credssp-template.c"
+#line 156 "../../asn1/credssp/packet-credssp-template.c"
   };
 
 
index 29f6cd61b5755d10c08b9f5924ced2a87a406877..1b20ee547cafcb7b7a50abe2609a9228d020ded8 100644 (file)
@@ -340,7 +340,8 @@ export_diameter_pdu(packet_info *pinfo, tvbuff_t *tvb)
 
        exp_pdu_data = load_export_pdu_tags(pinfo, "diameter", -1, tags_bit_field);
 
-       exp_pdu_data->tvb_length = tvb_length(tvb);
+       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);
index 67d53e230b8e6e63d1fc35a39ddeb5d109b46980..628ba19f0456103333db7a13a383f1da36a30291 100644 (file)
@@ -1040,7 +1040,8 @@ dissect_dtls_record(tvbuff_t *tvb, packet_info *pinfo,
                                                 (EXP_PDU_TAG_IP_SRC_BIT | EXP_PDU_TAG_IP_DST_BIT | EXP_PDU_TAG_SRC_PORT_BIT |
                                                  EXP_PDU_TAG_DST_PORT_BIT | EXP_PDU_TAG_ORIG_FNO_BIT));
 
-            exp_pdu_data->tvb_length = tvb_length(next_tvb);
+            exp_pdu_data->tvb_captured_length = tvb_captured_length(next_tvb);
+            exp_pdu_data->tvb_reported_length = tvb_reported_length(next_tvb);
             exp_pdu_data->pdu_tvb = next_tvb;
 
             tap_queue_packet(exported_pdu_tap, pinfo, exp_pdu_data);
index 1a74095e21c29154611d1416585100a4cbdb4fb5..9c1a427ac4404e77772c25effffae8be865196b7 100644 (file)
@@ -3417,7 +3417,8 @@ dissect_sac_msg(guint32 tag, tvbuff_t *tvb, gint offset,
         exp_pdu_data = load_export_pdu_tags(
                 pinfo, EXPORTED_SAC_MSG_PROTO, -1, EXP_PDU_TAG_DVBCI_EVT_BIT);
 
-        exp_pdu_data->tvb_length = tvb_length(clear_sac_msg_tvb);
+        exp_pdu_data->tvb_captured_length = tvb_captured_length(clear_sac_msg_tvb);
+        exp_pdu_data->tvb_reported_length = tvb_reported_length(clear_sac_msg_tvb);
         exp_pdu_data->pdu_tvb = clear_sac_msg_tvb;
         tap_queue_packet(exported_pdu_tap, pinfo, exp_pdu_data);
     }
index a07281c398b99abcdcbe09a475e7aa16a43d2903..7ff497e04e2edc9d56427bb715f67c268ef3f0bd 100644 (file)
@@ -868,7 +868,8 @@ export_ipsec_pdu(dissector_handle_t dissector_handle, packet_info *pinfo, tvbuff
                                         (EXP_PDU_TAG_IP_SRC_BIT | EXP_PDU_TAG_IP_DST_BIT | EXP_PDU_TAG_SRC_PORT_BIT |
                                          EXP_PDU_TAG_DST_PORT_BIT | EXP_PDU_TAG_ORIG_FNO_BIT));
 
-    exp_pdu_data->tvb_length = tvb_length(tvb);
+    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);
index 9e7660d778bcc6fd9e97124dc8dba5966ef1bcf2..1a0b5e2b5e36a99d1f018a1c8e106173cd814875 100644 (file)
@@ -179,7 +179,8 @@ dissect_logcat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
         exp_pdu_data_t *exp_pdu_data;
 
         exp_pdu_data = load_export_pdu_tags(pinfo, "logcat", -1, EXP_PDU_TAG_END_OF_OPT);
-        exp_pdu_data->tvb_length = tvb_length(tvb);
+        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);
     }
index c60378bd6642963b5b0f89a59b2255b26a8cb573..000a1ed190a0ab4b5e5cdc0ed35e069a63980b57 100644 (file)
@@ -129,7 +129,7 @@ dissect_reload_framing_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr
   guint8              type;
 
   offset = 0;
-  effective_length = tvb_length(tvb);
+  effective_length = tvb_captured_length(tvb);
 
   /* First, make sure we have enough data to do the check. */
   if (effective_length < MIN_HDR_LENGTH)
@@ -180,7 +180,8 @@ dissect_reload_framing_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr
                                         (EXP_PDU_TAG_IP_SRC_BIT | EXP_PDU_TAG_IP_DST_BIT | EXP_PDU_TAG_SRC_PORT_BIT |
                                          EXP_PDU_TAG_DST_PORT_BIT | EXP_PDU_TAG_ORIG_FNO_BIT));
 
-    exp_pdu_data->tvb_length = effective_length;
+    exp_pdu_data->tvb_captured_length = effective_length;
+    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);
index 2653d5ff2301317b4733ff0800a82f9fc71b426d..5c0e3e9067f5f11ff0f111e9c4c6f5dfae5cba25 100644 (file)
@@ -3046,7 +3046,8 @@ export_sctp_data_chunk(packet_info *pinfo, tvbuff_t *tvb, const gchar *proto_nam
 
        exp_pdu_data = load_export_pdu_tags(pinfo, proto_name, -1, tags_bit_field);
 
-       exp_pdu_data->tvb_length = tvb_captured_length(tvb);
+       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);
index 09bec53be8afa0fe4db6824d5fd4bddde2cc13b7..399a4a7f605b42b08f1648fb386aeaaac3327399 100644 (file)
@@ -994,7 +994,8 @@ export_sip_pdu(packet_info *pinfo, tvbuff_t *tvb)
 
   exp_pdu_data = load_export_pdu_tags(pinfo, "sip", -1, tags_bit_field);
 
-  exp_pdu_data->tvb_length = tvb_length(tvb);
+  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);
index 0e54dfc6c10472ab83eec0abf3a5ff0af0722db7..8cb95714f518e3a70ecccfa3e72ab74de3663e8d 100644 (file)
@@ -1369,7 +1369,8 @@ process_ssl_payload(tvbuff_t *tvb, volatile int offset, packet_info *pinfo,
                                                     (EXP_PDU_TAG_IP_SRC_BIT | EXP_PDU_TAG_IP_DST_BIT | EXP_PDU_TAG_SRC_PORT_BIT |
                                                      EXP_PDU_TAG_DST_PORT_BIT | EXP_PDU_TAG_ORIG_FNO_BIT));
 
-                exp_pdu_data->tvb_length = tvb_length(next_tvb);
+                exp_pdu_data->tvb_captured_length = tvb_captured_length(next_tvb);
+                exp_pdu_data->tvb_reported_length = tvb_reported_length(next_tvb);
                 exp_pdu_data->pdu_tvb = next_tvb;
 
                 tap_queue_packet(exported_pdu_tap, pinfo, exp_pdu_data);
index cf73c009291350709fdc2256d7d30a28fef4539a..9546517eb163dd1f2b3211d55c778cad2741c6e9 100644 (file)
 
 
 typedef struct _exp_pdu_data_t {
-    int          tlv_buffer_len;
+    guint        tlv_buffer_len;
     guint8      *tlv_buffer;
-    int          tvb_length;
+    guint        tvb_captured_length;
+    guint        tvb_reported_length;
     tvbuff_t    *pdu_tvb;
 } exp_pdu_data_t;
 
index e93014d97e693ab39a82c1590c39801586719bd9..7c35ad36d52b884146b9f1b74bb12b06aada1d3c 100644 (file)
@@ -48,7 +48,7 @@ export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, co
     int buffer_len;
     guint8 *packet_buf;
 
-    buffer_len = exp_pdu_data->tvb_length + exp_pdu_data->tlv_buffer_len;
+    buffer_len = exp_pdu_data->tvb_captured_length + exp_pdu_data->tlv_buffer_len;
     packet_buf = (guint8 *)g_malloc(buffer_len);
 
     if(exp_pdu_data->tlv_buffer_len > 0){
@@ -60,7 +60,8 @@ export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, co
     }
     pkthdr.ts.secs   = pinfo->fd->abs_ts.secs;
     pkthdr.ts.nsecs  = pinfo->fd->abs_ts.nsecs;
-    pkthdr.caplen    = pkthdr.len = buffer_len;
+    pkthdr.caplen    = buffer_len;
+    pkthdr.len       = exp_pdu_data->tvb_reported_length + exp_pdu_data->tlv_buffer_len;
 
     pkthdr.pkt_encap = exp_pdu_tap_data->pkt_encap;
     pkthdr.interface_id = 0;