$Revision$
$Date$
$Author$
+Tabsize: 4
This file is a HOWTO for Wireshark developers. It describes how to start coding
a Wireshark protocol dissector and the use of some of the important functions
environment is required - there's no such thing as a standalone "dissector
build toolkit".
-How to setup such an environment is platform dependent, detailed information
+How to setup such an environment is platform dependent; detailed information
about these steps can be found in the "Developer's Guide" (available from:
http://www.wireshark.org) and in the INSTALL and README files of the sources
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
You'll find additional dissector related information in the following README
files:
-- README.binarytrees - fast access to large data collections
-- 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
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];
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 it.
Example:
typedef struct foo {
guint32 foo;
which will be defined as the appropriate types for 64-bit signed and
unsigned integers.
+On LLP64 data model systems (notably 64-bit Windows), "int" and "long"
+are 32 bits while "size_t" and "ptrdiff_t" are 64 bits. This means that
+the following will generate a compiler warning:
+
+ int i;
+ i = strlen("hello, sailor"); /* Compiler warning */
+
+Normally, you'd just make "i" a size_t. However, many GLib and Wireshark
+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 */
+
+Try to use the appropriate data type when you can. When you can't, you
+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 */
+
+or
+
+ gint i;
+ char greeting[] = "hello, sailor";
+ guint byte_after_greet;
+
+ i = (gint) strlen(greeting);
+ 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.
+
When printing or displaying the values of 64-bit integral data types,
don't use "%lld", "%llu", "%llx", or "%llo" - not all platforms
support "%ll" for printing 64-bit integral data types. Instead, for
"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()"
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
When using a buffer to create a string, do not use a buffer stored on the stack.
I.e. do not use a buffer declared as
+
char buffer[1024];
-instead allocate a buffer dynamically using the emem routines (see
-README.malloc) such as
+
+instead allocate a buffer dynamically using the string-specific or plain emem
+routines (see README.malloc) such as
+
+ emem_strbuf_t *strbuf;
+ strbuf = ep_strbuf_new_label("");
+ ep_strbuf_append_printf(strbuf, ...
+
+or
+
char *buffer=NULL;
...
#define MAX_BUFFER 1024
don't have to worry about free()ing them explicitly in order to not leak memory.
Please read README.malloc.
+Don't use non-ASCII characters in source files; not all compiler
+environments will be using the same encoding for non-ASCII characters,
+and at least one compiler (Microsoft's Visual C) will, in environments
+with double-byte character encodings, such as many Asian environments,
+fail if it sees a byte sequence in a source file that doesn't correspond
+to a valid character. This causes source files using either an ISO
+8859/n single-byte character encoding or UTF-8 to fail to compile. Even
+if the compiler doesn't fail, there is no guarantee that the compiler,
+or a developer's text editor, will interpret the characters the way you
+intend them to be interpreted.
+
1.1.3 Robustness.
Wireshark is not guaranteed to read only network traces that contain correctly-
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
the chunk of memory is derived from a size field in the packet, make
sure all the data is present in the packet before allocating the buffer.
-Doing so means that
+Doing so means that:
1) Wireshark won't leak that chunk of memory if an attempt to
- fetch data not present in the packet throws an exception
+ fetch data not present in the packet throws an exception.
and
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
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.
------------------------------------Cut here------------------------------------
/* packet-PROTOABBREV.c
* Routines for PROTONAME dissection
- * Copyright 200x, YOUR_NAME <YOUR_EMAIL_ADDRESS>
+ * Copyright 201x, YOUR_NAME <YOUR_EMAIL_ADDRESS>
*
* $Id$
*
* in a "Copied from" if you copied an existing dissector, especially
* if the bulk of the code in the new dissector is your code)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#if 0
+/* Include only as needed */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#endif
#include <glib.h>
in a header file. If not, a header file is not needed at all. */
#include "packet-PROTOABBREV.h"
-/* Forward declaration we need below */
+/* Forward declaration we need below (if using proto_reg_handoff...
+ as a prefs callback) */
void proto_reg_handoff_PROTOABBREV(void);
/* Initialize the protocol and registered fields */
/* Global sample preference ("controls" display of numbers) */
static gboolean gPREF_HEX = FALSE;
+/* Global sample port pref */
+static guint gPORT_PREF = 1234;
/* Initialize the subtree pointers */
static gint ett_PROTOABBREV = -1;
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.
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".
-
- (b) Detailed dissection
+ col_set_str(pinfo->cinfo, COL_INFO, "XXX Request");
- In this mode, Wireshark is also interested in all details of
- a given protocol, so a "protocol tree" is created.
+/* A protocol dissector may be called in 2 different ways - with, or
+ without a non-null "tree" argument.
- 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
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
static hf_register_info hf[] = {
{ &hf_PROTOABBREV_FIELDABBREV,
{ "FIELDNAME", "PROTOABBREV.FIELDABBREV",
- FIELDTYPE, FIELDBASE, FIELDCONVERT, BITMASK,
+ FIELDTYPE, FIELDDISPLAY, FIELDCONVERT, BITMASK,
"FIELDDESCR", HFILL }
}
};
proto_register_subtree_array(ett, array_length(ett));
/* Register preferences module (See Section 2.6 for more on preferences) */
+/* (Registration of a prefs callback is not required if there are no */
+/* prefs-dependent registration functions (eg: a port pref). */
+/* See proto_reg_handoff below. */
+/* If a prefs callback is not needed, use NULL instead of */
+/* proto_reg_handoff_PROTOABBREV in the following). */
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);
}
This exact format is required because a script is used to find these
routines and create the code that calls these routines.
- This function is also called by preferences whenever "Apply" is pressed
- (see prefs_register_protocol above) so it should accommodate being called
- more than once.
+ 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
+ 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.
*/
void
proto_reg_handoff_PROTOABBREV(void)
{
- static gboolean inited = FALSE;
+ static gboolean initialized = FALSE;
+ static dissector_handle_t PROTOABBREV_handle;
+ static int currentPort;
- if (!inited) {
-
- dissector_handle_t PROTOABBREV_handle;
+ if (!initialized) {
/* Use new_create_dissector_handle() to indicate that dissect_PROTOABBREV()
* returns the number of bytes it dissected (or 0 if it thinks the packet
* does not belong to PROTONAME).
*/
- PROTOABBREV_handle = new_create_dissector_handle(dissect_PROTOABBREV,
- proto_PROTOABBREV);
- dissector_add("PARENT_SUBFIELD", ID_VALUE, PROTOABBREV_handle);
-
- inited = TRUE;
+ PROTOABBREV_handle = new_create_dissector_handle(dissect_PROTOABBREV,
+ proto_PROTOABBREV);
+ dissector_add("PARENT_SUBFIELD", ID_VALUE, PROTOABBREV_handle);
+
+ initialized = TRUE;
+ } else {
+
+ /*
+ 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
+ you registered. The PROTOABBREV_handle value and the value of the
+ preference can be saved using local statics in this
+ function (proto_reg_handoff).
+ */
+
+ dissector_delete("tcp.port", currentPort, PROTOABBREV_handle);
}
- /*
- 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
- you registered. The PROTOABBREV_handle value and the value of the preference
- can be saved using local statics in this function (proto_reg_handoff). ie.
-
- static PROTOABBREV_handle;
- static int currentPort = -1;
+ currentPort = gPORT_PREF;
- ...
+ dissector_add("tcp.port", currentPort, PROTOABBREV_handle);
- if (currentPort != -1) {
- dissector_delete("tcp.port", currentPort, PROTOABBREV_handle);
- }
+}
- currentPort = gPortPref;
+#if 0
+/* Simple form of proto_reg_handoff_PROTOABBREV which can be used if there are
+ no prefs-dependent registration function calls.
+ */
- dissector_add("tcp.port", currentPort, PROTOABBREV_handle);
+void
+proto_reg_handoff_PROTOABBREV(void)
+{
+ dissector_handle_t PROTOABBREV_handle;
- */
+/* Use new_create_dissector_handle() to indicate that dissect_PROTOABBREV()
+ * returns the number of bytes it dissected (or 0 if it thinks the packet
+ * does not belong to PROTONAME).
+ */
+ PROTOABBREV_handle = new_create_dissector_handle(dissect_PROTOABBREV,
+ proto_PROTOABBREV);
+ dissector_add("PARENT_SUBFIELD", ID_VALUE, PROTOABBREV_handle);
}
+#endif
+
------------------------------------Cut here------------------------------------
FT_UINT32, FT_UINT64, FT_INT8, FT_INT16, FT_INT24, FT_INT32,
FT_INT64, FT_FLOAT, FT_DOUBLE, FT_ABSOLUTE_TIME,
FT_RELATIVE_TIME, FT_STRING, FT_STRINGZ, FT_EBCDIC,
- FT_UINT_STRING, FT_ETHER, FT_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
+ FT_UINT_STRING, FT_ETHER, FT_BYTES, FT_UINT_BYTES, FT_IPv4,
+ FT_IPv6, FT_IPXNET, FT_FRAMENUM, FT_PROTOCOL, FT_GUID, FT_OID
+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.
guint8 *tvb_get_string(tvbuff_t*, gint offset, gint length);
guint8 *tvb_get_ephemeral_string(tvbuff_t*, gint offset, gint length);
+guint8 *tvb_get_seasonal_string(tvbuff_t*, gint offset, gint length);
Returns a null-terminated buffer containing data from the specified
tvbuff, starting at the specified offset, and containing the specified
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_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_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);
guint8 *tvb_get_ephemeral_stringz(tvbuff_t *tvb, gint offset, gint *lengthp);
+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
free() this buffer, it will happen automatically once the next packet is
dissected.
+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);
free() this buffer, it will happen automatically once the next packet is
dissected.
+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.
+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
+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.
+
Copying memory:
guint8* tvb_memcpy(tvbuff_t*, guint8* target, gint offset, gint length);
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.
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.
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
after it has called any subdissectors for that chunk so that subdissectors
of any subsequent chunks may only append to the Info column.
'col_prepend_fence_fstr' prepends data before a fence (moving it if
-necessary). It will create a fence at the end of the prended data if the
+necessary). It will create a fence at the end of the prepended data if the
fence does not already exist.
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.
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";
Here is how the frame "protocol" is registered.
- int proto_frame;
+ int proto_frame;
proto_frame = proto_register_protocol (
/* name */ "Frame",
subtree below it containing fields for
the members of the array, might be an
FT_NONE field.
- FT_PROTOCOL Used for protocols which will be placing
+ FT_PROTOCOL Used for protocols which will be placing
themselves as top-level items in the
- "Packet Details" pane of the UI.
+ "Packet Details" pane of the UI.
FT_BOOLEAN 0 means "false", any other value means
"true".
FT_FRAMENUM A frame number; if this is used, the "Go
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.
Ethernet-address format.
FT_BYTES A string of bytes with arbitrary values;
used for raw binary data.
+ FT_UINT_BYTES A counted string of bytes, consisting
+ of a count (represented as an integral value,
+ of width given in the proto_tree_add_item()
+ call) followed immediately by that number of
+ arbitrary values; used for raw binary data.
FT_IPv4 A version 4 IP address (4 bytes) displayed
in dotted-quad IP address format (4
decimal numbers separated by dots).
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,
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.
-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.
+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 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
-------
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.
proto_item*
proto_tree_add_item(tree, id, tvb, start, length, little_endian);
- proto_item*
- proto_tree_add_bits_item(tree, id, tvb, bit_offset, no_of_bits, little_endian);
-
- proto_item *
- proto_tree_add_bits_ret_val(tree, id, tvb, bit_offset, no_of_bits, return_value, little_endian);
-
proto_item*
proto_tree_add_none_format(tree, id, tvb, start, length, format, ...);
proto_item*
proto_tree_add_protocol_format(tree, id, tvb, start, length,
- format, ...);
+ format, ...);
proto_item *
proto_tree_add_bytes(tree, id, tvb, start, length, start_ptr);
proto_item *
proto_tree_add_bytes_format(tree, id, tvb, start, length, start_ptr,
- format, ...);
+ format, ...);
proto_item *
proto_tree_add_bytes_format_value(tree, id, tvb, start, length,
- start_ptr, format, ...);
+ start_ptr, format, ...);
proto_item *
proto_tree_add_time(tree, id, tvb, start, length, value_ptr);
proto_item *
proto_tree_add_time_format(tree, id, tvb, start, length, value_ptr,
- format, ...);
+ format, ...);
proto_item *
proto_tree_add_time_format_value(tree, id, tvb, start, length,
- value_ptr, format, ...);
+ value_ptr, format, ...);
proto_item *
proto_tree_add_ipxnet(tree, id, tvb, start, length, value);
proto_item *
proto_tree_add_ipxnet_format(tree, id, tvb, start, length, value,
- format, ...);
+ format, ...);
proto_item *
proto_tree_add_ipxnet_format_value(tree, id, tvb, start, length,
- value, format, ...);
+ value, format, ...);
proto_item *
proto_tree_add_ipv4(tree, id, tvb, start, length, value);
proto_item *
proto_tree_add_ipv4_format(tree, id, tvb, start, length, value,
- format, ...);
+ format, ...);
proto_item *
proto_tree_add_ipv4_format_value(tree, id, tvb, start, length,
- value, format, ...);
+ value, format, ...);
proto_item *
proto_tree_add_ipv6(tree, id, tvb, start, length, value_ptr);
proto_item *
proto_tree_add_ipv6_format(tree, id, tvb, start, length, value_ptr,
- format, ...);
+ format, ...);
proto_item *
proto_tree_add_ipv6_format_value(tree, id, tvb, start, length,
- value_ptr, format, ...);
+ value_ptr, format, ...);
proto_item *
proto_tree_add_ether(tree, id, tvb, start, length, value_ptr);
proto_item *
proto_tree_add_ether_format(tree, id, tvb, start, length, value_ptr,
- format, ...);
+ format, ...);
proto_item *
proto_tree_add_ether_format_value(tree, id, tvb, start, length,
- value_ptr, format, ...);
+ value_ptr, format, ...);
proto_item *
proto_tree_add_string(tree, id, tvb, start, length, value_ptr);
proto_item *
proto_tree_add_string_format(tree, id, tvb, start, length, value_ptr,
- format, ...);
+ format, ...);
proto_item *
proto_tree_add_string_format_value(tree, id, tvb, start, length,
- value_ptr, format, ...);
+ value_ptr, format, ...);
proto_item *
proto_tree_add_boolean(tree, id, tvb, start, length, value);
proto_item *
proto_tree_add_boolean_format(tree, id, tvb, start, length, value,
- format, ...);
+ format, ...);
proto_item *
proto_tree_add_boolean_format_value(tree, id, tvb, start, length,
- value, format, ...);
+ value, format, ...);
proto_item *
proto_tree_add_float(tree, id, tvb, start, length, value);
proto_item *
proto_tree_add_float_format(tree, id, tvb, start, length, value,
- format, ...);
+ format, ...);
proto_item *
proto_tree_add_float_format_value(tree, id, tvb, start, length,
- value, format, ...);
+ value, format, ...);
proto_item *
proto_tree_add_double(tree, id, tvb, start, length, value);
proto_item *
proto_tree_add_double_format(tree, id, tvb, start, length, value,
- format, ...);
+ format, ...);
proto_item *
proto_tree_add_double_format_value(tree, id, tvb, start, length,
- value, format, ...);
+ value, format, ...);
proto_item *
proto_tree_add_uint(tree, id, tvb, start, length, value);
proto_item *
proto_tree_add_uint_format(tree, id, tvb, start, length, value,
- format, ...);
+ format, ...);
proto_item *
proto_tree_add_uint_format_value(tree, id, tvb, start, length,
- value, format, ...);
+ value, format, ...);
proto_item *
proto_tree_add_uint64(tree, id, tvb, start, length, value);
proto_item *
proto_tree_add_uint64_format(tree, id, tvb, start, length, value,
- format, ...);
+ format, ...);
proto_item *
proto_tree_add_uint64_format_value(tree, id, tvb, start, length,
- value, format, ...);
+ value, format, ...);
proto_item *
proto_tree_add_int(tree, id, tvb, start, length, value);
proto_item *
proto_tree_add_int_format(tree, id, tvb, start, length, value,
- format, ...);
+ format, ...);
proto_item *
proto_tree_add_int_format_value(tree, id, tvb, start, length,
- value, format, ...);
+ value, format, ...);
proto_item *
proto_tree_add_int64(tree, id, tvb, start, length, value);
proto_item *
proto_tree_add_int64_format(tree, id, tvb, start, length, value,
- format, ...);
+ format, ...);
proto_item *
proto_tree_add_int64_format_value(tree, id, tvb, start, length,
- value, format, ...);
+ value, format, ...);
proto_item*
proto_tree_add_text(tree, tvb, start, length, format, ...);
proto_item *
proto_tree_add_guid_format(tree, id, tvb, start, length, value_ptr,
- format, ...);
+ format, ...);
proto_item *
proto_tree_add_guid_format_value(tree, id, tvb, start, length,
- value_ptr, format, ...);
+ value_ptr, format, ...);
proto_item *
proto_tree_add_oid(tree, id, tvb, start, length, value_ptr);
proto_item *
proto_tree_add_oid_format(tree, id, tvb, start, length, value_ptr,
- format, ...);
+ format, ...);
proto_item *
proto_tree_add_oid_format_value(tree, id, tvb, start, length,
- value_ptr, format, ...);
+ value_ptr, format, ...);
+
+ proto_item*
+ proto_tree_add_bits_item(tree, id, tvb, bit_offset, no_of_bits,
+ little_endian);
proto_item *
- proto_tree_add_bitmask(tree, tvb, start, header, ett, **fields,
- little_endian);
+ proto_tree_add_bits_ret_val(tree, id, tvb, bit_offset, no_of_bits,
+ return_value, little_endian);
proto_item *
- proto_tree_add_bitmask_text(proto_tree *tree, tvbuff_t *tvb,
- guint offset, guint len, const char *name, const char *fallback,
- gint ett, const int **fields, gboolean little_endian, int flags);
+ proto_tree_add_bitmask(tree, tvb, start, header, ett, fields,
+ little_endian);
+
+ proto_item *
+ proto_tree_add_bitmask_text(tree, tvb, offset, len, name, fallback,
+ ett, fields, little_endian, flags);
The 'tree' argument is the tree to which the item is to be added. The
'tvb' argument is the tvbuff from which the item's value is being
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
{ 0x3, "Subarea Node or SNA host <--> Subarea Node" },
{ 0x4, "?" },
{ 0x5, "?" },
- { 0xf, "Adjaced Subarea Nodes" },
+ { 0xf, "Adjacent Subarea Nodes" },
{ 0, NULL }
};
the high nibble of the byte ("sna.th.fid == 0xf0") as was necessary
in the past.
-proto_tree_add_bits_item()
---------------------------
-Adds a number of bits to the protocol tree which does not have to be byte aligned.
-The offset and length is in bits.
-Output format:
-
-..10 1010 10.. .... "value" (formated as FT_ indicates).
-
-proto_tree_add_bits_ret_val()
------------------------------
-Works in the same way but alo returns the value of the read bits.
-
proto_tree_add_protocol_format()
--------------------------------
proto_tree_add_protocol_format is used to add the top-level item for the
variable-length list of arguments to add a text item to the protocol
tree.
+proto_tree_add_bits_item()
+--------------------------
+Adds a number of bits to the protocol tree which does not have to be byte
+aligned. The offset and length is in bits.
+Output format:
+
+..10 1010 10.. .... "value" (formatted as FT_ indicates).
+
+proto_tree_add_bits_ret_val()
+-----------------------------
+Works in the same way but also returns the value of the read bits.
+
proto_tree_add_bitmask() and proto_tree_add_bitmask_text()
----------------------------------------------------------
This function provides an easy to use and convenient helper function
'header' and 'ett' are the hf fields and ett field respectively to create an
expansion that covers the 1-4 bytes of the bitmask.
-'**fields' is a NULL terminated a array of pointers to hf fields representing
+'fields' is a NULL terminated array of pointers to hf fields representing
the individual subfields of the bitmask. These fields must either be integers
of the same byte width as 'header' or of the type FT_BOOLEAN.
-Each of the entries in '**fields' will be dissected as an item under the
+Each of the entries in 'fields' will be dissected as an item under the
'header' expansion and also IF the field is a boolean and IF it is set to 1,
then the name of that boolean field will be printed on the 'header' expansion
line. For integer type subfields that have a value_string defined, the
-matched string from that value_string will be printed on the expansion line as well.
+matched string from that value_string will be printed on the expansion line
+as well.
-Example: (from the scsi dissector)
+Example: (from the SCSI dissector)
static int hf_scsi_inq_peripheral = -1;
static int hf_scsi_inq_qualifier = -1;
+ static int hf_scsi_inq_devtype = -1;
+ ...
static gint ett_scsi_inq_peripheral = -1;
...
static const int *peripheal_fields[] = {
};
...
/* Qualifier and DeviceType */
- proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_inq_peripheral, ett_scsi_inq_peripheral, peripheal_fields, FALSE);
+ proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_inq_peripheral,
+ ett_scsi_inq_peripheral, peripheal_fields, FALSE);
offset+=1;
...
{ &hf_scsi_inq_peripheral,
{ &hf_scsi_inq_qualifier,
{"Qualifier", "scsi.inquiry.qualifier", FT_UINT8, BASE_HEX,
VALS (scsi_qualifier_val), 0xE0, NULL, HFILL}},
+ { &hf_scsi_inq_devtype,
+ {"Device Type", "scsi.inquiry.devtype", FT_UINT8, BASE_HEX,
+ VALS (scsi_devtype_val), SCSI_DEV_BITS, NULL, HFILL}},
...
Which provides very pretty dissection of this one byte bitmask.
+ Peripheral: 0x05, Qualifier: Device type is connected to logical unit, Device Type: CD-ROM
+ 000. .... = Qualifier: Device type is connected to logical unit (0x00)
+ ...0 0101 = Device Type: CD-ROM (0x05)
+
+The proto_tree_add_bitmask_text() function is an extended version of
+the proto_tree_add_bitmask() function. In addition, it allows to:
+- Provide a leading text (e.g. "Flags: ") that will appear before
+ the comma-separated list of field values
+- Provide a fallback text (e.g. "None") that will be appended if
+ no fields warranted a change to the top-level title.
+- Using flags, specify which fields will affect the top-level title.
+
+There are the following flags defined:
+
+ BMT_NO_APPEND - the title is taken "as-is" from the 'name' argument.
+ BMT_NO_INT - only boolean flags are added to the title.
+ BMT_NO_FALSE - boolean flags are only added to the title if they are set.
+ BMT_NO_TFS - only add flag name to the title, do not use true_false_string
+
+The proto_tree_add_bitmask() behavior can be obtained by providing
+both 'name' and 'fallback' arguments as NULL, and a flags of
+(BMT_NO_FALSE|BMT_NO_TFS).
+
+PROTO_ITEM_SET_GENERATED()
+--------------------------
+PROTO_ITEM_SET_GENERATED is used to mark fields as not being read from the
+captured data directly, but inferred from one or more values.
+
+One of the primary uses of this is the presentation of verification of
+checksums. Every IP packet has a checksum line, which can present the result
+of the checksum verification, if enabled in the preferences. The result is
+presented as a subtree, where the result is enclosed in square brackets
+indicating a generated field.
+
+ Header checksum: 0x3d42 [correct]
+ [Good: True]
+ [Bad: False]
+
PROTO_ITEM_SET_HIDDEN()
-----------------------
PROTO_ITEM_SET_HIDDEN is used to hide fields, which have already been added
tr.rif_ring eq 0x013
-The proto_tree_add_bitmask_text() function is an extended version of
-the proto_tree_add_bitmask() function. In addition, it allows to:
-- Provide a leading text (e.g. "Flags: ") that will appear before
- the comma-separated list of field values
-- Provide a fallback text (e.g. "None") that will be appended if
- no fields warranted a change to the top-level title.
-- Using flags, specify which fields will affect the top-level title.
-
-There are the following flags defined:
-
- BMT_NO_APPEND - the title is taken "as-is" from the 'name' argument.
- BMT_NO_INT - only boolean flags are added to the title.
- BMT_NO_FALSE - boolean flags are only added to the title if they are set.
- BMT_NO_TFS - only add flag name to the title, do not use true_false_string
-
-The proto_tree_add_bitmask() behavior can be obtained by providing
-both 'name' and 'fallback' arguments as NULL, and a flags of
-(BMT_NO_FALSE|BMT_NO_TFS).
+PROTO_ITEM_SET_URL
+------------------
+PROTO_ITEM_SET_URL is used to mark fields as containing a URL. This can only
+be done with fields of type FT_STRING(Z). If these fields are presented they
+are underlined, as could be done in a browser. These fields are sensitive to
+clicks as well, launching the configured browser with this URL as parameter.
1.7 Utility routines.
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
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>
- 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
matching any "wildcarded" port.
-2.2.4 The conversation_add_proto_data function.
+2.2.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.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.
The conversation_add_proto_data prototype:
void conversation_add_proto_data(conversation_t *conv, int proto,
- void *proto_data);
+ void *proto_data);
Where:
conversation_t *conv = the conversation in question
associate data with a given conversation.
-2.2.5 The conversation_get_proto_data function.
+2.2.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.
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.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
typically in the proto_register_XXXX portion of a dissector.
-2.2.7 Using timestamps relative to the conversation
+2.2.8 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
the tcp-dissector.
-2.2.8 The example conversation code with GMemChunk's.
+2.2.9 The example conversation code with GMemChunk's.
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
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.10 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
}
-2.2.10 The example conversation code using conversation index field.
+2.2.11 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
/* 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);
Where:
fd - The fd pointer in the pinfo structure, pinfo->fd
proto - Protocol id returned by the proto_register_protocol call
- during initialization
+ during initialization
proto_data - pointer to the dissector data.
You must register the module with the preferences routine with -
-module_t *prefs_register_protocol(proto_id, void (*apply_cb)(void))
+ 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
+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 -
static hf_register_info hf[] = {
{&hf_cstring,
{"C String", "c.string", FT_STRING, BASE_NONE, NULL, 0x0,
- "C String", HFILL}
+ NULL, HFILL}
}
};
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' */
ptvcursor_set_subtree(ptvcursor_t* ptvc, proto_item* it, gint ett_subtree);
Creates a subtree and adds it to the cursor as the working tree but does
not save the old working tree.
+