Commit Graph

118 Commits

Author SHA1 Message Date
Martin Mathieson e0300eaed8 Fix lots of spellings 2024-02-25 22:46:47 +00:00
Stig Bjørlykke 2a9bc63325 Remove init of proto variables
Remove init of proto, header field, expert info and subtree variables.
This will reduces the binary size by approximate 1266320 bytes due to
using .bss to zero-initialize the fields.

The conversion is done using the tools/convert-proto-init.py script.
2023-11-20 08:20:54 +01:00
Stig Bjørlykke 34d9cc68a1 dissectors: Remove init of hf and ett variable arrays
Manually remove init of hf and ett variable arrays because this
cannot be easily done using the convert script.
2023-11-17 07:41:44 +00:00
David Perry 5468611d57 Use `register_dissector()` for more protocols
Changes several calls of `create_dissector_handle()` to instead call
`register_dissector()` with a name for the dissector.

This should handle all dissectors in `epan/` from `packet-a*` to
`packet-d*`.

This change allows affected dissectors to be findable by calls to
`find_dissector()`. In turn, this opens up more command-line use for
these protocols, including fuzzshark and rawshark, as well as lua use
via `Dissector.get()`.

Where needed, move the call from the protocol handoff function to the
protocol register function, and use `find_dissector()` in the handoff
function.

There were some calls to `create_dissector_handle()` or
`register_dissector()` which passed `-1` as the protocol argument. When
I saw those I corrected them to pass the actual `proto_foo` identifier
instead.

Partially addresses #5612
2023-05-16 08:18:10 +00:00
John Thacker e6d81e8731 ANSI IS-637 A: Use tvb_new_octet_aligned for addresses
Use tvb_new_octet_aligned when adding addresses (strings or bytes)
that are not byte aligned. That is not only clearer code, but also
prevents attempting to add unvalidated strings.

Since we're aligning the fields properly, get rid of the extra
fields for the MSB of the first field and LSB of the last field.

Fix #18664
2022-11-23 07:01:19 -05:00
John Thacker fa1d908f9e gsm_sms: Use character_set enum when decoding DCS and TP-UD
Rather than using three mutually exclusive booleans for the
encoding, use the existing enum, adding entries to distinguish
UCS2 from 8 bit binary and to support GSM 7-bit unpacked in a
more natural way.
2022-06-10 12:58:31 +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
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
Martin Mathieson 678914ca0b Fix some item lengths.
As seen by tools/check_type_item_lengths.py
2021-03-29 05:30:27 +00:00
John Thacker e20bd408de Use iconv to support GB 18030 and EUC-KR, allow future encodings
Add support internally to using iconv (always present with glib) to convert
strings from various encodings to UTF-8 (using REPLACEMENT CHARACTER as
recommended), and use that to support GB 18030 and EUC-KR. Replace call
directly to iconv in ANSI 637 for EUC-KR to new API. Update comments
and documentation around character encodings. It is possible to replace
the calls to iconv with an internal decoder later. Tested on Linux and
on Windows (including with illegal characters). Closes #16630.
2020-10-21 11:26:23 +00:00
Guy Harris c597927da8 Add some more string encodings.
Add an encoding for "unpacked" 3GPP TS 23.038 7-bit strings, in which
each code position is in a byte of its own, rather than with the code
positions packed into 7 bits.  Rename the packed encoding to explicitly
indicate that it's packed.

Add an encoding for ETSI TS 102 221 Annex A strings.

Use the new encodings.
2020-09-28 22:30:35 +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
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
Michael Mann 51a3014225 format_text_wmem -> format_text
All cases of the "original" format_text have been handled to add the
proper wmem allocator scope.  Remove the "original" format_text
and replace it with one that has a wmem allocator as a parameter.

Change-Id: I278b93bcb4a17ff396413b75cd332f5fc2666719
Reviewed-on: https://code.wireshark.org/review/19884
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-01-31 17:08:47 +00:00
Michael Mann d802b5b0ec Add format_text_wmem.
This allows for a wmem_allocator for users of format_text who want
it (dissectors for wmem_packet_scope()).  This lessens the role of
current format_text functionality in hopes that it will eventually
be replaced.

Change-Id: I970557a65e32aa79634a3fcc654ab641b871178e
Reviewed-on: https://code.wireshark.org/review/19855
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-01-31 02:26:35 +00:00
Pascal Quantin 3b1d991371 ANSI IS-637 A: fix decoding of IA5 SMS
Give the right buffer to the decoding function

Bug: 13065
Change-Id: I0e41e04fb68602d95ea6f060c1a37c8b8596134d
Reviewed-on: https://code.wireshark.org/review/18548
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2016-10-28 12:47:01 +00:00
Guy Harris a4c8ebc18b Don't do any Decode As stuff for dissector tables not used with Decode As.
Have all dissector tables have a "supports Decode As" flag, which
defaults to FALSE, and which is set to TRUE if a register_decode_as()
refers to it.

When adding a dissector to a dissector table with a given key, only add
it for Decode As if the dissector table supports it.

For non-FT_STRING dissector tables, always check for multiple entries
for the same protocol with different dissectors, and report an error if
we found them.

This means there's no need for the creator of a dissector table to
specify whether duplicates of that sort should be allowed - we always do
the check when registering something for "Decode As" (in a non-FT_STRING
dissector table), and just don't bother registering anything for "Decode
As" if the dissector table doesn't support "Decode As", so there's no
check done for those dissector tables.

Change-Id: I4a1fdea3bddc2af27a65cfbca23edc99b26c0eed
Reviewed-on: https://code.wireshark.org/review/17402
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-08-31 00:08:01 +00:00
Pascal Quantin e65ab3cd94 ANSI IS-637 A: fix display of reserved bits when using 7bits GSM encoding
Change-Id: Ida59c339d174e8f9a3b8bf108374875d12c51b21
Reviewed-on: https://code.wireshark.org/review/15153
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2016-04-29 05:48:32 +00:00
Joerg Mayer 8f3ad91905 Fix some warnings/errors of type
git/epan/dissectors/packet-a21.c:478:25: error: 'item' was marked unused but was used
      [-Werror,-Wused-but-marked-unused]
        proto_item_append_text(item, "%s", val_to_str_const(event_id, a21_event_vals, "Unknown"));
                               ^
Added manual change id because file-jpeg.c forced the use of commit -n

Change-Id: Iffff53d6253758c8454d9583f0a11f317c8390cb

Fix warnings/errors of type:
git/epan/dissectors/packet-ax25-kiss.c:205:52: error: 'pseudo_header' was marked unused but was
      used [-Werror,-Wused-but-marked-unused]
                        return capture_ax25( pd, l_offset, len, cpinfo, pseudo_header );

Fix checkhf warnings:
Unused entry: epan/dissectors/packet-artnet.c, hf_artnet_address_netswitch
Unused entry: epan/dissectors/packet-artnet.c, hf_artnet_address_subswitch
Unused entry: epan/dissectors/packet-artnet.c, hf_artnet_poll_reply_trailer
Unused entry: epan/dissectors/packet-artnet.c, hf_artnet_rdm_universe
Unused entry: epan/dissectors/packet-artnet.c, hf_artnet_tod_data_universe

Change-Id: Id1fa12afb97a8e9cd4ed0ea25351c3b2639c930e
Reviewed-on: https://code.wireshark.org/review/14667
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
2016-03-28 12:46:31 +00:00
Michael Mann e37275bfde Associate dissector tables and heuristic subdissector lists with a protocol.
This will make it easier to determine protocol dependencies.

Some LLC OUI dissector tables didn't have an associated protocol, so they were left without one (-1 used)

Change-Id: I6339f16476510ef3f393d6fb5d8946419bfb4b7d
Reviewed-on: https://code.wireshark.org/review/14446
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-03-17 00:05:17 +00:00
Michael Mann 31a54708f4 new_register_dissector -> register_dissector for dissector directory.
Change-Id: Ie39ef054a4a942687bd079f3a4d8c2cc55d5f22c
Reviewed-on: https://code.wireshark.org/review/12485
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-12-09 12:38:06 +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 01f7356f85 register_dissector -> new_register_dissector
Picking off "easy" dissectors that only have one or two exit points at most.

Change-Id: I3d5e576b796556ef070bb36d8b55da0b175dcba8
Reviewed-on: https://code.wireshark.org/review/11805
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-11-13 17:44:24 +00:00
Michael Mann 74541a9596 Don't allow multiple registrations of a protocol in dissector tables.
The target here is the Decode As dialog where protocols have multiple registrations into a dissector table and that shows up as multiple entries in the Decode As dialog list with the same name so users are unsure which "dissector" they are choosing.

The "default" behavior (done in this commit) is to not allow duplicates for a dissector table, whether its part of Decode As or not.  It's just ENFORCED for Decode As.

Bug: 3949
Change-Id: Ibe14fa61aaeca0881f9cc39b78799e314b5e8127
Reviewed-on: https://code.wireshark.org/review/11405
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-11-04 12:39:40 +00:00
Pascal Quantin c8f87842cb ANSI A: fix dissection of numerous fields broken in g7298a31
Change-Id: I09898cfc1aedc4b8067c6d12c94effc51a5ebbc0
Reviewed-on: https://code.wireshark.org/review/10345
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-09-01 19:23:52 +00:00
Michael Mann 7298a31687 Eliminate proto_tree_add_text from ANSI dissectors.
Change-Id: I22dccb2f2d71897334e11632f4060ccfbf4794ad
Reviewed-on: https://code.wireshark.org/review/10334
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-09-01 04:10:06 +00:00
Michael Mann 2e2129a914 Conversion of random proto_tree_add_text calls.
Change-Id: I6505ce34de84bfe46d5bc7b4d6a3c6044f3fb4b5
Reviewed-on: https://code.wireshark.org/review/10041
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-08-16 02:32:12 +00:00
Pascal Quantin 6c58665540 ANSI IS-637 A: fix byte highlighting of destination address when using ASCII encoding
Change-Id: I11d5de26bd73bada742e808f582e0dd746032aa2
Reviewed-on: https://code.wireshark.org/review/8684
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-05-29 12:08:11 +00:00
Pascal Quantin 82503258ff ANSI IS-637 A: dump bytes when SMS encoding format is set to octet
Change-Id: I3d8a72a9549d170e0b1d54ad930da8c9dd510134
Reviewed-on: https://code.wireshark.org/review/8663
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-05-27 15:56:19 +00:00
Pascal Quantin 3b9cf24be6 ANSI IS-637 A: add dissection of Multiple Encoding User Data and Service Category Program Data
Bug: 11086
Change-Id: I36096d35038bc71191040514a38dcdf9e1373f31
Reviewed-on: https://code.wireshark.org/review/7840
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-03-30 06:06:35 +00:00
Pascal Quantin 123be13127 ANSI IS-637 A: ensure that num_fields is not null before calling text_decoder
Bug: 11014
Change-Id: Id2c7913d96743424380bd75c4005ec747ee7dd50
Reviewed-on: https://code.wireshark.org/review/7412
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-02-26 16:36:45 +00:00
Pascal Quantin d7538cbe4b ANSI IS-637-A: prevent an out of bounds access
Bug: 10897
Change-Id: I8316ba40ec00b612e4edd490e3cd36e7277912a9
Reviewed-on: https://code.wireshark.org/review/6824
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2015-01-28 10:06:25 +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
Michael Mann d65b7d5cd2 Eliminate proto_tree_add_text from GSM_SMS dissector.
Change-Id: Ibe189239735da2ebb1b0ce61a5af249975b38be3
Reviewed-on: https://code.wireshark.org/review/4402
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-10-01 13:37:51 +00:00
Pascal Quantin e179870a12 ANSI IS-637 A: remove a useless variable
Change-Id: I50077329d6e78ca39312e72eb04b7a5db85b977b
Reviewed-on: https://code.wireshark.org/review/4301
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-09-26 08:57:32 +00:00
Pascal Quantin 7c54eb23e5 ANSI IS-637 A: get rid of tvb_length() deprecated API
Change-Id: I40de03605c051024c604679a1e141afa841a77e9
Reviewed-on: https://code.wireshark.org/review/4287
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-09-25 16:11:57 +00:00
Pascal Quantin e520b2b800 ANSI IS-637-A: fix dissection of fragmented Unicode SMS
The computation of the number of characters available was wrong when the User Data Header is present

Change-Id: I2809c1460316530654a997b26cfc33c60a32fd6f
Reviewed-on: https://code.wireshark.org/review/4284
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-09-25 15:36:37 +00:00
Michael Mann 188aa9a80e convert to proto_tree_add_subtree[_format]
Change-Id: Ib60ca75b7da8cfa21cfe2999c9b9448a02c332df
Reviewed-on: https://code.wireshark.org/review/2560
Tested-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-06-22 21:07:16 +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
Michael Mann 73217d9f3f tvb_new_subset -> tvb_new_subset_length when length parameters are equal.
tvb_new_subset -> tvb_new_subset_remaining it appears that's what the intention is.

Change-Id: I2334bbf3f10475b3c22391392fc8b6864454de2d
Reviewed-on: https://code.wireshark.org/review/1999
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-06-07 15:41:07 +00:00
Pascal Quantin cfe11b1097 Add ENC_ASCII_7BITS encoding
Change-Id: I01ec87ff4181afb5b2de487fd5f5200f8d62f17d
Reviewed-on: https://code.wireshark.org/review/1088
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-04-13 20:02:52 +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
Guy Harris ea1d5c151e Use proto_tree_add_item() for most string encodings.
We support ISO 8859-1 and 8859-8, so use proto_tree_add_item() for them.
That leaves only EUC-KR.

Change-Id: Ie61f69af43be03e5abeb84b95601a407900fb79b
Reviewed-on: https://code.wireshark.org/review/403
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-02-26 10:17:22 +00:00
Guy Harris 205a9f9b50 Use tvb_get_string_enc() rather than tvb_get_string(); according to
TIA/EIA-637-A, call-back numbers are either BCD or ASCII.

svn path=/trunk/; revision=54917
2014-01-22 22:37:08 +00:00
Pascal Quantin eabf15f80a Fix dissection of 3GPP2 SMS encoded in UCS2
svn path=/trunk/; revision=54787
2014-01-14 16:23:38 +00:00
Alexis La Goutte 86f6c85860 Fix Dead Store (Dead assignement/Dead increment) warning found by Clang
svn path=/trunk/; revision=54731
2014-01-13 22:25:03 +00:00
Pascal Quantin 70dc6197ec From Michael Lum via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9472 :
ANSI IS-637 SMS enhancements for CMAS (TIA-1149) and header dissection

svn path=/trunk/; revision=54684
2014-01-09 21:58:09 +00:00
Pascal Quantin 6ebc058f47 Add proto_tree_add_ts_23_038_7bits_item() / tvb_get_ts_23_038_7bits_string() functions and update dissectors to use it.
Remove gsm_sms_char_7bit_unpack() / gsm_sms_chars_to_utf8() functions.
Update documentation a bit.

svn path=/trunk/; revision=54534
2014-01-01 14:33:19 +00:00