Commit Graph

2553 Commits

Author SHA1 Message Date
Martin Tschoepe d3ec582c26 PROFINET: Ensure multiple submodules are parsed
GSML parsing has a bug related to multiple submodules,
such that, the first submodule found in the GSDML needs
to be the PROFIsafe element, otherwise the description
is not parsed.
2021-06-30 13:45:18 +00:00
Gerald Combs 4609bc4ad5 CMake: Mark our plugin include directories PRIVATE.
Use target_include_directories to mark our local include directories
PRIVATE, similar to what we do elsewhere.
2021-06-22 22:17:42 +00:00
João Valverde 8cf9791679 Replace some lingering references to g_log() 2021-06-19 02:34:36 +00:00
João Valverde 0e50979b3f Replace g_assert() with ws_assert() 2021-06-19 01:23:31 +00:00
João Valverde 39df3ae3c0 Replace g_log() calls with ws_log() 2021-06-16 12:50:27 +00:00
basakkalfa 7132fcaeb0 PROFINET: DCP SET Block with 0 Block Length
If there is DCP SET block with 0 block length, it is dissected
as erroneous block since DCP SET block can not have 0 block
length. Moreover, DCPBlockLength is not decoded if DCP option
and suboption is 0. However, each DCP block must have
Option/Suboption/DCPBlockLength. This is also fixed.
2021-06-09 05:23:16 +00:00
João Valverde 9ba97d12d6 Add ws_debug() and use it
Replace most instances of ws_debug_printf() except in
epan/dissectors and dissector plugins.

Some replacements use printf(), some use ws_debug(), and
some were removed because they were dead or judged to be
temporary.
2021-05-24 01:13:19 +00:00
Martin Tschoepe d9a93acc93 PROFInet: Correct handling for multiple APIs
When dissecting messages with multiple API types
within the same message, the parsing of the connect
request fails to take all elements into account.
This results in only partial parsing of the elements.

This fix ensures that all parts of the message are taken
into account and dissected correctly.
2021-05-23 20:47:50 +00:00
Guy Harris 57a1514ac7 Cast away the return value of g_strlcpy() and g_strlcat().
Most of the time, the return value tells us nothing useful, as we've
already decided that we're perfectly willing to live with string
truncation.  Hopefully this keeps Coverity from whining that those
routines could return an error code (NARRATOR: They don't) and thus that
we're ignoring the possibility of failure (as indicated, we've already
decided that we can live with string truncation, so truncation is *NOT*
a failure).
2021-04-30 03:19:19 -07:00
Gerald Combs a27391ab16 Plugins: Add missing prototypes.
Fixes -Wmissing-prototypes found by Clang.
2021-04-16 20:32:23 +00:00
Martin Mathieson d06287ec2e Some more spelling fixes.
Changed script to allow recursive search for multi-words.
2021-04-10 22:50:52 +00:00
Basak Kalfa e04ea5c108 PROFINET: Rsi dissection errors are fixed.
According to specification, size of PROFINETIOServiceResPDU
is calculated and checked under dissect_RSI_RSP_block
function. Moreover, dissect_rsi_blocks function is added and
type of PDU and operation number (Opnum) are checked before
dissection starts.
2021-04-10 08:09:18 +00:00
João Valverde d7401147b4 CMake: Remove non existent '/codecs' include path
The '/codecs' dir was removed in g63af1da7e7.

Avoid using include_directories(), prefer target_include_directories().
Remove some unnecessary CMAKE_CURRENT_*_DIR includes and some other
small cleanups while at it.
2021-03-29 00:00:57 +00:00
João Valverde 0fd2033ba2 plugin_ifdemo: Add missing QtMultimedia dependency
On my system I had to add a QtMultimedia dependency to get this plugin
to build.
2021-03-29 00:00:57 +00:00
João Valverde b807020537 'stats_tree' is not a dissector plugin (CheckAPI.pl) 2021-03-02 18:38:30 +00:00
João Valverde 8f7303df82 Fix checkapi stats_tree files
Should not include "plugin.c".
2021-03-01 21:19:40 +00:00
João Valverde 7f105d3981 CMake: Use CheckAPI's abort/termoutput with dissectors only
I believe this was the original intention, to use these API restricitons
with dissectors only (not that I necessarily agree with that policy either),
and through copy-paste and lack of clear guidelines it spread to other
parts of the build.

Rename the checkAPI groups to make it very clear that this is dissector-only.

This doesn't mean, of course, that good programming practices shouldn't be
followed everywhere. In particular assertions need to be used properly.
Don't use them to catch runtime errors or validate input data.

This commit will be followed by another removing the various ugly hacks
people have been using to get around the checkAPI hammer.
2021-03-01 20:59:39 +00:00
Vahap Emin Agaogullari e247ffa906 PROFINET: Multiple write in record dissection
COContainerContent dissects PDInterfaceMrpDataAdjust and
PDInterfaceMrpDataAdjust dissects remaining COContainerContent
because of offset problem. Offset problem is fixed.
2021-02-28 14:45:55 +00:00
Guy Harris ed86f51e49 wiretap: rename wtap_register_file_type_subtypes().
It only registers one file type/subtype, so rename it to
wtap_register_file_type_subtype().

That will also force plugins to be recompiled; that will produce compile
errors for some plugins that didn't change to match the new contents of
the file_type_subtype_info structure.

Also check to make sure that the registered file type/subtype supports
at least one type of block; a file type/subtype that doesn't return
*any* blocks and doesn't permit *any* block types to be written is not
very useful.  That should also catch most if not all other plugins that
didn't change to match the new contents of the file_type_subtype_info
structure.

Don't make errors registering a file type/subtype fatal; just complain,
don't register the bogus file type/subtype, and drive on.
2021-02-23 20:39:16 -08:00
Guy Harris 0e301fba78 usbdump: update struct file_type_subtype_info.
Update this to match the new layout of that structure, providing a list
of supported packets.
2021-02-23 16:59:44 -08:00
Guy Harris a7256d50b5 wiretap: more work on file type/subtypes.
Provide a wiretap routine to get an array of all savable file
type/subtypes, sorted with pcap and pcapng at the top, followed by the
other types, sorted either by the name or the description.

Use that routine to list options for the -F flag for various commands

Rename wtap_get_savable_file_types_subtypes() to
wtap_get_savable_file_types_subtypes_for_file(), to indicate that it
provides an array of all file type/subtypes in which a given file can be
saved.  Have it sort all types, other than the default type/subtype and,
if there is one, the "other" type (both of which are put at the top), by
the name or the description.

Don't allow wtap_register_file_type_subtypes() to override any existing
registrations; have them always register a new type.  In that routine,
if there are any emply slots in the table, due to an entry being
unregistered, use it rather than allocating a new slot.

Don't allow unregistration of built-in types.

Rename the "dump open table" to the "file type/subtype table", as it has
entries for all types/subtypes, even if we can't write them.

Initialize that table in a routine that pre-allocates the GArray before
filling it with built-in types/subtypes, so it doesn't keep getting
reallocated.

Get rid of wtap_num_file_types_subtypes - it's just a copy of the size
of the GArray.

Don't have wtap_file_type_subtype_description() crash if handed an
file type/subtype that isn't a valid array index - just return NULL, as
we do with wtap_file_type_subtype_name().

In wtap_name_to_file_type_subtype(), don't use WTAP_FILE_TYPE_SUBTYPE_
names for the backwards-compatibility names - map those names to the
current names, and then look them up.  This reduces the number of
uses of hardwired WTAP_FILE_TYPE_SUBTYPE_ values.

Clean up the type of wtap_module_count - it has no need to be a gulong.

Have built-in wiretap file handlers register names to be used for their
file type/subtypes, rather than building the table in init.lua.

Add a new Lua C function get_wtap_filetypes() to construct the
wtap_filetypes table, based on the registered names, and use it in
init.lua.

Add a #define WSLUA_INTERNAL_FUNCTION to register functions intended
only for internal use in init.lua, so they can be made available from
Lua without being documented.

Get rid of WTAP_NUM_FILE_TYPES_SUBTYPES - most code has no need to use
it, as it can just request arrays of types, and the space of
type/subtype codes can be sparse due to registration in any case, so
code has to be careful using it.

wtap_get_num_file_types_subtypes() is no longer used, so remove it.  It
returns the number of elements in the file type/subtype array, which is
not necessarily the name of known file type/subtypes, as there may have
been some deregistered types, and those types do *not* get removed from
the array, they just get cleared so that they're available for future
allocation (we don't want the indices of any registered types to changes
if another type is deregistered, as those indicates are the type/subtype
values, so we can't shrink the array).

Clean up white space and remove some comments that shouldn't have been
added.
2021-02-17 21:54:28 +00:00
Guy Harris c0711693ab Enable -Wredundant-decls.
Add it to the default list of checks, and fix some errors it causes.
(Sadly, it doesn't work in CLang.)
2021-02-14 14:43:42 -08:00
Guy Harris 2c719d4517 Generate plugin.c for tap plugins.
Instead of having the source file containing the top-level registration
routine for the pinfo_stats_tree plugin checked into our repository,
generate it with tools/make-plugin-reg.py, as we do with other plugins.

While we're at it, fix a comment - "DLL" is a Windows term; the
equivalent term in UN*Xes would be "shared object" ("so" or ".so") or
"dynamic library" ("dylib" or ".dylib").
2021-01-30 19:06:22 -08:00
Jaap Keuter 8bfff60293 Avoid CMP0071 warning when configuring with the pluginifdemo 2021-01-15 09:04:37 +00:00
Gizem Yurdagül cb65f9c150 PN: CIMVDIValue is not part of DNCP Suboption 2020-12-31 09:01:23 +00:00
Basak Kalfa 9783caebdf PROFINET: According to PN spec, RSI dissections are added.
Current Profinet Spec includes additional RSI features.
As a result, new file is added for PN-RSI protocol.
DCP substitutions related to RSI are added under PN-DCP.
PDRsiInstances record is added under PN-IO.
2020-12-29 08:43:11 +00:00
Dario Lombardo 93f6aa2c69 iLBC: fix deprecation type and cast.
Starting from libilbc 3.0.0 the type iLBC_decinst_t has been marked
deprecated.
Other fixes rely on function prototype requiring uint8_t pointer.
2020-12-28 12:45:41 +00:00
Moshe Kaplan fe6b774358 mate: replace g_malloc with g_new
Replace `g_malloc` with `g_new` to improve
source code readability.
2020-12-27 08:45:54 +00:00
Moshe Kaplan 1c7edf49f8 mate_setup: allocate correct amount of memory
When creating a _mate_cfg_gog, instead of
allocating space for a `_mate_cfg_gop`,
allocate space for a _mate_cfg_gog. Also, use
`g_new` instead of `gmalloc`.
2020-12-22 22:53:26 +00:00
Moshe Kaplan e16166a74c Detect and replace bad allocation patterns
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-12-22 14:56:38 +00:00
John Thacker 15d315c2ae GLib: Bump requirement 2.32 -> 2.36 2020-11-25 06:25:38 +00:00
Martin Mathieson 07df04e4c7 Unistim: Set the length and type of IP address fields properly. 2020-11-01 19:43:24 +00:00
Jaap Keuter 5b2901d090 MATE: Improve MATE debug facility
1) Allow AVP_DEBUGGING settings to be made from Preferences, iff compiled so.
2) Flush MATE/AVP debug output once sequential packet parse has completed.
2020-10-24 18:42:50 +00:00
Jaap Keuter 87a42de393 MATE: allow _AVP_DEBUGGING flag to be set 2020-10-22 16:07:55 +00:00
Martin Mathieson 16dc0c71d3 Last batch of filter field string fixes.
There may still be some cases seen by
./toos/check_typed_item_calls.py --consecutive
that ought to be fixed, but wasn't sure so left.
2020-10-04 00:07:59 +01:00
Lin Sun 6136c719da RTP: opus playback
It's possible to play opus payload with libopus (https://opus-codec.org/).
Closes #16882.

Helped-by: Pascal Quantin <pascal.quantin@gmail.com>
Signed-off-by: Lin Sun <lin.sun@zoom.us>
Signed-off-by: Yuanzhi Li <ryanlee@mail.ustc.edu.cn>
2020-10-03 21:15:09 +00:00
Martin Mathieson 8b4e0148a2 Fix some more wrong filter names.
These are duplicates detected seen by running
check_typed_item_calls.py  --consecutive.

There are still quite a few more to go.
2020-09-28 18:20:09 +01:00
Basak Kalfa 91418775aa PROFINET: IOCS and IOData object dissection with Multi AR
when a new AR is established between devices which already
has another AR, same station_info was used and it caused wrong
dissection problem of IOCS and IOData objects of related AR.
In order to fix problem, new struct is added in order to match
station_info and corresponding ARs. New struct is used for
keeping ARUUID, related inputCR and outputCR frame IDs and
setup/release frame numbers of ARs. ARUUID's are used for
adding station_info data to their corresponding conversations.
If matching ARUUID and Frame IDs are found in RTC frame
dissection, then corresponding IOCS and IOData objects are
dissected.
2020-09-21 12:54:12 +00:00
Gizem Yurdagül ecbc0a5611 PROFINET: CBAVersion control is removed.
According to specification, CBA is not supported on Profinet anymore.
2020-09-10 12:13:00 +00:00
Gerald Combs 7ab6440416 Tools: Clean up checkAPI and add ui/qt.
Remove the --check-addtext and --build flags. They were used for
checkAddTextCalls, which was removed in e2735ecfdd.

Add the sources in ui/qt except for qcustomplot.{cpp,h}. Fix issues in
main.cpp, rtp_audio_stream.cpp, and wireshark_zip_helper.cpp.

Rename "index"es in packet-usb-hid.c.
2020-09-05 07:41:29 +00:00
Martin Mathieson 4f3f9ca54b Fix some spelling mistakes found among plugins. 2020-09-02 10:13:37 +01:00
Tomas Kukosa 82a4968bc3 plugin_if: add plugin_if_get_frame_data() and plugin_if_get_capture_file()
Change-Id: I7505d4185f18d13d6836c9c9bb8f400d12f2a524
Reviewed-on: https://code.wireshark.org/review/38217
Petri-Dish: Tomáš Kukosa <keksa@email.cz>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2020-08-22 05:32:29 +00:00
Basak Kalfa 4e595577f3 PROFINET: DHCP suboption undefined bytes
There are undefined bytes which must be included in DHCP
suboption block according to DCP Block Length. In other
words, there are still bytes after dissection of defined
parameters finish but DCP block length does not finish.
In order to solve the problem, these bytes are included in
DHCP suboption block and marked Undefined. The byte number
can be 1, so bytes word in pn_user_data is changed to byte.

Change-Id: I2be23b41a9827f9c2159b97a05658ddf557865cf
Reviewed-on: https://code.wireshark.org/review/38203
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
2020-08-20 10:46:31 +00:00
Moshe Kaplan 3b47a55b0d Replace instances of wmem_alloc with wmem_new
This commit replaces instances of
  (myobj *)wmem_alloc(wmem_X_scope(), sizeof(myobj))
and replaces them with:
  wmem_new(wmem_X_scope(), myobj)
to improve the readability of Wireshark's code.

Replacements were made with the following Python script:

import os
import re
import sys

pattern = r'\(([^\s\n]+) ?\*\) ?wmem_alloc(0?)\((wmem_[a-z]+_scope\(\)), sizeof\(\1\)\)'
replacewith = r'wmem_new\2(\3, \1)'

startdir = sys.argv[1]

for root, dirs, files in os.walk(startdir):
    for fname in files:
        fpath = os.path.join(root, fname)
        if not fpath.endswith('.c'):
            continue
        with open(fpath, 'r') as fh:
            fdata = fh.read()
        output = re.sub(pattern, replacewith, fdata)
        if fdata != output:
            print(fpath)
            with open(fpath, 'w') as fh:
                fh.write(output)

Change-Id: I223cb2fcce336bc99ca21c4a74e4cf758fd00572
Reviewed-on: https://code.wireshark.org/review/38088
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-08-08 09:54:29 +00:00
Tomas Kukosa e80d08974a pluginifdemo compilable on Windows
Change-Id: I81c40746d3e523da690205186eb3e3c2e1f26292
Reviewed-on: https://code.wireshark.org/review/37935
Petri-Dish: Tomáš Kukosa <keksa@email.cz>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-07-24 06:00:48 +00:00
vahapemin 48237f77aa Profinet: Wrong Block Length Dissection Fix
There were some cases which has zero remaining data
and it was causing an error.
Remaining Data length check added.

Change-Id: Ib0132d892e871c0f7980ff297d18c276aee26ba6
Reviewed-on: https://code.wireshark.org/review/37815
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-07-16 08:17:55 +00:00
vahapemin 734287d6d4 Profinet: ControlBlockProperties Decoded Properly
According to specification, problematic Block Decode
is fixed.

Change-Id: I0d1a13a26771231eb6f05b18325ee2bb94e975bc
Reviewed-on: https://code.wireshark.org/review/37813
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-07-10 06:26:05 +00:00
Jaap Keuter 7c855fba83 UNISTIM: Remove useless bit field true_false_string
This true_false_string does not provide anything in relation to the whole
bitfield. The field itself is questionable as a boolean anyway.
This is reported by the conflict checker.

Change-Id: I4a67db6755038b5a07ce4402181a0ea2a3a2b392
Reviewed-on: https://code.wireshark.org/review/37710
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-07-05 20:12:47 +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
David Perry d34a806e86 UNISTIM: Refactor display address/control/tag handling
The 8 combinations of the display address, control, and tag were being
handled as 8 separate cases in `dissect_display_switch()`. This resulted
in duplicated, inconsistent code. Some paths resulted in bug #15219
while others did not have this problem.

I believe I have been able to combine them all into a single case branch
which handles each aspect correctly. I am not a UNISTIM expert and
welcome more knowledgeable reviewers.

Bug: 15219
Change-Id: Ie3eee8e19c10daab27c1df599ce0d03b52f69205
Reviewed-on: https://code.wireshark.org/review/37190
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-05-24 13:05:31 +00:00