Use TCP FIN bit to help determine desegmentation in HTTP dissector.

Have the TCP dissector pass FIN bit to subdissectors (HTTP only one currently using it) so subdissector can use information to determine that no more segments are coming.

Bug: 9848
Change-Id: I4aebb5141f41d99598e4776bf25e74101016f5d1
Reviewed-on: https://code.wireshark.org/review/12984
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Michael Mann 2015-12-31 21:10:05 -05:00
parent 1b222b8b65
commit 4762828133
3 changed files with 12 additions and 8 deletions

View File

@ -717,7 +717,7 @@ static http_info_value_t *stat_info;
static int
dissect_http_message(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_tree *tree, http_conv_t *conv_data, const char* proto_tag, int proto)
proto_tree *tree, http_conv_t *conv_data, const char* proto_tag, int proto, struct tcpinfo *tcpinfo)
{
proto_tree *http_tree = NULL;
proto_item *ti = NULL;
@ -822,9 +822,9 @@ dissect_http_message(tvbuff_t *tvb, int offset, packet_info *pinfo,
* contain a message body, so ignore the Content-Length header
* which is done by disabling body desegmentation.
*/
gboolean try_desegment_body = http_desegment_body &&
!(conv_data->request_method &&
g_str_equal(conv_data->request_method, "HEAD"));
gboolean try_desegment_body = (http_desegment_body &&
(!(conv_data->request_method && g_str_equal(conv_data->request_method, "HEAD"))) &&
((tcpinfo == NULL) || (tcpinfo->fin == FALSE)));
if (!req_resp_hdrs_do_reassembly(tvb, offset, pinfo,
http_desegment_headers, try_desegment_body)) {
/*
@ -2998,6 +2998,7 @@ dissect_http(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
int len;
conversation_t *conversation;
dissector_handle_t next_handle = NULL;
struct tcpinfo *tcpinfo = (struct tcpinfo *)data;
conv_data = get_http_conversation_data(pinfo, &conversation);
/* Call HTTP2 dissector directly when detected via heuristics, but not
@ -3006,7 +3007,7 @@ dissect_http(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
conv_data->upgrade != UPGRADE_HTTP2) {
if (pinfo->can_desegment > 0)
pinfo->can_desegment++;
return call_dissector_only(http2_handle, tvb, pinfo, tree, NULL);
return call_dissector_only(http2_handle, tvb, pinfo, tree, data);
}
/*
@ -3043,7 +3044,7 @@ dissect_http(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
call_dissector_only(next_handle, tvb_new_subset_remaining(tvb, offset), pinfo, tree, NULL);
break;
}
len = dissect_http_message(tvb, offset, pinfo, tree, conv_data, "HTTP", proto_http);
len = dissect_http_message(tvb, offset, pinfo, tree, conv_data, "HTTP", proto_http, tcpinfo);
if (len == -1)
break;
offset += len;
@ -3096,7 +3097,7 @@ dissect_ssdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
http_conv_t *conv_data;
conv_data = get_http_conversation_data(pinfo, &conversation);
dissect_http_message(tvb, 0, pinfo, tree, conv_data, "SSDP", proto_ssdp);
dissect_http_message(tvb, 0, pinfo, tree, conv_data, "SSDP", proto_ssdp, NULL);
return tvb_captured_length(tvb);
}

View File

@ -5187,9 +5187,11 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
tcpd->ts_mru_syn.nsecs = pinfo->fd->abs_ts.nsecs;
}
}
if(tcph->th_flags & TH_FIN)
if(tcph->th_flags & TH_FIN) {
/* XXX - find a way to know the server port and output only that one */
expert_add_info(pinfo, tf_fin, &ei_tcp_connection_fin);
tcpinfo.fin = TRUE;
}
if(tcph->th_flags & TH_RST)
/* XXX - find a way to know the server port and output only that one */
expert_add_info(pinfo, tf_rst, &ei_tcp_connection_rst);

View File

@ -106,6 +106,7 @@ struct tcpinfo {
guint32 nxtseq; /* Sequence number of first byte after data */
guint32 lastackseq; /* Sequence number of last ack */
gboolean is_reassembled; /* This is reassembled data. */
gboolean fin; /* TRUE if FIN flag bit is set */
gboolean urgent; /* TRUE if "urgent_pointer" is valid */
guint16 urgent_pointer; /* Urgent pointer value for the current packet. */
};