aboutsummaryrefslogtreecommitdiffstats
path: root/sharkd_session.c
AgeCommit message (Collapse)AuthorFilesLines
2023-03-06sharkd: allow nameless base64 items and objects.Guy Harris1-2/+4
Elements of an array don't have names.
2023-03-06sharkd: clean up the JSON marshalling.Guy Harris1-51/+47
Add routines to open and close an object, and use them. The open routine takes a member name as an argument, sets it, and begins an object; the close routine ends the object. Have sharkd_json_response_close() end the object, just as sharkd_json_response_open() begins it. Have sharkd_session_process_tap_stats_node_cb() take a key and use that when opening the array. Have sharkd_session_process_frame_cb_tree() take a key and use that when opening the array. This makes the structure of the code better mirror the structure of the JSON objects it marshals. If there's a key for a string value, but there's no string value or no format for a string value, crash with a null-pointer dereference rather than putting out the key and then, on the next operation, getting a "json_dumper_bad(): Bad json_dumper state: illegal transition" error as in, for example, issue #18886. This way, it will be a bit more obvious what the true error is. If thre's no key for a base-64 value, crash rather than not setting the key, for the same reason.
2023-03-05sharkd: don't report an error if there is no error.Guy Harris1-1/+1
If dfilter_compile() succeeds, but the filter contains deprecated tokens, don't report an error from dfilter_compile() as a warning, as there *is* no error from dfilter_compile(). Instead, report "Filter contains deprecated tokens". (Feel free to improve the error text.) Fixes the crash, at least, in #18886.
2023-03-04Sharkd: show RTP ssrc as hex and improve errorsZach Chadwick1-2/+9
The token format used by rtp-analyse and rtp-download expect the SSRC field to be a hex string parsable by `ws_hexstrtou32()` as seen in sharkd_session.c:760. The output from tap:rtp-streams was displaying it as an unsigned integer. For consistency, this field is now displayed as a hex string in the output. If the call to download an RTP stream did not match any payloads, Sharkd would not return any information at all. This now returns an error message indicating that there is no RTP data available. Adds three new selftests and sample pcap.
2023-03-01Sharkd: Return error message on load if err!=0Zach Chadwick1-0/+10
Fixes a bug when the return value from load_cap_file() is nonzero. No response is currently returned causing the client to hang. A non-zero error code can happen for a variety of reasons, one of which is when the PCAP is truncated. An error message from cfile_read_failure_message() is displayed on the console, but no data was returned to the RPC client. This adds a call to wtap_strerrror() to look up a human consumable error message for the specific error code returned during wtap_read(). Adds new self-test to suite_sharkd.py
2023-02-25Sharkd: Fix types of prev_frame and ref_frameZach Chadwick1-2/+2
The 'frame' command accepts both 'prev_frame' and 'ref_frame' as arguments. Both should be defined as a UINTEGER rather than a BOOL.
2023-02-19Sharkd: Add column header labels to the "status" outputZach Chadwick1-0/+11
2023-02-13Zero-pad any RGB color used for a bg or fgZach Chadwick1-4/+4
The `color_t_to_rgb` method returns an unsigned int, taking a 32-bit color code and reducing it to an integer. Sharkd displays these as hex colors. However, if this color is missing a Red or Green component, the hex output is missing the zero-padding for those parts of the color, resulting in the wrong or invalid hex code. This patch simply pads the output with zeros.
2023-02-07Move ui/version_info.[ch] to wsutilJoão Valverde1-1/+1
2022-12-16Windows: Use SpeexDSP binary packageJoão Valverde1-5/+1
Remove bundled code and use vcpkg binary library instead.
2022-11-28dfilter: Return an error object instead of stringJoão Valverde1-5/+6
Return an struct containing error information. This simplifies the interface to more easily provide richer diagnostics in the future. Add an error code besides a human-readable error string to allow checking programmatically for errors in a robust manner. Currently there is only a generic error code, it is expected to increase in the future. Move error location information to the struct. Change callers and implementation to use the new interface.
2022-08-25Rename a bunch of things with "conversation".Guy Harris1-3/+3
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-23Change names to reflect that it's an endpoint table.Guy Harris1-9/+9
More {host, hostlist} -> endpoint.
2022-08-23Rename some functions and types for endpoint tables.Guy Harris1-5/+5
The "conversation table" mechanism supports two types of tables, one for the "Conversations" menu item under "Statistics" and one for the "Endpoints" menu item under "Statistics". The first of them shows statistics for conversations at various layers of the networking stack; the second of them shows statistics for endpoints at various layers of the networking stack. The latter is *not* a table of hosts; an endpoint might be a host, identified by an address at some network level (MAC, IP, etc.), or it might be a port on a host, identified by an address/port pair. Some data types, function names, etc. use "host" or "hostlist" or other terms that imply that an endpoint is a host; change them to speak of endpoints rather than hosts, using names similar to the corresponding functions for conversations. Provide wrapper functions and typedefs for backwards source and binary compatibility; mark them as deprecated in favor of the new names. Clean up some comment errors found in the process.
2022-08-13epan: Rearrange column includesJohn Thacker1-0/+1
Move all the declarations of routines that are internal and not for use by dissectors from column-utils.h column-info.h Move the column max length defines into column-utils.h because dissectors might need that Since packet.h already includes column-utils.h, dissectors don't need to include column-utils.h anymore. Remove or downgrade a few other column header includes that are unnecessary.
2022-07-12epan: Respect custom column resolved/unresolved status everywhereJohn Thacker1-6/+2
Add a function to get the column text of the nth column, taking into account whether the column is resolved or unresolved. Use this function in the GUI, as well as in tshark, when writing PSML, exporting dissection to PSML, etc., instead of accessing col_data directly. This removes the direct accesses of col_data from outside column.c and column-utils.c Fix #18168.
2022-06-10tap: Adding flags for tap_packetRoland Knall1-4/+4
This allows flags to be passed by the registering listener to the collection of information
2022-02-20Remove editor modelines and .editorconfig exceptions from root filesDavid Perry1-3710/+3697
2021-12-30Prefs/Extcap: Added support for password which is never stored on the diskj.novak@netsystem.cz1-1/+2
2021-12-19Replace g_strdup_printf() with ws_strdup_printf()João Valverde1-2/+2
Use macros from inttypes.h.
2021-12-19Replace g_snprintf() with snprintf()João Valverde1-13/+13
Use macros from inttypes.h with format strings.
2021-09-07sharkd_session: Fix Branch condition evaluate to a garbage valueAlexis La Goutte1-1/+1
sharkd_session.c:3307:18: warning: Branch condition evaluates to a garbage value [core.uninitialized.Branch]
2021-08-29wiretap: always allocate a block for a record.Guy Harris1-2/+2
Without that, you could add a comment to a record in a file format the reading code for which doesn't allocate blocks, but the comment doesn't get saved, as there's no block in which to save the comment option. This simplifies some code paths, as we're either using the record's modified block or we're using the block as read from the file, there's no third possibility. If we attempt to read a record, and we get an error, and a block was allocated for the record, unreference it, so the individual file readers don't have to worry about it.
2021-07-19Remove unused variables in sharkd_session.cEvan Huus1-14/+1
The compiler pointed them out. I'm not sure what purpose they were meant to serve originally but they're dead now.
2021-07-11sharkd: various cleanups.Guy Harris1-50/+163
Extend sharkd_dissect_request() so that it can replace sharkd_dissect_columns(). Have it return a status indicating success, invalid frame number, or read error, so that the caller knows what the problem is. Pass it pointers to the wtap_rec and Buffer to use when reading packets from the file, so that if it's called in a loop iterating over all frames, those structures can be initialized once, before the loop, and cleaned up once, after the loop, rather than doing both once per loop iteration. Pass pointers to the read error code and additional read error information string pointer, so that, on a file read error, that information is available to the caller. Get rid of sharkd_dissect_columns(); instead, use sharkd_dissect_request(), with code from the loop body pulled into a callback routine. Fix that code to correctly determine whether the current frame has any comments, rather than just treating all frames that have blocks as having comments. Use _U_ to mark arguments as unused, rather than throwing in a (void) variablename; statement. Move some variables used only within a loop into the for() statement or the loop body.
2021-07-08Consistently refer to blocks that have been modified as "modified".Guy Harris1-5/+5
"User" sounds as if the blocks belong to the user; at most, the current user might have modified them directly, but they might also have, for example, run a Lua script that, unknown to them, modified comments. Also, a file might have "user comments" added by a previous user, who them wrote the file and and provided it to the current user. "Modified" seems a bit clearer than "changed".
2021-07-07Use wtap_blocks for packet commentsDavid Perry1-12/+38
Mostly functioning proof of concept for #14329. This work is intended to allow Wireshark to support multiple packet comments per packet. Uses and expands upon the `wtap_block` API in `wiretap/wtap_opttypes.h`. It attaches a `wtap_block` structure to `wtap_rec` in place of its current `opt_comment` and `packet_verdict` members to hold OPT_COMMENT and OPT_PKT_VERDICT option values.
2021-07-04Move version_info.[ch] to ui/João Valverde1-1/+1
Version info is an aspect of UI implementation so move it to a more appropriate place, such as ui/. This also helps declutter the top-level. A static library is appropriate to encapsulate the dependencies as private and it is better supported by CMake than object libraries. Also version_info.h should not be installed as a public header.
2021-07-04sharkd: Prefer version_info.h instead of version.hJoão Valverde1-1/+2
2021-06-22sharkd: fix implicit conversion warningUli Heilmeier1-1/+1
With int we have a implicit conversion loses integer precision warning
2021-06-22sharkd: prevent a NULL pointer dereference (CID 1486264)Pascal Quantin1-0/+6
2021-06-22sharkd: fix JSON boolean sanity check (CID 1486263)Pascal Quantin1-1/+1
2021-06-21sharkd: fix compilation with gcc 11.0.1Pascal Quantin1-20/+17
2021-06-21removed reference to wsutil/ws_printf.hPaul Offord1-1/+0
2021-06-21solved code conflicts pre rebasePaul Offord1-229/+871
2021-06-19Replace g_assert() with ws_assert()João Valverde1-1/+2
2021-06-08epan: Change export_object_entry_t.payload_len to size_tStig Bjørlykke1-2/+2
The *real* maximum object size is size_t, so change payload_len to match this.
2021-06-07ui: Return length from ssl_export_sessions()Stig Bjørlykke1-2/+3
All users of ssl_export_sessions() calculates the length of the returned string, so let's return the length instead.
2021-04-14VoIP dialogs: Performance improvementsJirka Novak1-1/+1
Retap and UI response are much faster when many RTP streams are processed. RTP Streams/Analyse 1000+, RTP Player 500+. Changes: - RTP streams are searched with hash, not by iterating over list. - UI operations do not redraw screen after every change, just after all changes. UI is locked when rereading packets. - Sample list during RTP decoding is stored in memory so wireshark uses just half of opened files for audio decoding than before. - Analysis window checkbox area is limited in height - Dialogs shows shows count of streams, count of selected streams and count of unmuted streams - Documentation extended with chapter about RTP decoding parameters - Documentation extended with performance estimates
2021-03-27Follow SIP Call: Added Follow SIP Call to Follow menuJirka Novak1-1/+1
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-25wsutils: add local implementation of g_memdup2.Dario Lombardo1-2/+2
g_memdup() was deprecated and replaced with g_memdup2() in GLib 2.68, we provide our own copy of g_memdup2() for older GLib versions.
2021-02-28Remove and replace obsolete ws_snprintf() definitionJoão Valverde1-4/+3
Since fe94133f0d06935bb5f2afe21f59bbb078d3d9d3 ws_snprintf() and ws_vsnprintf() don't actually do anything anymore. The return value of ws_[v]snprintf was discarded before, now it too conforms to C99.
2021-02-08sharkd: Add configuration profile and other optionsPaul Offord1-1/+6
This change adds code to allow the selection of a configuration profile during sharkd start by adding a -C command line option. A new -a option has been added to specify the api service endpoint e.g. tcp:127.0.0.1:4446 The change also adds version display (-v) and help display (-h) options. These additions have been made in a way to ensure that the original command line options still work correctly to maintain backward compatibility. The new options have been added using the getopt_long(...) function that is used by tshark to simplify the addition of further command line options. Closes #17222
2021-01-01Voice dialogs: Added option to apply display filter in VoIP/RTP dialogsJirka Novak1-1/+1
VoIP Calls dialog and RTP Streams dialog has now option to apply display filter dialog during processing packets. Filter checkbox is activated during dialog open when display filter is active. New field apply_display_filter had to be added to voip_calls_tapinfo_t and _rtpstream_tapinfo/rtpstream_tapinfo_t structures.
2020-12-22Detect and replace bad allocation patternsMoshe Kaplan1-4/+4
Adds a pre-commit hook for detecting and replacing occurrences of `g_malloc()` and `wmem_alloc()` with `g_new()` and `wmem_new()`, to improve the readability of Wireshark's code, and occurrences of `g_malloc(sizeof(struct myobj) * foo)` with `g_new(struct myobj, foo)` to prevent integer overflows Also fixes all existing occurrences across the codebase.
2020-08-14Check that at least one token exists to consider the JSON as validPascal Quantin1-2/+2
Bug: 16780 Change-Id: I07ca12675fc79a7c524719d18b85e5d3dada6652 Reviewed-on: https://code.wireshark.org/review/38160 Petri-Dish: Pascal Quantin <pascal@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin <pascal@wireshark.org>
2020-05-14sharkd_session.c: fix a warning reported by gcc 10Pascal Quantin1-2/+2
warning: ‘%s’ directive argument is null [-Wformat-overflow=] 544 | fprintf(stderr, "load: filename=%s\n", tok_file); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Change-Id: I583a94308ad53b461606053def17e8537eec8d65 Reviewed-on: https://code.wireshark.org/review/37195 Petri-Dish: Pascal Quantin <pascal@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2019-11-23Add c-ares to the required library list.Gerald Combs1-2/+0
Although c-ares support was techically optional, it was either on by default or required in all of our packaging. Go ahead and require it globally. C-ares is widely available and synchronous name resolution can easily result in a horrific user experience. Change-Id: Id67c797316ed6b8a0ab5052e55a43a1b9e2a2464 Reviewed-on: https://code.wireshark.org/review/35188 Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2019-09-22Qt, http2: Add Follow HTTP/2 Stream functionalityAlexander Gryanko1-1/+2
The HTTP/2 protocol multiplexes a single TCP connection into multiple independent streams. The Follow TCP output can interleave multiple HTTP/2 streams, making it harder to analyze a single HTTP/2 stream. Add the ability to select HTTP/2 Streams within a TCP stream. Internally, the HTTP/2 dissector now stores the known Stream IDs in a set for every TCP session which allows an amortized O(n) lookup time for the previous/next/max Stream ID. [Peter: make the dissector responsible for clamping the HTTP/2 Stream ID instead of the Qt code, that should permit future optimizations.] Change-Id: I5d78f29904ae8f227ae36e1a883155c0ed719200 Reviewed-on: https://code.wireshark.org/review/32221 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Alexander Gryanko <xpahos@gmail.com> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2019-07-26HTTPS (almost) everywhere.Guy Harris1-1/+1
Change all wireshark.org URLs to use https. Fix some broken links while we're at it. Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c Reviewed-on: https://code.wireshark.org/review/34089 Reviewed-by: Guy Harris <guy@alum.mit.edu>