summaryrefslogtreecommitdiff
path: root/epan/tvbuff.h
AgeCommit message (Collapse)AuthorFilesLines
2017-01-31Have tvb_format_text use wmem_packet_scope() memory.Michael Mann1-1/+2
It's only use is in dissectors or other tree creation APIs (where packet scope is valid), so have it use format_text_wmem with wmem_packet_scope(). Change-Id: I1f34e284a870c9844c6b27f4ae08a1e7efe54098 Reviewed-on: https://code.wireshark.org/review/19883 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>
2017-01-31Have tvb_format_stringzpad use wmem_packet_scope() memory.Michael Mann1-1/+2
It's only use is in dissectors, so have it use format_text_wmem with wmem_packet_scope(). Change-Id: I22121324fd47aee32174b65104458ad2ef329bd7 Reviewed-on: https://code.wireshark.org/review/19856 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-01-30Have format_text_wsp use wmem allocated memory.Michael Mann1-2/+2
format_text_wsp is fed into by tvb_format_text_wsp and tvb_format_stringzpad_wsp so those functions need to add a wmem allocated parameter as well. Most of the changes came from tvb_format_text_wsp and tvb_format_stringzpad_wsp being changed more so than format_text_wsp. Change-Id: I52214ca107016f0e96371a9a8430aa89336f91d7 Reviewed-on: https://code.wireshark.org/review/19851 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-13Decode TBCD strings in GSM MAP as per the GSM MAP spec.Guy Harris1-1/+2
Hex digits 0xa through 0xe are '*', '#', 'a', 'b', and 'c', respectively. Constify the dgt_set_t argument to tvb_bcd_dig_to_wmem_packet_str(), while we're at it. Bug: 13316 Change-Id: I7586f35d23fd262453779d99946e7ccad4b6ffab Reviewed-on: https://code.wireshark.org/review/19620 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-01-10Rename tvb_new_subset() to tvb_new_subset_length_caplen().Guy Harris1-4/+4
This emphasizes that there is no such thing as *the* routine to construct a subset tvbuff; you need to choose one of tvb_new_subset_remaining() (if you want a new tvbuff that contains everything past a certain point in an existing tvbuff), tvb_new_subset_length() (if you want a subset that contains everything past a certain point, for some number of bytes, in an existing tvbuff), and tvb_new_subset_length_caplen() (for all other cases). Many of the calls to tvb_new_subset_length_caplen() should really be calling one of the other routines; that's the next step. (This also makes it easier to find the calls that need fixing.) Change-Id: Ieb3d676d8cda535451c119487d7cd3b559221f2b Reviewed-on: https://code.wireshark.org/review/19597 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-10-08add tvb_find_guint16() utilityFrancesco Fondelli1-0/+3
Change-Id: I75c0165948325c2e50918706d8a821411761727b Signed-off-by: Francesco Fondelli <francesco.fondelli@gmail.com> Reviewed-on: https://code.wireshark.org/review/17734 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-01-03Rename ipv6-utils.h to ipv6.h.Guy Harris1-1/+1
By analogy to ipv4.h. Change-Id: I147565b332024b1bb88e9cd15889255773d04524 Reviewed-on: https://code.wireshark.org/review/13034 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-03If you want nstime_t, include <wsutil/nstime.h>.Guy Harris1-4/+4
Don't just define struct nstime_t yourself. Change-Id: I275f53c6c9f34813898e7ffe4493583017fbf7f0 Reviewed-on: https://code.wireshark.org/review/13021 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-03If you want struct e_in6_addr, include <epan/ipv6-utils.h>.Guy Harris1-1/+1
Don't just define it yourself. (And especially don't define it yourself if you're already including epan/ipv6-utils.h.) Change-Id: I9970d0edecef0c820b2a7fdce34509b54e7b3106 Reviewed-on: https://code.wireshark.org/review/13020 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-27Officially remove tvb_get_string and tvb_get_stringz.Michael Mann1-20/+0
Almost all replacements were done awhile ago, just put the final nail in the coffin. Change-Id: I0a708d886da5a500c2a1e2c9ee2736794bdb9411 Reviewed-on: https://code.wireshark.org/review/12206 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-08-27Remove calls of tvb_ensure_length_remaining.Michael Mann1-3/+0
The remaining calls seem to fall into 3 categories: 1. passing it to tvb_find_line_end when -1 (for length) will do. 2. duplicating the checking of tvb_reported_length_remaining, which is already in use near the tvb_ensure_length_remaining call. 3. Those that (probably) need tvb_ensure_capture_length_remaining Change-Id: I1e77695251e055644bcbbb89f3c181c65d1671ca Reviewed-on: https://code.wireshark.org/review/10268 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-06-24Remove the last deprecated tvb_length callsEvan Huus1-6/+0
And remove the shims themselves! Change-Id: I511c06eb21eaf68d1dc36bbb9558408807472f9c Reviewed-on: https://code.wireshark.org/review/9088 Reviewed-by: Evan Huus <eapache@gmail.com>
2015-02-21Remove tvb_ from the names of wsutil mempbrk routines.Guy Harris1-3/+3
Routines that don't take a tvbuff as an argument shouldn't have tvb_ in the name. Change-Id: I3550256551e30b3f329cbbfca71ef27c727d29c0 Reviewed-on: https://code.wireshark.org/review/7302 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-11Combine SSE and pre-compiled patterns for faster pbrkHadriel Kaplan1-3/+8
This combines the SSE4.2 instructions usage, with pre-compiled pattern searching usage, for a faster pbrk search method. Testing against large files of HTTP and SIP, there is about a 5% performance improvement by using pre-"compiled" patterns for guint8_pbrk() instead of passing it the search string and having it build the match array every time. Similar to regular expressions, "compiling" the pattern match array in advance only once and using the "compiled" patterns for the searches is faster than compiling it every time. Change-Id: Ifcbc14a6c93f32d15663a10d974bacdca5119a8e Ping-Bug: 10798 Reviewed-on: https://code.wireshark.org/review/6990 Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-01-07tvb_bytes_to_ep_str -> tvb_bytes_to_strMichael Mann1-7/+1
Change-Id: I79c613cbdd8dc939dd4c29ebc477fb6eefd5bfc4 Reviewed-on: https://code.wireshark.org/review/6371 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-01-07tvb_bytes_to_ep_str_punct -> tvb_bytes_to_str_punctMichael Mann1-1/+1
Also change bytestring_to_str to match bytes_to_ep_str_punct functionality (limiting byte string size) Change-Id: Idb958c7f0c203d103629469302b81fa922714f7e Reviewed-on: https://code.wireshark.org/review/6369 Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-01-04Make all Lua code use wmem not ememHadriel Kaplan1-0/+6
Changed all remaining code in wslua that was using emem, to use wmem or simpler methods. Bug: 9927 Change-Id: I3d19a770e0fd77d996bdb6b61a76a722cc2bcd55 Reviewed-on: https://code.wireshark.org/review/6109 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com> Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-01-02tvb: implement endianness-paramterized gettersEvan Huus1-1/+14
e.g. tvb_get_guint16(tvb, offset, ENC_LITTLE_ENDIAN) Change-Id: Iea02fd59b13678aca741d028fb1f66f334447498 Reviewed-on: https://code.wireshark.org/review/6191 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: Evan Huus <eapache@gmail.com>
2014-12-22Fix unknown command tag name [-Wdocumentation-unknown-command]Alexis La Goutte1-1/+1
Change-Id: I6c2564a86e13d9321001856ba1f51681a9f20976 Reviewed-on: https://code.wireshark.org/review/5979 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-11-29Revert "Add QNX' QNET protocol"Guy Harris1-11/+0
This reverts commit 72b91a56f86e3bbab700900366f81dc8c353b91d. value_string_ext tables ***MUST*** be sorted numerically, otherwise the code prints warnings such as the ones in http://buildbot.wireshark.org/trunk/builders/Ubuntu%2014.04%20x64/builds/1419/steps/test.sh/logs/stdio Fix this and resubmit. Change-Id: I448025bb7b19a607e992831202ed31d243ce70d8 Reviewed-on: https://code.wireshark.org/review/5530 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-11-29Add QNX' QNET protocolAlexis La Goutte1-0/+11
no ethertype 0x8203-0x8205 support in trunk. 0x8204 is QNX OS VER 6's qnet ethernet protocol number. Bug:3934 Change-Id: I5f3e910876bb7fb86de2111f856d026fdf220917 Reviewed-on: https://code.wireshark.org/review/2954 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-08-22Fix a comment typo: tvb_bcd_dig_to_wmem_packet_str() returns a WMEM-allocatedJeff Morriss1-3/+3
string, not an EP-allocated one. Change-Id: I3918ed66429c588d4503d98e10dc460b099e550e Reviewed-on: https://code.wireshark.org/review/3795 Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com>
2014-08-02Add a routine to check whether all bytes implied by a 64-bit length exist.Guy Harris1-0/+6
This lets us blow up with oversized 64-bit length values, before casting them to the 31-bit lengths we can actually handle in Wireshark, rather than blindly casting them with weird results. Use that in the MySQL dissector, and, if we get past the test, cast the lengths to int to squelch warnings. Change-Id: I3a5e9bd0027fa4ddcb9622f77952dba8f6b23c27 Reviewed-on: https://code.wireshark.org/review/3362 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-14Revert "Don't throw for offset at end of TVB with len -1."Evan Huus1-6/+0
This reverts commit fe195c0c978b4b92dc5a77daa6449a7f1314243d. Conflicts: epan/tvbuff.c Change-Id: I1af618d0bd1e6211281b6d67c0ad197cfa513a0c Reviewed-on: https://code.wireshark.org/review/1639 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-04-23Don't throw for offset at end of TVB with len -1.Evan Huus1-0/+6
g867a1827e7dc88896ee27a107eb35c4b3973d270 introduced a change to cleanup/fix handling of bounds checks for -1 length fields, but it ended up guaranteeing a throw for 0-length tvbs, which isn't good; we ought to be able to add 0-length FT_PROTOCOL items at the very least. Better names for the function than _cheat are welcome, but I want to shut up the buildbot. Change-Id: I24610f947d03dac32766e2a0ffa0ff7bcc74c3e8 Reviewed-on: https://code.wireshark.org/review/1303 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-04-17Add tvb_get and proto_tree_add for string-encoded byte arraysHadriel Kaplan1-0/+12
This commit adds tvb_get_string_bytes and proto_tree_add_bytes_item routines for getting GByteArrays fields from the tvb when they are encoded in ASCII hex string form. The proto_tree_add_bytes_item routine is also usable for normal binary encoded byte arrays, and has the advantage of retrieving the array values even if there's no proto tree. It also exposes the routines to Lua, both so that a Lua script can take advantage of this, but also so I can write a testsuite to test the functions. Change-Id: I112a038653df6482a5d0ebe7c95708f207319e20 Reviewed-on: https://code.wireshark.org/review/1158 Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-04-14Add tvb_get and proto_tree_add for string-encoded timestampsHadriel Kaplan1-0/+32
This commit adds tvb_get_string_time and proto_tree_add_time_item routines for getting nstime fields from the tvb when they are encoded in ASCII string form. The proto_tree_add_time_item routine is also usable for normal big/little-endian encoded time_t, and has the advantage of retrieving the value even if there's no proto tree. It also exposes the routines to Lua, both so that a Lua script can take advantage of this, but also so I can write a testsuite to test the functions. Change-Id: I955da10f68f2680e3da3a5be5ad8fdce7ed6808c Reviewed-on: https://code.wireshark.org/review/1084 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-04-13Add ENC_ASCII_7BITS encodingPascal Quantin1-0/+23
Change-Id: I01ec87ff4181afb5b2de487fd5f5200f8d62f17d Reviewed-on: https://code.wireshark.org/review/1088 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-04-12Get rid of more tvb_get_nstringz* calls.Guy Harris1-0/+23
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-07Add WS_DLL_PUBLIC for p_remove_proto_data and tvb_child_uncompres functionAlexis La Goutte1-1/+1
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-03(Pedantic): set editor modelines tab-width & etc to 8; Also: fix some ↵Bill Meier1-7/+7
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-03-06Have NFLOG TLV type and length be in host byte order.Guy Harris1-0/+17
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-04Remove all $Id$ from top of fileAlexis La Goutte1-2/+0
(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-02-26Document tvb_memdup() in more detail.Guy Harris1-4/+15
Change-Id: Iec94342b7d033fb6e8597bbffea563128182316b Reviewed-on: https://code.wireshark.org/review/417 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-02-26Regularize the formatting of some comments.Guy Harris1-5/+4
Change-Id: I1009c75d5a4f074767dbc3600e7a6edfd0031460 Reviewed-on: https://code.wireshark.org/review/416 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-02-26Fix a copy-and-pasteo.Guy Harris1-2/+2
Change-Id: Ied8830e2e7a689197870a4d839fd08b36546c75f Reviewed-on: https://code.wireshark.org/review/414 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-02-26Some g_free() -> wmem_free() changes missed in earlier checkins.Guy Harris1-2/+2
Change-Id: I5858e0ee8fc8584b35145c943e19e8e5f7dba77c Reviewed-on: https://code.wireshark.org/review/413 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-02-26More tvbuff API deprecation, comment expansion, and documentation updates.Guy Harris1-33/+80
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-22TVB API deprecations and cleanupEvan Huus1-17/+25
- 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-01-21Get rid of tvb_get_faked_unicode() - tvb_get_string_enc() does the jobGuy Harris1-13/+0
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-21Fix declaration of tvb_get_string().Guy Harris1-1/+1
svn path=/trunk/; revision=54870
2014-01-21Don't do the byte-with-8th-bit-set-to-REPLACEMENT-CHARACTER mapping forGuy Harris1-6/+11
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-20tvb_get_string(): replace 8bit characters with the unicode replacement charMartin Kaiser1-5/+6
svn path=/trunk/; revision=54864
2014-01-01Add proto_tree_add_ts_23_038_7bits_item() / tvb_get_ts_23_038_7bits_string() ↵Pascal Quantin1-0/+13
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
2013-12-30Add new function: tvb_skip_guint8()Jakub Zawadzki1-0/+2
svn path=/trunk/; revision=54505
2013-12-22(Trivial)Bill Meier1-2/+2
- Minor whitespace changes; - Fix a typo; - Add editor modelines to tnbuff_subset.c svn path=/trunk/; revision=54364
2013-12-21Move base64_to_tvb() to tvbuff_base64.cJakub Zawadzki1-0/+9
svn path=/trunk/; revision=54325
2013-12-21Get rid of tvb_get_unicode_string() and tvb_get_unicode_stringz();Guy Harris1-10/+2
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-19Rename a couple of to_str functions to have ep_ in the name. This makes itEvan Huus1-2/+2
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-18Add a sixteenth element to all BCD digit sets to avoid garbage values whenEvan Huus1-1/+1
decoding corrupt bytes. Some of these digit sets could probably be deduplicated... svn path=/trunk/; revision=54224