Commit Graph

34 Commits

Author SHA1 Message Date
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
Adrien Aubry 80e1c54ff4 CANopen: Add SDO Block Upload/Download decoding
Previous code did not properly decode protocol (Object dictionnary is not always sent). All changes comply with CANopen DS301 freely available on the web.

Change-Id: Ibaae09af0f1a5300a323a9c94077d1fb7dadd560
Reviewed-on: https://code.wireshark.org/review/35558
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-02-07 04:39:05 +00:00
Stefan Tatschner 40eece98f8 Change struct can_identifier to can_info
The can specific data structure `struct can_identifier` is used as
supplementary data for higher level dissectors. This patch adds more
data to this struct and renames it accordingly to `struct can_info`.

More supplementary data is needed in order to dissect iso15765
correctly, since the header format depends on details on the underlying
CAN protocol (CAN 2.0B vs CAN-FD).

Change-Id: Id068cf38453f98b67a5ec470a22e7013548c5a14
Reviewed-on: https://code.wireshark.org/review/35246
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-11-28 18:27:16 +00:00
Guy Harris 20800366dd HTTPS (almost) everywhere.
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>
2019-07-26 18:44:40 +00:00
Gerald Combs 8d3ac3af86 epan: Convert our PROTO_ITEM_ macros to inline functions.
Convert our various PROTO_ITEM_ macros to inline functions and document
them.

Change-Id: I070b15d4f70d2189217a177ee8ba2740be36327c
Reviewed-on: https://code.wireshark.org/review/32706
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-04-04 04:03:38 +00:00
Maksim Salau eaee707941 dissectors: can: Handle CAN id flags
The change adds support of CAN flags stored in ids.
The flags allow dissectors to distinguish error frames,
remote transmission request frames and identify id type used (either
standard 11-bit or extended 29-bit).

Addition of bit flags allowed to add more checks whether a CAN frame may
be decoded by a particular dissector. I.e. some dissectors work only
with 11-bit ids (CANopen, DeviceNet) some only with 29-bit (J1939,
ISObus), others should be fine with bot types (OBD-II, ISO 15765).

The change also fixes 2 bugs in the DeviceNet dissector:
* removed byte swapping of CAN id (the pcap file seems to be broken;
  verified dissector operation with random traffic generated by cangen)
* fixed "Warn Dissector bug, protocol DeviceNet, in packet N":
  added a default value for fragmented message type string value lookup.

Bug: 15418
Change-Id: I70e91130789bb3367fe19e51489cd34e97d678a6
Reviewed-on: https://code.wireshark.org/review/31471
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-13 21:13:54 +00:00
Dario Lombardo fe219637a6 dissectors: use SPDX identifiers.
Change-Id: I92c94448e6641716d03158a5f332c8b53709423a
Reviewed-on: https://code.wireshark.org/review/25756
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-12 16:49:58 +00:00
Jakub Zawadzki 753d6f6667 can: remove duplicated can_identifier struct.
Change-Id: Ib6f0bcd1bec9a1fc5cbcd797a1f418270ae74a0e
Reviewed-on: https://code.wireshark.org/review/21537
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-05-06 15:56:40 +00:00
Adrien Aubry cb96331602 CANopen: EMCY manufacturer error field size bug fix
-Manufacturer error field has 5 bytes (not 4)
-corrected two descriptions

Change-Id: Ic6f3e8fdf08c52f1d4f987410e1e0597a9f6aaed
Reviewed-on: https://code.wireshark.org/review/17575
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-09-09 11:27:50 +00:00
Adrien Aubry cec2946460 CANopen: Added some improvements to CANopen emergency dissector
-Added description to Emergency error code
-Added bitmask dissector to Emergency register
-Added descriptions to object dictionary SDO related index
All these changes were found inside the CiA CANopen norm, and were useful
in my work while debugging CANopen frames

Change-Id: I76bc1eab9f75fc242eaf3200af81593f65570658
Reviewed-on: https://code.wireshark.org/review/16823
Reviewed-by: João Valverde <j@v6e.pt>
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-08-02 11:58:03 +00:00
João Valverde ee6e89d900 CANopen: Check array bounds for untrusted index (CID 1356262)
Change-Id: If5ca51e5703fa4137ab9f388a99d613752d3b0d0
Reviewed-on: https://code.wireshark.org/review/15983
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2016-06-16 22:05:21 +00:00
Michael Mann 5beb48b843 Fix some hf_ field datatype conflicts.
'ieee17221.clock_source_id' exists multiple times with NOT compatible types: FT_UINT16 and FT_UINT64
'ieee17221.stream_format' exists multiple times with NOT compatible types: FT_NONE and FT_UINT64
'afp.unknown' exists multiple times with NOT compatible types: FT_UINT16 and FT_BYTES
'afp.toc_offset' exists multiple times with NOT compatible types: FT_NONE and FT_UINT64
'bootp.client_id.iaid' exists multiple times with NOT compatible types: FT_UINT32 and FT_STRING
'bthfp.chld.mode' exists multiple times with NOT compatible types: FT_STRING and FT_UINT8
'canopen.pdo.data' exists multiple times with NOT compatible types: FT_STRINGZ and FT_BYTES
'canopen.sdo.data' exists multiple times with NOT compatible types: FT_UINT32 and FT_BYTES
'ceph.msg.' exists multiple times with NOT compatible types: FT_UINT32 and FT_UINT64
'ceph.version' exists multiple times with NOT compatible types: FT_UINT16 and FT_UINT64
'cip.linkaddress' exists multiple times with NOT compatible types: FT_STRING and FT_UINT8
'dnp3.al.ana' exists multiple times with NOT compatible types: FT_FLOAT and FT_INT32
'dnp3.al.anaout' exists multiple times with NOT compatible types: FT_FLOAT and FT_INT32
'dtls.handshake.cert_url.url_hash_len' exists multiple times with NOT compatible types: FT_STRING and FT_UINT16
'ssl.handshake.cert_url.url_hash_len' exists multiple times with NOT compatible types: FT_STRING and FT_UINT16
'dvb-s2_gse.label' exists multiple times with NOT compatible types: FT_UINT24 and FT_ETHER
'fcdns.rply.fc4type' exists multiple times with NOT compatible types: FT_NONE and FT_UINT8
'fcdns.req.fc4type' exists multiple times with NOT compatible types: FT_NONE and FT_UINT8
'icmp.int_info.name' exists multiple times with NOT compatible types: FT_STRING and FT_BOOLEAN
'icmpv6.ilnp.nb_locs' exists multiple times with NOT compatible types: FT_UINT64 and FT_UINT8
'icmpv6.ilnp.nb_locs' exists multiple times with NOT compatible types: FT_UINT32 and FT_UINT64
'mausb.clear_transfers.status' exists multiple times with NOT compatible types: FT_BOOLEAN and FT_NONE
'mikey.v' exists multiple times with NOT compatible types: FT_BOOLEAN and FT_NONE
'mswsp.rangeboundry.ultype' exists multiple times with NOT compatible types: FT_STRING and FT_UINT32
'mswsp.arrayvector.address64' exists multiple times with NOT compatible types: FT_UINT32 and FT_UINT64
'nlm.lock.l_offset' exists multiple times with NOT compatible types: FT_UINT32 and FT_UINT64
'nlm.lock.l_len' exists multiple times with NOT compatible types: FT_UINT32 and FT_UINT64
'pflog.saddr' exists multiple times with NOT compatible types: FT_IPv6 and FT_IPv4
'pflog.daddr' exists multiple times with NOT compatible types: FT_IPv6 and FT_IPv4
'pflog.saddr' exists multiple times with NOT compatible types: FT_BYTES and FT_IPv6
'pflog.daddr' exists multiple times with NOT compatible types: FT_BYTES and FT_IPv6
'pgm.spm.path' exists multiple times with NOT compatible types: FT_IPv6 and FT_IPv4
'pgm.nak.src' exists multiple times with NOT compatible types: FT_IPv6 and FT_IPv4
'pgm.nak.grp' exists multiple times with NOT compatible types: FT_IPv6 and FT_IPv4
'pgm.poll.path' exists multiple times with NOT compatible types: FT_IPv6 and FT_IPv4
'pgm.opts.ccdata.acker' exists multiple times with NOT compatible types: FT_IPv6 and FT_IPv4
'pgm.opts.ccdata.acker' exists multiple times with NOT compatible types: FT_IPv4 and FT_IPv6
'pgm.opts.ccdata.acker' exists multiple times with NOT compatible types: FT_IPv6 and FT_IPv4
'pgm.opts.redirect.dlr' exists multiple times with NOT compatible types: FT_IPv6 and FT_IPv4

Change-Id: Iaf694699d108a12db172da8dd9fbab211adb329d
Reviewed-on: https://code.wireshark.org/review/14070
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-02-22 16:51:22 +00:00
Michael Mann 443a7ed259 new_create_dissector_handle -> create_dissector_handle for dissector directory.
Some of the ASN.1 dissectors still generate a new_create_dissector_handle from the tool itself, so leave those for now.

Change-Id: Ic6e5803b1444d7ac24070949f5fd557909a5641f
Reviewed-on: https://code.wireshark.org/review/12484
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-12-09 12:37:36 +00:00
Michael Mann 9d10be54c7 Some CANopen frame types can have zero size, so use tvb_reported_length instead of -1.
Bug: 11083
Change-Id: Ib17649fbbc4f79705e3ad18903b5c8847cb09054
Reviewed-on: https://code.wireshark.org/review/7881
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-04-04 13:01:27 +00:00
Michael Mann f7b1678b12 Replace enumerated preference for choosing subdissector with a subdissector table and Decode As functionality.
This makes it much easier for other subdissectors (and plugins) to associate themselves with CAN.

Change-Id: I49dd832af51651d0c91f9850c100e544d178b8c4
Reviewed-on: https://code.wireshark.org/review/7734
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-03-19 12:49:10 +00:00
Enrico Jorns 29d02a3134 canopen: Verbosity for INFO column
Display basic information about what is going on in the INFO column to
ease protocol debugging.

Change-Id: I2a3aba8008bf65ab9e236a3d81335cf723b2edd0
Reviewed-on: https://code.wireshark.org/review/5521
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-12-24 14:57:49 +00:00
Bill Meier b5d7b7ab6e Cleanup use of #includes in non-generated epan/dissector/*.c
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-21 05:46:22 +00:00
Bill Meier 94d7e8d838 Use ENC_LITTLE_ENDIAN when fetching FT_U?INT8 fields ...
(for some dissectors which fetch all other integral fields using
   ENC_LITTLE_ENDIAN).

Change-Id: Ica72a68ac560f2920d61e0769de83130557c46fd
Reviewed-on: https://code.wireshark.org/review/5752
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-12-13 21:58:59 +00:00
Enrico Jorns b4b6a5d5c6 canopen: LSS dissection
Dissection of Layer setting services (LSS) sub-protocol
according to CiA 305.

Change-Id: I24ca1827b25c30a672fb31cad390b3c1486102f4
Reviewed-on: https://code.wireshark.org/review/5516
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-11-27 15:22:10 +00:00
Enrico Jorns c2913d25a9 canopen: Enhanced SDO decoding
* Move sdo dissection to separate function

  Added dissect_sdo() function to handle the more complex SDO dissection.

* SDO command specifier decoding

  Decoding of both client and server command specifier for SDO transfers
  according to CiA 301 Chaper 7.2.4.3.

  Note: Fully decoding block transfer frames is more complex and not supported
  yet.

* basic SDO abort code decoding

  SDO abort codes as specified in CiA 301 Chapter 7.2.4.3.17 (Table 22).

* Basic value ranges for object dict index parameter

  Object dict ranges as specified in CiA 301 7.4.1 (Table 41)

* cs-based multiplexer and data decoding

  A data width of 4 byte is valid only for expedited transfer and a
  multiplex value is present only in initialisation messages.

  This patch now handles also normal sdo segment data.

  Reference: CiA 301, Chapter 7.2.4.3.3 and 7.2.4.3.6

Change-Id: I37005894082d62eed1ddd85e09e3676aa3af8222
Reviewed-on: https://code.wireshark.org/review/5504
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: Michael Mann <mmann78@netscape.net>
2014-11-26 19:15:04 +00:00
Enrico Jorns 5464bc69ae canopen: Improve NMT error control and SYNC message dissection
1.  Also show Reserved/Toggle bit of NMT error control

  In case of the node guarding protocol this bit is used as a toggle bit.
  In case of the hearbeat protocol this bit is reserved.

  Reference: CiA 301 (rev 4.2.0), Chap. 7.2.8.3.2

2. Show optional 'counter' parameter of SYNC messages if available

  Reference: CiA 301 (rev 4.2.0), Chap. 7.2.5.3.1

Change-Id: I5dc0ab65e95fec4846a9c8bd8972ef2eba664ee2
Reviewed-on: https://code.wireshark.org/review/5484
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-11-26 05:17:59 +00:00
Enrico Jorns b01ff09eb9 canopen: Fixed tree expansion
Previously the COB-ID and Type subtree also used the main ett_canopen
variable. This made control of subtree expansion impossible as both
parent and subtree nodes shared the same state.

Change-Id: I3dabf7f399e83bfcfbf78bc0e633e3696776c043
Reviewed-on: https://code.wireshark.org/review/5480
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-11-25 11:19:15 +00:00
Michael Mann d7e277aa08 CANopen bugfixes
1. Fixed endianess in CANopen dissector.
According to CiA 301, 7.1.1. (p. 26):
"For numerical data types the encoding is little endian style."

2. Fixed NMT type string in CANopen dissector
NMT function code should not display 'EMERGENCY'

3. Fixed time stamp decoding

* Offset increment was too low for data type size
* Decoding of time_stamp_days must equal time_stamp_msec and thus be letohs instead of ntohs. CANopen data is little-endian encoded.

4. Fix: Use correct description string for NMT error control state bits
canopen.nmt_guard.state was faulty named "Node-ID". This was changed to "State".

5. Fix nmt_guard_state value_string array
CiA 301 desribes only 4 valid values. All other were deleted.
0x00 was renamed from 'Initalisation' to 'Boot-up' following CiA301.

6. Shortened EMERGENCY to EMCY

The term EMCY is the standard abbreviation used in CiA standard for Emergency service.

7. Fix: Allow SYNC and NMT error frames without any payload
NMT node guard remote requests do note have a payload,
SYNC frames only have an optional payload (counter)

If item length is set to -1, decode will cause a 'Malformed Packet' error.

8.  Rename MT_NMT_GUARD to MT_NMT_ERR_CTRL which better reflects its scope

Change-Id: I676f9b5f2e4efd8e7c9528fe289e7510c4d43235
Reviewed-on: https://code.wireshark.org/review/5425
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-11-21 21:51:10 +00:00
Bill Meier ff5a77256c Add editor modelines and adjust indentation as needed.
Change-Id: Id57d264299f2026d703c5b08bace4b24b32f184c
Reviewed-on: https://code.wireshark.org/review/4371
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-09-29 18:21:50 +00:00
Michael Mann 29ecd114bf convert to proto_tree_add_subtree[_format]
Change-Id: I5f573dffabb8685a8e5a334ff2bfb24d9838daa6
Reviewed-on: https://code.wireshark.org/review/2601
Tested-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-06-24 23:42:13 +00:00
Michael Mann 14824e6adf Revert "Fixup: tvb_* -> tvb_captured"
https://www.wireshark.org/lists/wireshark-dev/201406/msg00131.html

This reverts commit 246fe2ca4c.

Change-Id: Ib24bae0198c13a84bd7f731bf4af921212109a8f
Reviewed-on: https://code.wireshark.org/review/2430
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-06-19 18:25:59 +00:00
Dario Lombardo 246fe2ca4c Fixup: tvb_* -> tvb_captured
Change-Id: I9209c1271967405c34c1b6fa43e1726a4d3a5a3f
Reviewed-on: https://code.wireshark.org/review/2377
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-06-18 14:14:58 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(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-03-04 14:27:33 +00:00
Evan Huus a6415ece0a Rename a couple of to_str functions to have ep_ in the name. This makes it
obvious that the returned string is ephemeral, and opens up the original names
in the API for versions that take a wmem pool (and thus can work in any scope).

svn path=/trunk/; revision=54249
2013-12-19 15:49:09 +00:00
Michael Mann 8d0dc9f935 CAN protocols have a CAN ID and up to 8 bytes of data. How the CAN ID and data are presented is the responsibility of the previous layer. Make the interface be passing the CAN ID in dissector data and have the (up to) 8 bytes be the tvb. CAN protocols should treat the CAN ID as "generated" data.
svn path=/trunk/; revision=53792
2013-12-05 03:36:49 +00:00
Anders Broman ef249623e6 [-Wmissing-prototypes]
Use explicit casts.

svn path=/trunk/; revision=48313
2013-03-15 06:26:47 +00:00
Jeff Morriss 2552c750e5 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45017
2012-09-20 02:03:38 +00:00
Bill Meier 82ff1fd754 General cleanup:
- Setup COL_PROTO & COL_INFO before fetching from the tvb;
- Improve byte pane highlighing: Use proper length in proto_tree_add_item() calls;
- Remove unneeded include;
- Use VALS macro when referencing a value_string in hf[];
- Simplify/rework code slightly;
- Whitespace.

svn path=/trunk/; revision=42464
2012-05-07 13:35:45 +00:00
Anders Broman 93d9658e93 From Yegor Yefremov: Add dissector for CANopen protocol https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6651 with some modifications
svn path=/trunk/; revision=41394
2012-03-07 14:28:29 +00:00