diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2016-06-08 22:26:02 +0200 |
---|---|---|
committer | Pascal Quantin <pascal.quantin@gmail.com> | 2016-06-09 05:03:54 +0000 |
commit | d907fc2800f7ae4bf7472ffdd20d5d85931f5907 (patch) | |
tree | 19e05679972cb8b32a6952fb7a8b18efceedfc86 /docbook/wsdg_src/WSDG_chapter_dissection.asciidoc | |
parent | 078ab458a6c73a1a0d58ad2014a1b423c0bc97e8 (diff) | |
download | wireshark-d907fc2800f7ae4bf7472ffdd20d5d85931f5907.tar.gz |
Update Developer's Guide to reflect dissector_t signature change
Change-Id: Ia793d94c7e79e49d1f27ad8adbdbafdb30131abe
Reviewed-on: https://code.wireshark.org/review/15783
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Diffstat (limited to 'docbook/wsdg_src/WSDG_chapter_dissection.asciidoc')
-rw-r--r-- | docbook/wsdg_src/WSDG_chapter_dissection.asciidoc | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/docbook/wsdg_src/WSDG_chapter_dissection.asciidoc b/docbook/wsdg_src/WSDG_chapter_dissection.asciidoc index 9c4c6e61ca..6f418b05b5 100644 --- a/docbook/wsdg_src/WSDG_chapter_dissection.asciidoc +++ b/docbook/wsdg_src/WSDG_chapter_dissection.asciidoc @@ -141,12 +141,14 @@ leave it as a basic placeholder. .Dissection. ==== ---- -static void -dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +static int +dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void *data _U_) { col_set_str(pinfo->cinfo, COL_PROTOCOL, "FOO"); /* Clear out stuff in the info column */ col_clear(pinfo->cinfo,COL_INFO); + + return tvb_captured_length(tvb); } ---- ==== @@ -206,8 +208,8 @@ This helps to keep things looking nice in the detailed display. .Plugin Packet Dissection. ==== ---- -static void -dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +static int +dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { col_set_str(pinfo->cinfo, COL_PROTOCOL, "FOO"); @@ -215,6 +217,8 @@ dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_clear(pinfo->cinfo,COL_INFO); proto_item *ti = proto_tree_add_item(tree, proto_foo, tvb, 0, -1, ENC_NA); + + return tvb_captured_length(tvb); } ---- ==== @@ -347,8 +351,8 @@ static int hf_foo_sequenceno = -1; static int hf_foo_initialip = -1; ... -static void -dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +static int +dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { gint offset = 0; @@ -364,6 +368,8 @@ dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_item(foo_tree, hf_foo_initialip, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; ... + + return tvb_captured_length(tvb); } void @@ -451,8 +457,8 @@ static int hf_foo_startflag = -1; static int hf_foo_endflag = -1; static int hf_foo_priorityflag = -1; -static void -dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +static int +dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { ... ... @@ -463,6 +469,7 @@ dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset += 1; ... ... + return tvb_captured_length(tvb); } void @@ -515,9 +522,10 @@ window. .Enhancing the display. ==== ---- -static void -dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +static int +dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { + gint offset = 0; guint8 packet_type = tvb_get_guint8(tvb, 0); col_set_str(pinfo->cinfo, COL_PROTOCOL, "FOO"); @@ -526,14 +534,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)")); - gint offset = 0; - 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; + + return tvb_captured_length(tvb); } ---- ==== @@ -912,7 +920,7 @@ This function is implemented in 'epan/dissectors/packet-tcp.h'. /* This method dissects fully reassembled messages */ static int -dissect_foo_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) +dissect_foo_message(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { /* TODO: implement your dissecting code */ return tvb_captured_length(tvb); @@ -1010,7 +1018,8 @@ of the dissector. .Calling a protocol tap ==== ---- -void dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +static int +dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { ... fooinfo = wmem_alloc(wmem_packet_scope(), sizeof(struct FooTap)); @@ -1018,6 +1027,8 @@ void dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) fooinfo->priority = tvb_get_ntohs(tvb, 8); ... tap_queue_packet(foo_tap, pinfo, fooinfo); + + return tvb_captured_length(tvb); } ---- ==== |