Commit Graph

82 Commits

Author SHA1 Message Date
Anders Broman 2c5f2ac6f3 BER: Add a function to add a BER encoded boilerplate. 2022-03-29 11:23:07 +00:00
Guy Harris 1f595c435c BER: get rid of WTAP_FILE_TYPE_SUBTYPE_BER.
Save a copy of the pathname used to open a file in the wtap structure.
This allows the BER file reader to put a pointer to it in the
pseudo-header; it also would allow file readers to attempt to read
"associated" files that have the same name as the file, but with a
different extension.

Instead of having cf_open() special-case BER files, and calling a
routine in the BER dissector to specify the file name to the dissector,
have separate dissectors for "dissect packet payload as BER" and
"dissect a file as BER", and have the latter get the pathname of the
file from the pseudo-header and determine the ASN.1 syntax from that.

(Side-effect - this means that you can now dissect a BER file, and have
the syntax be determined by the file extension, in TShark as well; the
above cf_open() special-casing was *not* done in TShark, so it didn't
work before.  Now the application code doesn't need to do any of that,
so it works in TShark as well as Wireshark.)
2021-02-20 01:36:26 -08: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
Andre Luyer dbfb204f48 ber: display x509af.utcTime year in 4 digits
Because:
- the 2-digit year can only be in the range 1950..2049 according to
https://tools.ietf.org/html/rfc5280#section-4.1.2.5.1
- to avoid confusion, interpreting the year/month/day in a different order may
still represent a valid date.
- now both utcTime and GeneralizedTime are displayed in exactly the same way.
- some tools, like Perl, apply a different date range when converting 2-digit years.

In packet-ber.c two parameters are added to the function dissect_ber_UTCTime:
datestrptr: if not NULL return datetime string instead of adding to tree
or NULL when packet is malformed
tvblen: if not NULL return consumed packet bytes
Also the memory allocation for outstr is now done using the recommended method
as described in the README.developer document.

The calling function in x509af/x509sat uses this to prepend the century.
Added generated files.

Change-Id: I714c2e8e7f899211caaa1f4136ca0d27cb1aba4a
Reviewed-on: https://code.wireshark.org/review/35414
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
2020-01-11 18:36:35 +00:00
Guy Harris f72e504817 Dissect LDAP strings as UTF-8.
This requires some special hackery, including a new packet-ber.c
routine, as those strings are just OCTET STRINGs, not UTF8Strings.

Change-Id: I776ed47f7400eba366a630b60b94be3397f7b45f
Reviewed-on: https://code.wireshark.org/review/33403
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-05-28 04:11:35 +00:00
Anders Broman c2ac157ac0 ASN.1: Use proto_tree_add_bitmask... () for named bits.
Change-Id: Ied0c91ea070ee76603e7ecb29d874e0c1a65892e
Reviewed-on: https://code.wireshark.org/review/32684
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-04-03 14:53:08 +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
Guy Harris ab784d60b3 Rename new_dissector_t to dissector_t.
There are no longer any "old" dissectors, so "new_" is redundant.

Change-Id: I5fee51228c2a8562166f5991e1f30c2c697e45c8
Reviewed-on: https://code.wireshark.org/review/13273
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-14 01:03:10 +00:00
Michael Mann a33209d69e Convert ASN.1 dissectors to remove "new" from "new-style" dissector function names that were generated from asn2wrs.py
This includes:
1. new_create_dissector_handle -> create_dissector_handle
2. new_register_dissector -> register_dissector
3. new_register_ber_oid_dissector -> register_ber_oid_dissector
4. new_register_ber_syntax_dissector -> register_ber_syntax_dissector

Also remove PDU_NEW, SYNTAX_NEW and REGISTER_NEW as there is no need for the distinction anymore.

Change-Id: I82c7de7c8ffeeab3259d1b55bb4afc5f6a1e0329
Reviewed-on: https://code.wireshark.org/review/12491
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-12-10 17:06:02 +00:00
Michael Mann 0cd1a85064 Require BER dissector (OID) registration to be "new style".
Both old and new style API existed, just remove the "old" one.

Change-Id: If725e778a0ecad5a431d634ed5c4856b4a281013
Reviewed-on: https://code.wireshark.org/review/12107
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-11-25 19:21:14 +00:00
Michael Mann d1d5bf121e Replace proto_tree_add_text in dissector header files where it was used in a macro that should be expert info.
Change-Id: I045368a0a91586231fc4b1e2700c2275088b76af
Reviewed-on: https://code.wireshark.org/review/6244
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-01-02 22:11:34 +00:00
Maarten Bezemer 08c0247b78 Support dissecting REAL (BER) data values
Both exponent and 'integer N' values are limited:
 * max exponent is 3 octets/24-bits
 * max integer N is 8 octets/64-bit

Tested with zero value/length, integers, doubles, positive and negative numbers all using the Basic Encoding Rules (BER)

Change-Id: If92e1b3e209c42909b8cb76e6f50b8e6cd1da0da
Reviewed-on: https://code.wireshark.org/review/5527
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: Anders Broman <a.broman58@gmail.com>
2014-12-03 09:02:05 +00:00
Stig Bjørlykke d89cc1cf9a ASN1: Added support for using #.REGISTER_NEW
This will register BER PDU-dissectors as "new".
Return number of bytes dissected from dissector_try_* functions.
Return number of bytes dissected in DissectorTable:try()

This will make it possible to get dissected length when using
dissector_try_*() and dissected ASN.1 length in Lua when using
DissectorTable:try() (as we already have for Dissector:call).

Change-Id: Iee17a68dc214fa0fb50b25fc927026ad7c1cbce4
Reviewed-on: https://code.wireshark.org/review/4531
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-10-07 20:27:35 +00:00
Gerald Combs 9033f137a9 Revert "ASN1: Added support for using #.REGISTER_NEW"
This temporarily reverts commit
acc09c2aa2.

Change-Id: I7a55c8c2da3f65e914b90648ee92c84efd57f1a0
Reviewed-on: https://code.wireshark.org/review/4525
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-10-07 16:34:18 +00:00
Stig Bjørlykke acc09c2aa2 ASN1: Added support for using #.REGISTER_NEW
This will register BER PDU-dissectors as "new".
Return number of bytes dissected from dissector_try_* functions.
Return number of bytes dissected in DissectorTable:try()

This will make it possible to get dissected length when using
dissector_try_*() and dissected ASN.1 length in Lua when using
DissectorTable:try() (as we already have for Dissector:call).

Change-Id: I8802a812bd484c1e8794c618b87e676003aea94a
Reviewed-on: https://code.wireshark.org/review/4493
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-10-07 16:23:55 +00:00
Bill Meier b14bf98c06 Fix spelling: cant-->can't, wont-->won't, etc
Change-Id: I4497f1b8b6eab0e576d9dd31b732965f9a6679c6
Reviewed-on: https://code.wireshark.org/review/4124
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-09-16 13:51:51 +00:00
Stig Bjørlykke 79b401b7f4 Remove all old BER functions.
This should complete the transition to the "New" type.

Change-Id: I882b088206c6e6d0592159451c943caeaf5b90ec
Reviewed-on: https://code.wireshark.org/review/1202
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-04-18 21:44:28 +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
Michael Mann c0fcebb07a Add a data parameter to call_ber_oid_callback to be able to pass data to subdissectors found with dissector_try_string_new.
The intention is to aid in the removal of pinfo->private_data use as well as static global variables in a dissector.  For now, all calls to call_ber_oid_callback have the data parameter set to NULL.

svn path=/trunk/; revision=52994
2013-10-31 00:57:03 +00:00
Bill Meier 2ac134b3c5 whitespace fixes; mostly: remove trailing blanks
svn path=/trunk/; revision=52591
2013-10-13 19:56:52 +00:00
Michael Mann ee208c8dcc Add support for RELATIVE-OID ASN.1 type. Bug 9192 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9192)
From Ed Beroset.

svn path=/trunk/; revision=52393
2013-10-06 02:31:10 +00:00
Balint Reczey 1ebdb2e521 Export libwireshark symbols using WS_DLL_PUBLIC define
Also remove old WS_VAR_IMPORT define and related Makefile magic
everywhere in the project.

svn path=/trunk/; revision=47992
2013-03-01 23:53:11 +00:00
Jakub Zawadzki bf81b42e1e Update Free Software Foundation address.
(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536
2012-06-28 22:56:06 +00:00
Anders Broman b431591727 Get rod of " warning: identifier ‘class’ conflicts with C++ keyword"
svn path=/trunk/; revision=39945
2011-11-19 09:08:50 +00:00
Anders Broman 4b952c1324 Get rid of check_col, while at it set ENC.
svn path=/trunk/; revision=39146
2011-09-26 08:25:18 +00:00
Stig Bjørlykke 6a433058f9 Added check for SIZE constraints in bit-string.
svn path=/trunk/; revision=31447
2010-01-05 11:38:33 +00:00
Stig Bjørlykke e73a89d91a Added option (-C) to check for SIZE constraints in octet-string, integer,
enumerated, sequence-of and set-of types.

Added BER functions to check for SIZE constraints and give expert info warnings.

svn path=/trunk/; revision=31309
2009-12-18 15:18:31 +00:00
Stig Bjørlykke 76ba68775b Do not call a variable value_string as we have a struct with this name.
svn path=/trunk/; revision=26658
2008-10-31 18:42:53 +00:00
Stig Bjørlykke d255e44bfa From Martin Peylo (bug 2507):
The attached patch enables asn2wrs.py and packet-ber.c to decode UTCTime
according to the definitions in X.680.

svn path=/trunk/; revision=25897
2008-08-01 16:44:06 +00:00
Anders Broman de16039c51 Get rid of dissect_ber_boolean_value() and change the signature of
dissect_ber_boolean() to return a value and update asn2wrs to generate the new signature.
Regenerate all BER dissectors.

svn path=/trunk/; revision=24015
2008-01-04 16:21:07 +00:00
Anders Broman 73fee653de Get rid of ber_last_created_item(). (Final?)
svn path=/trunk/; revision=24010
2008-01-04 13:39:24 +00:00
Jörg Mayer b312e64f6a get_ber_length doesn't need the tree argument, get rid of it.
Rebuild asn1 dissectors.

svn path=/trunk/; revision=22627
2007-08-24 07:12:04 +00:00
Anders Broman 58f01d87cc Preparations for updated CMIP dissector:
- Export AE-title from ACSE
- Start REAL dissection(unfinished).

svn path=/trunk/; revision=22083
2007-06-12 21:29:27 +00:00
Anders Broman 4393bceae5 INAP:
- Use (some) IN CS4 asn1 files Q.1248.1 Q.1248.2 Q.1248.3

BER/asn2wrs:
-  Add basic support for EmbeddedPDVType

svn path=/trunk/; revision=22031
2007-06-03 19:58:59 +00:00
Anders Broman dca634c4de Prepare for the use of the new -X parameter for BER encoded protocols.
svn path=/trunk/; revision=21889
2007-05-22 16:17:54 +00:00
Anders Broman f08cd1e5e3 actx in the rest of dissect_ber..()l
svn path=/trunk/; revision=21773
2007-05-15 05:49:43 +00:00
Ronnie Sahlberg fc5ce01ee4 replace an incorrect '{' with ';' in the ber header file
change the signature for dissect_ber_external_type() to only provide the 
parameter actx once


svn path=/trunk/; revision=21756
2007-05-13 22:19:04 +00:00
Anders Broman 0bc558f88d actx in ber_external
svn path=/trunk/; revision=21755
2007-05-13 22:01:17 +00:00
Anders Broman c01f382974 Second step in introducing asn context to BER dissectors just like in PER.
svn path=/trunk/; revision=21753
2007-05-13 20:58:29 +00:00
Anders Broman 4c692a62b6 Start introducing actx to ber functions.
svn path=/trunk/; revision=21705
2007-05-06 22:34:05 +00:00
Anders Broman 83f17c25a7 Revert some private experiments checked in by misstake.
svn path=/trunk/; revision=21609
2007-04-28 14:47:43 +00:00
Anders Broman 2630b817b0 From Gavin Heer:
Here's a patch that decodes MMS(Manufacturing Messaging
Specification) when transported over COTP/TPKT/TCP.  Previously, MMS would only be decoded if the OSI Presentation Layers were present. Now MMS/COTP/TPKT/TCP is dissected.
With a change to use more functions from packet-ber

svn path=/trunk/; revision=21608
2007-04-28 14:38:53 +00:00
Guy Harris 1bc049906a Add some GCC warnings to the standard set, and add some others to the
--enable-extra-gcc-checks set.

If we turn on -pedantic, try turning on -Wno-long-long as well, so that
it's not *so* pedantic that it rejects the 64-bit integral data types
that we explicitly require.

Constify a bunch of stuff, and make some other changes, to get rid of
warnings.

Clean up some indentation.

svn path=/trunk/; revision=21526
2007-04-23 10:59:26 +00:00
Anders Broman 5954b97ac4 Add EXTERNAL to the value string and add comments about UNIVERSAL tags.
svn path=/trunk/; revision=21479
2007-04-20 13:54:56 +00:00
Graeme Lunt 2fd7d2c620 New "decode as ..." feature for BER-encoded files (WTAP_FILE_BER).
A BER-encoded file can be dissected as one of a number of registered syntaxes (registered using register_ber_syntax_dissector()). 
Syntaxes may also be associated with OIDs (or other strings) using register_ber_oid_syntax(). 

A default syntax with which to dissect a BER-encoded file is determined from its filename (extension). For example, ".cer" and ".crt" files will be dissected as "Certificate".


svn path=/trunk/; revision=20414
2007-01-13 12:59:27 +00:00
Graeme Lunt e15d91a592 General updates to:
*) Remove maximum LDAP PDU size check - they can get large with either large attributes (e.g. CRLs, SPIFs) or with lots of results (see http://www.wireshark.org/lists/wireshark-users/200610/msg00197.html). The max size preference is also removed.
*) Support for dissecting LDAP controls including server side sorting and paged results. A new BER function is introduced to see if there is a dissector for a given OID.
*) Remove reference to removed BER preference in the LDAP reassembly preference.
*) Mark a LDAPURL as a URL


svn path=/trunk/; revision=19792
2006-11-04 09:14:54 +00:00
Ronnie Sahlberg d0aae6dd3e from metze
prettify dissection of filters containing substring and extensiblematch



svn path=/trunk/; revision=18617
2006-06-29 21:04:37 +00:00
Tomas Kukosa 56d7db0c08 remove functions register_ber_oid_name() and get_ber_oid_name() from packet-ber.c, they were only OID but not BER related
use add_oid_str_name() and get_oid_str_name() instead of them

svn path=/trunk/; revision=18595
2006-06-28 14:19:08 +00:00
Tomas Kukosa f0f319acf1 - BER_MAX_OID_STR_LEN removed and replaced with MAX_OID_STR_LEN
- x411 and dop regenerated
- dissect_ber_tagged_type() prepared (support in asn2wrs will follow)

svn path=/trunk/; revision=18468
2006-06-15 07:46:07 +00:00
Ronnie Sahlberg feab79e328 change a whole bunch of ethereal into wireshark
svn path=/trunk/; revision=18196
2006-05-21 04:49:01 +00:00