summaryrefslogtreecommitdiff
path: root/docbook/wsdg_src/WSDG_chapter_dissection.asciidoc
diff options
context:
space:
mode:
Diffstat (limited to 'docbook/wsdg_src/WSDG_chapter_dissection.asciidoc')
-rw-r--r--docbook/wsdg_src/WSDG_chapter_dissection.asciidoc68
1 files changed, 22 insertions, 46 deletions
diff --git a/docbook/wsdg_src/WSDG_chapter_dissection.asciidoc b/docbook/wsdg_src/WSDG_chapter_dissection.asciidoc
index ccfcb45aa7..9c4c6e61ca 100644
--- a/docbook/wsdg_src/WSDG_chapter_dissection.asciidoc
+++ b/docbook/wsdg_src/WSDG_chapter_dissection.asciidoc
@@ -201,13 +201,7 @@ The simplest thing to do to start with is to just label the payload.
This will allow us to set up some of the parts we will need.
The first thing we will do is to build a subtree to decode our results into.
-This helps to keep things looking nice in the detailed display. Now the
-dissector is called in two different cases. In one case it is called to get a
-summary of the packet, in the other case it is called to look into details of
-the packet. These two cases can be distinguished by the tree pointer. If the
-tree pointer is NULL, then we are being asked for a summary. If it is non NULL,
-we can pick apart the protocol for display. So with that in mind, let's enhance
-our dissector.
+This helps to keep things looking nice in the detailed display.
.Plugin Packet Dissection.
====
@@ -220,10 +214,7 @@ dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* Clear out stuff in the info column */
col_clear(pinfo->cinfo,COL_INFO);
- if (tree) { /* we are being asked for details */
- proto_item *ti = NULL;
- ti = proto_tree_add_item(tree, proto_foo, tvb, 0, -1, ENC_NA);
- }
+ proto_item *ti = proto_tree_add_item(tree, proto_foo, tvb, 0, -1, ENC_NA);
}
----
====
@@ -299,14 +290,9 @@ Now we can enhance the protocol display with some detail.
.Dissector starting to dissect the packets.
====
----
- if (tree) { /* we are being asked for details */
- proto_item *ti = NULL;
- proto_tree *foo_tree = NULL;
-
- ti = proto_tree_add_item(tree, proto_foo, tvb, 0, -1, ENC_NA);
- foo_tree = proto_item_add_subtree(ti, ett_foo);
- proto_tree_add_item(foo_tree, hf_foo_pdu_type, tvb, 0, 1, ENC_BIG_ENDIAN);
- }
+ proto_item *ti = proto_tree_add_item(tree, proto_foo, tvb, 0, -1, ENC_NA);
+ proto_tree *foo_tree = proto_item_add_subtree(ti, ett_foo);
+ proto_tree_add_item(foo_tree, hf_foo_pdu_type, tvb, 0, 1, ENC_BIG_ENDIAN);
----
====
@@ -367,22 +353,16 @@ dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
gint offset = 0;
...
-
- if (tree) { /* we are being asked for details */
- proto_item *ti = NULL;
- proto_tree *foo_tree = NULL;
-
- ti = proto_tree_add_item(tree, proto_foo, tvb, 0, -1, ENC_NA);
- foo_tree = proto_item_add_subtree(ti, ett_foo);
- proto_tree_add_item(foo_tree, hf_foo_pdu_type, tvb, offset, 1, ENC_BIG_ENDIAN);
- offset += 1;
- proto_tree_add_item(foo_tree, hf_foo_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
- offset += 1;
- proto_tree_add_item(foo_tree, hf_foo_sequenceno, tvb, offset, 2, ENC_BIG_ENDIAN);
- offset += 2;
- proto_tree_add_item(foo_tree, hf_foo_initialip, tvb, offset, 4, ENC_BIG_ENDIAN);
- offset += 4;
- }
+ proto_item *ti = proto_tree_add_item(tree, proto_foo, tvb, 0, -1, ENC_NA);
+ proto_tree *foo_tree = proto_item_add_subtree(ti, ett_foo);
+ proto_tree_add_item(foo_tree, hf_foo_pdu_type, tvb, offset, 1, ENC_BIG_ENDIAN);
+ offset += 1;
+ proto_tree_add_item(foo_tree, hf_foo_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
+ offset += 1;
+ proto_tree_add_item(foo_tree, hf_foo_sequenceno, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
+ proto_tree_add_item(foo_tree, hf_foo_initialip, tvb, offset, 4, ENC_BIG_ENDIAN);
+ offset += 4;
...
}
@@ -546,18 +526,14 @@ dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
col_add_fstr(pinfo->cinfo, COL_INFO, "Type %s",
val_to_str(packet_type, packettypenames, "Unknown (0x%02x)"));
- if (tree) { /* we are being asked for details */
- proto_item *ti = NULL;
- proto_tree *foo_tree = NULL;
- gint offset = 0;
+ gint offset = 0;
- ti = proto_tree_add_item(tree, proto_foo, tvb, 0, -1, ENC_NA);
- proto_item_append_text(ti, ", Type %s",
- val_to_str(packet_type, packettypenames, "Unknown (0x%02x)"));
- foo_tree = proto_item_add_subtree(ti, ett_foo);
- proto_tree_add_item(foo_tree, hf_foo_pdu_type, tvb, offset, 1, ENC_BIG_ENDIAN);
- offset += 1;
- }
+ proto_item *ti = proto_tree_add_item(tree, proto_foo, tvb, 0, -1, ENC_NA);
+ proto_item_append_text(ti, ", Type %s",
+ val_to_str(packet_type, packettypenames, "Unknown (0x%02x)"));
+ proto_tree *foo_tree = proto_item_add_subtree(ti, ett_foo);
+ proto_tree_add_item(foo_tree, hf_foo_pdu_type, tvb, offset, 1, ENC_BIG_ENDIAN);
+ offset += 1;
}
----
====