aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
AgeCommit message (Collapse)AuthorFilesLines
2021-08-21Fix some issues with Exported PDUs.Guy Harris1-26/+27
Fix the description in wsutil/exported_pdu_tlvs.h to reflect reality (i.e., to match what the code in Wireshark that reads the exported PDU TLVs, and all code that writes them, does). In the code that dissects them, treat all strings as FT_STRINGZPAD, as any null bytes at the end of the string are padding, not part of the string. See merge request !3895 and issue #17535.
2021-08-20Move LINKTYPE_WIRESHARK_UPPER_PDU definitions to a separate header.Guy Harris2-0/+167
Have wsutil/exported_pdu_tlvs.h define the LINKTYPE_WIRESHARK_UPPER_PDU TLV type and length values, as well as the port type values written to files in EXP_PDU_TAG_PORT_TYPE TLVs. Update the comment that describes the LINKTYPE_WIRESHARK_UPPER_PDU TLVs to more completely and correctly reflect reality (it was moved from epan/exported_pdu.h to wsutil/exported_pdu_tlvs.h). Rename those port type values from OLD_PT_ to EXP_PDU_PT_; there is nothing "old" about them - yes, they originally had the same numerical values as the PT_ enum values in libwireshark, but that's no longer the case, and the two are now defined independently. Rename routines that map between libwireshark PT_ values and EXP_PDU_PT_ values to remove "old" from the name while we're at it. Don't include epan/exported_pdu.h if we only need the LINKTYPE_WIRESHARK_UPPER_PDU definitions - just include wsutil/exported_pdu_tlvs.h. In extcap/udpdump.c, include wsutil/exported_pdu_tlvs.h rather than defining the TLV types ourselves.
2021-07-30nstime: Fix Dead Store (found by Clang Analyzer)Alexis La Goutte1-2/+2
Although the value stored to 'n_scanned' is used in the enclosing expression, the value is never actually read from 'n_scanned'
2021-07-29wslog: Add function to log directly without filteringJoão Valverde2-0/+25
Used to write custom logging functions.
2021-07-29wsutil: rename bytestring_to_str() -> bytes_to_str_punct()João Valverde3-8/+8
2021-07-29wsutil: Clean up unit test namespacesJoão Valverde1-10/+25
Remove implicit root and separate tests for proper coverage.
2021-07-29wsutil: Add max length argument to bytes_to_str()João Valverde2-15/+27
2021-07-29wsutil: Add some tests for bytes_to_str()João Valverde1-0/+38
2021-07-29Move bytes_to_str() to wsutilJoão Valverde3-0/+262
This utility function is useful outside of epan. Move it to wsutil and export the interface. The move isn't completely clean as it requires duplicating two small inline functions but that was necessary to avoiding moving too much at once.
2021-07-29wslog: Avoid macro duplicationJoão Valverde1-6/+7
2021-07-26Remove duplicate format_size() functionJoão Valverde4-23/+41
We have two format_size()s, with and without wmem scoped memory. Move the wmem version to wsutil and add a convenience macro to use g_malloc()ed memory.
2021-07-26Move wmem to wsutilJoão Valverde40-0/+8525
This allows wmem to be used from other libraries, namely wsutil. It is often the case that a funtion exists in wsutil and cannot be used with a wmem scope, requiring some code duplication or extra memory allocations, or vice-versa, code in epan cannot be moved to wsutil because it has a wmem dependency. To this end wmem is moved to wsutil. Scope management remains part of epan because those scope semantics are specific to dissection.
2021-07-25wslog: Minor fixes and cleanupsJoão Valverde2-10/+8
2021-07-15CMake: Don't bother checking for fcntl.h or floorl.Gerald Combs1-2/+0
fcntl.h appears to be available on all of our supported platforms, including Windows. We've also been including it without HAVE_FCNTL_H guards in a few places (e.g. sshdump.c) without any issues for some time. floorl is part of C99.
2021-07-14CMake: Adjust wsutil includes and linking.Gerald Combs1-14/+15
Mark wsutil's includes SYSTEM PRIVATE. This exposed a lot of targets that were indirectly picking up include paths via the wsutil target, so add direct includes where needed. The G.722 and G.726 codecs were implicilty including tiffio.h; find it explicitly instead. Mark some of wsutil's libraries PRIVATE, but leave commonly-used ones PUBLIC. Ping #17477.
2021-07-11wsutil: Start adding a test suiteJoão Valverde2-0/+69
2021-07-11wsutil: Revert some changes to format_size()João Valverde2-26/+15
Revert change to format_size() added in f509a83381b81b1189ddb2226b12743f5b9f1c79. This commit broke formatting with spaces and introduced some dead code. Also replace unnecessary call to format_size_wmem() and remove unnecessary casts (since our warning settings were fixed in the mean time).
2021-07-09wslog: Fix representation of null domainJoão Valverde1-1/+1
Map "" to "(none)", besides NULL.
2021-07-09wslog: fixup copyrightJoão Valverde2-2/+6
2021-07-09wslog: Fix commentJoão Valverde1-2/+2
2021-06-29wslog: Prefer more modern time APIsJoão Valverde2-43/+74
Functions clock_gettime() and timespec_get() cover all the platforms we support with sub-second resolution in a a portable manner. Fallback to using time(). Pass a struct timespec to the log writer callback for maximum flexibility.
2021-06-28wslog: don't assume how big struct timeval's tv_usec is.Guy Harris1-1/+1
At least according to the Single UNIX Standard, it merely has to be big enough to hold a value in the range [-1, 1000000], and there must be *an* environment in which it's no *larger* than a long. Just cast it to long, and continue to print the result of dividing it by 1000 with %03ld.
2021-06-28wslog: Replace g_date_time_format()João Valverde2-24/+54
Calling GLib functions inside the log writer is not safe, it might infinitely recurse or abort if g_date_time_* logs warnings because we registered our log handler for GLib itself.
2021-06-26wslog: Update API documentation and improve code formattingJoão Valverde2-72/+96
2021-06-26wslog: Check environment initialization for errorsJoão Valverde2-45/+97
Initialiaze the cmdarg error stream earlier. Dumpcap also needs to know earlier if it is running in capture child mode.
2021-06-26wslog: Fatal messages should always be activeJoão Valverde1-0/+6
2021-06-25"config.h" need not and should not be included in any headerJoão Valverde1-2/+0
config.h is included in the source file before including the header that uses it.
2021-06-25wsutil: Rewrite ws_assert() to minimize dependenciesJoão Valverde3-22/+84
This includes as little as possible in the assertion header, so that it can be included globally in every file without pulling any unwanted definitions. In particular pulling stdlib.h is avoided because that can have side effects if it wants to include non-portable extensions. It is possible to have side-effects from include glib.h too, for example because of G_LOG_DOMAIN. These side-effects are usually avoidable with careful ordering of pre-processor directives but with multiple levels of indirections it can be hard to track. Better to make it robust to these kinds of failures in the first place. Also integrate with our logger for a cohesive experience (but keep it a private dependency).
2021-06-25wsutil: Rewrite ws_log() to minimize dependenciesJoão Valverde2-34/+28
Minimizing the dependencies on other wsutil and GLib functions reduces the chance that we will have a weird recursion pattern in wslog and makes the code easier to analyze.
2021-06-25wsutil: Fix incorrect header includeJoão Valverde2-3/+3
wsutil should not have any dependency on epan, replace the extraneous header.
2021-06-24wslog: Register log handler with GLibJoão Valverde1-0/+38
This avoids having to manage two different implementations. For example with this change GLib functions will terminate if Wireshark's fatal log level is set to a matching level and the --log-file option will also output messages from GLib itself.
2021-06-24wslog: Fix initialization with invalid environmentJoão Valverde1-6/+11
We can't write to stderr outside of the default writer context. Wireshark and tshark will block if we do that and dumpcap is running as capture child.
2021-06-24wslog: Slight color and format changeJoão Valverde1-9/+7
This changes color use to be the very similar with GLib to maintain familiarity. The only difference is that Message and Info use a different color than Debug. Also use the more familiar format of <domain> <level> instead of <level> <domain>.
2021-06-23Debug: Lower priority to "noisy" for pipe spawn outputJoão Valverde1-1/+1
Spawn output can include very long multiline extcap arguments.
2021-06-23wslog: Fix crash using a custom log fileJoão Valverde1-5/+11
Add missing va_copy() call.
2021-06-22Fix some includes.Dario Lombardo1-0/+1
2021-06-21wslog: Documentation fixupsJoão Valverde1-6/+7
2021-06-21wslog: Format and color amendmentsJoão Valverde1-22/+49
2021-06-21wslog: Check if we are initialized and add missing initsJoão Valverde2-19/+62
Instead of receiving the program name from GLib, pass it explicitly to ws_log_init() instead and use that to initialize the GLib program name. ws_log_parse_args() will now exit the program when it encounters an argument error if exit_failure >= 0.
2021-06-21wslog: Reverse order for level priorityJoão Valverde1-12/+12
Consistently speaking of ascending priority for higher levels seems slightly more intuitive. Use that instead.
2021-06-21wslog: Cleanup the filter/match logicJoão Valverde1-112/+126
2021-06-21wslog: Critical and error are always active.João Valverde1-7/+7
The intention was that "error" and "critical" are *always* active (always...). Do that.
2021-06-21wslog: "Warning" can also be set as fatalJoão Valverde1-2/+3
2021-06-21NGAP: fix dissection of multiple NGAP messages in the same HTTP2 packetPascal Quantin2-6/+61
Also add dissection for more containers
2021-06-21wslog: Shorten ws_log_message_is_active() nameJoão Valverde2-6/+6
2021-06-19ws_assert: remove a stray semicolon at the end of an inline function.Guy Harris1-1/+1
2021-06-19wslog: Set registered name earlierJoão Valverde1-7/+8
2021-06-19wslog: Be more obvious in the log that the domain is unsetJoão Valverde1-5/+10
Currently we are not filtering the unset (NULL) domain, on the assumption that every log call should belong to a defined domain. However there are still many places in the codebase where this isn't true and the fact that the null/default domain name is omitted from the output and never filtered is probably surprising and user-unfriendly. Users might understandably assume the filtering is buggy. Give an indication, such as (none)-MESSAGE, to make this more obvious.
2021-06-19wslog: Fix domain filteringJoão Valverde1-0/+3
Fixes 051a74378d3d3bd15710d9e2656d963555950fad.
2021-06-18wslog: Add support for inverted debug matchesJoão Valverde2-28/+58
The --log-debug and --log-noisy now accepts a '!' to invert the match and disable the debug (noisy respectively) log level for the listed domains. Note this is different from --log-domains, that option enables/disables the entire log domain itself, regardless of log level.