aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-websocket.c
AgeCommit message (Collapse)AuthorFilesLines
2017-09-23WebSocket: remove useless pointer checks (CID 1418346)Pascal Quantin1-2/+2
websocket_conv is always allocated Change-Id: Ic119e22ee37703ccea2a42e53d6616faa0901cf9 Reviewed-on: https://code.wireshark.org/review/23662 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2017-09-19WebSocket: check websocket_extensions pointer validityPascal Quantin1-1/+3
Bug: 14075 Change-Id: I825a30e5b8bfa57a020ae208a3a6ee67ee1a58d3 Reviewed-on: https://code.wireshark.org/review/23622 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2017-09-19WebSocket: add permessage-deflate extension supportPascal Quantin1-19/+273
Bug: 14054 Change-Id: Ib6fbb58cab4d9eb140c0911391a9c330a036cfd1 Reviewed-on: https://code.wireshark.org/review/23515 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-01-10Rename tvb_new_subset() to tvb_new_subset_length_caplen().Guy Harris1-2/+2
This emphasizes that there is no such thing as *the* routine to construct a subset tvbuff; you need to choose one of tvb_new_subset_remaining() (if you want a new tvbuff that contains everything past a certain point in an existing tvbuff), tvb_new_subset_length() (if you want a subset that contains everything past a certain point, for some number of bytes, in an existing tvbuff), and tvb_new_subset_length_caplen() (for all other cases). Many of the calls to tvb_new_subset_length_caplen() should really be calling one of the other routines; that's the next step. (This also makes it easier to find the calls that need fixing.) Change-Id: Ieb3d676d8cda535451c119487d7cd3b559221f2b Reviewed-on: https://code.wireshark.org/review/19597 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-08-31Don't do any Decode As stuff for dissector tables not used with Decode As.Guy Harris1-2/+2
Have all dissector tables have a "supports Decode As" flag, which defaults to FALSE, and which is set to TRUE if a register_decode_as() refers to it. When adding a dissector to a dissector table with a given key, only add it for Decode As if the dissector table supports it. For non-FT_STRING dissector tables, always check for multiple entries for the same protocol with different dissectors, and report an error if we found them. This means there's no need for the creator of a dissector table to specify whether duplicates of that sort should be allowed - we always do the check when registering something for "Decode As" (in a non-FT_STRING dissector table), and just don't bother registering anything for "Decode As" if the dissector table doesn't support "Decode As", so there's no check done for those dissector tables. Change-Id: I4a1fdea3bddc2af27a65cfbca23edc99b26c0eed Reviewed-on: https://code.wireshark.org/review/17402 Petri-Dish: Guy Harris <guy@alum.mit.edu> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-03-27Add dissector table for negotiated WebSocket protocolGregor Jasny1-2/+11
This adds the possibility to filter on the negotiated WebSocket protocol from the upgrade response as well as on a specific TCP port Bug: 12298 Change-Id: I8e0b785cec0b8c71ec558b74ac07c81194268b38 Signed-off-by: Gregor Jasny <gjasny@googlemail.com> Reviewed-on: https://code.wireshark.org/review/14645 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-03-20Create call_data_dissector() to call data dissector.Michael Mann1-3/+1
This saves many dissectors the need to find the data dissector and store a handle to it. There were also some that were finding it, but not using it. For others this was the only reason for their handoff function, so it could be eliminated. Change-Id: I5d3f951ee1daa3d30c060d21bd12bbc881a8027b Reviewed-on: https://code.wireshark.org/review/14530 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-03-20Manually add protocol dependencies derived from find_dissector.Michael Mann1-3/+3
Started by grepping call_dissector_with_data, call_dissector_only and call_dissector and traced the handles passed into them to a find_dissector within the dissector. Then replaced find_dissector with find_dissector_add_dependency and added the protocol id from the dissector. "data" dissector was not considered to be a dependency. Change-Id: I15d0d77301306587ef8e7af5876e74231816890d Reviewed-on: https://code.wireshark.org/review/14509 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-03-17Associate dissector tables and heuristic subdissector lists with a protocol.Michael Mann1-2/+2
This will make it easier to determine protocol dependencies. Some LLC OUI dissector tables didn't have an associated protocol, so they were left without one (-1 used) Change-Id: I6339f16476510ef3f393d6fb5d8946419bfb4b7d Reviewed-on: https://code.wireshark.org/review/14446 Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-01-24Add the packet number to the packet_info structure, and use it.Guy Harris1-1/+1
That removes most of the uses of the frame number field in the frame_data structure. Change-Id: Ie22e4533e87f8360d7c0a61ca6ffb796cc233f22 Reviewed-on: https://code.wireshark.org/review/13509 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-09new_register_dissector -> register_dissector for dissector directory.Michael Mann1-1/+1
Change-Id: Ie39ef054a4a942687bd079f3a4d8c2cc55d5f22c Reviewed-on: https://code.wireshark.org/review/12485 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-11-04Don't allow multiple registrations of a protocol in dissector tables.Michael Mann1-1/+1
The target here is the Decode As dialog where protocols have multiple registrations into a dissector table and that shows up as multiple entries in the Decode As dialog list with the same name so users are unsure which "dissector" they are choosing. The "default" behavior (done in this commit) is to not allow duplicates for a dissector table, whether its part of Decode As or not. It's just ENFORCED for Decode As. Bug: 3949 Change-Id: Ibe14fa61aaeca0881f9cc39b78799e314b5e8127 Reviewed-on: https://code.wireshark.org/review/11405 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-06-01Websocket: Fix Dead Store (Dead assignement/Dead increment) warning found by ↵Alexis La Goutte1-1/+1
Clang Change-Id: Ica45c5d316d04df977449a12f824c76642d6c4bd Reviewed-on: https://code.wireshark.org/review/8722 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-05-31websocket: restructure tree, always unmask payloadPeter Wu1-205/+124
Changes: - Instead of special-casing masked and unmasked payload data, always unmask the payload before using it. This fixes handling of SIP requests which are masked and would previously not be dissected by the SIP handle. (As a result, many fields are removed). - Dissected text protocols (for example SIP) are now shown below the Websocket layer instead of inside the payload tree. - Use line-based text dissector as fallback for text decoding, and use data dissector for binary decoding. - Treat the optional close reason as UTF-8 instead of ASCII. - Group the close fields (status code, reason) in a subtree below close to avoid confusion. Make Close FT_NONE to avoid displaying hex. - Split dissection of the payload in separate functions for control and data frames. Change-Id: I78b0078d51271bef94229d4b7c6c528b5e3a424d Reviewed-on: https://code.wireshark.org/review/7294 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2015-02-24websocket: avoid recursion, use tcp_dissect_pdusPeter Wu1-50/+52
Use tcp_dissect_pdus to handle reassembly and avoid a recursion in dissect_websocket. The HTTP dissector is modified to preserve desegmentation functionality (tested with the capture from bug 8448). As tcp_dissect_pdus is used now, the workaround for bug 8448 can be removed and the actual frame dissection logic becomes simpler (the length is checked in get_websocket_frame_length). Bug: 10989 Change-Id: I67af96a6c7be88c2a77e1c4138abe90bdb880774 Reviewed-on: https://code.wireshark.org/review/7285 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-01-08use the http server port as index for the ws.port dissector tableMartin Kaiser1-5/+19
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>
2014-12-30Websocket: use pinfo pool and not packet one for the unmasked data tvbPascal Quantin1-3/+3
As indicated in README.wmem, pinfo pool must be used for anything that might end up being passed to add_new_data_source Change-Id: I4a6396fc52e6c70c771390f502d58199c38c172a Reviewed-on: https://code.wireshark.org/review/6144 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-12-30clean up the part where dissect_websocket() is called recursivelyMartin Kaiser1-2/+5
Change-Id: Ia94ddb2c4cb03fe5d1af9f8d316e1cdb18fe8283 Reviewed-on: https://code.wireshark.org/review/6143 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx> Tested-by: Martin Kaiser <wireshark@kaiser.cx>
2014-12-30use packet-scoped memory for the unmasked data tvbMartin Kaiser1-5/+2
Change-Id: I5f9b769e26c16072a1656dfe9094487d6dfe76f4 Reviewed-on: https://code.wireshark.org/review/6142 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx> Tested-by: Martin Kaiser <wireshark@kaiser.cx>
2014-12-30skip the payload if it's emptyMartin Kaiser1-2/+4
Change-Id: Ib38e747bc762422c690abc1cb127bb0944c80ce2 Reviewed-on: https://code.wireshark.org/review/6141 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx> Tested-by: Martin Kaiser <wireshark@kaiser.cx>
2014-12-30no need for if(tree)Martin Kaiser1-5/+3
Change-Id: I0b20b66e1b44da0362c13009946a69738a2aa267 Reviewed-on: https://code.wireshark.org/review/6138 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx> Tested-by: Martin Kaiser <wireshark@kaiser.cx>
2014-12-21Cleanup use of #includes in non-generated epan/dissector/*.cBill Meier1-2/+0
Specifically: - Set packet.h to be the first wireshark #include after config.h and "system" #includes. packet.h added as an #include in some cases when missing. - Remove some #includes included (directly/indirectly) in packet.h. E.g., glib.h. (Done only for those files including packet.h). - As needed, move "system" #includes to be after config.h and before wireshark #includes. - Rework various #include file specifications for consistency. - Misc. Change-Id: Ifaa1a14b50b69fbad38ea4838a49dfe595c54c95 Reviewed-on: https://code.wireshark.org/review/5923 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-12-21Have a heur_dissector_list_t be an opaque handle.Guy Harris1-1/+1
This allows dissector lists to be looked up by name, so they can be shared by multiple dissectors. (This means that there's no "udplite" heuristic dissector list, but there shouldn't be one - protocols can run atop UDP or UDPLite equally well, and they share a port namespace and uint dissector table, so they should share a heuristic dissector table as well.) Change-Id: Ifb2d2c294938c06d348a159adea7a57db8d770a7 Reviewed-on: https://code.wireshark.org/review/5936 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-13Use ENC_BIG_ENDIAN when fetching FT_U?INT8 fields ...Bill Meier1-3/+3
(for some dissectors which fetch all other integral fields using ENC_BIG_ENDIAN). Change-Id: Ic18e3172aad76af12b12d6732c88497be22aed56 Reviewed-on: https://code.wireshark.org/review/5748 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-11-26Remove the use of pinfo->private_data from dissectors that just save it to ↵Michael Mann1-3/+0
restore it. Change-Id: I13197cc48068bb35ee12a7023cfe5f76bbc4e264 Reviewed-on: https://code.wireshark.org/review/5486 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-07-18WebSocket: increase max unmask payload size to 256K and indicate that packet ↵Pascal Quantin1-3/+6
is truncated is going above the new limit Bug: 10283 Change-Id: Iea5401d02bcf50a3427dce5f2b817c3b73a7dc11 Reviewed-on: https://code.wireshark.org/review/3098 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Evan Huus <eapache@gmail.com>
2014-06-19Revert "Fixup: tvb_* -> tvb_captured"Michael Mann1-2/+2
https://www.wireshark.org/lists/wireshark-dev/201406/msg00131.html This reverts commit 246fe2ca4c67d8c98caa84e2f57694f6322e2f96. Change-Id: Ib24bae0198c13a84bd7f731bf4af921212109a8f Reviewed-on: https://code.wireshark.org/review/2430 Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-06-18Fixup: tvb_* -> tvb_capturedDario Lombardo1-2/+2
Change-Id: I9209c1271967405c34c1b6fa43e1726a4d3a5a3f Reviewed-on: https://code.wireshark.org/review/2377 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-05-21Change the signature of dissector_try_heuristic() to return hdtbl_entryAndersBroman1-1/+2
which can be used to call the found heuristic dissector on the next pass. Introduce call_heur_dissector_direct() to be used to call a heuristic dissector which accepted the frame on the first pass. Change-Id: I524edd717b7d92b510bd60acfeea686d5f2b4582 Reviewed-on: https://code.wireshark.org/review/1697 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04Remove all $Id$ from top of fileAlexis La Goutte1-2/+0
(Using sed : sed -i '/^ \* \$Id\$/,+1 d') Fix manually some typo (in export_object_dicom.c and crc16-plain.c) Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8 Reviewed-on: https://code.wireshark.org/review/497 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-02-12Add support of SIP subprotocol for WebSocketAlexis La Goutte1-0/+7
RFC 7118: The WebSocket Protocol as a Transport for the Session Initiation Protocol (SIP) No yet support of auto-detect subprotocol (via Sec-WebSocket-Protocol) Change-Id: I16e8ddd37002b3982673bd4a4a7b15f6200a4d85 Reviewed-on: https://code.wireshark.org/review/192 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Evan Huus <eapache@gmail.com>
2013-12-12In one or more of the files:Bill Meier1-50/+50
- Create/use some extended value-strings; - Remove some unneeded initializers; - 'offset++' --> 'offset += 1' for consistency; - Set editor modelines 'tab-width' to 8 (not 4); - tabs --> spaces (to match editor modelines); - Rework/add whitespace. svn path=/trunk/; revision=53998
2013-12-11- Make local functions static.Anders Broman1-1/+2
- Forward declaration of register functions. svn path=/trunk/; revision=53941
2013-10-29From didier gautheron: remove redundant or use faster col_xxx functionsBill Meier1-2/+2
- when the text parameter is constant col_add_str() and col_set_str() are equivalent but col_set_str() is faster. - same for replace col_append_fstr and col_append_str - remove col_clear() when it's redundant: + before a col_set/col_add if the dissector can't throw an exception. - replace col_append() after a col_clear() with faster col_add... or col_set https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9344 svn path=/trunk/; revision=52948
2013-10-13whitespace fixes; mostly: remove trailing blanksBill Meier1-1/+1
svn path=/trunk/; revision=52591
2013-09-09expert_add_info_format_text -> expert_add_info_formatMichael Mann1-1/+1
svn path=/trunk/; revision=51852
2013-08-05Make some global variables staticJakub Zawadzki1-2/+2
svn path=/trunk/; revision=51163
2013-05-28Batch of filterable expert infos. This (mostly) completes the non-ASN.1 ↵Michael Mann1-1/+10
list of (built-in) dissectors that only had a small handful of add_expert_info_format calls. svn path=/trunk/; revision=49602
2013-03-16Check for overflow in the websocket dissector payload.Evan Huus1-0/+7
Fixes https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8448 svn path=/trunk/; revision=48336
2013-03-12Introduce a preference to select how Websocket text should be dissected.Anders Broman1-3/+57
svn path=/trunk/; revision=48264
2013-03-04Use explicit casts.Anders Broman1-1/+1
svn path=/trunk/; revision=48048
2013-02-17From Alyssa Milburn via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8341Evan Huus1-11/+11
With small additional changes by me Make many of the length and offset fields in the websocket dissector unsigned. This fixes a case where we could attempt to malloc (unsigned)-1 bytes of memory. Also fix one small copy-paste string typo. svn path=/trunk/; revision=47700
2012-11-03Make it compil by adding a cast, not sure if payload_length = ↵Anders Broman1-2/+4
(int)tvb_get_ntoh64(tvb, 2); can overflow svn path=/trunk/; revision=45878
2012-11-02Try to fix Windows XP/7 buildbotAlexis La Goutte1-1/+1
svn path=/trunk/; revision=45876
2012-11-02From vanviegen via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7934 ↵Alexis La Goutte1-96/+146
WebSocket dissector improvements - Now works for WebSocket packets not aligned with IP packets. - Support subdissectors. From me : - Fix checkAPIs warning (about comments) - Remove some whitespace svn path=/trunk/; revision=45875
2012-09-20We always HAVE_CONFIG_H so don't bother checking whether we have it or not.Jeff Morriss1-3/+1
svn path=/trunk/; revision=45017
2012-09-10Initial commit to support yet another method of passing data between dissectors.Jakub Zawadzki1-1/+1
Add new parameter 'data' to heur_dissector_t and new_dissector_t, for now it's always NULL svn path=/trunk/; revision=44860
2012-07-24(Trivial) remove unneeded #include.Bill Meier1-1/+0
svn path=/trunk/; revision=43962
2012-05-04Websocket masked tvb was never freed, set it as child of original tvb.Jakub Zawadzki1-1/+2
Also change data memory allocator from ep_ to glib one. svn path=/trunk/; revision=42426
2012-04-20Add an arbitrary (64K) size limit for the unmasked TVBs that weGerald Combs1-22/+24
create. Fix a bunch of signedness mismatches. TVB variable names usually end in "_tvb"; do the same here. Fixup whitespace. svn path=/trunk/; revision=42169