2 * Routines for WebSocket dissection
3 * Copyright 2012, Alexis La Goutte <alexis.lagoutte@gmail.com>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <epan/packet.h>
31 #include <epan/expert.h>
32 #include <epan/prefs.h>
36 * The information used comes from:
37 * RFC6455: The WebSocket Protocol
38 * http://www.iana.org/assignments/websocket (last updated 2012-04-12)
41 void proto_reg_handoff_websocket(void);
43 static dissector_handle_t text_lines_handle
;
44 static dissector_handle_t json_handle
;
46 #define WEBSOCKET_NONE 0
47 #define WEBSOCKET_TEXT 1
48 #define WEBSOCKET_JSON 2
50 static gint pref_text_type
= WEBSOCKET_NONE
;
52 /* Initialize the protocol and registered fields */
53 static int proto_websocket
= -1;
54 static int hf_ws_fin
= -1;
55 static int hf_ws_reserved
= -1;
56 static int hf_ws_opcode
= -1;
57 static int hf_ws_mask
= -1;
58 static int hf_ws_payload_length
= -1;
59 static int hf_ws_payload_length_ext_16
= -1;
60 static int hf_ws_payload_length_ext_64
= -1;
61 static int hf_ws_masking_key
= -1;
62 static int hf_ws_payload
= -1;
63 static int hf_ws_payload_unmask
= -1;
64 static int hf_ws_payload_continue
= -1;
65 static int hf_ws_payload_text
= -1;
66 static int hf_ws_payload_text_mask
= -1;
67 static int hf_ws_payload_text_unmask
= -1;
68 static int hf_ws_payload_binary
= -1;
69 static int hf_ws_payload_binary_mask
= -1;
70 static int hf_ws_payload_binary_unmask
= -1;
71 static int hf_ws_payload_close
= -1;
72 static int hf_ws_payload_close_mask
= -1;
73 static int hf_ws_payload_close_unmask
= -1;
74 static int hf_ws_payload_close_status_code
= -1;
75 static int hf_ws_payload_close_reason
= -1;
76 static int hf_ws_payload_ping
= -1;
77 static int hf_ws_payload_ping_mask
= -1;
78 static int hf_ws_payload_ping_unmask
= -1;
79 static int hf_ws_payload_pong
= -1;
80 static int hf_ws_payload_pong_mask
= -1;
81 static int hf_ws_payload_pong_unmask
= -1;
82 static int hf_ws_payload_unknown
= -1;
84 static gint ett_ws
= -1;
85 static gint ett_ws_pl
= -1;
86 static gint ett_ws_mask
= -1;
88 static expert_field ei_ws_payload_unknown
= EI_INIT
;
90 #define WS_CONTINUE 0x0
97 static const value_string ws_opcode_vals
[] = {
98 { WS_CONTINUE
, "Continuation" },
100 { WS_BINARY
, "Binary" },
101 { WS_CLOSE
, "Connection Close" },
107 #define MASK_WS_FIN 0x80
108 #define MASK_WS_RSV 0x70
109 #define MASK_WS_OPCODE 0x0F
110 #define MASK_WS_MASK 0x80
111 #define MASK_WS_PAYLOAD_LEN 0x7F
113 static const value_string ws_close_status_code_vals
[] = {
114 { 1000, "Normal Closure" },
115 { 1001, "Going Away" },
116 { 1002, "Protocol error" },
117 { 1003, "Unsupported Data" },
118 { 1004, "---Reserved----" },
119 { 1005, "No Status Rcvd" },
120 { 1006, "Abnormal Closure" },
121 { 1007, "Invalid frame payload data" },
122 { 1008, "Policy Violation" },
123 { 1009, "Message Too Big" },
124 { 1010, "Mandatory Ext." },
125 { 1011, "Internal Server" },
126 { 1015, "TLS handshake" },
130 static dissector_table_t port_subdissector_table
;
131 static heur_dissector_list_t heur_subdissector_list
;
133 #define MAX_UNMASKED_LEN (1024 * 64)
135 tvb_unmasked(tvbuff_t
*tvb
, const guint offset
, guint payload_length
, const guint8
*masking_key
)
139 tvbuff_t
*tvb_unmask
= NULL
;
141 const guint8
*data_mask
;
142 guint unmasked_length
= payload_length
> MAX_UNMASKED_LEN
? MAX_UNMASKED_LEN
: payload_length
;
144 data_unmask
= (gchar
*)g_malloc(unmasked_length
);
145 data_mask
= tvb_get_ptr(tvb
, offset
, unmasked_length
);
146 /* Unmasked(XOR) Data... */
147 for(i
=0; i
< unmasked_length
; i
++){
148 data_unmask
[i
] = data_mask
[i
] ^ masking_key
[i
%4];
151 tvb_unmask
= tvb_new_real_data(data_unmask
, unmasked_length
, unmasked_length
);
152 tvb_set_free_cb(tvb_unmask
, g_free
);
157 dissect_websocket_payload(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, proto_tree
*ws_tree
, guint8 opcode
, guint payload_length
, guint8 mask
, const guint8
* masking_key
)
160 proto_item
*ti_unmask
, *ti
;
161 dissector_handle_t handle
;
162 proto_tree
*pl_tree
, *mask_tree
= NULL
;
163 tvbuff_t
*payload_tvb
= NULL
;
166 ti
= proto_tree_add_item(ws_tree
, hf_ws_payload
, tvb
, offset
, payload_length
, ENC_NA
);
167 pl_tree
= proto_item_add_subtree(ti
, ett_ws_pl
);
169 payload_tvb
= tvb_unmasked(tvb
, offset
, payload_length
, masking_key
);
170 tvb_set_child_real_data_tvbuff(tvb
, payload_tvb
);
171 add_new_data_source(pinfo
, payload_tvb
, payload_length
> tvb_length(payload_tvb
) ? "Unmasked Data (truncated)" : "Unmasked Data");
172 ti
= proto_tree_add_item(ws_tree
, hf_ws_payload_unmask
, payload_tvb
, offset
, payload_length
, ENC_NA
);
173 mask_tree
= proto_item_add_subtree(ti
, ett_ws_mask
);
175 payload_tvb
= tvb_new_subset(tvb
, offset
, payload_length
, -1);
178 handle
= dissector_get_uint_handle(port_subdissector_table
, pinfo
->match_uint
);
180 call_dissector_only(handle
, payload_tvb
, pinfo
, tree
, NULL
);
182 dissector_try_heuristic(heur_subdissector_list
, payload_tvb
, pinfo
, tree
, NULL
);
186 /* TODO: Add dissector of Extension (not extension available for the moment...) */
188 /* Application Data */
191 case WS_CONTINUE
: /* Continue */
192 proto_tree_add_item(pl_tree
, hf_ws_payload_continue
, tvb
, offset
, payload_length
, ENC_NA
);
193 /* TODO: Add Fragmentation support... */
196 case WS_TEXT
: /* Text */
199 proto_tree_add_item(pl_tree
, hf_ws_payload_text_mask
, tvb
, offset
, payload_length
, ENC_NA
);
200 ti_unmask
= proto_tree_add_item(mask_tree
, hf_ws_payload_text_unmask
, payload_tvb
, offset
, payload_length
, ENC_UTF_8
|ENC_NA
);
201 PROTO_ITEM_SET_GENERATED(ti_unmask
);
202 ti_unmask
= proto_tree_add_item(mask_tree
, hf_ws_payload_text
, payload_tvb
, offset
, payload_length
, ENC_UTF_8
|ENC_NA
);
203 PROTO_ITEM_SET_HIDDEN(ti_unmask
);
205 const gchar
*saved_match_string
= pinfo
->match_string
;
206 void *save_private_data
= pinfo
->private_data
;
208 pinfo
->match_string
= NULL
;
209 pinfo
->private_data
= NULL
;
210 switch(pref_text_type
){
212 call_dissector(text_lines_handle
, payload_tvb
, pinfo
, pl_tree
);
215 call_dissector(json_handle
, payload_tvb
, pinfo
, pl_tree
);
220 proto_tree_add_item(pl_tree
, hf_ws_payload_text
, tvb
, offset
, payload_length
, ENC_UTF_8
|ENC_NA
);
223 pinfo
->match_string
= saved_match_string
;
224 pinfo
->private_data
= save_private_data
;
226 offset
+= payload_length
;
229 case WS_BINARY
: /* Binary */
231 proto_tree_add_item(pl_tree
, hf_ws_payload_binary_mask
, tvb
, offset
, payload_length
, ENC_NA
);
232 ti_unmask
= proto_tree_add_item(mask_tree
, hf_ws_payload_binary_unmask
, payload_tvb
, offset
, payload_length
, ENC_NA
);
233 PROTO_ITEM_SET_GENERATED(ti_unmask
);
234 ti_unmask
= proto_tree_add_item(mask_tree
, hf_ws_payload_binary
, payload_tvb
, offset
, payload_length
, ENC_NA
);
235 PROTO_ITEM_SET_HIDDEN(ti_unmask
);
237 proto_tree_add_item(pl_tree
, hf_ws_payload_binary
, tvb
, offset
, payload_length
, ENC_NA
);
239 offset
+= payload_length
;
242 case WS_CLOSE
: /* Close */
244 proto_tree_add_item(pl_tree
, hf_ws_payload_close_mask
, tvb
, offset
, payload_length
, ENC_NA
);
245 ti_unmask
= proto_tree_add_item(mask_tree
, hf_ws_payload_close_unmask
, payload_tvb
, offset
, payload_length
, ENC_NA
);
246 PROTO_ITEM_SET_GENERATED(ti_unmask
);
247 ti_unmask
= proto_tree_add_item(mask_tree
, hf_ws_payload_close
, payload_tvb
, offset
, payload_length
, ENC_NA
);
248 PROTO_ITEM_SET_HIDDEN(ti_unmask
);
249 ti_unmask
= proto_tree_add_item(mask_tree
, hf_ws_payload_close_status_code
, payload_tvb
, offset
, 2, ENC_BIG_ENDIAN
);
250 PROTO_ITEM_SET_GENERATED(ti_unmask
);
252 if(payload_length
> 2){
253 ti_unmask
= proto_tree_add_item(mask_tree
, hf_ws_payload_close_reason
, payload_tvb
, offset
+2, payload_length
-2, ENC_ASCII
|ENC_NA
);
254 PROTO_ITEM_SET_GENERATED(ti_unmask
);
257 proto_tree_add_item(pl_tree
, hf_ws_payload_close
, tvb
, offset
, payload_length
, ENC_NA
);
258 proto_tree_add_item(pl_tree
, hf_ws_payload_close_status_code
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
259 if(payload_length
> 2){
260 proto_tree_add_item(pl_tree
, hf_ws_payload_close_reason
, tvb
, offset
+2, payload_length
-2, ENC_ASCII
|ENC_NA
);
263 offset
+= payload_length
;
266 case WS_PING
: /* Ping */
268 proto_tree_add_item(pl_tree
, hf_ws_payload_ping_mask
, tvb
, offset
, payload_length
, ENC_NA
);
269 ti_unmask
= proto_tree_add_item(mask_tree
, hf_ws_payload_ping_unmask
, payload_tvb
, offset
, payload_length
, ENC_NA
);
270 PROTO_ITEM_SET_GENERATED(ti_unmask
);
271 ti_unmask
= proto_tree_add_item(mask_tree
, hf_ws_payload_ping
, payload_tvb
, offset
, payload_length
, ENC_NA
);
272 PROTO_ITEM_SET_HIDDEN(ti_unmask
);
274 proto_tree_add_item(pl_tree
, hf_ws_payload_ping
, tvb
, offset
, payload_length
, ENC_NA
);
276 offset
+= payload_length
;
279 case WS_PONG
: /* Pong */
281 proto_tree_add_item(pl_tree
, hf_ws_payload_pong_mask
, tvb
, offset
, payload_length
, ENC_NA
);
282 ti_unmask
= proto_tree_add_item(mask_tree
, hf_ws_payload_pong_unmask
, payload_tvb
, offset
, payload_length
, ENC_NA
);
283 PROTO_ITEM_SET_GENERATED(ti_unmask
);
284 ti_unmask
= proto_tree_add_item(mask_tree
, hf_ws_payload_pong
, payload_tvb
, offset
, payload_length
, ENC_NA
);
285 PROTO_ITEM_SET_HIDDEN(ti_unmask
);
287 proto_tree_add_item(pl_tree
, hf_ws_payload_pong
, tvb
, offset
, payload_length
, ENC_NA
);
289 offset
+= payload_length
;
292 default: /* Unknown */
293 ti
= proto_tree_add_item(pl_tree
, hf_ws_payload_unknown
, tvb
, offset
, payload_length
, ENC_NA
);
294 expert_add_info_format(pinfo
, ti
, &ei_ws_payload_unknown
, "Dissector for Websocket Opcode (%d)"
295 " code not implemented, Contact Wireshark developers"
296 " if you want this supported", opcode
);
304 dissect_websocket(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
306 proto_item
*ti
, *ti_len
;
307 guint8 fin
, opcode
, mask
;
308 guint length
, short_length
, payload_length
, recurse_length
;
309 guint payload_offset
, mask_offset
, recurse_offset
;
310 proto_tree
*ws_tree
= NULL
;
311 const guint8
*masking_key
= NULL
;
312 tvbuff_t
*tvb_payload
= NULL
;
314 length
= tvb_length(tvb
);
316 pinfo
->desegment_len
= 2;
320 short_length
= tvb_get_guint8(tvb
, 1) & MASK_WS_PAYLOAD_LEN
;
321 if(short_length
==126){
323 pinfo
->desegment_len
= 2+2;
326 payload_length
= tvb_get_ntohs(tvb
, 2);
329 else if(short_length
==127){
331 pinfo
->desegment_len
= 2+8;
334 /* warning C4244: '=' : conversion from 'guint64' to 'guint ', possible loss of data */
335 payload_length
= (guint
)tvb_get_ntoh64(tvb
, 2);
339 payload_length
= short_length
;
344 mask
= (tvb_get_guint8(tvb
, 1) & MASK_WS_MASK
) >> 4;
345 payload_offset
= mask_offset
+ (mask
? 4 : 0);
347 if (payload_offset
+ payload_length
< payload_length
) {
348 /* Integer overflow, which means the packet contains a ridiculous
349 * payload length. Just take what we've got available.
350 * See bug https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8448 */
351 payload_length
= tvb_reported_length_remaining(tvb
, payload_offset
);
354 if(length
< payload_offset
+ payload_length
){
355 /* XXXX Warning desegment_len is 32 bits */
356 pinfo
->desegment_len
= payload_offset
+ payload_length
- length
;
360 /* We've got the entire message! */
362 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "WebSocket");
363 col_set_str(pinfo
->cinfo
, COL_INFO
, "WebSocket");
366 ti
= proto_tree_add_item(tree
, proto_websocket
, tvb
, 0, payload_offset
, ENC_NA
);
367 ws_tree
= proto_item_add_subtree(ti
, ett_ws
);
371 proto_tree_add_item(ws_tree
, hf_ws_fin
, tvb
, 0, 1, ENC_NA
);
372 fin
= (tvb_get_guint8(tvb
, 0) & MASK_WS_FIN
) >> 4;
373 proto_tree_add_item(ws_tree
, hf_ws_reserved
, tvb
, 0, 1, ENC_NA
);
376 proto_tree_add_item(ws_tree
, hf_ws_opcode
, tvb
, 0, 1, ENC_NA
);
377 opcode
= tvb_get_guint8(tvb
, 0) & MASK_WS_OPCODE
;
378 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " %s", val_to_str_const(opcode
, ws_opcode_vals
, "Unknown Opcode"));
379 col_append_str(pinfo
->cinfo
, COL_INFO
, fin
? " [FIN]" : " ");
381 /* Add Mask bit to the tree */
382 proto_tree_add_item(ws_tree
, hf_ws_mask
, tvb
, 1, 1, ENC_NA
);
383 col_append_str(pinfo
->cinfo
, COL_INFO
, mask
? " [MASKED]" : " ");
385 /* (Extended) Payload Length */
386 ti_len
= proto_tree_add_item(ws_tree
, hf_ws_payload_length
, tvb
, 1, 1, ENC_NA
);
387 if(short_length
==126){
388 proto_item_append_text(ti_len
, " Extended Payload Length (16 bits)");
389 proto_tree_add_item(ws_tree
, hf_ws_payload_length_ext_16
, tvb
, 2, 2, ENC_BIG_ENDIAN
);
391 else if(short_length
==127){
392 proto_item_append_text(ti_len
, " Extended Payload Length (64 bits)");
393 proto_tree_add_item(ws_tree
, hf_ws_payload_length_ext_64
, tvb
, 2, 8, ENC_BIG_ENDIAN
);
398 proto_tree_add_item(ws_tree
, hf_ws_masking_key
, tvb
, mask_offset
, 4, ENC_NA
);
399 masking_key
= tvb_get_ptr(tvb
, mask_offset
, 4);
402 tvb_payload
= tvb_new_subset_remaining(tvb
, payload_offset
);
403 dissect_websocket_payload(tvb_payload
, pinfo
, tree
, ws_tree
, opcode
, payload_length
, mask
, masking_key
);
405 /* Call this function recursively, to see if we have enough data to parse another websocket message */
407 recurse_offset
= payload_offset
+ payload_length
;
408 if(length
> recurse_offset
){
409 recurse_length
= dissect_websocket(tvb_new_subset_remaining(tvb
, payload_offset
+payload_length
), pinfo
, tree
, data
);
410 if(pinfo
->desegment_len
) pinfo
->desegment_offset
+= recurse_offset
;
411 return recurse_offset
+ recurse_length
;
413 return recurse_offset
;
418 proto_register_websocket(void)
421 static hf_register_info hf
[] = {
423 { "Fin", "websocket.fin",
424 FT_BOOLEAN
, 8, NULL
, MASK_WS_FIN
,
425 "Indicates that this is the final fragment in a message", HFILL
}
428 { "Reserved", "websocket.rsv",
429 FT_UINT8
, BASE_HEX
, NULL
, MASK_WS_RSV
,
430 "Must be zero", HFILL
}
433 { "Opcode", "websocket.opcode",
434 FT_UINT8
, BASE_DEC
, VALS(ws_opcode_vals
), MASK_WS_OPCODE
,
435 "Defines the interpretation of the Payload data", HFILL
}
438 { "Mask", "websocket.mask",
439 FT_BOOLEAN
, 8, NULL
, MASK_WS_MASK
,
440 "Defines whether the Payload data is masked", HFILL
}
442 { &hf_ws_payload_length
,
443 { "Payload length", "websocket.payload_length",
444 FT_UINT8
, BASE_DEC
, NULL
, MASK_WS_PAYLOAD_LEN
,
445 "The length of the Payload data", HFILL
}
447 { &hf_ws_payload_length_ext_16
,
448 { "Extended Payload length (16 bits)", "websocket.payload_length_ext_16",
449 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
450 "The length (16 bits) of the Payload data", HFILL
}
452 { &hf_ws_payload_length_ext_64
,
453 { "Extended Payload length (64 bits)", "websocket.payload_length_ext_64",
454 FT_UINT64
, BASE_DEC
, NULL
, 0x0,
455 "The length (64 bits) of the Payload data", HFILL
}
457 { &hf_ws_masking_key
,
458 { "Masking-Key", "websocket.masking_key",
459 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
460 "All frames sent from the client to the server are masked by a 32-bit value that is contained within the frame", HFILL
}
463 { "Payload", "websocket.payload",
464 FT_NONE
, BASE_NONE
, NULL
, 0x0,
467 { &hf_ws_payload_unmask
,
468 { "Unmask Payload", "websocket.payload.unmask",
469 FT_NONE
, BASE_NONE
, NULL
, 0x0,
472 { &hf_ws_payload_continue
,
473 { "Continue", "websocket.payload.continue",
474 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
477 { &hf_ws_payload_text
,
478 { "Text", "websocket.payload.text",
479 FT_STRING
, BASE_NONE
, NULL
, 0x0,
482 { &hf_ws_payload_text_mask
,
483 { "Text", "websocket.payload.text_mask",
484 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
487 { &hf_ws_payload_text_unmask
,
488 { "Text unmask", "websocket.payload.text_unmask",
489 FT_STRING
, BASE_NONE
, NULL
, 0x0,
492 { &hf_ws_payload_binary
,
493 { "Binary", "websocket.payload.binary",
494 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
497 { &hf_ws_payload_binary_mask
,
498 { "Binary", "websocket.payload.binary_mask",
499 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
502 { &hf_ws_payload_binary_unmask
,
503 { "Binary", "websocket.payload.binary_unmask",
504 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
507 { &hf_ws_payload_close
,
508 { "Close", "websocket.payload.close",
509 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
512 { &hf_ws_payload_close_mask
,
513 { "Close", "websocket.payload.close_mask",
514 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
517 { &hf_ws_payload_close_unmask
,
518 { "Unmask Close", "websocket.payload.close_unmask",
519 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
522 { &hf_ws_payload_close_status_code
,
523 { "Close", "websocket.payload.close.status_code",
524 FT_UINT16
, BASE_DEC
, VALS(ws_close_status_code_vals
), 0x0,
527 { &hf_ws_payload_close_reason
,
528 { "Reason", "websocket.payload.close.reason",
529 FT_STRING
, BASE_NONE
, NULL
, 0x0,
532 { &hf_ws_payload_ping
,
533 { "Ping", "websocket.payload.ping",
534 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
537 { &hf_ws_payload_ping_mask
,
538 { "Ping", "websocket.payload.ping_mask",
539 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
542 { &hf_ws_payload_ping_unmask
,
543 { "Ping", "websocket.payload.ping_unmask",
544 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
547 { &hf_ws_payload_pong
,
548 { "Pong", "websocket.payload.pong",
549 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
552 { &hf_ws_payload_pong_mask
,
553 { "Pong", "websocket.payload.pong_mask",
554 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
557 { &hf_ws_payload_pong_unmask
,
558 { "Pong", "websocket.payload.pong_unmask",
559 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
562 { &hf_ws_payload_unknown
,
563 { "Unknown", "websocket.payload.unknown",
564 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
570 static gint
*ett
[] = {
576 static ei_register_info ei
[] = {
577 { &ei_ws_payload_unknown
, { "websocket.payload.unknown.expert", PI_UNDECODED
, PI_NOTE
, "Dissector for Websocket Opcode", EXPFILL
}},
580 static const enum_val_t text_types
[] = {
581 {"None", "No subdissection", WEBSOCKET_NONE
},
582 {"Line based text", "Line based text", WEBSOCKET_TEXT
},
583 {"As JSON", "As json", WEBSOCKET_JSON
},
587 module_t
*websocket_module
;
588 expert_module_t
* expert_websocket
;
590 proto_websocket
= proto_register_protocol("WebSocket",
591 "WebSocket", "websocket");
594 * Heuristic dissectors SHOULD register themselves in
595 * this table using the standard heur_dissector_add()
598 register_heur_dissector_list("ws", &heur_subdissector_list
);
600 port_subdissector_table
= register_dissector_table("ws.port",
601 "TCP port for protocols using WebSocket", FT_UINT16
, BASE_DEC
);
603 proto_register_field_array(proto_websocket
, hf
, array_length(hf
));
604 proto_register_subtree_array(ett
, array_length(ett
));
605 expert_websocket
= expert_register_protocol(proto_websocket
);
606 expert_register_field_array(expert_websocket
, ei
, array_length(ei
));
608 new_register_dissector("websocket", dissect_websocket
, proto_websocket
);
610 websocket_module
= prefs_register_protocol(proto_websocket
, proto_reg_handoff_websocket
);
612 prefs_register_enum_preference(websocket_module
, "text_type",
613 "Dissect websocket text as",
614 "Select dissector for websocket text",
615 &pref_text_type
, text_types
, WEBSOCKET_NONE
);
621 proto_reg_handoff_websocket(void)
623 text_lines_handle
= find_dissector("data-text-lines");
624 json_handle
= find_dissector("json");
627 * Editor modelines - http://www.wireshark.org/tools/modelines.html
632 * indent-tabs-mode: nil
635 * vi: set shiftwidth=2 tabstop=8 expandtab:
636 * :indentSize=2:tabSize=8:noTabs=true: