aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.h
AgeCommit message (Collapse)AuthorFilesLines
2005-01-07Doxygen cleanups, from Mike Duigou.guy1-47/+58
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@12980 f5534014-38df-0310-8fa8-9805f1628bb7
2004-12-30Add a "tvb_bytes_to_str_punct()" routine, which wrapsguy1-0/+8
"bytes_to_str_punct()", and use it instead of extracting the bytes and formatting them by hand. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@12876 f5534014-38df-0310-8fa8-9805f1628bb7
2004-08-22Add "tvb_get_ntoh64()" and "tvb_get_letoh64()" routines to fetch 64-bitguy1-0/+2
integers. Make FT_INT64 and FT_UINT64 add numerical values, rather than byte-array values, to the protocol tree, and add routines to add specified 64-bit integer values to the protocol tree. Use those routines in the RSVP dissector. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@11796 f5534014-38df-0310-8fa8-9805f1628bb7
2004-07-18Set the svn:eol-style property on all text files to "native", so thatguy1-1/+1
they have LF at the end of the line on UN*X and CR/LF on Windows; hopefully this means that if a CR/LF version is checked in on Windows, the CRs will be stripped so that they show up only when checked out on Windows, not on UN*X. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@11400 f5534014-38df-0310-8fa8-9805f1628bb7
2004-05-05From Jerry Talkington:obiot1-1/+8
- Helper functions for uncompressing compressed tvbuffers. - Compressed content coding dissection in HTTP. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@10799 f5534014-38df-0310-8fa8-9805f1628bb7
2004-03-23Use "tvb_format_text()" to display strings, so we handle non-printableguy1-1/+7
characters. Some strings appear to be null-padded; add a "tvb_format_stringzpad()" routine to handle them, so that we don't show the padding characters as "\000". git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@10461 f5534014-38df-0310-8fa8-9805f1628bb7
2004-02-19Constify a bunch of stuff.guy1-2/+2
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@10106 f5534014-38df-0310-8fa8-9805f1628bb7
2004-02-01Make "tvb_strneql()" take a "gchar *" rather than a "guint8 *" as theguy1-2/+2
string argument. Add some casts to squelch compiler warnings. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@9951 f5534014-38df-0310-8fa8-9805f1628bb7
2004-02-01packet-dcerpc-afs4int.cjmayer1-2/+2
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@9938 f5534014-38df-0310-8fa8-9805f1628bb7
2004-01-23Change return type of tvb_format_text from guint8* to gchar*.jmayer1-2/+2
Remove now unnecessary casts in two files. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@9801 f5534014-38df-0310-8fa8-9805f1628bb7
2003-12-03performance updatesahlberg1-2/+5
replace tvb_raw_offset() which is essentially a simple assignment and which is called a lot with a macro. this makes my tethereal testcase 2-3% faster. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@9152 f5534014-38df-0310-8fa8-9805f1628bb7
2003-12-02Move the definition of the tvbuff_t structure and friends to tvbuff.hsahlberg1-6/+68
so that we can change tvb_get_ds_tvb() into a macro. This function was a single line assignment and was called a lot. This made tethereal ~2.5% faster in one testcase I use. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@9141 f5534014-38df-0310-8fa8-9805f1628bb7
2003-08-27Add a "contains" operator for byte-strings, strings, and tvbuffs (protocols).gram1-1/+8
The search uses a naive approach; more work is required to add a Boyer-Moore Search algorithm. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@8280 f5534014-38df-0310-8fa8-9805f1628bb7
2003-06-12Add new routines:guy1-1/+21
tvb_get_string() - takes a tvbuff, an offset, and a length as arguments, allocates a buffer big enough to hold a string with the specified number of bytes plus an added null terminator (i.e., length+1), copies the specified number of bytes from the tvbuff, at the specified offset, to that buffer and puts in a null terminator, and returns a pointer to that buffer (or throws an exception before allocating the buffer if that many bytes aren't available in the tvbuff); tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to a "gint" as arguments, gets the size of the null-terminated string starting at the specified offset in the tvbuff (throwing an exception if the null terminator isn't found), allocates a buffer big enough to hold that string, copies the string to that buffer, and returns a pointer to that buffer and stores the length of the string (including the terminating null) in the variable pointed to by the "gint" pointer. Replace many pieces of code allocating a buffer and copying a string with calls to "tvb_get_string()" (for one thing, "tvb_get_string()" doesn't require you to remember that the argument to "tvb_get_nstringz0()" is the size of the buffer into which you're copying the string, which might be the length of the string to be copied *plus 1*). Don't use fixed-length buffers for null-terminated strings (even if the code that generates those packets has a #define to limit the length of the string). Use "tvb_get_stringz()", instead. In some cases where a value is fetched but is only used to pass an argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()" instead. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7859 f5534014-38df-0310-8fa8-9805f1628bb7
2003-05-19More tvb_get_nstringz0() fixes. Timo Sirainen pointed out that Badgerald1-1/+3
Things can happen if we pass a zero buffer length to tvb_get_nstringz0(). Throw an exception if this happens. In various dissectors make sure the tvb_get_nstringz0()'s buffer length is greater than zero. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7688 f5534014-38df-0310-8fa8-9805f1628bb7
2003-04-30Modify tvb_get_nstringz*() to behave more like snprintf(). Make changesgerald1-6/+6
where necessary to reflect the new behavior. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7607 f5534014-38df-0310-8fa8-9805f1628bb7
2003-02-24Rename "fake_unicode()" to "tvb_fake_unicode()" as it works on a tvbuff,guy1-1/+8
give it a byte-order argument, and move it to "epan/tvbuff.c". Use it to handle UCS-2 strings in version 1 of the Service Location Protocol. In SRVLOC V1, use registered fields that are already there for SRVLOC V2, and add some as needed. Fix some field names. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7186 f5534014-38df-0310-8fa8-9805f1628bb7
2002-08-28Removed trailing whitespaces from .h and .c files using thejmayer1-5/+5
winapi_cleanup tool written by Patrik Stridvall for the wine project. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@6116 f5534014-38df-0310-8fa8-9805f1628bb7
2002-07-17Add an extra argument to "tvb_find_line_end()", which specifies what itguy1-4/+14
should do if it doesn't find an EOL; if FALSE, it behaves as before, returning values that treat the line as ending at the end of the tvbuff, and if TRUE, it returns -1, so its caller can do segment reassembly until it gets the EOL. Add an option to the SMTP dissector to do segment reassembly, and do segment reassembly of the first line. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@5891 f5534014-38df-0310-8fa8-9805f1628bb7
2002-05-13Add a "tvb_ensure_bytes_exist()", which is like "tvb_bytes_exist()" onlyguy1-3/+7
it throws the appropriate exception if the bytes don't exist. Use it in the GIOP and ASN.1 code to check whether the bytes to be copied to a buffer exist before allocating the buffer. Make "check_offset_length_no_exception()" check for an overflow, so that it can be used in "tvb_ensure_bytes_exist()" and do all the checking that the code "tvb_ensure_bytes_exist()" replaces did. Make "get_CDR_wchar()" return a "gint", so that if the length octet it fetched has a value between 128 and 255, the length can be returned correctly. Fix some comments not to specify the exception thrown by various routines that can throw various exceptions. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@5453 f5534014-38df-0310-8fa8-9805f1628bb7
2002-05-05Make "tvb_ensure_length_remaining()" return a "guint" - it can't returnguy1-2/+2
a negative value. Use "tvb_ensure_length_remaining()" in "tcp_dissect_pdus()", rather than checking the return value of "tvb_length_remaining()" ourselves, and make various variables and parameters in it "guint" as appropriate. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@5396 f5534014-38df-0310-8fa8-9805f1628bb7
2002-04-24Use "gfloat" and "gdouble", rather than "float" and "double", as theguy1-5/+5
return types of the tvbuff accessors for floating-point types, to more closely match the tvbuff accessors for integral types. Fix an error in the code for fetching doubles on VAXes, and get rid of unused union members on VAXes. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@5245 f5534014-38df-0310-8fa8-9805f1628bb7
2002-04-12Add (untested) routines to fetch IEEE single-precision andguy1-1/+5
double-precision floating-point numbers, in big-endian and little-endian format (hopefully there aren't any middle-endian formats; if there are, we'll have to add them), from a tvbuff, and to return floats (for single-precision) and doubles (for double-precision). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@5147 f5534014-38df-0310-8fa8-9805f1628bb7
2002-03-06tvb_get_nstringz() needs to terminate a string with a NUL if thegram1-1/+8
end of the tvbuff is reached before the maximum_length passed by the caller is reached and before a terminating NUL is found. In this case, tvb_get_nstringz() returns a -1, but if the string is not artificially terminated with a NUL by tvb_get_nstringz(), the caller has no idea where the string should end because 1) the return value "-1" gives the impression that the string ends at the end of the buffer but 2) the string does not end at the end of the buffer, but somewhere in the middle, due to the packet being shorter than expected. tvb_get_nstringz() and tvb_get_nstringz0() were both modified. The FT_STRINGZ case in proto_tree_add_item() is made simpler. During regression testing, when investigating a regression that I later corrected, I discovered that strings added through proto_tree_add_item (FT_STRING, FT_STRINGZ, and FT_UINT_STRING) leaked memory due to double allocation of the string. The proto_tree_add_string*() functions do not leak memory, since they only copy the string once. The memory leak was fixed by adding another argument to the static function proto_tree_set_string() to let the string ftype code know to g_strdup() the string or not. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4891 f5534014-38df-0310-8fa8-9805f1628bb7
2002-02-18Don't give tvbuffs names; instead, give data sources names, where aguy1-3/+3
"data source" has a name and a top-level tvbuff, and frames can have a list of data sources associated with them. Use the tvbuff pointer to determine which data source is the data source for a given field; this means we don't have to worry about multiple data sources with the same name - the only thing the name does is label the notebook tab for the display of the data source, and label the hex dump of the data source in print/Tethereal output. Clean up a bunch of things discovered in the process of doing the above. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4749 f5534014-38df-0310-8fa8-9805f1628bb7
2002-02-01Provide tvb_ensure_length_remaining(), which is likegram1-1/+4
tvb_length_remaining() except that it throws BoundsError if 'offset' is out-of-bounds. Allow a length argument of -1 for FT_STRING and FT_BYTES fields in proto_tree_add_item(). Change some dissectors to either use -1 for the length argument in calls to proto_tree_add_item(), or call tvb_ensure_length_remaining() instead of tvb_length_remaining(), or to check the return-value of tvb_length_remaining(). Changes to more dissectors are necessary, but will follow later. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4656 f5534014-38df-0310-8fa8-9805f1628bb7
2001-11-20Get rid of "tvb_compat()"; it's no longer needed (the one remaining callguy1-9/+2
to it returns data that's no longer used). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4237 f5534014-38df-0310-8fa8-9805f1628bb7
2001-11-15Get rid of NullTVB, the "compat_top_tvb" member of the "packet_info"guy1-5/+2
structure, the check for a null tvbuff pointer in "alloc_field_info()", and the "tvb_create_from_top()" macro; they're no longer needed, as there's no non-tvbuffified dissector code remaining. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4205 f5534014-38df-0310-8fa8-9805f1628bb7
2001-11-13Hopefully the last time I have to change my e-mail address.gram1-2/+2
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4199 f5534014-38df-0310-8fa8-9805f1628bb7
2001-10-31Put "extern" in front of a pile of function declarations.guy1-53/+61
It makes no difference if they really are function declarations; however, in plugins, when building on OSes that don't let dynamically-loaded modules access functions in the main program (e.g., Windows), when compiling a plugin, <plugin_api.h> defines the names of those functions as (*pointer_name), so they turn into declarations of pointer variables pointing to the functions in question, and, on platforms with a def/ref model in the linker, if a plugin has more than one source file that gets linked into the plugin, the linker may get upset at two definitions of the same variable. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4114 f5534014-38df-0310-8fa8-9805f1628bb7
2001-10-29Stop using "tvb_get_ntohll()" and "%llX" in the BOOTP dissector, as theguy1-7/+1
former depends on having "guint64" and the latter depends on "%ll[douxX]" being what's used to print 64-bit integers, and there are platforms on which Etheeal runs that don't have "guint64" or that don't use "%ll[douxX]" to print 64-bit integers. Get rid of the routines to extract 64-bit integers into "gint64"s and "guint64"s, as per Ronnie Sahlberg's suggestion, to discourage people from writing code that won't work on all platforms; they should be using FT_UINT64, or the routines in "int-64bit.c", instead. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4102 f5534014-38df-0310-8fa8-9805f1628bb7
2001-10-26Fix some signed/unsigned comparison warnings. In the case of tvbuff.h,gram1-3/+3
there were 2 functions which accepted 'maxlength' == -1, but the function prototypes had maxlength as a guint --- fixed. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4087 f5534014-38df-0310-8fa8-9805f1628bb7
2001-07-02Tvbuffify the DNS, NBNS, NBDS, and NBSS dissectors.guy1-3/+15
Add a "tvb_memeql()" routine, for doing "memcmp()"-style equality comparisons. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@3631 f5534014-38df-0310-8fa8-9805f1628bb7
2001-05-27Fix a comment, and update Gerald's e-mail address.guy1-3/+3
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@3471 f5534014-38df-0310-8fa8-9805f1628bb7
2001-03-23Changes required to support multiple named data sources.jfoster1-2/+4
Tvbuffers changed to added the data source name, GUI and printing code changed to support these changes and display the multiple hex views. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@3165 f5534014-38df-0310-8fa8-9805f1628bb7
2001-03-13Make tvb_get_ptr() return 'const guint8*', and clean up all thegram1-2/+2
usages of tvb_get_ptr(). packet-ieee80211.c still has one bad usage, in which it *does* modify the tvbuff's data. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@3128 f5534014-38df-0310-8fa8-9805f1628bb7
2000-12-27Tvbuffify the RIP and OSPF dissectors.guy1-2/+8
Change them to use facilities in Ethereal that were probably not present when they were originally written, e.g. routines to fetch 24-bit integers and to dump a bunch of raw bytes in hex. Redo them to extract data from the packet as they dissect it, rather than extracting an entire data structure at once; that way, it may be able to dissect a structure not all of which is in the packet. Dissect a bit more of the type-of-service metrics etc. in OSPF packets. Make "tvb_length_remaining()" return a "gint", not a "guint"; it returns -1 if the offset is past the end of the tvbuff. Add a "tvb_reported_length_remaining()" routine, similar to "tvb_length_remaining()". Use it instead of just subtracting an offset from "tvb_reported_length()". git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2787 f5534014-38df-0310-8fa8-9805f1628bb7
2000-12-25Add a new "tvb_strsize()" routine, which finds the size of aguy1-1/+8
NUL-terminated string, starting at a given offset. The size includes the terminating NUL. If it doesn't find the terminating NUL, it throws the appropriate exception, as either there's no terminating NUL in the packet or there is but it's past the end of the captured data in the packet. Use that routine in the TFTP dissector. As it throws an exception if the string isn't NUL-terminated, we can just use "%s" to print option strings; we don't need to use "%.*s" with a string length. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2783 f5534014-38df-0310-8fa8-9805f1628bb7
2000-11-18Tvbuffify the IP, ICMP, TCP, UDP, OSI CLNP, OSI COTP, OSI CLTP, and OSIguy1-1/+9
ESIS dissectors. Register the IP dissector and have dissectors that call it directly (rather than through a port table) call it through a handle. Add a routine "tvb_set_reported_length()" which a dissector can use if it was handed a tvbuff that contains more data than is actually in its part of the packet - for example, handing a padded Ethernet frame to IP; the routine sets the reported length of the tvbuff (and also adjusts the actual length, as appropriate). Then use it in IP. Given that, "ethertype()" can determine how much of the Ethernet frame was actually part of an IP datagram (and can do the same for other protocols under Ethernet that use "tvb_set_reported_length()"; have it return the actual length, and have "dissect_eth()" and "dissect_vlan()" use that to mark trailer data in Ethernet II frames as well as in 802.3 frames. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2658 f5534014-38df-0310-8fa8-9805f1628bb7
2000-11-14Add tvb_set_child_real_data_tvbuff(), which allows you to tell thegram1-2/+13
tvbuff routines that a particular TVBUFF_REAL_DATA tvbuff is a "child" of another tvbuff. This link is utilized during a tvb_free_chain(), so that the child is freed when no longer necessary. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2642 f5534014-38df-0310-8fa8-9805f1628bb7
2000-11-13Move "bytes_to_str()" to "strutil.c" from "packet.c" - it's just aguy1-1/+7
string formatter, like "format_text()", and, as "tvbuff.c" now calls it (*vide infra*), we don't want to have to make "tvbuff.c" drag "packet.h" in just to declare "bytes_to_str()". It's now declared in "strutil.h", so include it in modules that use "bytes_to_str()" and weren't already including it. Add a "tvb_bytes_to_str()" wrapper that calls "tvb_get_ptr()" to get a pointer to a chunk of N bytes at a given offset in a tvbuff and then hands that chunk to "bytes_to_str()". Convert the code that was doing that to use "tvb_bytes_to_str()" instead (which caught what I suspect is a bug in the Q.2931 dissector, where it was handing an offset of 0 to "tvb_get_ptr()" - a cut-and-pasteo, I think). Tvbuffify the ARP dissector. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2634 f5534014-38df-0310-8fa8-9805f1628bb7
2000-11-11Make the string-to-compare-with arguments to "tvb_strneql()" andguy1-3/+3
"tvb_strncaseeql()" "const guint8 *", so that you can pass them pointers to "const". git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2611 f5534014-38df-0310-8fa8-9805f1628bb7
2000-11-10Allow "tvb_find_guint8()", "tvb_pbrk_guint8()", and "tvb_strnlen()" toguy1-8/+15
take -1 as a "maxlength" value, meaning "to the end of the tvbuff". git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2598 f5534014-38df-0310-8fa8-9805f1628bb7
2000-11-10Tvbuffify the SAP and SDP dissectors.guy1-1/+29
Add "tvb_find_line_end_unquoted()" for the benefit of the SDP dissector; get rid of "find_line_end_unquoted()" as nobody uses it any more. Add "tvb_pbrk_guint8()" for the benefit of "tvb_find_line_end_unquoted()"; it searches for any of a number of characters, unlike "tvb_find_guint8()" which searches for only one. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2595 f5534014-38df-0310-8fa8-9805f1628bb7
2000-11-09Tvbuffify the HTTP, NNTP, RSH, RTSP, and Telnet dissectors.guy1-1/+15
Add "tvb_find_line_end()", to find a CR and/or LF-terminated line in a tvbuff and return its length and the offset of the character after the line end, for the use of those dissectors. Add "tvb_strncaseeql()", which is like "tvb_strneql()" except that it does a case-insensitive comparison. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2590 f5534014-38df-0310-8fa8-9805f1628bb7
2000-09-27First step in moving core Ethereal routines to libepan.gram1-0/+290
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2458 f5534014-38df-0310-8fa8-9805f1628bb7