Commit Graph

146 Commits

Author SHA1 Message Date
João Valverde eda38f5f2d Replace g_utf8_make_valid() with own function
The function ws_utf8_make_valid() is all-around better and
also does maximal substitution of subparts.
2023-02-08 11:21:19 +00:00
Ryan Doyle 48fa729a9c HTTP2: Track the frame the request/response is contained in
Similar to the HTTP dissector, link between the frames that contain the request
and response.
2023-01-26 19:37:34 +00:00
Kevin Grigorenko 43c5eedc97 Handle NULL http2_session_t parsing an H2 settings frame 2023-01-19 17:35:48 +00:00
Kevin Grigorenko b301dee0e1 Add HTTP2 connection and session window sizes 2023-01-18 07:04:53 +00:00
Martin Mathieson 30ef9d38cd Make a couple of functions static 2023-01-16 18:17:59 +00:00
Kevin Albertson e8cd0d1457 http2: fix leak of composite 2023-01-09 08:04:08 +00:00
John Thacker 0e93070745 follow: Add function for sub stream id to registration
When dissectors register for Follow Stream, have them register a
function for finding the next valid sub stream id for a given
stream and substream id pair. This function is NULL if the dissector
does not use sub stream IDs.

Use this function in follow_stream_dialog to update the sub stream
id widget (and use the absence of the function to disable and hide
the widget.) Use this function in the CLI tap-follow to determine
whether to parse a sub stream id from the command line options.

This removes the dependencies on epan/dissectors from the Qt
follow_stream_dialog, and gets us closer to having dissectors
being able to register for Follow Stream without having to update
anything in the common source code.
2023-01-05 05:04:33 +00:00
John Thacker 10c84b6450 HTTP2: Load dynamic hf entries when UAT is changed
The dynamic hf entries for HTTP2 read from the UAT should be
changed when the UAT is changed or reset, not on each file
load and file close. If a field is added as a column, coloring
rule, or filter, and the capture file is changed, deregistering
the field and reregistering it can cause a crash.

Use the same approach as with HTTP and SIP, slightly modified
because in HTTP2 the header fields hash contains the static
headers as well, to prevent adding duplicate entries via the UAT.

Fix #14768
2022-11-30 11:04:05 +00:00
John Thacker 92208e4330 HTTP2: Ensure that the unescaped header value is valid encoding
It's possible, in the case of errors, for the result of
g_uri_unescape_string not to be valid UTF-8, either if originally
some other encoding was percent-encoded, or if there were errors.
Check for it.

Fix #18658.
2022-11-20 11:44:39 +00:00
John Thacker dcbd3874d3 tls: add support for DESEGMENT_UNTIL_FIN, sequence numbers
Add a tlsinfo struct that is similar to tcpinfo, and carries
the sequence number (within the TLS stream) and the end of
stream notification (from the TCP FIN or close_notify alerts)
in addition to the session app handle pointer already used
by TLS heuristic dissectors.

Have HTTP use the end of stream notification in order to
handle DESEGMENT_UNTIL_FIN the same way it does when HTTP
is directly over TCP. Also have HTTP use the sequence number
in order to reduce chunked processing from O(N^2) to O(N)
similar to done over TCP.

Update all the TLS heuristic dissectors that set the app
handle to use the new structure.

Note the workaround for the issue #15159 - the TLS dissector
has to report to the TCP dissector that desegmentation at FIN
is required, so that the TCP dissector will know to call the
TLS dissector at FIN. However, the TLS dissector does not request
that the TCP dissector resend bytes belonging to records that
TLS has already desegmented (and decrypted, if possible), to
avoid decrypting twice (and upsetting the decoder state.)

This can mean the TCP dissector calling the TLS dissector to
desegment at FIN with a zero byte payload. In such as case, the
TLS dissector artificially returns "1" byte dissected to avoid
indicating rejecting the payload and having the TLS (and subdissector)
layers removed. (TCP ignores the value returned when desegmenting
at FIN.)

Fix #9154. Fix #14382.
2022-11-01 10:03:35 +00:00
John Thacker 2762c64010 follow: Have followers register their stream count function
Instead of having the UI have to know about each type of follow
stream, and how to retrieve its total number of streams, have
each follow type register a function that returns the total
number of stream. (The function can be NULL, for protocols like
SIP that do not use this.)

This gets us closer to making follow stream registration generic.
2022-09-14 00:03:07 +00:00
Guy Harris 8195bdd340 Rename a bunch of things with "conversation".
A conversation in Wireshark might have two endpoints or might have no
endpoints; few if any have one endpoint.  Distinguish between
conversations and endpoints.
2022-08-25 20:02:20 -07:00
John Thacker 862803de5c HTTP2: Send headers to the follow tap after decompression
Field blocks (carried in HEADERS, PUSH_PROMISE, and CONTINUATION
frames) are compressed by HPACK. Send them to the follow tap only
after decompression. Update the tests to match the new output.

Ping #18239 (There's still the case of gzip and brotli compressed
DATA frames to handle).
2022-08-08 23:50:20 +00:00
John Thacker 66b26d7251 follow: Only retrieve matching conversations
The TCP and UDP follow conversation filter functions should
only retrieve a conversation and conversation data, not
create new conversations or new stream numbers. (That should
only happen during actual packet processing.) So they should
match on the endpoint type and not look up endpoints (since
TCP and UDP don't use the endpoint API.)

They still don't work with tunneling, or any other situation where
the addresses and ports have been changed (see #18231), but this
at least works when some other protocol _has_ used the endpoint
API, and also avoids creating nonsensical streams.

Making them work properly with tunneling either requires adding
packet info to each packet with the stream information, or using
the endpoint API (after finishing it to allow more than one endpoint
on the packet, and a way of searching for endpoints other than
the most recent.)
2022-08-02 20:54:36 +00:00
Nardi Ivan 897bc6d27c HTTP2: display the full request URI
Close #18135
2022-07-20 16:32:47 +00:00
Anders Broman fed641fc27 http: Add path components to tree 2022-07-04 17:45:08 +00:00
Roland Knall 2cf938cfa8 tap: Adding flags for tap_packet
This allows flags to be passed by the registering listener
to the collection of information
2022-06-10 05:46:15 +00:00
John Thacker 91987dc0ab nghttp2: Implement minimum required version 1.11.0
All currently supported Linux distributions have a version greater
than 1.11.0 (and our macOS and Windows versions are also much greater),
and this allows us to use nghttp2_hd_inflate_hd2(), which replaced the
deprecated nghttp2_hd_inflate_hd()
2022-04-24 10:24:11 -04:00
John Thacker 856cd96bb3 http2: Use the actual maximum table size for partial header workaround
Use the actual maximum table table size, which may have been set to
a value other than the default 4096, to fill the table with dummy
entries. Fix #17936
2022-04-01 12:10:48 +00:00
John Thacker f43ce70fd9 HTTP2: Don't add a proto item before seeing if we'll dissect anything
Behave like other protcols that call tcp_dissect_pdus and don't set
COL_PROTOCOL or add a proto item before the call to tcp_dissect_pdus.

This avoids adding an empty tree in cases where there isn't enough
of the PDU to actually dissect anything. This makes the protocol
tree the same in the first pass (and thus tshark output), as in later
passes where the HTTP2 dissector won't get called.
2022-03-04 14:26:15 +00:00
João Valverde 8efad466c4 Tools: Fix fix-encoding-args.pl ASCII string validation
Do not require a useless ENC_NA parameter for string encodings.
FT_STRING and FT_STRINGZ types don't have any ndianness.

Follow-up to 6ec429622c.
2022-02-15 11:38:16 +00:00
Lucas Pardue a65abbc2bb http2: add PRIORITY_UPDATE frame dissection
The HTTP/2 priority update frame is an extension frame defined in
https://datatracker.ietf.org/doc/draft-ietf-httpbis-priority/.

With this change, we add new support for the frame to the HTTP/2
dissection, matching the capability in the HTTP/3 dissector, to expose
the target of the priority and the value of the hint.
2022-01-16 22:13:49 +00:00
Lucas Pardue fd72d99d7f http2: detect extended CONNECT setting 2022-01-16 09:47:59 +00:00
Lucas Pardue 9c318abef4 http2: add support for ORIGIN frame
Add support for ORIGIN frame (RFC 8336) to the HTTP/2 dissector. The
frame is a sequence of 0 or more origin entries (length and ASCII
value), hence dissection is implemented as a subtree.
2022-01-16 09:34:21 +00:00
Huang Qiangxiong 9a681f88ad http2/grpc: make fake headers be used in uncompleted HPACK index table situation
Some http2 headers are unable to be parse in current
HEADERS frame because previous HEADERS frames were not
captured that causing HPACK index table not completed.
This commit make fake headers can also be used in this
situation.

close #17799
2022-01-09 14:35:27 +00:00
João Valverde 0ccd69e530 Replace g_strdup_printf() with ws_strdup_printf()
Use macros from inttypes.h.
2021-12-19 21:21:58 +00:00
João Valverde 22ee2764a7 Replace g_snprintf() with snprintf() (dissectors)
Use macros from inttypes.h with format strings.
2021-12-19 20:25:11 +00:00
João Valverde 19dcb725b6 epan: Remove STR_ASCII and STR_UNICODE
These display bases work to replace unprintable characters so the
name is a misnomer. In addition they are the same option and this
display behaviour is not something that is configurable.

This does not affect encodings because all our internal text strings
need to be valid UTF-8 and the source encoding is specified using
ENC_*.

Remove the assertion for valid UTF-8 in proto.c because
tvb_get_*_string() must return a valid UTF-8 string, always, and we
don't need to assert that, it is expensive.
2021-12-03 04:35:56 +00:00
Huang Qiangxiong f029fa6b71 http2: fix building error caused by fake header feature without nghttp2
Fix a building error caused by fake header feature of
MR 4877 when building without nghttp2 library.
2021-11-28 11:29:48 +08:00
Huang Qiangxiong 2af95cbe1b HTTP2/GRPC: support using fake headers if first HEADERS frame is missing
Add an UAT for configuring fake headers according to the server port, stream
id and direction of the long-lived stream that we start capturing packets
after it is established. That helps to parsing the DATAs captured subsequently.
A testcase also added.

close #17691
2021-11-26 17:34:23 +00:00
Huang Qiangxiong ec36885eda http2: fix the stream mode reassembly issue
- Point all MSP related DATA frames to their MSP instead of
  using wmem_tree_lookup32_array_le().
- Add test_grpc_streaming_mode_reassembly testcase for verifying
  this feature.

close #17633
2021-10-20 17:25:17 +00:00
Nardi Ivan 3cb302f05b HTTP2, QUIC: fix "Follow Stream"
"Follow Stream" functionality assumes that all data in a single packet
belongs to the same stream. That is not true for HTTP2 and QUIC, where
we end up having data from unrelated streams.

Filter out the unwanted data directly in the protocol dissector code with
a custom `tap_handler` (as TCP already does).

Close #16093
2021-09-13 15:13:10 +00:00
Evan Huus 8ee8808876 First pass pinfo->pool conversion, part 2
Automated find/replace of wmem_packet_scope() with pinfo->pool in all
files where it didn't cause a build failure.
2021-07-21 09:54:57 -04:00
João Valverde 051a74378d wslog: Use NULL for empty/default domain 2021-06-18 10:43:39 +01:00
João Valverde dcc02b1003 dissectors: Replace g_log() with ws_log() 2021-06-16 12:50:28 +00:00
Anders Broman 71e6b0498a http: Add dissection of HTTP2-Settings
Closes #17370
2021-05-08 17:14:45 +00:00
Anders Broman 607aeb5416 HTTP2: Make it possible to configure a port range. 2021-05-06 13:33:55 +00:00
Wolfgang Steinwender ff9a89c8a2 http2: Rename GOAWAY Promised-Stream-ID to Last-Stream-ID
According to the RFC, the stream ID in a GOAWAY frame is called Last-Stream-ID.
2021-04-26 21:36:45 +00:00
Jirka Novak e75e1fb580 Follow SIP Call: Added Follow SIP Call to Follow menu
Changes:
- epan/follow.c: follow_conv_filter_func has new parameter
  epan_dissect_t *edt, so filter can be generated based on decoded tree
of packet below the cursor
- menu Follow/SIP Call is enabled when sip packet is selected
- value of sip.Call-ID is used as filter for SIP call
- for sharkd it generates filter just 'sip.Call-ID' with no value
2021-03-27 09:02:14 +00:00
Alexis La Goutte 64b7bb05d4 http2: fix no previous prototype for functio
packet-http2.c:285:6: warning: no previous prototype for ‘decode_as_http2_populate_list’ [-Wmissing-prototypes]

Change-Id: Ife66469b7016437c1e2b6d41df99571e73159851
Reviewed-on: https://code.wireshark.org/review/37741
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-07-06 14:50:54 +00:00
Guy Harris e1d9a226a2 Fix the type of arrays of pointers to hf_ values for bitfield routines.
The static arrays are supposed to be arrays of const pointers to int,
not arrays of non-const pointers to const int.

Fixing that means some bugs (scribbling on what's *supposed* to be a
const array) will be caught (see packet-ieee80211-radiotap.c for
examples, the first of which inspired this change and the second of
which was discovered while testing compiles with this change), and
removes the need for some annoying casts.

Also make some of those arrays static while we're at it.

Update documentation and dissector-generator tools.

Change-Id: I789da5fc60aadc15797cefecfd9a9fbe9a130ccc
Reviewed-on: https://code.wireshark.org/review/37517
Petri-Dish: Guy Harris <gharris@sonic.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-06-19 11:32:26 +00:00
Martin Mathieson 060f876f97 HTTP2: check return code of a strcmp() call
From a recent cppcheck scan:
epan/dissectors/packet-http2.c:1604: warning: The expression 'strcmp(header_name,"<unknown>") != 0' is suspicious. It overlaps 'strcmp(header_name,":method") == 0'.
epan/dissectors/packet-http2.c:1604: warning: The expression 'strcmp(header_name,"<unknown>") != 0' is suspicious. It overlaps 'strcmp(header_name,":status") == 0'.

Change-Id: I373398112ca9e44d848da4a2b21bd7d059fa049c
Reviewed-on: https://code.wireshark.org/review/37352
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2020-06-01 17:56:28 +00:00
Peter Wu 43cfa9c1fa http2: fix build error with nghttp2 before 1.11
nghttp2_hd_inflate_hd has only been deprecated because its "in" argument
is non-const, aside from this aspect the implementation is equivalent.
For inflate_http2_header_block there is no difference since the buffer
is already non-const. However in fix_partial_header_dissection_support,
the given buffer is const. To avoid new -Wcast-qual warnings while
keeping the buffer read-only, just add a simple wrapper function.

This fixes a build failure reported for libnghttp2-devel
1.7.1-1.15.x86_64 on openSUSE Leap 42.3.

Change-Id: I9ab9305ffc5920f5e3f4866c2f0378d45008b57a
Reviewed-on: https://code.wireshark.org/review/37346
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-06-01 03:40:33 +00:00
Anders Broman e2f43f4cfa nghttp2: Assume we have a method header if we find <unknown>
In incomplete streams the http2 dissector fails to display the content of
a data packet following a header with unknown fields as
reassembly_info->data_initiated_in is not set.

Change-Id: I754bdc92049124bcc722a25f8cf791e36f8f523a
Reviewed-on: https://code.wireshark.org/review/37311
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-05-26 09:16:56 +00:00
Peter Wu 06f06eec3c http2: workaround to fix headers dissection for partial captures
Populate the dynamic table with dummy entries to ensure that nghttp2
will continue even if previous headers were missing (for example, due to
the capture starting in the middle of a plaintext h2c connection).

Bug: 16496
Change-Id: Ifb2fd4c6b8f3f93babed42e1f803048a695b23e9
Reviewed-on: https://code.wireshark.org/review/37278
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-05-25 17:55:10 +00:00
Anders Broman 2a64d97d8c http2: Replace deprecated function.
Change-Id: I98ef5756f970b95471500f9fd655b2e6294e8274
Reviewed-on: https://code.wireshark.org/review/36903
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-04-22 14:11:28 +00:00
Anders Broman c0069d9676 http2: Use proto_tree_add_bitmask_with_flags_ret_uint64() to dis flags.
Change-Id: Ie40568120c8a96e584dc7073fd0578574218f02b
Reviewed-on: https://code.wireshark.org/review/36891
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-04-20 11:45:01 +00:00
Anders Broman 5115fc50db http2: Introduce decode as for streams without content-type.
If the packet containing the content type header is missing the stream
can be dissected by using decode as.

Change-Id: I40c57e34971c9eee3d694975262dd7b3c7b3ef89
Reviewed-on: https://code.wireshark.org/review/36852
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-04-20 08:20:20 +00:00
Dario Lombardo c7316b4c78 http2: fix compilation without HAVE_HTTP2.
Change-Id: Ie141ee9905e5528bb875401f401ab6a7abaa2e09
Reviewed-on: https://code.wireshark.org/review/36875
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-04-17 18:34:28 +00:00
Anders Broman a9ea061368 http2: Make session info part of function signatures.
Change-Id: I7078a89a1997f370a03809ee6943ab394ec6d0e1
Reviewed-on: https://code.wireshark.org/review/36873
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-04-17 13:54:01 +00:00