aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-tcp.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-02-20 19:33:16 +0100
committerEvan Huus <eapache@gmail.com>2015-03-06 04:02:00 +0000
commit4ca3dbae9440c202c9b2346010c1986ee8e8968e (patch)
treebefdcd4335978d9439b32574223f2004cb752d72 /epan/dissectors/packet-tcp.c
parent554c8fd7caf3987637aa00f7b6c27d0a7fedfb02 (diff)
tcp: support variable-length tcp_dissect_pdus
Originally suggested by Bill Meier for the MQTT protocol[1], but the Websocket protocol can also benefit from this. Since DESEGMENT_ONE_MORE_SEGMENT is a valid packet length, use the zero length instead as an indicator that the length is not yet known. Updated documentation too and remove the function documentation from packet-tcp.c since it is duplicated in packet-tcp.h. A noteworthy WSDG change is that the get_pdu_len parameter of tcp_dissect_pdus gained another void pointer since v1.99.2rc0-890-gceb8d95 ("Lua: Expose tcp_dissect_pdus() to Lua"). [1]: https://www.wireshark.org/lists/wireshark-dev/201405/msg00044.html Change-Id: I4eba380e00cd757635eb5639c2857356dae3171e Reviewed-on: https://code.wireshark.org/review/7279 Reviewed-by: Guy Harris <guy@alum.mit.edu> Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-tcp.c')
-rw-r--r--epan/dissectors/packet-tcp.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c
index 037a7f262f..1b8fbc51fe 100644
--- a/epan/dissectors/packet-tcp.c
+++ b/epan/dissectors/packet-tcp.c
@@ -2306,24 +2306,6 @@ again:
}
}
-/*
- * Loop for dissecting PDUs within a TCP stream; assumes that a PDU
- * consists of a fixed-length chunk of data that contains enough information
- * to determine the length of the PDU, followed by rest of the PDU.
- *
- * The first three arguments are the arguments passed to the dissector
- * that calls this routine.
- *
- * "proto_desegment" is the dissector's flag controlling whether it should
- * desegment PDUs that cross TCP segment boundaries.
- *
- * "fixed_len" is the length of the fixed-length part of the PDU.
- *
- * "get_pdu_len()" is a routine called to get the length of the PDU from
- * the fixed-length part of the PDU; it's passed "pinfo", "tvb" and "offset".
- *
- * "dissect_pdu()" is the routine to dissect a PDU.
- */
void
tcp_dissect_pdus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gboolean proto_desegment, guint fixed_len,
@@ -2379,6 +2361,16 @@ tcp_dissect_pdus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
* Get the length of the PDU.
*/
plen = (*get_pdu_len)(pinfo, tvb, offset, dissector_data);
+ if (plen == 0) {
+ /*
+ * Support protocols which have a variable length which cannot
+ * always be determined within the given fixed_len.
+ */
+ DISSECTOR_ASSERT(proto_desegment && pinfo->can_desegment);
+ pinfo->desegment_offset = offset;
+ pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
+ return;
+ }
if (plen < fixed_len) {
/*
* Either: