Commit Graph

161 Commits

Author SHA1 Message Date
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
Guy Harris cb16dff992 Get rid of more tvb_get_nstringz* calls.
Add an FT_STRINGZPAD type, for null-padded strings (typically
fixed-length fields, where the string can be up to the length of the
field, and is null-padded if it's shorter than that), and use it.  Use
IS_FT_STRING() in more cases, so that less code needs to know what types
are string types.

Add a tvb_get_stringzpad() routine, which gets null-padded strings.
Currently, it does the same thing that tvb_get_string_enc() does, but
that might change if we don't store string values as null-terminated
strings.

Change-Id: I46f56e130de8f419a19b56ded914e24cc7518a66
Reviewed-on: https://code.wireshark.org/review/1082
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-04-12 22:27:22 +00:00
Alexis La Goutte 58a6487b54 Add WS_DLL_PUBLIC for p_remove_proto_data and tvb_child_uncompres function
Change-Id: If043683f366fedd849688ca3c512707954221a3b
Reviewed-on: https://code.wireshark.org/review/984
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-04-07 04:09:10 +00:00
Bill Meier c0b0a11e4e (Pedantic): set editor modelines tab-width & etc to 8; Also: fix some indentation in packet-sip.c
Change-Id: I623fc5e4c1247dbe5e15f0f33270f4f0994268ab
Reviewed-on: https://code.wireshark.org/review/943
Reviewed-by: Bill Meier <wmeier@newsguy.com>
Tested-by: Bill Meier <wmeier@newsguy.com>
2014-04-03 15:31:56 +00:00
Guy Harris e2ed48a8d3 Have NFLOG TLV type and length be in host byte order.
When capturing, they'll be in host byte order.  The top of the libpcap
trunk and 1.5 branch, when reading a file, will, if necessary, byte-swap
the type and length values so that they're in the byte order of the host
reading the file (rather than the host that wrote the file).

Do the same when we read a file, and have the NFLOG dissector assume
host byte order for those fields.

Change-Id: I493aed1e07b626af1157d75f3bc293b0a694ad07
Reviewed-on: https://code.wireshark.org/review/148
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-06 05:53:08 +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 46d8abe252 Document tvb_memdup() in more detail.
Change-Id: Iec94342b7d033fb6e8597bbffea563128182316b
Reviewed-on: https://code.wireshark.org/review/417
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-02-26 22:28:48 +00:00
Guy Harris a8ef66f250 Regularize the formatting of some comments.
Change-Id: I1009c75d5a4f074767dbc3600e7a6edfd0031460
Reviewed-on: https://code.wireshark.org/review/416
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-02-26 22:25:00 +00:00
Guy Harris 5de2dacde8 Fix a copy-and-pasteo.
Change-Id: Ied8830e2e7a689197870a4d839fd08b36546c75f
Reviewed-on: https://code.wireshark.org/review/414
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-02-26 22:23:04 +00:00
Guy Harris 910949ce84 Some g_free() -> wmem_free() changes missed in earlier checkins.
Change-Id: I5858e0ee8fc8584b35145c943e19e8e5f7dba77c
Reviewed-on: https://code.wireshark.org/review/413
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-02-26 22:15:03 +00:00
Guy Harris 8d234a0d8c More tvbuff API deprecation, comment expansion, and documentation updates.
Do with tvb_get_stringz() what was done with tvb_get_string().

Redo the comments for the string get routines to try to give more detail
in a fashion that's a bit less hard to read.

Warn, in comments, of the problems with using
tvb_get_string()/tvb_get_stringz() (i.e., if your strings are non-ASCII,
all bytes with the 8th bit set are going be replaced by the Unicode
REPLACEMENT CHARACTER, and displayed as such).

Warn, in a comment, of the problems with tvb_get_const_stringz() (i.e.,
it gives you raw bytes, rather than guaranteed-to-be-valid UTF-8).

Update documentation and release notes appropriately.

Change-Id: Ibd3efb92a203861f507ce71bc8d04d19d9d38a93
Reviewed-on: https://code.wireshark.org/review/327
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-02-26 22:04:08 +00:00
Evan Huus 22149c5523 TVB API deprecations and cleanup
- rename tvb_length and similar to tvb_captured_length and similar; leave
  #defines in place for backwards-compat, but mark them clearly as deprecated in
  code comments and in checkAPI
- remove tvb_get_string as C code and just leave a #define in place for
  backwards-compat; mark it clearly as deprecated in code comment and checkAPI
- update READMEs and sample dissector for all of the above
- while in the neighbourhood, make checkAPI skip (and warn) for missing files
  instead of bailing on the whole check, so subsequent files still get checked

Change-Id: I32fc437896ca86ca73e9b49d5f50400adf8ec5ad
Reviewed-on: https://code.wireshark.org/review/311
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-02-22 15:02:01 +00:00
Guy Harris 4d9475e4ef Get rid of tvb_get_faked_unicode() - tvb_get_string_enc() does the job
better.

We don't need eventlog_get_unicode_string_length() in the eventlog
dissector, either - tvb_unicode_strsize() does the job just as well.

svn path=/trunk/; revision=54874
2014-01-21 09:56:34 +00:00
Guy Harris 45d5b74219 Fix declaration of tvb_get_string().
svn path=/trunk/; revision=54870
2014-01-21 01:44:58 +00:00
Guy Harris 9cdf8dd5f5 Don't do the byte-with-8th-bit-set-to-REPLACEMENT-CHARACTER mapping for
UTF-8 strings.

Add that mapping for null-terminated ASCII strings.

Factor out some common parts of comments about string routines, and
clean up some other comments.

svn path=/trunk/; revision=54868
2014-01-21 01:23:29 +00:00
Martin Kaiser 933e95c8ec tvb_get_string(): replace 8bit characters with the unicode replacement char
svn path=/trunk/; revision=54864
2014-01-20 21:39:00 +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
Jakub Zawadzki a65cbe8e7b Add new function: tvb_skip_guint8()
svn path=/trunk/; revision=54505
2013-12-30 23:58:45 +00:00
Bill Meier e348c13deb (Trivial)
- Minor whitespace changes;
- Fix a typo;
- Add editor modelines to tnbuff_subset.c

svn path=/trunk/; revision=54364
2013-12-22 15:47:17 +00:00
Jakub Zawadzki 576c7eae45 Move base64_to_tvb() to tvbuff_base64.c
svn path=/trunk/; revision=54325
2013-12-21 14:33:54 +00:00
Guy Harris 92f177ec97 Get rid of tvb_get_unicode_string() and tvb_get_unicode_stringz();
instead, have static routines to get UCS-2 (no surrogate pairs) and
UTF-16 (with surrogate pairs) strings, with the routines to handle
UTF-16 actually handling surrogate pairs.

Update some out-of-date comments while we're at it.

svn path=/trunk/; revision=54318
2013-12-21 01:42:41 +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
Evan Huus 8f665d9b36 Add a sixteenth element to all BCD digit sets to avoid garbage values when
decoding corrupt bytes. Some of these digit sets could probably be
deduplicated...

svn path=/trunk/; revision=54224
2013-12-18 15:54:32 +00:00
Michael Mann 79d336c664 Handle signed integers > 32 bits. Bug 8454 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8454)
svn path=/trunk/; revision=54183
2013-12-17 16:50:33 +00:00
Jakub Zawadzki 617f2eddef Remove <epan/ipv6-utils.h> from tvbuff.
svn path=/trunk/; revision=53221
2013-11-10 12:31:17 +00:00
Jakub Zawadzki 8b73d378a4 exceptions.h not needed by tvbuff.h (no much progress because it's needed by proto.h)
svn path=/trunk/; revision=53219
2013-11-10 11:48:03 +00:00
Jakub Zawadzki f207c70075 I have added tvb_get_bits_buf() in r37217, nobody is using it, remove.
svn path=/trunk/; revision=53183
2013-11-09 10:08:58 +00:00
Chris Maynard f1a3e8634f Try to clarify the documentation for tvb_length_remaining() and tvb_reported_length_remaining() based on Jörg's recommendation from bug 9263.
svn path=/trunk/; revision=53070
2013-11-03 18:02:17 +00:00
Chris Maynard a95614a79c Make declarations consistent, fix typos, remove tabs, use consistent indentation, wrap text at column 80, add modelines.
svn path=/trunk/; revision=53004
2013-10-31 17:30:22 +00:00
Evan Huus cbe8af0a8b Revert the optimization in r52578. As Jakub predicted, it caused at least one
infinite loop to pop up. We're just going to have to eat the performance hit.
(https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9282)

svn path=/trunk/; revision=52660
2013-10-17 12:24:25 +00:00
Evan Huus efdbb598b8 So a while back Jeff added some code to check that the offset+length passed to
proto_tree_add_item was valid *before* we short-circuited based on a NULL tree.
This was good in that it removed a common source of really-long-loop bugs. It
was less good in that it cost us about 8% in speed when doing a tree-less
dissection, but we decided the tradeoff was worth it.

After Anders' recent mail to -dev about performance, I started thinking about
how to optimize this. It occurred to me that the vast majority of the logic
involved in the check was dealing with the length value - fetching the actual
length if it was a counted string, calculating the length if it was -1, adding
the length to the offset in a way that was free from overflows, etc.

All of this is (theoretically) unnecessary - simply checking the offset without
worrying about the length will still catch the very-long-loops, since it is the
offset that increases in each iteration, not the length.

All that to justify:
- implement tvb_ensure_offset_exists which throws an exception if the offset is
  not within the tvb
- use it instead of all the complicated other logic in the pre-short-circuit
  step of proto_tree_add_item and friends

This gives us back about 3/4 of the performance we lost in the original patch.
We're still ~2% slower than without any check, but this is the best I can think
of right now.

svn path=/trunk/; revision=52578
2013-10-13 04:54:14 +00:00
Chris Maynard b610734a12 If the offset is out of bounds, have tvb_length_remaining() and tvb_reported_length_remaining() return 0 instead of -1. This should provide a better long-term fix for bugs/problems such as seen in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9263. In the long-run, if we like this behavior, we can change the return value to a guint as well. Let's let it simmer for awhile first ...
svn path=/trunk/; revision=52571
2013-10-12 18:13:26 +00:00
Pascal Quantin 102c452bcb More emem -> wmem conversion:
- tvb_get_g_stringz()/tvb_get_ephemeral_stringz()/tvb_get_seasonal_stringz() -> tvb_get_stringz()
- tvb_get_g_stringz_enc()/tvb_get_ephemeral_stringz_enc() -> tvb_get_stringz_enc()
- tvb_get_ephemeral_unicode_stringz() -> tvb_get_unicode_stringz()
- tvb_bcd_dig_to_ep_str() -> tvb_bcd_dig_to_wmem_packet_str()
- update docs accordingly

svn path=/trunk/; revision=52180
2013-09-22 20:04:35 +00:00
Pascal Quantin a0c53ffaa1 emem -> wmem conversion:
- ep_tvb_get_bits() -> wmem_packet_tvb_get_bits()
- tvb_g_memdup()/ep_tvb_memdup() -> tvb_memdup()
- tvb_fake_unicode()/tvb_get_ephemeral_faked_unicode() -> tvb_get_faked_unicode()
- tvb_get_g_string()/tvb_get_ephemeral_string()/tvb_get_seasonal_string() -> tvb_get_string()
- tvb_get_g_unicode_string()/tvb_get_ephemeral_unicode_string() -> tvb_get_unicode_string()
- tvb_get_ephemeral_string_enc() -> tvb_get_string_enc()
- update docs accordingly

svn path=/trunk/; revision=52172
2013-09-22 15:50:55 +00:00
Evan Huus 6df83e8078 Add _g_ to the names of functions that allocate glib memory. This is a bit more
explicit, and frees up the "generic" names (like tvb_memdup) for new signatures
that take the appropriate wmem pool.

Majority of the conversion done with sed.

svn path=/trunk/; revision=52164
2013-09-21 17:04:41 +00:00
Pascal Quantin 50815e08e4 Update a comment with the correct memory allocator type
svn path=/trunk/; revision=51615
2013-08-31 15:30:07 +00:00
Jakub Zawadzki c766e78cfa Rewrite reassemble API to use TVBs instead of raw data.
(it seems to be working for TCP ^^)

svn path=/trunk/; revision=50580
2013-07-14 14:42:05 +00:00
Guy Harris 1f32615d99 Export tvb_free_chain() so that tvbtest can use it.
As on Windows with MSVC, and as with reassemble_test, link tvbtest with
libwireshark and the libraries it requires.

svn path=/trunk/; revision=50575
2013-07-14 10:30:49 +00:00
Jakub Zawadzki ef93945811 Add support for cloning TVBs, move tvb_new() prototype to wtap-int.h
svn path=/trunk/; revision=50558
2013-07-13 17:53:33 +00:00
Jakub Zawadzki 97456cde01 Fix two problems in tvbuff.h
svn path=/trunk/; revision=50499
2013-07-11 06:08:28 +00:00
Jakub Zawadzki ce81449ed9 packet dissection now takes pointer to tvb instead of guint8 data
implement frame_tvbuff, right now almost a copy of 'real' tvb.

svn path=/trunk/; revision=50497
2013-07-11 05:47:02 +00:00
Jakub Zawadzki f3ed13c22e tvbuff: replace type with operation vtable
It's begin of work to allow adding new tvbuff types (think: wtap_tvbuff, base64_tvbuff).

svn path=/trunk/; revision=50486
2013-07-10 18:14:15 +00:00
Gerald Combs d14fa4914d Add Doxygen boilerplate for some of our core modules and data structures.
svn path=/trunk/; revision=49640
2013-05-30 22:20:21 +00:00
Guy Harris 0efcd0632b When we're dissecting the beginning of a fragmented packet that we
haven't reassembled, we're probably moving sequentially through the
packet, which means that we'll run past the end of the fragment rather
than past the end of what would have been the reassembled packet had we
reassembled it.

I.e., there's little reason to care whether we're past the end of the
fragment but not past the end of the packet, or whether we're past the
end of the packet; in either case, we're past the end of the fragment,
and if somebody wants to know whether the packet is malformed by
stopping short of certain fields, they should enable reassembly.

So we get rid of the explicit fragment length in tvbuffs and, instead,
have a "this is a fragment" flag; if that flag is set, we throw
FragmentBoundsError rather than ReportedBoundsError if we run past the
end of the reported data.

(This also means we could flag the tvbuff even if we don't know how
large the reassembled packet will be, e.g. when doing IP reassembly.)

Replace tvb_new_subset_length_fragment() with tvb_new_subset_length()
and a new "set the "this is a fragment flag"" routine.

svn path=/trunk/; revision=48940
2013-04-20 02:53:57 +00:00
Guy Harris c0c15029ed Add to tvbuffs a "fragment length" field; if the tvbuff represents the
first fragment of a non-reassembled packet, and we know the length the
packet would have if it were reassembled, this field holds the length of
the fragment, and the "reported length" field shows the length the
packet would have if it were reassembled, so going past the end of the
fragment but staying within the length of the reassembled packet can be
reported as "dissection would have worked if the packet had been
reassembled" rather than "the packet is too short, so it was probably
malformed".

Add a FragmentBoundsError exception, thrown in the "dissection would
have worked if the packet had been reassembled" case.

Add a new tvb_new_subset_length_fragment() routine to create a new
subset tvb with specified fragment and reported lengths.  Use it in the
CLNP dissector.

Add some more sanity checks in the CLNP dissector.

svn path=/trunk/; revision=48917
2013-04-18 19:22:24 +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
Bill Meier 96a24cc79f Fix spelling/typos found using a list of commonly misspelled words.
The misspellings were mostly in comments but some were
in text strings visible to the user.


svn path=/trunk/; revision=47899
2013-02-26 04:42:26 +00:00
Guy Harris 67e692da1c Add a tvb_new_subset_length() that takes a tvbuff, an offset in a
tvbuff, and a length from that offset, and returns a subset tvbuff
referring to that data (or throws an exception).  This does what most if
not all calls to tvb_new_subset() (other than the ones that really
should be calls to tvb_new_subset_remaining()) should be doing, i.e.
setting the reported length of the tvbuff to the specified length and
calculating the appropriate value of the captured length based on that.

We aren't using it yet, but we will....

svn path=/trunk/; revision=47768
2013-02-20 08:10:14 +00:00
Guy Harris 5f5e1085ea Reflect that tvb_new() is now an internal routine.
svn path=/trunk/; revision=47756
2013-02-20 00:57:10 +00:00
Guy Harris 75168f6bf7 No more tvb_new(), so no more need for tvb_set_real_data() or
tvb_set_subset(); code should use tvb_new_real_data() and various
tvb_new_subset routines.  (Neither tvb_new() nor tvb_set_real_data() nor
tvb_set_subset() were exported in libwireshark.def, nor were they used
outside tvbuff.c; tvb_set_real_data() and tvb_set_subset() weren't even
being used *inside* tvbuff.c.)

svn path=/trunk/; revision=47753
2013-02-20 00:09:41 +00:00