MAX_MCS_INDEX is a valid array index.
[metze/wireshark/wip.git] / epan / tvbuff.h
index 5e75bce146f4a914168c32669066caf0793b56cb..c52e3b03f1afc6c323545034bd6b7b1c9d98bf91 100644 (file)
@@ -3,13 +3,11 @@
  * Testy, Virtual(-izable) Buffer of guint8*'s
  *
  * "Testy" -- the buffer gets mad when an attempt is made to access data
- *             beyond the bounds of the buffer. An exception is thrown.
+ *      beyond the bounds of the buffer. An exception is thrown.
  *
  * "Virtual" -- the buffer can have its own data, can use a subset of
- *             the data of a backing tvbuff, or can be a composite of
- *             other tvbuffs.
- *
- * $Id$
+ *      the data of a backing tvbuff, or can be a composite of
+ *      other tvbuffs.
  *
  * Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu>
  *
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #ifndef __TVBUFF_H__
 #define __TVBUFF_H__
 
 #include <glib.h>
-#include <epan/ipv6-utils.h>
 #include <epan/guid-utils.h>
-#include "exceptions.h"
+#include <epan/wmem/wmem.h>
+#include <epan/ipv6.h>
+
+#include <wsutil/nstime.h>
+#include "wsutil/ws_mempbrk.h"
 
-/** @file
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
  * "testy, virtual(-izable) buffer".  They are testy in that they get mad when
  * an attempt is made to access data beyond the bounds of their array. In that
  * case, they throw an exception.
  * virtual data.
  */
 
-
-/** The different types of tvbuff's */
-typedef enum {
-       TVBUFF_REAL_DATA,
-       TVBUFF_SUBSET,
-       TVBUFF_COMPOSITE
-} tvbuff_type;
-
 struct tvbuff;
 typedef struct tvbuff tvbuff_t;
 
+/** @defgroup tvbuff Testy, Virtual(-izable) Buffers
+ *
+ * Dissector use and management
+ *
+ *  Consider a collection of tvbs as being a chain or stack of tvbs.
+ *
+ *  When dissecting a frame:
+ *   The top-level dissector (packet.c) pushes the initial tvb (containing
+ *   the complete frame) onto the stack (starts the chain) and then calls
+ *   a sub-dissector which in turn calls the next sub-dissector and so on.
+ *   Each sub-dissector may chain additional tvbs (see below) to the tvb
+ *   handed to that dissector. After dissection is complete and control has
+ *   returned to the top-level dissector, the chain of tvbs (stack) is free'd
+ *   via a call to tvb_free_chain() (in epan_dissect_cleanup()).
+ *
+ * A dissector:
+ *  - Can chain new tvbs (subset, real, composite) to the
+ *    tvb handed to the dissector using tvb_new_subset(),
+ *    tvb_new_subset_length(), tvb_new_subset_remaining(),
+ *    tvb_new_child_real_data(), tvb_set_child_real_data_tvbuff(),
+ *    tvb_composite_finalize(), and tvb_child_uncompress(). (Composite
+ *    tvbs should reference only tvbs which are already part of the chain).
+ *  - Must not save for later use (e.g., when dissecting another frame) a
+ *    pointer to a tvb handed to the dissector; (A higher level function
+ *    may very well free the chain thus leaving a dangling pointer).
+ *    This (obviously) also applies to any tvbs chained to the tvb handed
+ *    to the dissector.
+ *  - Can create its own tvb chain (using tvb_new_real_data() which the
+ *
+ *    dissector is free to manage as desired.
+ * @{
+ */
+
 /** TVBUFF_REAL_DATA contains a guint8* that points to real data.
  * The data is allocated and contiguous.
  *
  * TVBUFF_SUBSET has a backing tvbuff. The TVBUFF_SUBSET is a "window"
  * through which the program sees only a portion of the backing tvbuff.
  *
- * TVBUFF_COMPOSITE combines multiple tvbuffs sequentually to produce
+ * TVBUFF_COMPOSITE combines multiple tvbuffs sequentially to produce
  * a larger byte array.
  *
  * tvbuff's of any type can be used as the backing-tvbuff of a
@@ -77,154 +107,163 @@ typedef struct tvbuff tvbuff_t;
  * Once a tvbuff is create/initialized/finalized, the tvbuff is read-only.
  * That is, it cannot point to any other data. A new tvbuff must be created if
  * you want a tvbuff that points to other data.
+ *
+ * tvbuff's are normally chained together to allow efficient de-allocation of
+ * tvbuff's.
  */
 
 typedef void (*tvbuff_free_cb_t)(void*);
 
-/** Returns a pointer to a newly initialized tvbuff. Note that
- * tvbuff's of types TVBUFF_SUBSET and TVBUFF_COMPOSITE
- * require further initialization via the appropriate functions */
-extern tvbuff_t* tvb_new(tvbuff_type);
-
-/** Marks a tvbuff for freeing. The guint8* data of a TVBUFF_REAL_DATA
- * is *never* freed by the tvbuff routines. The tvbuff itself is actually freed
- * once its usage count drops to 0.
- *
- * Usage counts increment for any time the tvbuff is
- * used as a member of another tvbuff, i.e., as the backing buffer for
- * a TVBUFF_SUBSET or as a member of a TVBUFF_COMPOSITE.
- *
- * Although you may call tvb_free(), the tvbuff may still be in use
- * by other tvbuff's (TVBUFF_SUBSET or TVBUFF_COMPOSITE), so it is not
- * safe, unless you know otherwise, to free your guint8* data. If you
- * cannot be sure that your TVBUFF_REAL_DATA is not in use by another
- * tvbuff, register a callback with tvb_set_free_cb(); when your tvbuff
- * is _really_ freed, then your callback will be called, and at that time
- * you can free your original data.
- *
- * The caller can artificially increment/decrement the usage count
- * with tvbuff_increment_usage_count()/tvbuff_decrement_usage_count().
+/** Extracts 'number of bits' starting at 'bit offset'.
+ * Returns a pointer to a newly initialized g_malloc'd REAL_DATA
+ * tvbuff with the bits octet aligned.
  */
-extern void tvb_free(tvbuff_t*);
+WS_DLL_PUBLIC tvbuff_t *tvb_new_octet_aligned(tvbuff_t *tvb,
+    guint32 bit_offset, gint32 no_of_bits);
 
-/** Free the tvbuff_t and all tvbuff's created from it. */
-extern void tvb_free_chain(tvbuff_t*);
+WS_DLL_PUBLIC tvbuff_t *tvb_new_chain(tvbuff_t *parent, tvbuff_t *backing);
 
-/** Both return the new usage count, after the increment or decrement */
-extern guint tvb_increment_usage_count(tvbuff_t*, const guint count);
+WS_DLL_PUBLIC tvbuff_t *tvb_clone(tvbuff_t *tvb);
 
-/** If a decrement causes the usage count to drop to 0, a the tvbuff
- * is immediately freed. Be sure you know exactly what you're doing
- * if you decide to use this function, as another tvbuff could
- * still have a pointer to the just-freed tvbuff, causing corrupted data
- * or a segfault in the future */
-extern guint tvb_decrement_usage_count(tvbuff_t*, const guint count);
+WS_DLL_PUBLIC tvbuff_t *tvb_clone_offset_len(tvbuff_t *tvb, guint offset,
+    guint len);
 
-/** Set a callback function to call when a tvbuff is actually freed
- * (once the usage count drops to 0). One argument is passed to
- * that callback --- a void* that points to the real data.
- * Obviously, this only applies to a TVBUFF_REAL_DATA tvbuff. */
-extern void tvb_set_free_cb(tvbuff_t*, const tvbuff_free_cb_t);
+/** Free a tvbuff_t and all tvbuffs chained from it
+ * The tvbuff must be 'the 'head' (initial) tvb of a chain or
+ * must not be in a chain.
+ * If specified, a callback to free the tvbuff data will be invoked
+ * for each tvbuff free'd */
+WS_DLL_PUBLIC void tvb_free(tvbuff_t *tvb);
 
+/** Free the tvbuff_t and all tvbuffs chained from it.
+ * The tvbuff must be 'the 'head' (initial) tvb of a chain or
+ * must not be in a chain.
+ * If specified, a callback to free the tvbuff data will be invoked
+ * for each tvbuff free'd */
+WS_DLL_PUBLIC void tvb_free_chain(tvbuff_t *tvb);
+
+/** Set a callback function to call when a tvbuff is actually freed
+ * One argument is passed to that callback --- a void* that points
+ * to the real data. Obviously, this only applies to a
+ * TVBUFF_REAL_DATA tvbuff. */
+WS_DLL_PUBLIC void tvb_set_free_cb(tvbuff_t *tvb, const tvbuff_free_cb_t func);
 
 /** Attach a TVBUFF_REAL_DATA tvbuff to a parent tvbuff. This connection
  * is used during a tvb_free_chain()... the "child" TVBUFF_REAL_DATA acts
- * as if is part of the chain-of-creation of the parent tvbuff, although it
+ * as if it is part of the chain-of-creation of the parent tvbuff, although it
  * isn't. This is useful if you need to take the data from some tvbuff,
  * run some operation on it, like decryption or decompression, and make a new
  * tvbuff from it, yet want the new tvbuff to be part of the chain. The reality
  * is that the new tvbuff *is* part of the "chain of creation", but in a way
- * that these tvbuff routines is ignorant of. Use this function to make
+ * that these tvbuff routines are ignorant of. Use this function to make
  * the tvbuff routines knowledgable of this fact. */
-extern void tvb_set_child_real_data_tvbuff(tvbuff_t* parent, tvbuff_t* child);
-
-extern tvbuff_t* tvb_new_child_real_data(tvbuff_t* parent, const guint8* data, const guint length,
-    const gint reported_length);
+WS_DLL_PUBLIC void tvb_set_child_real_data_tvbuff(tvbuff_t *parent,
+    tvbuff_t *child);
 
-/**Sets parameters for TVBUFF_REAL_DATA. Can throw ReportedBoundsError. */
-extern void tvb_set_real_data(tvbuff_t*, const guint8* data, const guint length,
-    const gint reported_length);
-
-/** Combination of tvb_new() and tvb_set_real_data(). Can throw ReportedBoundsError. */
-extern tvbuff_t* tvb_new_real_data(const guint8* data, const guint length,
-    const gint reported_length);
+WS_DLL_PUBLIC tvbuff_t *tvb_new_child_real_data(tvbuff_t *parent,
+    const guint8 *data, const guint length, const gint reported_length);
 
+/** Create a tvbuff backed by existing data. Can throw ReportedBoundsError.
+ * Normally, a callback to free the data should be registered using
+ * tvb_set_free_cb(); when this tvbuff is freed, then your callback will be
+ * called, and at that time you can free your original data. */
+WS_DLL_PUBLIC tvbuff_t *tvb_new_real_data(const guint8 *data,
+    const guint length, const gint reported_length);
 
-/** Define the subset of the backing buffer to use.
+/** Create a tvbuff that's a subset of another tvbuff.
  *
- * 'backing_offset' can be negative, to indicate bytes from
- * the end of the backing buffer.
+ * 'backing_offset', if positive, is the offset from the beginning of
+ * the backing tvbuff at which the new tvbuff's data begins, and, if
+ * negative, is the offset from the end of the backing tvbuff at which
+ * the new tvbuff's data begins.
  *
- * 'backing_length' can be 0, although the usefulness of the buffer would
- * be rather limited.
- *
- * 'backing_length' of -1 means "to the end of the backing buffer"
+ * 'backing_length' is the length of the data to include in the new
+ * tvbuff, starting with the byte at 'backing_offset"; if -1, it
+ * means "to the end of the backing tvbuff".  It can be 0, although
+ * the usefulness of the buffer would be rather limited.
  *
  * Will throw BoundsError if 'backing_offset'/'length'
  * is beyond the bounds of the backing tvbuff.
  * Can throw ReportedBoundsError. */
-extern void tvb_set_subset(tvbuff_t* tvb, tvbuff_t* backing,
-               const gint backing_offset, const gint backing_length, const gint reported_length);
+WS_DLL_PUBLIC tvbuff_t *tvb_new_subset(tvbuff_t *backing,
+    const gint backing_offset, const gint backing_length,
+    const gint reported_length);
 
-/** Combination of tvb_new() and tvb_set_subset()
+/**
+ * Similar to tvb_new_subset() but with captured length calculated
+ * to fit within the existing captured length and the specified
+ * backing length (which is used as the reported length).
  * Can throw ReportedBoundsError. */
-extern tvbuff_t* tvb_new_subset(tvbuff_t* backing,
-               const gint backing_offset, const gint backing_length, const gint reported_length);
+WS_DLL_PUBLIC tvbuff_t *tvb_new_subset_length(tvbuff_t *backing,
+    const gint backing_offset, const gint backing_length);
 
-/** Similar to tvb_new_subset() but with backing_length and reported_length set to -1.
- * Can throw ReportedBoundsError. */
-extern tvbuff_t* tvb_new_subset_remaining(tvbuff_t* backing,
-               const gint backing_offset);
+/** Similar to tvb_new_subset() but with backing_length and reported_length set
+ * to -1.  Can throw ReportedBoundsError. */
+WS_DLL_PUBLIC tvbuff_t *tvb_new_subset_remaining(tvbuff_t *backing,
+    const gint backing_offset);
 
-/** Both tvb_composite_append and tvb_composite_prepend can throw
+/*
+* Both tvb_composite_append and tvb_composite_prepend can throw
  * BoundsError if member_offset/member_length goes beyond bounds of
  * the 'member' tvbuff. */
 
 /** Append to the list of tvbuffs that make up this composite tvbuff */
-extern void tvb_composite_append(tvbuff_t* tvb, tvbuff_t* member);
+WS_DLL_PUBLIC void tvb_composite_append(tvbuff_t *tvb, tvbuff_t *member);
 
 /** Prepend to the list of tvbuffs that make up this composite tvbuff */
-extern void tvb_composite_prepend(tvbuff_t* tvb, tvbuff_t* member);
+extern void tvb_composite_prepend(tvbuff_t *tvb, tvbuff_t *member);
 
-/** Helper function that calls tvb_new(TVBUFF_COMPOSITE).
- * Provided only to maintain symmetry with other constructors */
-extern tvbuff_t* tvb_new_composite(void);
+/** Create an empty composite tvbuff. */
+WS_DLL_PUBLIC tvbuff_t *tvb_new_composite(void);
 
 /** Mark a composite tvbuff as initialized. No further appends or prepends
  * occur, data access can finally happen after this finalization. */
-extern void tvb_composite_finalize(tvbuff_t* tvb);
+WS_DLL_PUBLIC void tvb_composite_finalize(tvbuff_t *tvb);
 
 
-/* Get total length of buffer */
-extern guint tvb_length(const tvbuff_t*);
+/* Get amount of captured data in the buffer (which is *NOT* necessarily the
+ * length of the packet). You probably want tvb_reported_length instead. */
+WS_DLL_PUBLIC guint tvb_captured_length(const tvbuff_t *tvb);
 
 /** Computes bytes to end of buffer, from offset (which can be negative,
- * to indicate bytes from end of buffer). Function returns -1 to
- * indicate that offset is out of bounds. No exception is thrown. */
-extern gint tvb_length_remaining(const tvbuff_t*, const gint offset);
+ * to indicate bytes from end of buffer). Function returns 0 if offset is
+ * either at the end of the buffer or out of bounds. No exception is thrown.
+ * You probably want tvb_reported_length_remaining instead. */
+WS_DLL_PUBLIC gint tvb_captured_length_remaining(const tvbuff_t *tvb, const gint offset);
 
 /** Same as above, but throws an exception if the offset is out of bounds. */
-extern guint tvb_ensure_length_remaining(const tvbuff_t*, const gint offset);
+WS_DLL_PUBLIC guint tvb_ensure_captured_length_remaining(const tvbuff_t *tvb,
+    const gint offset);
 
 /* Checks (w/o throwing exception) that the bytes referred to by
  * 'offset'/'length' actually exist in the buffer */
-extern gboolean tvb_bytes_exist(const tvbuff_t*, const gint offset, const gint length);
+WS_DLL_PUBLIC gboolean tvb_bytes_exist(const tvbuff_t *tvb, const gint offset,
+    const gint length);
+
+/** Checks that the bytes referred to by 'offset'/'length', where 'length'
+ * is a 64-bit unsigned integer, actually exist in the buffer, and throws
+ * an exception if they aren't. */
+WS_DLL_PUBLIC void tvb_ensure_bytes_exist64(const tvbuff_t *tvb,
+    const gint offset, const guint64 length);
 
 /** Checks that the bytes referred to by 'offset'/'length' actually exist
  * in the buffer, and throws an exception if they aren't. */
-extern void tvb_ensure_bytes_exist(const tvbuff_t *tvb, const gint offset, const gint length);
+WS_DLL_PUBLIC void tvb_ensure_bytes_exist(const tvbuff_t *tvb,
+    const gint offset, const gint length);
 
 /* Checks (w/o throwing exception) that offset exists in buffer */
-extern gboolean tvb_offset_exists(const tvbuff_t*, const gint offset);
+WS_DLL_PUBLIC gboolean tvb_offset_exists(const tvbuff_t *tvb,
+    const gint offset);
 
 /* Get reported length of buffer */
-extern guint tvb_reported_length(const tvbuff_t*);
+WS_DLL_PUBLIC guint tvb_reported_length(const tvbuff_t *tvb);
 
 /** Computes bytes of reported packet data to end of buffer, from offset
  * (which can be negative, to indicate bytes from end of buffer). Function
- * returns -1 to indicate that offset is out of bounds. No exception is
- * thrown. */
-extern gint tvb_reported_length_remaining(const tvbuff_t *tvb, const gint offset);
+ * returns 0 if offset is either at the end of the buffer or out of bounds.
+ * No exception is thrown. */
+WS_DLL_PUBLIC gint tvb_reported_length_remaining(const tvbuff_t *tvb,
+    const gint offset);
 
 /** Set the reported length of a tvbuff to a given value; used for protocols
    whose headers contain an explicit length and where the calling
@@ -232,67 +271,166 @@ extern gint tvb_reported_length_remaining(const tvbuff_t *tvb, const gint offset
    this protocol.
 
    Also adjusts the data length. */
-extern void tvb_set_reported_length(tvbuff_t*, const guint);
+WS_DLL_PUBLIC void tvb_set_reported_length(tvbuff_t *tvb, const guint);
 
-extern guint tvb_offset_from_real_beginning(const tvbuff_t *tvb);
+WS_DLL_PUBLIC guint tvb_offset_from_real_beginning(const tvbuff_t *tvb);
 
 /* Returns the offset from the first byte of real data. */
-extern gint tvb_raw_offset(tvbuff_t *tvb);
+WS_DLL_PUBLIC gint tvb_raw_offset(tvbuff_t *tvb);
+
+/** Set the "this is a fragment" flag. */
+WS_DLL_PUBLIC void tvb_set_fragment(tvbuff_t *tvb);
+
+WS_DLL_PUBLIC struct tvbuff *tvb_get_ds_tvb(tvbuff_t *tvb);
+
 
 /************** START OF ACCESSORS ****************/
 /* All accessors will throw an exception if appropriate */
 
-extern guint8  tvb_get_guint8(tvbuff_t*, const gint offset);
-
-extern guint16 tvb_get_ntohs(tvbuff_t*, const gint offset);
-extern guint32 tvb_get_ntoh24(tvbuff_t*, const gint offset);
-extern guint32 tvb_get_ntohl(tvbuff_t*, const gint offset);
-extern guint64 tvb_get_ntoh40(tvbuff_t*, const gint offset);
-extern guint64 tvb_get_ntoh48(tvbuff_t*, const gint offset);
-extern guint64 tvb_get_ntoh56(tvbuff_t*, const gint offset);
-extern guint64 tvb_get_ntoh64(tvbuff_t*, const gint offset);
-extern gfloat tvb_get_ntohieee_float(tvbuff_t*, const gint offset);
-extern gdouble tvb_get_ntohieee_double(tvbuff_t*, const gint offset);
-
-extern guint16 tvb_get_letohs(tvbuff_t*, const gint offset);
-extern guint32 tvb_get_letoh24(tvbuff_t*, const gint offset);
-extern guint32 tvb_get_letohl(tvbuff_t*, const gint offset);
-extern guint64 tvb_get_letoh40(tvbuff_t*, const gint offset);
-extern guint64 tvb_get_letoh48(tvbuff_t*, const gint offset);
-extern guint64 tvb_get_letoh56(tvbuff_t*, const gint offset);
-extern guint64 tvb_get_letoh64(tvbuff_t*, const gint offset);
-extern gfloat tvb_get_letohieee_float(tvbuff_t*, const gint offset);
-extern gdouble tvb_get_letohieee_double(tvbuff_t*, const gint offset);
+WS_DLL_PUBLIC guint8 tvb_get_guint8(tvbuff_t *tvb, const gint offset);
+
+WS_DLL_PUBLIC guint16 tvb_get_ntohs(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC guint32 tvb_get_ntoh24(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC guint32 tvb_get_ntohl(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC guint64 tvb_get_ntoh40(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC gint64 tvb_get_ntohi40(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC guint64 tvb_get_ntoh48(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC gint64 tvb_get_ntohi48(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC guint64 tvb_get_ntoh56(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC gint64 tvb_get_ntohi56(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC guint64 tvb_get_ntoh64(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC gfloat tvb_get_ntohieee_float(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC gdouble tvb_get_ntohieee_double(tvbuff_t *tvb,
+    const gint offset);
+
+WS_DLL_PUBLIC guint16 tvb_get_letohs(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC guint32 tvb_get_letoh24(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC guint32 tvb_get_letohl(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC guint64 tvb_get_letoh40(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC gint64 tvb_get_letohi40(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC guint64 tvb_get_letoh48(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC gint64 tvb_get_letohi48(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC guint64 tvb_get_letoh56(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC gint64 tvb_get_letohi56(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC guint64 tvb_get_letoh64(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC gfloat tvb_get_letohieee_float(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC gdouble tvb_get_letohieee_double(tvbuff_t *tvb,
+    const gint offset);
+
+WS_DLL_PUBLIC guint16 tvb_get_guint16(tvbuff_t *tvb, const gint offset, const guint encoding);
+WS_DLL_PUBLIC guint32 tvb_get_guint24(tvbuff_t *tvb, const gint offset, const guint encoding);
+WS_DLL_PUBLIC guint32 tvb_get_guint32(tvbuff_t *tvb, const gint offset, const guint encoding);
+WS_DLL_PUBLIC guint64 tvb_get_guint40(tvbuff_t *tvb, const gint offset, const guint encoding);
+WS_DLL_PUBLIC gint64 tvb_get_gint40(tvbuff_t *tvb, const gint offset, const guint encoding);
+WS_DLL_PUBLIC guint64 tvb_get_guint48(tvbuff_t *tvb, const gint offset, const guint encoding);
+WS_DLL_PUBLIC gint64 tvb_get_gint48(tvbuff_t *tvb, const gint offset, const guint encoding);
+WS_DLL_PUBLIC guint64 tvb_get_guint56(tvbuff_t *tvb, const gint offset, const guint encoding);
+WS_DLL_PUBLIC gint64 tvb_get_gint56(tvbuff_t *tvb, const gint offset, const guint encoding);
+WS_DLL_PUBLIC guint64 tvb_get_guint64(tvbuff_t *tvb, const gint offset, const guint encoding);
+WS_DLL_PUBLIC gfloat tvb_get_ieee_float(tvbuff_t *tvb, const gint offset, const guint encoding);
+WS_DLL_PUBLIC gdouble tvb_get_ieee_double(tvbuff_t *tvb, const gint offset, const guint encoding);
+
+/*
+ * Fetch 16-bit and 32-bit values in host byte order.
+ * Used for some pseudo-headers in pcap/pcap-ng files, in which the
+ * headers are, when capturing, in the byte order of the host, and
+ * are converted to the byte order of the host reading the file
+ * when reading a capture file.
+ */
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define tvb_get_h_guint16   tvb_get_letohs
+#define tvb_get_h_guint32   tvb_get_letohl
+#elif G_BYTE_ORDER == G_BIG_ENDIAN
+#define tvb_get_h_guint16   tvb_get_ntohs
+#define tvb_get_h_guint32   tvb_get_ntohl
+#else
+#error "Unsupported byte order"
+#endif
+
+
+/* Fetch a time value from an ASCII-style string in the tvb.
+ *
+ * @param[in] offset The beginning offset in the tvb (cannot be negative)
+ * @param[in] length The field's length in the tvb (or -1 for remaining)
+ * @param[in] encoding The ENC_* that defines the format (e.g., ENC_ISO_8601_DATE_TIME)
+ * @param[in,out] ns The pre-allocated nstime_t that will be set to the decoded value
+ * @param[out] endoff if not NULL, should point to a gint that this
+ *     routine will then set to be the offset to the character after
+ *     the last character used in the conversion. This is useful because
+ *     they may not consume the whole section.
+ *
+ * @return a pointer to the nstime_t passed-in, or NULL on failure; if no
+ *    valid conversion could be performed, *endoff is set to 0, and errno will be
+ *    EDOM or ERANGE, and the nstime_t* passed-in will be cleared.
+ *
+ * @note The conversion ignores leading spaces, and will succeed even if it does
+ *    not consume the entire string. If you care about such things, always compare
+ *    the *endoff to where you expect it to be (namely, offset+length).
+ *
+ * This routine will not throw an error unless the passed-in arguments are
+ * invalid (e.g., offset is beyond the tvb's length).
+ *
+ * @warning This only works for string encodings which encode ASCII characters in
+ * a single byte: ENC_ASCII, ENC_UTF_8, ENC_ISO_8859_*, etc. It does NOT work
+ * for purely multi-byte encodings such as ENC_UTF_16, ENC_UCS_*, etc.
+ */
+WS_DLL_PUBLIC
+nstime_t* tvb_get_string_time(tvbuff_t *tvb, const gint offset, const gint length,
+                              const guint encoding, nstime_t* ns, gint *endoff);
+
+/* Similar to above, but returns a GByteArray based on the case-insensitive
+ * hex-char strings with optional separators, and with optional leading spaces.
+ * The separators allowed are based on the ENC_SEP_* passed in the encoding param.
+ *
+ * The passed-in bytes is set to the values, and its pointer is also the return
+ * value or NULL on error. The GByteArray bytes must be pre-constructed with
+ * g_byte_array_new().
+ */
+WS_DLL_PUBLIC
+GByteArray* tvb_get_string_bytes(tvbuff_t *tvb, const gint offset, const gint length,
+                                 const guint encoding, GByteArray* bytes, gint *endoff);
 
 /**
  * Fetch an IPv4 address, in network byte order.
  * We do *not* convert it to host byte order; we leave it in
  * network byte order, as that's what its callers expect. */
-extern guint32 tvb_get_ipv4(tvbuff_t*, const gint offset);
+WS_DLL_PUBLIC guint32 tvb_get_ipv4(tvbuff_t *tvb, const gint offset);
 
 /* Fetch an IPv6 address. */
-extern void tvb_get_ipv6(tvbuff_t*, const gint offset, struct e_in6_addr *addr);
+WS_DLL_PUBLIC void tvb_get_ipv6(tvbuff_t *tvb, const gint offset,
+    struct e_in6_addr *addr);
 
 /* Fetch a GUID. */
-extern void tvb_get_ntohguid(tvbuff_t *tvb, const gint offset, e_guid_t *guid);
-extern void tvb_get_letohguid(tvbuff_t *tvb, const gint offset, e_guid_t *guid);
-extern void tvb_get_guid(tvbuff_t *tvb, const gint offset, e_guid_t *guid, const guint representation);
+WS_DLL_PUBLIC void tvb_get_ntohguid(tvbuff_t *tvb, const gint offset,
+    e_guid_t *guid);
+WS_DLL_PUBLIC void tvb_get_letohguid(tvbuff_t *tvb, const gint offset,
+    e_guid_t *guid);
+WS_DLL_PUBLIC void tvb_get_guid(tvbuff_t *tvb, const gint offset,
+    e_guid_t *guid, const guint encoding);
+
+/* Fetch a specified number of bits from bit offset in a tvb.  All of these
+ * functions are equivalent, except for the type of the return value.  Note
+ * that the parameter encoding (where supplied) is meaningless and ignored */
+
+/* get 1 - 8 bits returned in a guint8 */
+WS_DLL_PUBLIC guint8 tvb_get_bits8(tvbuff_t *tvb, guint bit_offset,
+    const gint no_of_bits);
+/* get 1 - 16 bits returned in a guint16 */
+WS_DLL_PUBLIC guint16 tvb_get_bits16(tvbuff_t *tvb, guint bit_offset,
+    const gint no_of_bits, const guint encoding);
+/* get 1 - 32 bits returned in a guint32 */
+WS_DLL_PUBLIC guint32 tvb_get_bits32(tvbuff_t *tvb, guint bit_offset,
+    const gint no_of_bits, const guint encoding);
+/* get 1 - 64 bits returned in a guint64 */
+WS_DLL_PUBLIC guint64 tvb_get_bits64(tvbuff_t *tvb, guint bit_offset,
+    const gint no_of_bits, const guint encoding);
 
-/* Fetch a specified number of bits from bit offset in a tvb */
-extern guint8 tvb_get_bits8(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits);
-extern guint16 tvb_get_bits16(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gboolean little_endian);
-extern guint32 tvb_get_bits32(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gboolean little_endian);
-extern guint64 tvb_get_bits64(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gboolean little_endian);
-
-/* Fetch a specified number of bits from bit offset in a tvb, but allow number
- * of bits to range between 1 and 32. If the requested number of bits is known
- * beforehand, or its range can be handled by a single function of the group
- * above, use one of them instead.
+/**
+ *  This function has EXACTLY the same behavior as
+ *  tvb_get_bits32()
  */
-extern guint32 tvb_get_bits(tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, const gboolean little_endian);
-
-void tvb_get_bits_buf(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, guint8 *buf, gboolean lsb0);
-guint8 *ep_tvb_get_bits(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean lsb0);
+WS_DLL_PUBLIC guint32 tvb_get_bits(tvbuff_t *tvb, const guint bit_offset,
+    const gint no_of_bits, const guint encoding);
 
 /** Returns target for convenience. Does not suffer from possible
  * expense of tvb_get_ptr(), since this routine is smart enough
@@ -300,17 +438,26 @@ guint8 *ep_tvb_get_bits(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolea
  * different TVBUFF_REAL_DATA tvbuffs. This function assumes that the
  * target memory is already allocated; it does not allocate or free the
  * target memory. */
-extern void* tvb_memcpy(tvbuff_t*, void* target, const gint offset, size_t length);
-
-/** It is the user's responsibility to g_free() the memory allocated by
- * tvb_memdup(). Calls tvb_memcpy() */
-extern void* tvb_memdup(tvbuff_t*, const gint offset, size_t length);
+WS_DLL_PUBLIC void *tvb_memcpy(tvbuff_t *tvb, void *target, const gint offset,
+    size_t length);
 
-/* Same as above but the buffer returned from this function does not have to
-* be freed. It will be automatically freed after the packet is dissected.
-* Buffers allocated by this function are NOT persistent.
-*/
-extern void* ep_tvb_memdup(tvbuff_t *tvb, const gint offset, size_t length);
+/** Given an allocator scope, a tvbuff, a byte offset, a byte length:
+ *
+ *    allocate a buffer using the specified scope;
+ *
+ *    copy the data from the tvbuff specified by the offset and length
+ *    into that buffer, using tvb_memcpy();
+ *
+ *    and return a pointer to the buffer.
+ *
+ * Throws an exception if the tvbuff ends before the data being copied does.
+ *
+ * If scope is set to NULL it is the user's responsibility to wmem_free()
+ * the memory allocated. Otherwise memory is automatically freed when the
+ * scope lifetime is reached.
+ */
+WS_DLL_PUBLIC void *tvb_memdup(wmem_allocator_t *scope, tvbuff_t *tvb,
+    const gint offset, size_t length);
 
 /** WARNING! This function is possibly expensive, temporarily allocating
  * another copy of the packet data. Furthermore, it's dangerous because once
@@ -337,119 +484,201 @@ extern void* ep_tvb_memdup(tvbuff_t *tvb, const gint offset, size_t length);
  * and the pointer to the newly-contiguous data is returned. This dynamically-
  * allocated memory will be freed when the tvbuff is freed, after the
  * tvbuff_free_cb_t() is called, if any. */
-extern const guint8* tvb_get_ptr(tvbuff_t*, const gint offset, const gint length);
+WS_DLL_PUBLIC const guint8 *tvb_get_ptr(tvbuff_t *tvb, const gint offset,
+    const gint length);
 
-/** Find first occurence of any of the needles in tvbuff, starting at offset.
- * Searches at most maxlength number of bytes; if maxlength is -1, searches
- * to end of tvbuff.
+/** Find first occurrence of needle in tvbuff, starting at offset. Searches
+ * at most maxlength number of bytes; if maxlength is -1, searches to
+ * end of tvbuff.
  * Returns the offset of the found needle, or -1 if not found.
  * Will not throw an exception, even if maxlength exceeds boundary of tvbuff;
  * in that case, -1 will be returned if the boundary is reached before
  * finding needle. */
-extern gint tvb_find_guint8(tvbuff_t*, const gint offset, const gint maxlength,
-    const guint8 needle);
+WS_DLL_PUBLIC gint tvb_find_guint8(tvbuff_t *tvb, const gint offset,
+    const gint maxlength, const guint8 needle);
+
 
-/** Find first occurence of any of the needles in tvbuff, starting at offset.
+/** Find first occurrence of any of the needles of the pre-compiled pattern in
+ * tvbuff, starting at offset. The passed in pattern must have been "compiled"
+ * before-hand, using ws_mempbrk_compile().
  * Searches at most maxlength number of bytes. Returns the offset of the
  * found needle, or -1 if not found and the found needle.
  * Will not throw an exception, even if
  * maxlength exceeds boundary of tvbuff; in that case, -1 will be returned if
  * the boundary is reached before finding needle. */
-extern gint tvb_pbrk_guint8(tvbuff_t *, const gint offset, const gint maxlength,
-    const guint8 *needles, guchar *found_needle);
+WS_DLL_PUBLIC gint tvb_ws_mempbrk_pattern_guint8(tvbuff_t *tvb, const gint offset,
+    const gint maxlength, const ws_mempbrk_pattern* pattern, guchar *found_needle);
+
 
 /** Find size of stringz (NUL-terminated string) by looking for terminating
  * NUL.  The size of the string includes the terminating NUL.
  *
  * If the NUL isn't found, it throws the appropriate exception.
  */
-extern guint tvb_strsize(tvbuff_t *tvb, const gint offset);
+WS_DLL_PUBLIC guint tvb_strsize(tvbuff_t *tvb, const gint offset);
+
+/** Find size of UCS-2 or UTF-16 stringz (NUL-terminated string) by
+ * looking for terminating 16-bit NUL.  The size of the string includes
+ * the terminating NUL.
+ *
+ * If the NUL isn't found, it throws the appropriate exception.
+ */
+WS_DLL_PUBLIC guint tvb_unicode_strsize(tvbuff_t *tvb, const gint offset);
 
 /** Find length of string by looking for end of zero terminated string, up to
  * 'maxlength' characters'; if 'maxlength' is -1, searches to end
  * of tvbuff.
  * Returns -1 if 'maxlength' reached before finding EOS. */
-extern gint tvb_strnlen(tvbuff_t*, const gint offset, const guint maxlength);
-
-/** Convert a string from Unicode to ASCII.  At the moment we fake it by
- * assuming all characters are ASCII  )-:  The len parameter is the number
- * of guint16's to convert from Unicode.
- *
- * XXX - These functions have been superceded by tvb_get_unicode_string()
- *       and tvb_get_ephemeral_unicode_string()
- *
- * tvb_fake_unicode() returns a buffer allocated by g_malloc() and must
- *                    be g_free() by the caller.
- * tvb_get_ephemeral_faked_unicode() returns a buffer that does not need
- *                    to be explicitely freed. Instead this buffer is
- *                    automatically freed when wireshark starts dissecting
- *                    the next packet.
- */
-extern char *tvb_fake_unicode(tvbuff_t *tvb, int offset, const int len,
-                              const gboolean little_endian);
-extern char *tvb_get_ephemeral_faked_unicode(tvbuff_t *tvb, int offset, const int len,
-                              const gboolean little_endian);
+WS_DLL_PUBLIC gint tvb_strnlen(tvbuff_t *tvb, const gint offset,
+    const guint maxlength);
 
 /**
  * Format the data in the tvb from offset for size ...
  */
-extern gchar * tvb_format_text(tvbuff_t *tvb, const gint offset, const gint size);
+WS_DLL_PUBLIC gchar *tvb_format_text(tvbuff_t *tvb, const gint offset,
+    const gint size);
 
 /**
  * Like "tvb_format_text()", but for 'wsp'; don't show
  * the characters as C-style escapes.
  */
-extern gchar * tvb_format_text_wsp(tvbuff_t *tvb, const gint offset, const gint size);
+WS_DLL_PUBLIC gchar *tvb_format_text_wsp(tvbuff_t *tvb, const gint offset,
+    const gint size);
 
 /**
  * Like "tvb_format_text()", but for null-padded strings; don't show
  * the null padding characters as "\000".
  */
-extern gchar *tvb_format_stringzpad(tvbuff_t *tvb, const gint offset, const gint size);
+extern gchar *tvb_format_stringzpad(tvbuff_t *tvb, const gint offset,
+    const gint size);
 
 /**
  * Like "tvb_format_text_wsp()", but for null-padded strings; don't show
  * the null padding characters as "\000".
  */
-extern gchar *tvb_format_stringzpad_wsp(tvbuff_t *tvb, const gint offset, const gint size);
+extern gchar *tvb_format_stringzpad_wsp(tvbuff_t *tvb, const gint offset,
+    const gint size);
 
+/**
+ * Given an allocator scope, a tvbuff, a byte offset, a byte length, and
+ * a string encoding, with the specified offset and length referring to
+ * a string in the specified encoding:
+ *
+ *    allocate a buffer using the specified scope;
+ *
+ *    convert the string from the specified encoding to UTF-8, possibly
+ *    mapping some characters or invalid octet sequences to the Unicode
+ *    REPLACEMENT CHARACTER, and put the resulting UTF-8 string, plus a
+ *    trailing '\0', into that buffer;
+ *
+ *    and return a pointer to the buffer.
+ *
+ * Throws an exception if the tvbuff ends before the string does.
+ *
+ * If scope is set to NULL it is the user's responsibility to wmem_free()
+ * the memory allocated. Otherwise memory is automatically freed when the
+ * scope lifetime is reached.
+ */
+WS_DLL_PUBLIC guint8 *tvb_get_string_enc(wmem_allocator_t *scope,
+    tvbuff_t *tvb, const gint offset, const gint length, const guint encoding);
 
 /**
- * Given a tvbuff, an offset, and a length, allocate a buffer big enough
- * to hold a non-null-terminated string of that length at that offset,
- * plus a trailing zero, copy the string into it, and return a pointer
- * to the string.
+ * Given an allocator scope, a tvbuff, a bit offset, and a length in
+ * 7-bit characters (not octets!), with the specified offset and
+ * length referring to a string in the 3GPP TS 23.038 7bits encoding:
+ *
+ *    allocate a buffer using the specified scope;
+ *
+ *    convert the string from the specified encoding to UTF-8, possibly
+ *    mapping some characters or invalid octet sequences to the Unicode
+ *    REPLACEMENT CHARACTER, and put the resulting UTF-8 string, plus a
+ *    trailing '\0', into that buffer;
+ *
+ *    and return a pointer to the buffer.
  *
  * Throws an exception if the tvbuff ends before the string does.
  *
- * tvb_get_string()  returns a string allocated by g_malloc() and therefore
- *                   MUST be g_free() by the caller in order not to leak
- *                   memory.
+ * If scope is set to NULL it is the user's responsibility to wmem_free()
+ * the memory allocated. Otherwise memory is automatically freed when the
+ * scope lifetime is reached.
+ */
+WS_DLL_PUBLIC gchar *tvb_get_ts_23_038_7bits_string(wmem_allocator_t *scope,
+    tvbuff_t *tvb, const gint bit_offset, gint no_of_chars);
+
+/**
+ * Given an allocator scope, a tvbuff, a bit offset, and a length in
+ * 7-bit characters (not octets!), with the specified offset and
+ * length referring to a string in the ASCII 7bits encoding:
  *
- * tvb_get_unicode_string() Unicode (UTF-16) version of above
+ *    allocate a buffer using the specified scope;
  *
- * tvb_get_ephemeral_string() returns a string that does not need to be freed,
- *                   instead it will automatically be freed once the next
- *                   packet is dissected.
+ *    convert the string from the specified encoding to UTF-8, possibly
+ *    mapping some characters or invalid octet sequences to the Unicode
+ *    REPLACEMENT CHARACTER, and put the resulting UTF-8 string, plus a
+ *    trailing '\0', into that buffer;
  *
- * tvb_get_ephemeral_string_enc() takes a string encoding as well, and
- *                   converts to UTF-8 from the encoding (only UTF-8 and
- *                   EBCDIC supported)
+ *    and return a pointer to the buffer.
  *
- * tvb_get_ephemeral_unicode_string() Unicode (UTF-16) version of above
+ * Throws an exception if the tvbuff ends before the string does.
  *
- * tvb_get_seasonal_string() returns a string that does not need to be freed,
- *                   instead it will automatically be freed when a new capture
- *                   or file is opened.
+ * If scope is set to NULL it is the user's responsibility to wmem_free()
+ * the memory allocated. Otherwise memory is automatically freed when the
+ * scope lifetime is reached.
  */
-extern guint8 *tvb_get_string(tvbuff_t *tvb, const gint offset, const gint length);
-extern gchar  *tvb_get_unicode_string(tvbuff_t *tvb, const gint offset, gint length, const guint encoding);
-extern guint8 *tvb_get_ephemeral_string(tvbuff_t *tvb, const gint offset, const gint length);
-extern guint8 *tvb_get_ephemeral_string_enc(tvbuff_t *tvb, const gint offset,
-    const gint length, const gint encoding);
-extern gchar  *tvb_get_ephemeral_unicode_string(tvbuff_t *tvb, const gint offset, gint length, const guint encoding);
-extern guint8 *tvb_get_seasonal_string(tvbuff_t *tvb, const gint offset, const gint length);
+WS_DLL_PUBLIC gchar *tvb_get_ascii_7bits_string(wmem_allocator_t *scope,
+    tvbuff_t *tvb, const gint bit_offset, gint no_of_chars);
 
+/**
+ * Given an allocator scope, a tvbuff, a byte offset, a byte length, and
+ * a string encoding, with the specified offset and length referring to
+ * a null-padded string in the specified encoding:
+ *
+ *    allocate a buffer using the specified scope;
+ *
+ *    convert the string from the specified encoding to UTF-8, possibly
+ *    mapping some characters or invalid octet sequences to the Unicode
+ *    REPLACEMENT CHARACTER, and put the resulting UTF-8 string, plus a
+ *    trailing '\0', into that buffer;
+ *
+ *    and return a pointer to the buffer.
+ *
+ * Throws an exception if the tvbuff ends before the string does.
+ *
+ * If scope is set to NULL it is the user's responsibility to wmem_free()
+ * the memory allocated. Otherwise memory is automatically freed when the
+ * scope lifetime is reached.
+ */
+WS_DLL_PUBLIC guint8 *tvb_get_stringzpad(wmem_allocator_t *scope,
+    tvbuff_t *tvb, const gint offset, const gint length, const guint encoding);
+
+/**
+ * Given an allocator scope, a tvbuff, a byte offset, a pointer to a
+ * gint, and a string encoding, with the specified offset referring to
+ * a null-terminated string in the specified encoding:
+ *
+ *    find the length of that string (and throw an exception if the tvbuff
+ *    ends before we find the null);
+ *
+ *    allocate a buffer using the specified scope;
+ *
+ *    convert the string from the specified encoding to UTF-8, possibly
+ *    mapping some characters or invalid octet sequences to the Unicode
+ *    REPLACEMENT CHARACTER, and put the resulting UTF-8 string, plus a
+ *    trailing '\0', into that buffer;
+ *
+ *    if the pointer to the gint is non-null, set the gint to which it
+ *    points to the length of the string;
+ *
+ *    and return a pointer to the buffer.
+ *
+ * Throws an exception if the tvbuff ends before the string does.
+ *
+ * If scope is set to NULL it is the user's responsibility to wmem_free()
+ * the memory allocated. Otherwise memory is automatically freed when the
+ * scope lifetime is reached.
+ */
+WS_DLL_PUBLIC guint8 *tvb_get_stringz_enc(wmem_allocator_t *scope,
+    tvbuff_t *tvb, const gint offset, gint *lengthp, const guint encoding);
 
 /**
  * Given a tvbuff and an offset, with the offset assumed to refer to
@@ -459,46 +688,24 @@ extern guint8 *tvb_get_seasonal_string(tvbuff_t *tvb, const gint offset, const g
  * and return a pointer to the string.  Also return the length of the
  * string (including the terminating null) through a pointer.
  *
- * tvb_get_stringz() returns a string allocated by g_malloc() and therefore
- *                   MUST be g_free() by the caller in order not to leak
- *                   memory.
+ * This returns a constant (unmodifiable) string that does not need
+ * to be freed; instead, it will automatically be freed once the next
+ * packet is dissected.
  *
- * tvb_get_stringz_enc() takes a string encoding as well, and converts to
- *                   UTF-8 from the encoding (only UTF-8 and EBCDIC supported)
- *
- * tvb_get_const_stringz() returns a constant (unmodifiable) string that does
- *                   not need to be freed, instead it will automatically be
- *                   freed once the next packet is dissected.  It is slightly
- *                   more efficient than the other routines.
- *
- * tvb_get_ephemeral_stringz() returns a string that does not need to be freed,
- *                   instead it will automatically be freed once the next
- *                   packet is dissected.
- *
- * tvb_get_ephemeral_stringz_enc() takes a string encoding as well, and
- *                   converts to UTF-8 from the encoding (only UTF-8 and
- *                   EBCDIC supported)
- *                   packet is dissected.
- *
- * tvb_get_ephemeral_unicode_stringz() Unicode (UTF-16) version of above
- *
- * tvb_get_seasonal_stringz() returns a string that does not need to be freed,
- *                   instead it will automatically be freed when a new capture
- *                   or file is opened.
+ * It is slightly more efficient than the other routines, but does *NOT*
+ * do any translation to UTF-8 - the string consists of the raw octets
+ * of the string, in whatever encoding they happen to be in, and, if
+ * the string is not valid in that encoding, with invalid octet sequences
+ * as they are in the packet.
  */
-extern guint8 *tvb_get_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp);
-extern guint8 *tvb_get_stringz_enc(tvbuff_t *tvb, const gint offset, gint *lengthp, gint encoding);
-extern const guint8 *tvb_get_const_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp);
-extern guint8 *tvb_get_ephemeral_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp);
-extern guint8 *tvb_get_ephemeral_stringz_enc(tvbuff_t *tvb, const gint offset, gint *lengthp, gint encoding);
-extern gchar  *tvb_get_ephemeral_unicode_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp, const guint encoding);
-extern guint8 *tvb_get_seasonal_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp);
+WS_DLL_PUBLIC const guint8 *tvb_get_const_stringz(tvbuff_t *tvb,
+    const gint offset, gint *lengthp);
 
 /** Looks for a stringz (NUL-terminated string) in tvbuff and copies
  * no more than bufsize number of bytes, including terminating NUL, to buffer.
- * Returns length of string (not including terminating NUL), or -1 if the string was
- * truncated in the buffer due to not having reached the terminating NUL.
- * In this way, it acts like g_snprintf().
+ * Returns length of string (not including terminating NUL), or -1 if the
+ * string was truncated in the buffer due to not having reached the terminating
+ * NUL.  In this way, it acts like g_snprintf().
  *
  * When processing a packet where the remaining number of bytes is less
  * than bufsize, an exception is not thrown if the end of the packet
@@ -507,8 +714,8 @@ extern guint8 *tvb_get_seasonal_stringz(tvbuff_t *tvb, const gint offset, gint *
  * is truncated with a NUL, albeit not at buffer[bufsize - 1], but
  * at the correct spot, terminating the string.
  */
-extern gint tvb_get_nstringz(tvbuff_t *tvb, const gint offset, const guint bufsize,
-    guint8* buffer);
+WS_DLL_PUBLIC gint tvb_get_nstringz(tvbuff_t *tvb, const gint offset,
+    const guint bufsize, guint8 *buffer);
 
 /** Like tvb_get_nstringz(), but never returns -1. The string is guaranteed to
  * have a terminating NUL. If the string was truncated when copied into buffer,
@@ -516,8 +723,8 @@ extern gint tvb_get_nstringz(tvbuff_t *tvb, const gint offset, const guint bufsi
  *
  * bufsize MUST be greater than 0.
  */
-extern gint tvb_get_nstringz0(tvbuff_t *tvb, const gint offset, const guint bufsize,
-    guint8* buffer);
+WS_DLL_PUBLIC gint tvb_get_nstringz0(tvbuff_t *tvb, const gint offset,
+    const guint bufsize, guint8 *buffer);
 
 /**
  * Given a tvbuff, an offset into the tvbuff, and a length that starts
@@ -529,16 +736,16 @@ extern gint tvb_get_nstringz0(tvbuff_t *tvb, const gint offset, const guint bufs
  * Return the length of the line (not counting the line terminator at
  * the end), or, if we don't find a line terminator:
  *
- *     if "deseg" is true, return -1;
+ *  if "deseg" is true, return -1;
  *
- *     if "deseg" is false, return the amount of data remaining in
- *     the buffer.
+ *  if "deseg" is false, return the amount of data remaining in
+ *  the buffer.
  *
  * Set "*next_offset" to the offset of the character past the line
  * terminator, or past the end of the buffer if we don't find a line
  * terminator.  (It's not set if we return -1.)
  */
-extern gint tvb_find_line_end(tvbuff_t *tvb, const gint offset, int len,
+WS_DLL_PUBLIC gint tvb_find_line_end(tvbuff_t *tvb, const gint offset, int len,
     gint *next_offset, const gboolean desegment);
 
 /**
@@ -559,8 +766,8 @@ extern gint tvb_find_line_end(tvbuff_t *tvb, const gint offset, int len,
  * terminator, or past the end of the buffer if we don't find a line
  * terminator.
  */
-extern gint tvb_find_line_end_unquoted(tvbuff_t *tvb, const gint offset, int len,
-    gint *next_offset);
+WS_DLL_PUBLIC gint tvb_find_line_end_unquoted(tvbuff_t *tvb, const gint offset,
+    int len, gint *next_offset);
 
 /**
  * Copied from the mgcp dissector. (This function should be moved to /epan )
@@ -579,85 +786,119 @@ extern gint tvb_find_line_end_unquoted(tvbuff_t *tvb, const gint offset, int len
  *          is smaller.
  */
 
-extern gint tvb_skip_wsp(tvbuff_t* tvb, const gint offset, const gint maxlength);
+WS_DLL_PUBLIC gint tvb_skip_wsp(tvbuff_t *tvb, const gint offset,
+    const gint maxlength);
+
+WS_DLL_PUBLIC gint tvb_skip_wsp_return(tvbuff_t *tvb, const gint offset);
 
-extern gint tvb_skip_wsp_return(tvbuff_t* tvb, const gint offset);
+int tvb_skip_guint8(tvbuff_t *tvb, int offset, const int maxlength, const guint8 ch);
 
 /**
  * Call strncmp after checking if enough chars left, returning 0 if
  * it returns 0 (meaning "equal") and -1 otherwise, otherwise return -1.
  */
-extern gint tvb_strneql(tvbuff_t *tvb, const gint offset, const gchar *str,
-    const size_t size);
+WS_DLL_PUBLIC gint tvb_strneql(tvbuff_t *tvb, const gint offset,
+    const gchar *str, const size_t size);
 
 /**
  * Call g_ascii_strncasecmp after checking if enough chars left, returning
  * 0 if it returns 0 (meaning "equal") and -1 otherwise, otherwise return -1.
  */
-extern gint tvb_strncaseeql(tvbuff_t *tvb, const gint offset, const gchar *str,
-    const size_t size);
+WS_DLL_PUBLIC gint tvb_strncaseeql(tvbuff_t *tvb, const gint offset,
+    const gchar *str, const size_t size);
 
 /**
  * Call memcmp after checking if enough chars left, returning 0 if
  * it returns 0 (meaning "equal") and -1 otherwise, otherwise return -1.
  */
-extern gint tvb_memeql(tvbuff_t *tvb, const gint offset, const guint8 *str,
-    size_t size);
+WS_DLL_PUBLIC gint tvb_memeql(tvbuff_t *tvb, const gint offset,
+    const guint8 *str, size_t size);
 
 /**
  * Format a bunch of data from a tvbuff as bytes, returning a pointer
  * to the string with the formatted data, with "punct" as a byte
  * separator.
  */
-extern gchar *tvb_bytes_to_str_punct(tvbuff_t *tvb, const gint offset, const gint len,
-    const gchar punct);
+WS_DLL_PUBLIC gchar *tvb_bytes_to_str_punct(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset,
+    const gint len, const gchar punct);
 
 /**
  * Format a bunch of data from a tvbuff as bytes, returning a pointer
  * to the string with the formatted data.
  */
-extern gchar *tvb_bytes_to_str(tvbuff_t *tvb, const gint offset, const gint len);
+WS_DLL_PUBLIC gchar *tvb_bytes_to_str(wmem_allocator_t *allocator, tvbuff_t *tvb,
+    const gint offset, const gint len);
 
 /**
  * Given a tvbuff, an offset into the tvbuff, and a length that starts
  * at that offset (which may be -1 for "all the way to the end of the
  * tvbuff"), fetch BCD encoded digits from a tvbuff starting from either
- * the low or high half byte, formating the digits according to an input digit set,
- * if NUll a default digit set of 0-9 returning "?" for overdecadic digits will be used.
- * A pointer to the EP allocated string will be returned.
- * Note a tvbuff content of 0xf is considered a 'filler' and will end the conversion.
+ * the low or high half byte, formatting the digits according to an input digit
+ * set, if NUL a default digit set of 0-9 returning "?" for overdecadic digits
+ * will be used.  A pointer to the packet-scope (WMEM-allocated) string will
+ * be returned. Note a tvbuff content of 0xf is considered a 'filler' and will
+ * end the conversion.
  */
 typedef struct dgt_set_t
 {
-       const unsigned char out[15];
+    const unsigned char out[16];
 }
 dgt_set_t;
 
-extern const gchar *tvb_bcd_dig_to_ep_str(tvbuff_t *tvb, const gint offset, const gint len, dgt_set_t *dgt, gboolean skip_first);
-
-struct tvbuff *tvb_get_ds_tvb(tvbuff_t *tvb);
+WS_DLL_PUBLIC const gchar *tvb_bcd_dig_to_wmem_packet_str(tvbuff_t *tvb,
+    const gint offset, const gint len, dgt_set_t *dgt, gboolean skip_first);
 
 /** Locate a sub-tvbuff within another tvbuff, starting at position
  * 'haystack_offset'. Returns the index of the beginning of 'needle' within
  * 'haystack', or -1 if 'needle' is not found. The index is relative
  * to the start of 'haystack', not 'haystack_offset'. */
-extern gint tvb_find_tvb(tvbuff_t *haystack_tvb, tvbuff_t *needle_tvb,
-       const gint haystack_offset);
+WS_DLL_PUBLIC gint tvb_find_tvb(tvbuff_t *haystack_tvb, tvbuff_t *needle_tvb,
+    const gint haystack_offset);
+
+/* From tvbuff_zlib.c */
 
 /**
  * Uncompresses a zlib compressed packet inside a tvbuff at offset with
  * length comprlen.  Returns an uncompressed tvbuffer if uncompression
  * succeeded or NULL if uncompression failed.
  */
-extern tvbuff_t* tvb_uncompress(tvbuff_t *tvb, const int offset,  int comprlen);
+WS_DLL_PUBLIC tvbuff_t *tvb_uncompress(tvbuff_t *tvb, const int offset,
+    int comprlen);
 
 /**
  * Uncompresses a zlib compressed packet inside a tvbuff at offset with
- * length comprlen.  Returns an uncompressed tvbuffer attached to tvb if uncompression
- * succeeded or NULL if uncompression failed.
+ * length comprlen.  Returns an uncompressed tvbuffer attached to tvb if
+ * uncompression succeeded or NULL if uncompression failed.
  */
-extern tvbuff_t* tvb_child_uncompress(tvbuff_t *parent, tvbuff_t *tvb, const int offset, int comprlen);
+WS_DLL_PUBLIC tvbuff_t *tvb_child_uncompress(tvbuff_t *parent, tvbuff_t *tvb,
+    const int offset, int comprlen);
+
+/* From tvbuff_base64.c */
+
+/** Return a tvb that contains the binary representation of a base64
+ *  string
+ */
+extern tvbuff_t* base64_to_tvb(tvbuff_t *parent, const char *base64);
 
 /************** END OF ACCESSORS ****************/
 
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
 #endif /* __TVBUFF_H__ */
+
+/*
+ * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */