summaryrefslogtreecommitdiff
path: root/docbook
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2011-10-25 00:03:47 +0000
committerBill Meier <wmeier@newsguy.com>2011-10-25 00:03:47 +0000
commit048b0c7ff014f9a305c987df386dd18738674345 (patch)
treef185073b3eab6988cb0c2a484e8765f13267f1fe /docbook
parentfff694bbeff0d35f09c14e25ff6041ecf9676bd0 (diff)
downloadwireshark-048b0c7ff014f9a305c987df386dd18738674345.tar.gz
From Ed Beroset: updated examples to use ENC_BIG_ENDIAN instead of FALSE.
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6482 From me: - Use ENC_NA for proto_tree_add_item(...,proto_foo,...); - Also: fix a typo unrelated to Ed's patch. svn path=/trunk/; revision=39547
Diffstat (limited to 'docbook')
-rw-r--r--docbook/wsdg_src/WSDG_chapter_dissection.xml44
1 files changed, 26 insertions, 18 deletions
diff --git a/docbook/wsdg_src/WSDG_chapter_dissection.xml b/docbook/wsdg_src/WSDG_chapter_dissection.xml
index 475486db0a..d38da565f1 100644
--- a/docbook/wsdg_src/WSDG_chapter_dissection.xml
+++ b/docbook/wsdg_src/WSDG_chapter_dissection.xml
@@ -249,7 +249,7 @@ dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (tree) { /* we are being asked for details */
proto_item *ti = NULL;
- ti = proto_tree_add_item(tree, proto_foo, tvb, 0, -1, FALSE);
+ ti = proto_tree_add_item(tree, proto_foo, tvb, 0, -1, ENC_NA);
}
}]]>
</programlisting></example>
@@ -265,7 +265,8 @@ dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
Therefore, we add the new tree node with <function>proto_tree_add_item()</function>,
adding it to the passed in tree, label it with the protocol, use the passed in
tvb buffer as the data, and consume from 0 to the end (-1) of this data.
- The FALSE we'll ignore for now.
+ ENC_NA ("not applicable") is specified as the "encoding" parameter.
+
</para>
<para>
After this change, there should be a label in the detailed display for the protocol,
@@ -330,9 +331,9 @@ static gint ett_foo = -1;]]>
proto_item *ti = NULL;
proto_tree *foo_tree = NULL;
- ti = proto_tree_add_item(tree, proto_foo, tvb, 0, -1, FALSE);
+ 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, FALSE);
+ proto_tree_add_item(foo_tree, hf_foo_pdu_type, tvb, 0, 1, ENC_BIG_ENDIAN);
}]]>
</programlisting></example>
<para>
@@ -350,8 +351,10 @@ static gint ett_foo = -1;]]>
A call to <function>proto_tree_add_item()</function> in the <varname>foo_tree</varname>,
this time using the <varname>hf_foo_pdu_type</varname> to control the formatting
of the item. The pdu type is one byte of data, starting at 0. We assume it is
- in network order, so that is why we use FALSE. Although for 1 byte there is
- no order issue it's best to keep this correct.
+ in network order (also called big endian), so that is why we use ENC_BIG_ENDIAN.
+ For a 1-byte quantity, there is no order issue, but it is good practice to
+ make this the same as any multibyte fields that may be present, and as we will
+ see in the next section, this particular protocol uses network order.
</para>
<para>
If we look in detail at the <varname>hf_foo_pdu_type</varname> declaration in
@@ -369,7 +372,7 @@ static gint ett_foo = -1;]]>
as foo.type=1 into the filter box.
</para></listitem>
<listitem><para>
- FT_UNIT8 - this specifies this item is an 8bit unsigned integer.
+ FT_UINT8 - this specifies this item is an 8bit unsigned integer.
This tallies with our call above where we tell it to only look at one byte.
</para></listitem>
<listitem><para>
@@ -407,12 +410,16 @@ dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_item *ti = NULL;
proto_tree *foo_tree = NULL;
- ti = proto_tree_add_item(tree, proto_foo, tvb, 0, -1, FALSE);
+ 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, FALSE); offset += 1;
- proto_tree_add_item(foo_tree, hf_foo_flags, tvb, offset, 1, FALSE); offset += 1;
- proto_tree_add_item(foo_tree, hf_foo_sequenceno, tvb, offset, 2, FALSE); offset += 2;
- proto_tree_add_item(foo_tree, hf_foo_initialip, tvb, offset, 4, FALSE); offset += 4;
+ 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;
}
...
}
@@ -500,10 +507,11 @@ dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
...
...
- proto_tree_add_item(foo_tree, hf_foo_flags, tvb, offset, 1, FALSE);
- proto_tree_add_item(foo_tree, hf_foo_startflag, tvb, offset, 1, FALSE);
- proto_tree_add_item(foo_tree, hf_foo_endflag, tvb, offset, 1, FALSE);
- proto_tree_add_item(foo_tree, hf_foo_priorityflag, tvb, offset, 1, FALSE); offset += 1;
+ proto_tree_add_item(foo_tree, hf_foo_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(foo_tree, hf_foo_startflag, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(foo_tree, hf_foo_endflag, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(foo_tree, hf_foo_priorityflag, tvb, offset, 1, ENC_BIG_ENDIAN);
+ offset += 1;
...
...
}
@@ -573,11 +581,11 @@ dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree *foo_tree = NULL;
gint offset = 0;
- ti = proto_tree_add_item(tree, proto_foo, tvb, 0, -1, FALSE);
+ 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, FALSE);
+ proto_tree_add_item(foo_tree, hf_foo_pdu_type, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
}
}]]>