aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-websocket.c
diff options
context:
space:
mode:
authorMartin Kaiser <wireshark@kaiser.cx>2015-01-06 23:04:55 +0100
committerMartin Kaiser <wireshark@kaiser.cx>2015-01-08 07:53:25 +0000
commitdcc49369b9ca5dc44395070c2f1e03694f6be24b (patch)
treee6d2c6c8a3914ce2dd5fc084e73fa2972c633c9a /epan/dissectors/packet-websocket.c
parent866d2f8b8752a4fe35c58444eaea0c460f752e1b (diff)
use the http server port as index for the ws.port dissector table
pinfo->match_uint is not set if websocket is called because of a previous http Upgrade: header and http is running on a non-standard port Bug: 10805 Change-Id: Ib0d35d29fe947cfb7b21107e734c64debbb91048 Reviewed-on: https://code.wireshark.org/review/6353 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx> Tested-by: Martin Kaiser <wireshark@kaiser.cx>
Diffstat (limited to 'epan/dissectors/packet-websocket.c')
-rw-r--r--epan/dissectors/packet-websocket.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/epan/dissectors/packet-websocket.c b/epan/dissectors/packet-websocket.c
index 98eaf57378..cab5ea85a3 100644
--- a/epan/dissectors/packet-websocket.c
+++ b/epan/dissectors/packet-websocket.c
@@ -23,10 +23,13 @@
#include "config.h"
+#include <epan/conversation.h>
#include <epan/packet.h>
#include <epan/expert.h>
#include <epan/prefs.h>
+#include "packet-http.h"
+
/*
* The information used comes from:
@@ -50,6 +53,8 @@ static gint pref_text_type = WEBSOCKET_NONE;
/* Initialize the protocol and registered fields */
static int proto_websocket = -1;
+static int proto_http = -1;
+
static int hf_ws_fin = -1;
static int hf_ws_reserved = -1;
static int hf_ws_opcode = -1;
@@ -154,10 +159,12 @@ dissect_websocket_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, p
{
guint offset = 0;
proto_item *ti_unmask, *ti;
- dissector_handle_t handle;
+ dissector_handle_t handle = NULL;
proto_tree *pl_tree, *mask_tree = NULL;
tvbuff_t *payload_tvb = NULL;
heur_dtbl_entry_t *hdtbl_entry;
+ conversation_t *conv;
+ http_conv_t *http_conv = NULL;
/* Payload */
ti = proto_tree_add_item(ws_tree, hf_ws_payload, tvb, offset, payload_length, ENC_NA);
@@ -175,12 +182,17 @@ dissect_websocket_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, p
payload_tvb = tvb_new_subset(tvb, offset, payload_length, -1);
}
- handle = dissector_get_uint_handle(port_subdissector_table, pinfo->match_uint);
- if (handle != NULL) {
+ conv = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
+ if (conv)
+ http_conv = (http_conv_t *)conversation_get_proto_data(conv, proto_http);
+
+ if (http_conv)
+ handle = dissector_get_uint_handle(port_subdissector_table, http_conv->server_port);
+
+ if (handle)
call_dissector_only(handle, payload_tvb, pinfo, tree, NULL);
- } else {
+ else
dissector_try_heuristic(heur_subdissector_list, payload_tvb, pinfo, tree, &hdtbl_entry, NULL);
- }
/* Extension Data */
/* TODO: Add dissector of Extension (not extension available for the moment...) */
@@ -627,6 +639,8 @@ proto_reg_handoff_websocket(void)
text_lines_handle = find_dissector("data-text-lines");
json_handle = find_dissector("json");
sip_handle = find_dissector("sip");
+
+ proto_http = proto_get_id_by_filter_name("http");
}
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html