From Clemens Auer:
[obnox/wireshark/wip.git] / doc / README.developer
index b975424e5e2dc92bcc0feaf8905082aa3b904312..b8956c82b85556dccea51ead638fb1d7a62c1749 100644 (file)
@@ -26,16 +26,16 @@ root dir.
 
 You'll find additional information in the following README files:
 
-- README.capture - the capture engine internals
-- README.design - Wireshark software design - incomplete
-- README.developer - this file
+- README.capture        - the capture engine internals
+- README.design         - Wireshark software design - incomplete
+- README.developer      - this file
 - README.display_filter - Display Filter Engine
-- README.idl2wrs - CORBA IDL converter
-- README.packaging - how to distribute a software package containing WS
-- README.regression - regression testing of WS and TS
-- README.stats_tree - a tree statistics counting specific packets
-- README.tapping - "tap" a dissector to get protocol specific events
-- README.xml-output - how to work with the PDML exported output
+- README.idl2wrs        - CORBA IDL converter
+- README.packaging      - how to distribute a software package containing WS
+- README.regression     - regression testing of WS and TS
+- README.stats_tree     - a tree statistics counting specific packets
+- README.tapping        - "tap" a dissector to get protocol specific events
+- README.xml-output     - how to work with the PDML exported output
 - wiretap/README.developer - how to add additional capture file types to
   Wiretap
 
@@ -44,10 +44,11 @@ You'll find additional information in the following README files:
 You'll find additional dissector related information in the following README
 files:
 
-- README.binarytrees - fast access to large data collections
-- README.heuristic - what are heuristic dissectors and how to write them
-- README.malloc - how to obtain "memory leak free" memory
-- README.plugins - how to "pluginize" a dissector
+- README.binarytrees    - fast access to large data collections
+- README.heuristic      - what are heuristic dissectors and how to write them
+- README.malloc         - how to obtain "memory leak free" memory
+- README.plugins        - how to "pluginize" a dissector
+- README.python         - writing a dissector in PYTHON.
 - README.request_response_tracking - how to track req./resp. times and such
 
 0.3 Contributors
@@ -81,6 +82,9 @@ thus run through C rather than C++ compilers, and not all C compilers
 support C++-style comments (GCC does, but IBM's C compiler for AIX, for
 example, doesn't do so by default).
 
+In general, don't use C99 features since some C compilers used to compile
+Wireshark don't support C99 (E.G. Microsoft C).
+
 Don't initialize variables in their declaration with non-constant
 values. Not all compilers support this. E.g. don't use
        guint32 i = somearray[2];
@@ -96,15 +100,16 @@ Don't declare variables in the middle of executable code; not all C
 compilers support that.  Variables should be declared outside a
 function, or at the beginning of a function or compound statement.
 
-Don't use anonymous unions; not all compilers support it. 
+Don't use anonymous unions; not all compilers support them.
 Example:
-typedef struct foo {
-  guint32 foo;
-  union {
-    guint32 foo_l;
-    guint16 foo_s;
-  } u;  /* have a name here */
-} foo_t;
+
+       typedef struct foo {
+         guint32 foo;
+         union {
+           guint32 foo_l;
+           guint16 foo_s;
+         } u;  /* have a name here */
+       } foo_t;
 
 Don't use "uchar", "u_char", "ushort", "u_short", "uint", "u_int",
 "ulong", "u_long" or "boolean"; they aren't defined on all platforms.
@@ -142,7 +147,7 @@ functions won't accept a size_t on LLP64:
        size_t i;
        char greeting[] = "hello, sailor";
        guint byte_after_greet;
-       
+
        i = strlen(greeting);
        byte_after_greet = tvb_get_guint8(tvb, i); /* Compiler warning */
 
@@ -152,7 +157,7 @@ will have to cast to a compatible data type, e.g.
        size_t i;
        char greeting[] = "hello, sailor";
        guint byte_after_greet;
-       
+
        i = strlen(greeting);
        byte_after_greet = tvb_get_guint8(tvb, (gint) i); /* OK */
 
@@ -161,9 +166,9 @@ or
        gint i;
        char greeting[] = "hello, sailor";
        guint byte_after_greet;
-       
+
        i = (gint) strlen(greeting);
-       byte_after_greet = tvb_get_guint8(tvb, i); /* Compiler warning */
+       byte_after_greet = tvb_get_guint8(tvb, i); /* OK */
 
 See http://www.unix.org/version2/whatsnew/lp64_wp.html for more
 information on the sizes of common types in different data models.
@@ -178,11 +183,6 @@ Wireshark that take format arguments, use G_GINT64_MODIFIER, for example:
                        "Sequence Number: %" G_GINT64_MODIFIER "u",
                        sequence_number);
 
-When using standard C routines, such as printf and scanf, use
-PRId64, PRIu64, PRIx64, PRIX64, and PRIo64; for example:
-
-   printf("Sequence Number: %" PRIu64 "\n", sequence_number);
-
 When specifying an integral constant that doesn't fit in 32 bits, don't
 use "LL" at the end of the constant - not all compilers use "LL" for
 that.  Instead, put the constant in a call to the "G_GINT64_CONSTANT()"
@@ -194,6 +194,26 @@ rather than
 
        11644473600ULL
 
+Don't assume that you can scan through a va_list initialized by va_start
+more than once without closing it with va_end and re-initalizing it with
+va_start.  This applies even if you're not scanning through it yourself,
+but are calling a routine that scans through it, such as vfprintf() or
+one of the routines in Wireshark that takes a format and a va_list as an
+argument.  You must do
+
+       va_start(ap, format);
+       call_routine1(xxx, format, ap);
+       va_end(ap);
+       va_start(ap, format);
+       call_routine2(xxx, format, ap);
+       va_end(ap);
+
+rather
+       va_start(ap, format);
+       call_routine1(xxx, format, ap);
+       call_routine2(xxx, format, ap);
+       va_end(ap);
+
 Don't use a label without a statement following it.  For example,
 something such as
 
@@ -414,10 +434,10 @@ cause a trap, which will, at best, result in the OS slowly performing an
 unaligned access for you, and will, on at least some platforms, cause
 the program to be terminated.
 
-Wireshark supports platforms with GLib 2.4[.x]/GTK+ 2.4[.x] or newer. 
-If a Glib/GTK+ mechanism is available only in Glib/GTK+ versions 
+Wireshark supports platforms with GLib 2.4[.x]/GTK+ 2.4[.x] or newer.
+If a Glib/GTK+ mechanism is available only in Glib/GTK+ versions
 newer than 2.4/2.4 then use "#if GTK_CHECK_VERSION(...)" to conditionally
-compile code using that mechanism. 
+compile code using that mechanism.
 
 When different code must be used on UN*X and Win32, use a #if or #ifdef
 that tests _WIN32, not WIN32.  Try to write code portably whenever
@@ -528,8 +548,15 @@ Do *NOT* use "g_assert()" or "g_assert_not_reached()" in dissectors.
 that it's a problem with the dissector if found; if it cannot do
 anything else with a particular value from a packet's data, the
 dissector should put into the protocol tree an indication that the
-value is invalid, and should return. You can use the DISSECTOR_ASSERT
-macro for that purpose.
+value is invalid, and should return.  The "expert" mechanism should be
+used for that purpose.
+
+If there is a case where you are checking not for an invalid data item
+in the packet, but for a bug in the dissector (for example, an
+assumption being made at a particular point in the code about the
+internal state of the dissector), use the DISSECTOR_ASSERT macro for
+that purpose; this will put into the protocol tree an indication that
+the dissector has a bug in it, and will not crash the application.
 
 If you are allocating a chunk of memory to contain data from a packet,
 or to contain information derived from data in a packet, and the size of
@@ -601,6 +628,17 @@ the length was added to it, if the length field is greater than 24 bits
 long, so that, if the length value is *very* large and adding it to the
 offset causes an overflow, that overflow is detected.
 
+If you have a
+
+       for (i = {start}; i < {end}; i++)
+
+loop, make sure that the type of the loop index variable is large enough
+to hold the maximum {end} value plus 1; otherwise, the loop index
+variable can overflow before it ever reaches its maximum value.  In
+particular, be very careful when using gint8, guint8, gint16, or guint16
+variables as loop indices; you almost always want to use an "int"/"gint"
+or "unsigned int"/"guint" as the loop index rather than a shorter type.
+
 If you are fetching a length field from the buffer, corresponding to the
 length of a portion of the packet, and subtracting from that length a
 value corresponding to the length of, for example, a header in the
@@ -693,8 +731,9 @@ protocol, if any.
 Usually, you will put your newly created dissector file into the directory
 epan/dissectors, just like all the other packet-....c files already in there.
 
-Also, please add your dissector file to the corresponding makefile,
-described in section "1.9 Editing Makefile.common to add your dissector" below.
+Also, please add your dissector file to the corresponding makefiles,
+described in section "1.9 Editing Makefile.common and CMakeLists.txt
+to add your dissector" below.
 
 Dissectors that use the dissector registration to register with a lower level
 dissector don't need to define a prototype in the .h file. For other
@@ -716,6 +755,9 @@ code inside
 is needed only if you are using a function from libpcre, e.g. the
 "pcre_compile()" function.
 
+The stdio.h, stdlib.h and string.h header files should be included only as needed.
+
+
 The "$Id$" in the comment will be updated by Subversion when the file is
 checked in.
 
@@ -726,7 +768,7 @@ SVN repository (committed).
 ------------------------------------Cut here------------------------------------
 /* packet-PROTOABBREV.c
  * Routines for PROTONAME dissection
- * Copyright 200x, YOUR_NAME <YOUR_EMAIL_ADDRESS>
+ * Copyright 201x, YOUR_NAME <YOUR_EMAIL_ADDRESS>
  *
  * $Id$
  *
@@ -759,9 +801,12 @@ SVN repository (committed).
 # include "config.h"
 #endif
 
+#if 0
+/* Include only as needed */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#endif
 
 #include <glib.h>
 
@@ -772,7 +817,7 @@ SVN repository (committed).
    in a header file. If not, a header file is not needed at all. */
 #include "packet-PROTOABBREV.h"
 
-/* Forward declaration we need below (if using proto_reg_handoff...     
+/* Forward declaration we need below (if using proto_reg_handoff...
    as a prefs callback)       */
 void proto_reg_handoff_PROTOABBREV(void);
 
@@ -817,18 +862,13 @@ dissect_PROTOABBREV(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                return 0;
 
 /* Make entries in Protocol column and Info column on summary display */
-       if (check_col(pinfo->cinfo, COL_PROTOCOL))
-               col_set_str(pinfo->cinfo, COL_PROTOCOL, "PROTOABBREV");
+       col_set_str(pinfo->cinfo, COL_PROTOCOL, "PROTOABBREV");
 
 /* This field shows up as the "Info" column in the display; you should use
    it, if possible, to summarize what's in the packet, so that a user looking
    at the list of packets can tell what type of packet it is. See section 1.5
    for more information.
 
-   Before changing the contents of a column you should make sure the column is
-   active by calling "check_col(pinfo->cinfo, COL_*)". If it is not active
-   don't bother setting it.
-
    If you are setting the column to a constant string, use "col_set_str()",
    as it's more efficient than the other "col_set_XXX()" calls.
 
@@ -846,32 +886,19 @@ dissect_PROTOABBREV(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
    past the end of the packet, so that the Info column doesn't have data
    left over from the previous dissector; do
 
-       if (check_col(pinfo->cinfo, COL_INFO))
-               col_clear(pinfo->cinfo, COL_INFO);
+       col_clear(pinfo->cinfo, COL_INFO);
 
    */
 
-       if (check_col(pinfo->cinfo, COL_INFO))
-               col_set_str(pinfo->cinfo, COL_INFO, "XXX Request");
-
-/* A protocol dissector can be called in 2 different ways:
-
-       (a) Operational dissection
-
-               In this mode, Wireshark is only interested in the way protocols
-               interact, protocol conversations are created, packets are
-               reassembled and handed over to higher-level protocol dissectors.
-               In this mode Wireshark does not build a so-called "protocol
-               tree".
+       col_set_str(pinfo->cinfo, COL_INFO, "XXX Request");
 
-       (b) Detailed dissection
+/* A protocol dissector may be called in 2 different ways - with, or
+   without a non-null "tree" argument.
 
-               In this mode, Wireshark is also interested in all details of
-               a given protocol, so a "protocol tree" is created.
-
-   Wireshark distinguishes between the 2 modes with the proto_tree pointer:
-       (a) <=> tree == NULL
-       (b) <=> tree != NULL
+   If the proto_tree argument is null, Wireshark does not need to use
+   the protocol tree information from your dissector, and therefore is
+   passing the dissector a null "tree" argument so that it doesn't
+   need to do work necessary to build the protocol tree.
 
    In the interest of speed, if "tree" is NULL, avoid building a
    protocol tree and adding stuff to it, or even looking at any packet
@@ -891,7 +918,12 @@ dissect_PROTOABBREV(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
    work if you're not building a protocol tree, but if the code would
    have a lot of tests whether "tree" is null if you skipped that work,
    you might still be better off just doing all that work regardless of
-   whether "tree" is null or not. */
+   whether "tree" is null or not.
+
+   Note also that there is no guarantee, the first time the dissector is
+   called, whether "tree" will be null or not; your dissector must work
+   correctly, building or updating whatever state information is
+   necessary, in either case. */
        if (tree) {
 
 /* NOTE: The offset and length values in the call to
@@ -903,13 +935,13 @@ dissect_PROTOABBREV(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
    offset to the end of the packet. */
 
 /* create display subtree for the protocol */
-               ti = proto_tree_add_item(tree, proto_PROTOABBREV, tvb, 0, -1, FALSE);
+               ti = proto_tree_add_item(tree, proto_PROTOABBREV, tvb, 0, -1, ENC_NA);
 
                PROTOABBREV_tree = proto_item_add_subtree(ti, ett_PROTOABBREV);
 
 /* add an item to the subtree, see section 1.6 for more information */
                proto_tree_add_item(PROTOABBREV_tree,
-                   hf_PROTOABBREV_FIELDABBREV, tvb, offset, len, FALSE);
+                   hf_PROTOABBREV_FIELDABBREV, tvb, offset, len, ENC_xxx);
 
 
 /* Continue adding tree items to process the packet here */
@@ -939,7 +971,7 @@ proto_register_PROTOABBREV(void)
        static hf_register_info hf[] = {
                { &hf_PROTOABBREV_FIELDABBREV,
                        { "FIELDNAME",           "PROTOABBREV.FIELDABBREV",
-                       FIELDTYPE, FIELDBASE, FIELDCONVERT, BITMASK,
+                       FIELDTYPE, FIELDDISPLAY, FIELDCONVERT, BITMASK,
                        "FIELDDESCR", HFILL }
                }
        };
@@ -966,26 +998,38 @@ proto_register_PROTOABBREV(void)
        PROTOABBREV_module = prefs_register_protocol(proto_PROTOABBREV,
            proto_reg_handoff_PROTOABBREV);
 
+/* Register preferences module under preferences subtree.
+   Use this function instead of prefs_register_protocol if you want to group
+   preferences of several protocols under one preferences subtree.
+   Argument subtree identifies grouping tree node name, several subnodes can be
+   specified usign slash '/' (e.g. "OSI/X.500" - protocol preferences will be
+   accessible under Protocols->OSI->X.500-><PROTOSHORTNAME> preferences node.
+*/
+  PROTOABBREV_module = prefs_register_protocol_subtree(const char *subtree,
+       proto_PROTOABBREV, proto_reg_handoff_PROTOABBREV);
+
 /* Register a sample preference */
        prefs_register_bool_preference(PROTOABBREV_module, "show_hex",
             "Display numbers in Hex",
             "Enable to display numerical values in hexadecimal.",
             &gPREF_HEX);
-}
+
 /* Register a sample port preference   */
        prefs_register_uint_preference(PROTOABBREV_module, "tcp.port", "PROTOABBREV TCP Port",
             " PROTOABBREV TCP port if other than the default",
             10, &gPORT_PREF);
+}
+
 
 /* If this dissector uses sub-dissector registration add a registration routine.
    This exact format is required because a script is used to find these
    routines and create the code that calls these routines.
 
-   If this function is registered as a prefs callback (see prefs_register_protocol 
+   If this function is registered as a prefs callback (see prefs_register_protocol
    above) this function is also called by preferences whenever "Apply" is pressed;
    In that case, it should accommodate being called more than once.
 
-   This form of the reg_handoff function is used if if you perform 
+   This form of the reg_handoff function is used if if you perform
    registration functions which are dependent upon prefs. See below
    for a simpler form  which can be used if there are no
    prefs-dependent registration functions.
@@ -1005,8 +1049,6 @@ proto_reg_handoff_PROTOABBREV(void)
  */
                PROTOABBREV_handle = new_create_dissector_handle(dissect_PROTOABBREV,
                                                                 proto_PROTOABBREV);
-               dissector_add("PARENT_SUBFIELD", ID_VALUE, PROTOABBREV_handle);
-
                initialized = TRUE;
        } else {
 
@@ -1014,19 +1056,19 @@ proto_reg_handoff_PROTOABBREV(void)
                  If you perform registration functions which are dependent upon
                  prefs the you should de-register everything which was associated
                  with the previous settings and re-register using the new prefs
-                 settings here. In general this means you need to keep track of 
-                 the PROTOABBREV_handle and the value the preference had at the time 
+                 settings here. In general this means you need to keep track of
+                 the PROTOABBREV_handle and the value the preference had at the time
                  you registered.  The PROTOABBREV_handle value and the value of the
-                 preference can be saved using local statics in this 
+                 preference can be saved using local statics in this
                  function (proto_reg_handoff).
                */
 
-               dissector_delete("tcp.port", currentPort, PROTOABBREV_handle);
+               dissector_delete_uint("tcp.port", currentPort, PROTOABBREV_handle);
        }
 
        currentPort = gPORT_PREF;
 
-       dissector_add("tcp.port", currentPort, PROTOABBREV_handle);
+       dissector_add_uint("tcp.port", currentPort, PROTOABBREV_handle);
 
 }
 
@@ -1046,7 +1088,7 @@ proto_reg_handoff_PROTOABBREV(void)
  */
        PROTOABBREV_handle = new_create_dissector_handle(dissect_PROTOABBREV,
                                                         proto_PROTOABBREV);
-       dissector_add("PARENT_SUBFIELD", ID_VALUE, PROTOABBREV_handle);
+       dissector_add_uint("PARENT_SUBFIELD", ID_VALUE, PROTOABBREV_handle);
 }
 #endif
 
@@ -1081,11 +1123,27 @@ FIELDTYPE       FT_NONE, FT_BOOLEAN, FT_UINT8, FT_UINT16, FT_UINT24,
                FT_RELATIVE_TIME, FT_STRING, FT_STRINGZ, FT_EBCDIC,
                FT_UINT_STRING, FT_ETHER, FT_BYTES, FT_UINT_BYTES, FT_IPv4,
                FT_IPv6, FT_IPXNET, FT_FRAMENUM, FT_PROTOCOL, FT_GUID, FT_OID
-FIELDBASE      BASE_NONE, BASE_DEC, BASE_HEX, BASE_OCT, BASE_DEC_HEX,
-               BASE_HEX_DEC, BASE_RANGE_STRING, BASE_CUSTOM
+FIELDDISPLAY   For FT_UINT{8,16,24,32,64} and FT_INT{8,16,24,32,64):
+
+               BASE_DEC, BASE_HEX, BASE_OCT, BASE_DEC_HEX, BASE_HEX_DEC,
+               or BASE_CUSTOM, possibly ORed with BASE_RANGE_STRING
+
+               For FT_ABSOLUTE_TIME:
+
+               ABSOLUTE_TIME_LOCAL, ABSOLUTE_TIME_UTC, or
+               ABSOLUTE_TIME_DOY_UTC
+
+               For FT_BOOLEAN if BITMASK is non-zero:
+
+               Number of bits in the field containing the FT_BOOLEAN
+               bitfield
+
+               For all other types:
+
+               BASE_NONE
 FIELDCONVERT   VALS(x), RVALS(x), TFS(x), NULL
 BITMASK                Usually 0x0 unless using the TFS(x) field conversion.
-FIELDDESCR     A brief description of the field, or NULL.
+FIELDDESCR     A brief description of the field, or NULL. [Please do not use ""].
 PARENT_SUBFIELD        Lower level protocol field used for lookup, i.e. "tcp.port"
 ID_VALUE       Lower level protocol field value that identifies this protocol
                For example the TCP or UDP port number
@@ -1184,7 +1242,9 @@ void tvb_get_letohguid(tvbuff_t *, gint offset, e_guid_t *guid);
 String accessors:
 
 guint8 *tvb_get_string(tvbuff_t*, gint offset, gint length);
+gchar  *tvb_get_unicode_string(tvbuff_t *tvb, const gint offset, gint length, const guint encoding);
 guint8 *tvb_get_ephemeral_string(tvbuff_t*, gint offset, gint length);
+gchar  *tvb_get_ephemeral_unicode_string(tvbuff_t *tvb, const gint offset, gint length, const guint encoding);
 guint8 *tvb_get_seasonal_string(tvbuff_t*, gint offset, gint length);
 
 Returns a null-terminated buffer containing data from the specified
@@ -1196,72 +1256,93 @@ tvb_get_string() returns a buffer allocated by g_malloc() so you must
 g_free() it when you are finished with the string. Failure to g_free() this
 buffer will lead to memory leaks.
 
+tvb_get_unicode_string() is a unicode (UTF-16) version of above.  This
+is intended for reading UTF-16 unicode strings out of a tvbuff and
+returning them as a UTF-8 string for use in Wireshark.  The offset and
+returned length pointer are in bytes, not UTF-16 characters.
+
 tvb_get_ephemeral_string() returns a buffer allocated from a special heap
 with a lifetime until the next packet is dissected. You do not need to
 free() this buffer, it will happen automatically once the next packet is
 dissected.
 
+tvb_get_ephemeral_unicode_string() is a unicode (UTF-16) version of above.
+This is intended for reading UTF-16 unicode strings out of a tvbuff and
+returning them as a UTF-8 string for use in Wireshark.  The offset and
+returned length pointer are in bytes, not UTF-16 characters.
+
 tvb_get_seasonal_string() returns a buffer allocated from a special heap
 with a lifetime of the current capture session. You do not need to
 free() this buffer, it will happen automatically once the a new capture or
 file is opened.
 
 guint8 *tvb_get_stringz(tvbuff_t *tvb, gint offset, gint *lengthp);
+const guint8 *tvb_get_const stringz(tvbuff_t *tvb, gint offset, gint *lengthp);
 guint8 *tvb_get_ephemeral_stringz(tvbuff_t *tvb, gint offset, gint *lengthp);
+gchar  *tvb_get_ephemeral_unicode_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp, const guint encoding);
 guint8 *tvb_get_seasonal_stringz(tvbuff_t *tvb, gint offset, gint *lengthp);
 
-Returns a null-terminated buffer, allocated with "g_malloc()",
-containing data from the specified tvbuff, starting at the
-specified offset, and containing all characters from the tvbuff up to
-and including a terminating null character in the tvbuff.  "*lengthp"
-will be set to the length of the string, including the terminating null.
+Returns a null-terminated buffer containing data from the specified tvbuff,
+starting at the specified offset, and containing all characters from the
+tvbuff up to and including a terminating null character in the tvbuff.
+"*lengthp" will be set to the length of the string, including the terminating
+null.
 
 tvb_get_stringz() returns a buffer allocated by g_malloc() so you must
 g_free() it when you are finished with the string. Failure to g_free() this
 buffer will lead to memory leaks.
+
+tvb_get_const_stringz() returns a pointer to the (const) string in the tvbuff.
+You do not need to free() this buffer, it will happen automatically once the
+next packet is dissected.  This function is slightly more efficient than the
+others because it does not allocate memory and copy the string.
+
 tvb_get_ephemeral_stringz() returns a buffer allocated from a special heap
 with a lifetime until the next packet is dissected. You do not need to
 free() this buffer, it will happen automatically once the next packet is
 dissected.
 
+tvb_get_ephemeral_unicode_stringz() is a unicode (UTF-16) version of
+above.  This is intended for reading UTF-16 unicode strings out of a tvbuff
+and returning them as a UTF-8 string for use in Wireshark.  The offset and
+returned length pointer are in bytes, not UTF-16 characters.
+
 tvb_get_seasonal_stringz() returns a buffer allocated from a special heap
 with a lifetime of the current capture session. You do not need to
 free() this buffer, it will happen automatically once the a new capture or
 file is opened.
 
-guint8 *tvb_fake_unicode(tvbuff_t*, gint offset, gint length, gboolean little_endian);
-guint8 *tvb_get_ephemeral_faked_unicode(tvbuff_t*, gint offset, gint length, gboolean little_endian);
+tvb_fake_unicode() has been superceded by tvb_get_unicode_string(), which
+properly handles Unicode (UTF-16) strings by converting them to UTF-8.
 
-Converts a 2-byte unicode string to an ASCII string.
-Returns a null-terminated buffer containing data from the specified
-tvbuff, starting at the specified offset, and containing the specified
-length worth of characters (the length of the buffer will be length+1,
-as it includes a null character to terminate the string).
-
-tvb_fake_unicode() returns a buffer allocated by g_malloc() so you must
-g_free() it when you are finished with the string. Failure to g_free() this
-buffer will lead to memory leaks.
-tvb_get_ephemeral_faked_unicode() returns a buffer allocated from a special
-heap with a lifetime until the next packet is dissected. You do not need to
-free() this buffer, it will happen automatically once the next packet is
-dissected.
+tvb_get_ephemeral_faked_unicode() has been superceded by tvb_get_ephemeral_string(), which properly handles Unicode (UTF-16) strings by converting them
+to UTF-8.
 
 Byte Array Accessors:
 
 gchar *tvb_bytes_to_str(tvbuff_t *tvb, gint offset, gint len);
 
 Formats a bunch of data from a tvbuff as bytes, returning a pointer
-to the string with the data formatted as two hex digits for each byte. 
+to the string with the data formatted as two hex digits for each byte.
 The string pointed to is stored in an "ep_alloc'd" buffer which will be freed
 before the next frame is dissected. The formatted string will contain the hex digits
-for at most the first 16 bytes of the data. If len is greater than 16 bytes, a 
+for at most the first 16 bytes of the data. If len is greater than 16 bytes, a
 trailing "..." will be added to the string.
 
 gchar *tvb_bytes_to_str_punct(tvbuff_t *tvb, gint offset, gint len, gchar punct);
 
 This function is similar to tvb_bytes_to_str(...) except that 'punct' is inserted
-between the hex representation of each byte. 
+between the hex representation of each byte.
 
+gchar *tvb_bcd_dig_to_ep_str(tvbuff_t *tvb, const gint offset, const gint len, dgt_set_t *dgt, gboolean skip_first);
+
+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.
 
 Copying memory:
 guint8* tvb_memcpy(tvbuff_t*, guint8* target, gint offset, gint length);
@@ -1312,12 +1393,6 @@ the all-lower-case abbreviation used elsewhere) is COL_PROTOCOL, and the
 COL_ value for the "Info" field, giving a summary of the contents of the
 packet for that protocol, is COL_INFO.
 
-A value for a column should only be added if the user specified that it
-be displayed; to check whether a given column is to be displayed, call
-'check_col' with the COL_ value for that field as an argument - it will
-return TRUE if the column is to be displayed and FALSE if it is not to
-be displayed.
-
 The value for a column can be specified with one of several functions,
 all of which take the 'fd' argument to the dissector as their first
 argument, and the COL_ value for the column as their second argument.
@@ -1340,8 +1415,7 @@ that case.
 For example, to set the "Protocol" column
 to "PROTOABBREV":
 
-       if (check_col(pinfo->cinfo, COL_PROTOCOL))
-               col_set_str(pinfo->cinfo, COL_PROTOCOL, "PROTOABBREV");
+       col_set_str(pinfo->cinfo, COL_PROTOCOL, "PROTOABBREV");
 
 
 1.5.2 The col_add_str function.
@@ -1362,9 +1436,8 @@ the "Info" field to "<XXX> request, <N> bytes", where "reqtype" is a
 string containing the type of the request in the packet and "n" is an
 unsigned integer containing the number of bytes in the request:
 
-       if (check_col(pinfo->cinfo, COL_INFO))
-               col_add_fstr(pinfo->cinfo, COL_INFO, "%s request, %u bytes",
-                       reqtype, n);
+       col_add_fstr(pinfo->cinfo, COL_INFO, "%s request, %u bytes",
+                     reqtype, n);
 
 Don't use 'col_add_fstr' with a format argument of just "%s" -
 'col_add_str', or possibly even 'col_set_str' if the string that matches
@@ -1469,10 +1542,8 @@ based on the time-value.
 
 For example:
 
-if (check_col(pinfo->cinfo, COL_REL_CONV_TIME)) {
-  nstime_delta(&ts, &pinfo->fd->abs_ts, &tcpd->ts_first);
-  col_set_time(pinfo->cinfo, COL_REL_CONV_TIME, &ts, "tcp.time_relative");
-}
+       nstime_delta(&ts, &pinfo->fd->abs_ts, &tcpd->ts_first);
+       col_set_time(pinfo->cinfo, COL_REL_CONV_TIME, &ts, "tcp.time_relative");
 
 
 1.6 Constructing the protocol tree.
@@ -1516,7 +1587,8 @@ generated automatically; to arrange that a protocol's register routine
 be called at startup:
 
        the file containing a dissector's "register" routine must be
-       added to "DISSECTOR_SRC" in "epan/dissectors/Makefile.common";
+       added to "DISSECTOR_SRC" in "epan/dissectors/Makefile.common"
+       (and in "epan/CMakeLists.txt");
 
        the "register" routine must have a name of the form
        "proto_register_XXX";
@@ -1642,11 +1714,13 @@ The type of value this field holds. The current field types are:
        FT_FLOAT                A single-precision floating point number.
        FT_DOUBLE               A double-precision floating point number.
        FT_ABSOLUTE_TIME        Seconds (4 bytes) and nanoseconds (4 bytes)
-                               of time displayed as month name, month day,
-                               year, hours, minutes, and seconds with 9
-                               digits after the decimal point.
+                               of time since January 1, 1970, midnight
+                               UTC, displayed as the date, followed by
+                               the time, as hours, minutes, and seconds
+                               with 9 digits after the decimal point.
        FT_RELATIVE_TIME        Seconds (4 bytes) and nanoseconds (4 bytes)
-                               of time displayed as seconds and 9 digits
+                               of time relative to an arbitrary time.
+                               displayed as seconds and 9 digits
                                after the decimal point.
        FT_STRING               A string of characters, not necessarily
                                NUL-terminated, but possibly NUL-padded.
@@ -1689,6 +1763,15 @@ represent unsigned integers, and the FT_INT* variables all represent
 signed integers; the number on the end represent how many bits are used
 to represent the number.
 
+Some constraints are imposed on the header fields depending on the type
+(e.g.  FT_BYTES) of the field.  Fields of type FT_ABSOLUTE_TIME must use
+'ABSOLUTE_TIME_{LOCAL,UTC,DOY_UTC}, NULL, 0x0' as values for the
+'display, 'strings', and 'bitmask' fields, and all other non-integral
+types (i.e.. types that are _not_ FT_INT* and FT_UINT*) must use
+'BASE_NONE, NULL, 0x0' as values for the 'display', 'strings', 'bitmask'
+fields.  The reason is simply that the type itself implictly defines the
+nature of 'display', 'strings', 'bitmask'.
+
 display
 -------
 The display field has a couple of overloaded uses. This is unfortunate,
@@ -1720,23 +1803,34 @@ custom_fmt_func_t in epan/proto.h, specifically:
 The first argument is a pointer to a buffer of the ITEM_LABEL_LENGTH size
 and the second argument is the value to be formatted.
 
-For FT_BOOLEAN fields that are also bitfields, 'display' is used to tell
-the proto_tree how wide the parent bitfield is.  With integers this is
-not needed since the type of integer itself (FT_UINT8, FT_UINT16,
-FT_UINT24, FT_UINT32, etc.) tells the proto_tree how wide the parent
-bitfield is.
+For FT_BOOLEAN fields that are also bitfields (i.e. 'bitmask' is non-zero),
+'display' is used to tell the proto_tree how wide the parent bitfield is.
+With integers this is not needed since the type of integer itself
+(FT_UINT8, FT_UINT16, FT_UINT24, FT_UINT32, etc.) tells the proto_tree how
+wide the parent bitfield is.
+
+For FT_ABSOLUTE_TIME fields, 'display' is used to indicate whether the
+time is to be displayed as a time in the time zone for the machine on
+which Wireshark/TShark is running or as UTC and, for UTC, whether the
+date should be displayed as "{monthname}, {month} {day_of_month},
+{year}" or as "{year/day_of_year}".
 
-Additionally, BASE_NONE is used for 'display' as a NULL-value. That is,
-for non-integers and non-bitfield FT_BOOLEANs, you'll want to use BASE_NONE
-in the 'display' field.  You may not use BASE_NONE for integers.
+Additionally, BASE_NONE is used for 'display' as a NULL-value. That is, for
+non-integers other than FT_ABSOLUTE_TIME fields, and non-bitfield
+FT_BOOLEANs, you'll want to use BASE_NONE in the 'display' field.  You may
+not use BASE_NONE for integers.
 
 It is possible that in the future we will record the endianness of
 integers. If so, it is likely that we'll use a bitmask on the display field
 so that integers would be represented as BEND|BASE_DEC or LEND|BASE_HEX.
-But that has not happened yet.
+But that has not happened yet; note that there are protocols for which
+no endianness is specified, such as the X11 protocol and the DCE RPC
+protocol, so it would not be possible to record the endianness of all
+integral fields.
 
 strings
 -------
+-- value_string
 Some integer fields, of type FT_UINT*, need labels to represent the true
 value of a field.  You could think of those fields as having an
 enumerated data type, rather than an integral data type.
@@ -1763,6 +1857,37 @@ indicate the end of the array).  The 'strings' field would be set to
 If the field has a numeric rather than an enumerated type, the 'strings'
 field would be set to NULL.
 
+-- Extended value strings
+You can also use an extended version of the value_string for faster lookups.
+It requires a value_string as input.
+If all of a contiguous range of values from min to max are present in the array
+the value will be used as as a direct index into a value_string array.
+
+If the values in the array are not contiguous (ie: there are "gaps"), but are in assending order
+a binary search will be used.
+
+Note: "gaps" in a value_string array can be filled with "empty" entries eg: {value, "Unknown"} so that
+direct access to the array is is possible.
+
+The init macro (see below) will perform a check on the value string
+the first time it is used to determine which search algorithm fits and fall back to a linear search
+if the value_string does not meet the criteria above.
+
+Use this macro to initialise the extended value_string at comile time:
+
+static value_string_ext valstringname_ext = VALUE_STRING_EXT_INIT(valstringname);
+
+Extended value strings can be created at runtime by calling
+   value_string_ext_new(<ptr to value_string array>,
+                        <total number of entries in the value_string_array>, /* include {0, NULL} entry */
+                        <value_string_name>);
+
+For hf[] array FT_(U)INT* fields that need a 'valstringname_ext' struct, the 'strings' field
+would be set to '&valstringname_ext)'. Furthermore, 'display' field must be
+ORed with 'BASE_EXT_STRING' (e.g. BASE_DEC|BASE_EXT_STRING).
+
+
+-- Ranges
 If the field has a numeric type that might logically fit in ranges of values
 one can use a range_string struct.
 
@@ -1788,6 +1913,7 @@ For FT_(U)INT* fields that need a 'range_string' struct, the 'strings' field
 would be set to 'RVALS(rvalstringname)'. Furthermore, 'display' field must be
 ORed with 'BASE_RANGE_STRING' (e.g. BASE_DEC|BASE_RANGE_STRING).
 
+-- Booleans
 FT_BOOLEANs have a default map of 0 = "False", 1 (or anything else) = "True".
 Sometimes it is useful to change the labels for boolean values (e.g.,
 to "Yes"/"No", "Fast"/"Slow", etc.).  For these mappings, a struct called
@@ -1823,7 +1949,7 @@ If the field is a bitfield, then the bitmask is the mask which will
 leave only the bits needed to make the field when ANDed with a value.
 The proto_tree routines will calculate 'bitshift' automatically
 from 'bitmask', by finding the rightmost set bit in the bitmask.
-This shift is applied before applying string mapping functions or 
+This shift is applied before applying string mapping functions or
 filtering.
 If the field is not a bitfield, then bitmask should be set to 0.
 
@@ -1831,7 +1957,7 @@ blurb
 -----
 This is a string giving a proper description of the field.  It should be
 at least one grammatically complete sentence, or NULL in which case the
-name field is used.
+name field is used. (Please do not use "").
 It is meant to provide a more detailed description of the field than the
 name alone provides. This information will be used in the man page, and
 in a future GUI display-filter creation tool. We might also add tooltips
@@ -1946,7 +2072,7 @@ There are several functions that the programmer can use to add either
 protocol or field labels to the proto_tree:
 
        proto_item*
-       proto_tree_add_item(tree, id, tvb, start, length, little_endian);
+       proto_tree_add_item(tree, id, tvb, start, length, encoding);
 
        proto_item*
        proto_tree_add_none_format(tree, id, tvb, start, length, format, ...);
@@ -2158,7 +2284,7 @@ The 'tree' argument is the tree to which the item is to be added.  The
 extracted; the 'start' argument is the offset from the beginning of that
 tvbuff of the item being added, and the 'length' argument is the length,
 in bytes, of the item, bit_offset is the offset in bits and no_of_bits
-is the lenght in bits.
+is the length in bits.
 
 The length of some items cannot be determined until the item has been
 dissected; to add such an item, add it with a length of -1, and, when the
@@ -2177,8 +2303,12 @@ The item added to the GUI tree will contain the name (as passed in the
 proto_register_*() function) and a value.  The value will be fetched
 from the tvbuff by proto_tree_add_item(), based on the type of the field
 and, for integral and Boolean fields, the byte order of the value; the
-byte order is specified by the 'little_endian' argument, which is TRUE
-if the value is little-endian and FALSE if it is big-endian.
+byte order, for items for which that's relevant, is specified by the
+'encoding' argument, which is ENC_LITTLE_ENDIAN if the value is
+little-endian and ENC_BIG_ENDIAN if it is big-endian.  If the byte order
+is not relevant, use ENC_NA (Not Applicable).  In the future, other
+elements of the encoding, such as the character encoding for
+character strings, might be supported.
 
 Now that definitions of fields have detailed information about bitfield
 fields, you can use proto_tree_add_item() with no extra processing to
@@ -2199,7 +2329,8 @@ against the parent field, the first byte of the TH.
 
 The code to add the FID to the tree would be;
 
-       proto_tree_add_item(bf_tree, hf_sna_th_fid, tvb, offset, 1, TRUE);
+       proto_tree_add_item(bf_tree, hf_sna_th_fid, tvb, offset, 1,
+           ENC_BIG_ENDIAN);
 
 The definition of the field already has the information about bitmasking
 and bitshifting, so it does the work of masking and shifting for us!
@@ -2583,13 +2714,15 @@ skeleton of how the programmer might code this.
        for(i = 0; i < num_rings; i++) {
                proto_item *pi;
 
-               pi = proto_tree_add_item(tree, hf_tr_rif_ring, ..., FALSE);
+               pi = proto_tree_add_item(tree, hf_tr_rif_ring, ...,
+                   ENC_BIG_ENDIAN);
                PROTO_ITEM_SET_HIDDEN(pi);
        }
        for(i = 0; i < num_rings - 1; i++) {
                proto_item *pi;
 
-               pi = proto_tree_add_item(tree, hf_tr_rif_bridge, ..., FALSE);
+               pi = proto_tree_add_item(tree, hf_tr_rif_bridge, ...,
+                   ENC_BIG_ENDIAN);
                PROTO_ITEM_SET_HIDDEN(pi);
        }
 
@@ -2619,7 +2752,7 @@ clicks as well, launching the configured browser with this URL as parameter.
 
 1.7 Utility routines.
 
-1.7.1 match_strval and val_to_str.
+1.7.1 match_strval, match_strval_ext, val_to_str and val_to_str_ext.
 
 A dissector may need to convert a value to a string, using a
 'value_string' structure, by hand, rather than by declaring a field with
@@ -2654,6 +2787,17 @@ You can use it in a call to generate a COL_INFO line for a frame such as
 
        col_add_fstr(COL_INFO, ", %s", val_to_str(val, table, "Unknown %d"));
 
+The match_strval_ext and val_to_str_ext functions are "extended" versions
+of match_strval and val_to_str. They should be used for large value-string
+arrays which contain many entries. They implement value to string conversions
+which will do either a direct access or a binary search of the
+value string array if possible. See "Extended Value Strings" under
+section  1.6 "Constructing the protocol tree" for more information.
+
+See epan/value_string.h for detailed information on the various value_string
+functions.
+
+
 1.7.2 match_strrval and rval_to_str.
 
 A dissector may need to convert a range of values to a string, using a
@@ -2740,7 +2884,7 @@ dissect_ipx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        dissector_next( next_tvb, pinfo, tree);
 
 
-1.9 Editing Makefile.common to add your dissector.
+1.9 Editing Makefile.common and CMakeLists.txt to add your dissector.
 
 To arrange that your dissector will be built as part of Wireshark, you
 must add the name of the source file for your dissector to the
@@ -2755,6 +2899,10 @@ the 'epan/dissectors' directory, so that it's included when release source
 tarballs are built (otherwise, the source in the release tarballs won't
 compile).
 
+In addition to the above, you should add your dissector source file name
+to the DISSECTOR_SRC section of epan/CMakeLists.txt
+
+
 1.10 Using the SVN source code tree.
 
   See <http://www.wireshark.org/develop.html>
@@ -2787,6 +2935,8 @@ compile).
 
   - Create a Wiki page on the protocol at <http://wiki.wireshark.org>.
     A template is provided so it is easy to setup in a consistent style.
+      See: <http://wiki.wireshark.org/HowToEdit>
+      and  <http://wiki.wireshark.org/ProtocolReference>
 
   - If possible, add sample capture files to the sample captures page at
     <http://wiki.wireshark.org/SampleCaptures>.  These files are used by
@@ -2810,25 +2960,29 @@ address:port combinations.  A conversation is not sensitive to the direction of
 the packet.  The same conversation will be returned for a packet bound from
 ServerA:1000 to ClientA:2000 and the packet from ClientA:2000 to ServerA:1000.
 
-There are five routines that you will use to work with a conversation:
+2.2.1 Conversation Routines
+
+There are six routines that you will use to work with a conversation:
 conversation_new, find_conversation, conversation_add_proto_data,
-conversation_get_proto_data, and conversation_delete_proto_data.
+conversation_get_proto_data, conversation_delete_proto_data,
+and conversation_set_dissector.
 
 
-2.2.1 The conversation_init function.
+2.2.1.1 The conversation_init function.
 
 This is an internal routine for the conversation code.  As such you
 will not have to call this routine.  Just be aware that this routine is
 called at the start of each capture and before the packets are filtered
 with a display filter.  The routine will destroy all stored
 conversations.  This routine does NOT clean up any data pointers that are
-passed in the conversation_new 'data' variable.  You are responsible for
-this clean up if you pass a malloc'ed pointer in this variable.
+passed in the conversation_add_proto_data 'data' variable.  You are
+responsible for this clean up if you pass a malloc'ed pointer
+in this variable.
 
-See item 2.2.8 for more information about the 'data' pointer.
+See item 2.2.1.5 for more information about use of the 'data' pointer.
 
 
-2.2.2 The conversation_new function.
+2.2.1.2 The conversation_new function.
 
 This routine will create a new conversation based upon two address/port
 pairs.  If you want to associate with the conversation a pointer to a
@@ -2874,7 +3028,7 @@ packet indicates that, later in the capture, a conversation will be
 created using certain addresses and ports, in the case where the packet
 doesn't specify the addresses and ports of both sides.
 
-2.2.3 The find_conversation function.
+2.2.1.3 The find_conversation function.
 
 Call this routine to look up a conversation.  If no conversation is found,
 the routine will return a NULL value.
@@ -2924,7 +3078,25 @@ any "wildcarded" address and the "port_b" port will be treated as
 matching any "wildcarded" port.
 
 
-2.2.4 The conversation_add_proto_data function.
+2.2.1.4 The find_or_create_conversation function.
+
+This convenience function will create find an existing conversation (by calling
+find_conversation()) and, if a conversation does not already exist, create a
+new conversation by calling conversation_new().
+
+The find_or_create_conversation prototype:
+
+       extern conversation_t *find_or_create_conversation(packet_info *pinfo);
+
+Where:
+       packet_info *pinfo = the packet_info structure
+
+The frame number and the addresses necessary for find_conversation() and
+conversation_new() are taken from the pinfo structure (as is commonly done)
+and no 'options' are used.
+
+
+2.2.1.5 The conversation_add_proto_data function.
 
 Once you have created a conversation with conversation_new, you can
 associate data with it using this function.
@@ -2943,11 +3115,14 @@ Where:
 unique protocol number created with proto_register_protocol.  Protocols
 are typically registered in the proto_register_XXXX section of your
 dissector.  "data" is a pointer to the data you wish to associate with the
-conversation.  Using the protocol number allows several dissectors to
+conversation.  "data" usually points to "se_alloc'd" memory; the
+memory will be automatically freed each time a new dissection begins
+and thus need not be managed (freed) by the dissector.
+Using the protocol number allows several dissectors to
 associate data with a given conversation.
 
 
-2.2.5 The conversation_get_proto_data function.
+2.2.1.6 The conversation_get_proto_data function.
 
 After you have located a conversation with find_conversation, you can use
 this function to retrieve any data associated with it.
@@ -2966,12 +3141,12 @@ typically in the proto_register_XXXX portion of a dissector.  The function
 returns a pointer to the data requested, or NULL if no data was found.
 
 
-2.2.6 The conversation_delete_proto_data function.
+2.2.1.7 The conversation_delete_proto_data function.
 
 After you are finished with a conversation, you can remove your association
 with this function.  Please note that ONLY the conversation entry is
-removed.  If you have allocated any memory for your data, you must free it
-as well.
+removed.  If you have allocated any memory for your data (other than with se_alloc),
+ you must free it as well.
 
 The conversation_delete_proto_data prototype:
 
@@ -2985,8 +3160,22 @@ Where:
 is a unique protocol number created with proto_register_protocol,
 typically in the proto_register_XXXX portion of a dissector.
 
+2.2.1.8 The conversation_set_dissector function
+
+This function sets the protocol dissector to be invoked whenever
+conversation parameters (addresses, port_types, ports, etc) are matched
+during the dissection of a packet.
+
+The conversation_set_dissector prototype:
+
+        void conversation_set_dissector(conversation_t *conversation, const dissector_handle_t handle);
+
+Where:
+       conversation_t *conv = the conversation in question
+        const dissector_handle_t handle = the dissector handle.
 
-2.2.7 Using timestamps relative to the conversation
+
+2.2.2 Using timestamps relative to the conversation
 
 There is a framework to calculate timestamps relative to the start of the
 conversation. First of all the timestamp of the first packet that has been
@@ -3033,33 +3222,22 @@ SVN 23058 to see the implementation of conversation timestamps for
 the tcp-dissector.
 
 
-2.2.8 The example conversation code with GMemChunk's.
+2.2.3 The example conversation code using se_alloc'd memory.
 
 For a conversation between two IP addresses and ports you can use this as an
-example.  This example uses the GMemChunk to allocate memory and stores the data
+example.  This example uses se_alloc() to allocate memory and stores the data
 pointer in the conversation 'data' variable.
 
-NOTE: Remember to register the init routine (my_dissector_init) in the
-protocol_register routine.
-
-
 /************************ Global values ************************/
 
-/* the number of entries in the memory chunk array */
-#define my_init_count 10
-
 /* define your structure here */
 typedef struct {
 
 } my_entry_t;
 
-/* the GMemChunk base structure */
-static GMemChunk *my_vals = NULL;
-
 /* Registered protocol number */
 static int my_proto = -1;
 
-
 /********************* in the dissector routine *********************/
 
 /* the local variables in the dissector */
@@ -3080,7 +3258,7 @@ else {
 
     /* new conversation create local data structure */
 
-    data_ptr = g_mem_chunk_alloc(my_vals);
+    data_ptr = se_alloc(sizeof(my_entry_t));
 
     /*** add your code here to setup the new data structure ***/
 
@@ -3093,38 +3271,12 @@ else {
 
 /* at this point the conversation data is ready */
 
-
-/******************* in the dissector init routine *******************/
-
-#define my_init_count 20
-
-static void
-my_dissector_init(void)
-{
-
-    /* destroy memory chunks if needed */
-
-    if (my_vals)
-       g_mem_chunk_destroy(my_vals);
-
-    /* now create memory chunks */
-
-    my_vals = g_mem_chunk_new("my_proto_vals",
-           sizeof(my_entry_t),
-           my_init_count * sizeof(my_entry_t),
-           G_ALLOC_AND_FREE);
-}
-
 /***************** in the protocol register routine *****************/
 
-/* register re-init routine */
-
-register_init_routine(&my_dissector_init);
-
 my_proto = proto_register_protocol("My Protocol", "My Protocol", "my_proto");
 
 
-2.2.9 An example conversation code that starts at a specific frame number.
+2.2.4 An example conversation code that starts at a specific frame number.
 
 Sometimes a dissector has determined that a new conversation is needed that
 starts at a specific frame number, when a capture session encompasses multiple
@@ -3148,7 +3300,7 @@ that starts at the specific frame number.
        }
 
 
-2.2.10 The example conversation code using conversation index field.
+2.2.5 The example conversation code using conversation index field.
 
 Sometimes the conversation isn't enough to define a unique data storage
 value for the network traffic.  For example if you are storing information
@@ -3170,14 +3322,7 @@ upon the conversation index and values inside the request packets.
         /* then used the conversation index, and request data to find data */
         /* in the local hash table */
 
-       conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
-           pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
-       if (conversation == NULL) {
-               /* It's not part of any conversation - create a new one. */
-               conversation = conversation_new(pinfo->fd->num, &pinfo->src,
-                   &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport,
-                   NULL, 0);
-       }
+       conversation = find_or_create_conversation(pinfo);
 
        request_key.conversation = conversation->index;
        request_key.service = pntohs(&rxh->serviceId);
@@ -3190,10 +3335,10 @@ upon the conversation index and values inside the request packets.
        opcode = 0;
        if (!request_val && !reply)
        {
-               new_request_key = g_mem_chunk_alloc(afs_request_keys);
+               new_request_key = se_alloc(sizeof(struct afs_request_key));
                *new_request_key = request_key;
 
-               request_val = g_mem_chunk_alloc(afs_request_vals);
+               request_val = se_alloc(sizeof(struct afs_request_val));
                request_val -> opcode = pntohl(&afsh->opcode);
                opcode = request_val->opcode;
 
@@ -3256,7 +3401,7 @@ static void sub_dissector(tvbuff_t *tvb, packet_info *pinfo,
 */
        conversation = find_conversation(pinfo->fd->num,
                                &pinfo->src, &pinfo->dst, protocol,
-                               src_port, dst_port, new_conv_info, 0);
+                               src_port, dst_port,  0);
 
 /* If there is no such conversation, or if there is one but for
    someone else's protocol then we just create a new conversation
@@ -3264,7 +3409,7 @@ static void sub_dissector(tvbuff_t *tvb, packet_info *pinfo,
 */
        if ( (conversation == NULL) ||
             (conversation->dissector_handle != sub_dissector_handle) ) {
-            new_conv_info = g_mem_chunk_alloc(new_conv_vals);
+            new_conv_info = se_alloc(sizeof(struct _new_conv_info));
             new_conv_info->data1 = value1;
 
 /* create the conversation for the dynamic port */
@@ -3338,7 +3483,7 @@ static dissector_handle_t sub_dissector_handle;
 
 /* if conversation has a data field, create it and load structure */
 
-        new_conv_info = g_mem_chunk_alloc(new_conv_vals);
+        new_conv_info = se_alloc(sizeof(struct _new_conv_info));
         new_conv_info->data1 = value1;
 
 /* create the conversation for the dynamic server address and port     */
@@ -3394,11 +3539,17 @@ to a configuration dialog.
 You must register the module with the preferences routine with -
 
        module_t *prefs_register_protocol(proto_id, void (*apply_cb)(void))
+       or
+       module_t *prefs_register_protocol_subtree(const char *subtree, int id,
+              void (*apply_cb)(void));
+
 
 Where: proto_id   - the value returned by "proto_register_protocol()" when
                     the protocol was registered.
        apply_cb   - Callback routine that is called when preferences are
                     applied. It may be NULL, which inhibits the callback.
+       subtree    - grouping preferences tree node name (several protocols can
+                    be grouped under one preferences subtree)
 
 Then you can register the fields that can be configured by the user with these
 routines -
@@ -3435,9 +3586,14 @@ Where: module - Returned by the prefs_register_protocol routine
                    the preference file will already have it
         title    - Field title in the preferences dialog
         description - Comments added to the preference file above the
-                      preference value
+                      preference value and shown as tooltip in the GUI, or NULL
         var      - pointer to the storage location that is updated when the
-                   field is changed in the preference dialog box
+                   field is changed in the preference dialog box.  Note that
+                   with string preferences the given pointer is overwritten
+                   with a pointer to a new copy of the string during the
+                   preference registration.  The passed-in string may be
+                   freed, but you must keep another pointer to the string
+                   in order to free it.
         base     - Base that the unsigned integer is expected to be in,
                    see strtoul(3).
         enumvals - an array of enum_val_t structures.  This must be
@@ -3528,10 +3684,10 @@ example, stolen from packet-dns.c:
        mdns_udp_handle = create_dissector_handle(dissect_mdns_udp,
            proto_dns);
 
-       dissector_add("udp.port", UDP_PORT_DNS, dns_udp_handle);
-       dissector_add("tcp.port", TCP_PORT_DNS, dns_tcp_handle);
-       dissector_add("udp.port", UDP_PORT_MDNS, mdns_udp_handle);
-       dissector_add("tcp.port", TCP_PORT_MDNS, dns_tcp_handle);
+       dissector_add_uint("udp.port", UDP_PORT_DNS, dns_udp_handle);
+       dissector_add_uint("tcp.port", TCP_PORT_DNS, dns_tcp_handle);
+       dissector_add_uint("udp.port", UDP_PORT_MDNS, mdns_udp_handle);
+       dissector_add_uint("tcp.port", TCP_PORT_MDNS, dns_tcp_handle);
 
 The dissect_dns_udp function does very little work and calls
 dissect_dns_common, while dissect_dns_tcp calls tcp_dissect_pdus with a
@@ -3603,7 +3759,7 @@ boundary is set in stone.
 static hf_register_info hf[] = {
     {&hf_cstring,
      {"C String", "c.string", FT_STRING, BASE_NONE, NULL, 0x0,
-      "C String", HFILL}
+      NULL, HFILL}
      }
    };
 
@@ -3628,14 +3784,13 @@ static void dissect_cstr(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
             return;
         }
 
-        if (check_col(pinfo->cinfo, COL_INFO)) {
-            col_set_str(pinfo->cinfo, COL_INFO, "C String");
-        }
+        col_set_str(pinfo->cinfo, COL_INFO, "C String");
 
         len += 1; /* Add one for the '\0' */
 
         if (tree) {
-            proto_tree_add_item(tree, hf_cstring, tvb, offset, len, FALSE);
+            proto_tree_add_item(tree, hf_cstring, tvb, offset, len,
+                               ENC_NA);
         }
         offset += (guint)len;
     }