aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2014-08-19 13:25:11 -0400
committerEvan Huus <eapache@gmail.com>2014-08-19 18:30:17 +0000
commit2e3bc5790f7759e75f0899625cff2a3fee13b1e3 (patch)
tree0b68a57b73e72efa70438afd8e178bb71c435c2b /doc
parent0cda27c83e4aeadb195c9e9bbf55d51db5244347 (diff)
packet-PROTOABBREV.c: various minor changes:
- Specify that proto_register...() and proto_reg_handoff...() prototypes are required; - Indicate that certain #includes should be used only as needed; - Don't use CamelCase (or CAPS) in variable names; - Do some reformatting of certain lines; - Futz hf[] array entry so checkAPIs and checkhf tests don't fail. Change-Id: Ie03846f4bebd2a9bece464c85cc3c2ef46dd4fe5 Reviewed-on: https://code.wireshark.org/review/3724 Reviewed-by: Bill Meier <wmeier@newsguy.com> Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/packet-PROTOABBREV.c56
1 files changed, 33 insertions, 23 deletions
diff --git a/doc/packet-PROTOABBREV.c b/doc/packet-PROTOABBREV.c
index 0315082b89..241bc8d766 100644
--- a/doc/packet-PROTOABBREV.c
+++ b/doc/packet-PROTOABBREV.c
@@ -21,6 +21,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+/*
+ * (A short description of the protocol including links to specifications,
+ * detailed documentation, etc.)
+ */
+
#include "config.h"
#if 0
@@ -28,13 +33,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+...
#endif
#include <glib.h>
#include <epan/packet.h>
-#include <epan/expert.h>
-#include <epan/prefs.h>
+#include <epan/expert.h> /* Include only as needed */
+#include <epan/prefs.h> /* Include only as needed */
#if 0
/* IF AND ONLY IF your protocol dissector exposes code to other dissectors
@@ -45,9 +51,8 @@
#include "packet-PROTOABBREV.h"
#endif
-/* Forward declaration that is needed below if using the
- * proto_reg_handoff_PROTOABBREV function as a callback for when protocol
- * preferences get changed. */
+/* Prototypes */
+/* (Required to prevent [-Wmissing-prototypes] warnings */
void proto_reg_handoff_PROTOABBREV(void);
void proto_register_PROTOABBREV(void);
@@ -57,11 +62,12 @@ static int hf_PROTOABBREV_FIELDABBREV = -1;
static expert_field ei_PROTOABBREV_EXPERTABBREV = EI_INIT;
/* Global sample preference ("controls" display of numbers) */
-static gboolean gPREF_HEX = FALSE;
+static gboolean pref_hex = FALSE;
/* Global sample port preference - real port preferences should generally
* default to 0 unless there is an IANA-registered (or equivalent) port for your
* protocol. */
-static guint gPORT_PREF = 1234;
+#define PROTOABBREV_TCP_PORT 1234
+static guint tcp_port_pref = PROTOABBREV_TCP_PORT;
/* Initialize the subtree pointers */
static gint ett_PROTOABBREV = -1;
@@ -80,8 +86,8 @@ dissect_PROTOABBREV(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
proto_item *ti, *expert_ti;
proto_tree *PROTOABBREV_tree;
/* Other misc. local variables. */
- guint offset = 0;
- int len = 0;
+ guint offset = 0;
+ int len = 0;
/*** HEURISTICS ***/
@@ -201,16 +207,16 @@ dissect_PROTOABBREV(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void
proto_register_PROTOABBREV(void)
{
- module_t *PROTOABBREV_module;
- expert_module_t* expert_PROTOABBREV;
+ module_t *PROTOABBREV_module;
+ expert_module_t *expert_PROTOABBREV;
/* Setup list of header fields See Section 1.5 of README.dissector for
* details. */
static hf_register_info hf[] = {
{ &hf_PROTOABBREV_FIELDABBREV,
- { "FIELDNAME", "PROTOABBREV.FIELDABBREV",
- FIELDTYPE, FIELDDISPLAY, FIELDCONVERT, BITMASK,
- "FIELDDESCR", HFILL }
+ { "FIELDNAME", "PROTOABBREV.FIELDABBREV",
+ FT_FIELDTYPE, FIELDDISPLAY,/*FIELDCONVERT*/, BITMASK,
+ "FIELDDESCR", HFILL }
}
};
@@ -221,7 +227,10 @@ proto_register_PROTOABBREV(void)
/* Setup protocol expert items */
static ei_register_info ei[] = {
- { &ei_PROTOABBREV_EXPERTABBREV, { "PROTOABBREV.EXPERTABBREV", PI_SEVERITY, PI_GROUP, "EXPERTDESCR", EXPFILL }},
+ { &ei_PROTOABBREV_EXPERTABBREV,
+ { "PROTOABBREV.EXPERTABBREV", PI_SEVERITY, PI_GROUP,
+ "EXPERTDESCR", EXPFILL }
+ }
};
/* Register the protocol name and description */
@@ -231,6 +240,7 @@ proto_register_PROTOABBREV(void)
/* Required function calls to register the header fields and subtrees */
proto_register_field_array(proto_PROTOABBREV, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
+
/* Required function calls to register expert items */
expert_PROTOABBREV = expert_register_protocol(proto_PROTOABBREV);
expert_register_field_array(expert_PROTOABBREV, ei, array_length(ei));
@@ -249,7 +259,7 @@ proto_register_PROTOABBREV(void)
* Only use this function instead of prefs_register_protocol (above) 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 using slash '/' (e.g. "OSI/X.500" - protocol preferences
* will be accessible under Protocols->OSI->X.500-><PROTOSHORTNAME>
@@ -262,12 +272,12 @@ proto_register_PROTOABBREV(void)
prefs_register_bool_preference(PROTOABBREV_module, "show_hex",
"Display numbers in Hex",
"Enable to display numerical values in hexadecimal.",
- &gPREF_HEX);
+ &pref_hex);
/* Register an example port preference */
prefs_register_uint_preference(PROTOABBREV_module, "tcp.port", "PROTOABBREV TCP Port",
" PROTOABBREV TCP port if other than the default",
- 10, &gPORT_PREF);
+ 10, &tcp_port_pref);
}
/* If this dissector uses sub-dissector registration add a registration routine.
@@ -290,7 +300,7 @@ proto_reg_handoff_PROTOABBREV(void)
{
static gboolean initialized = FALSE;
static dissector_handle_t PROTOABBREV_handle;
- static int currentPort;
+ static int current_port;
if (!initialized) {
/* Use new_create_dissector_handle() to indicate that
@@ -311,12 +321,12 @@ proto_reg_handoff_PROTOABBREV(void)
* preference can be saved using local statics in this
* function (proto_reg_handoff).
*/
- dissector_delete_uint("tcp.port", currentPort, PROTOABBREV_handle);
+ dissector_delete_uint("tcp.port", current_port, PROTOABBREV_handle);
}
- currentPort = gPORT_PREF;
+ current_port = tcp_port_pref;
- dissector_add_uint("tcp.port", currentPort, PROTOABBREV_handle);
+ dissector_add_uint("tcp.port", current_port, PROTOABBREV_handle);
}
#if 0
@@ -333,7 +343,7 @@ proto_reg_handoff_PROTOABBREV(void)
*/
PROTOABBREV_handle = new_create_dissector_handle(dissect_PROTOABBREV,
proto_PROTOABBREV);
- dissector_add_uint("PARENT_SUBFIELD", ID_VALUE, PROTOABBREV_handle);
+ dissector_add_uint("tcp.port", PROTO_ABBREV_TCP_PORT, PROTOABBREV_handle);
}
#endif