forked from osmocom/wireshark
Update documentation for tcp_dissect_pdus. Bug 9491 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9491)
From Peter Wu: update to README.dissector From me: update to WSDG_chapter_dissection.xml svn path=/trunk/; revision=53678
This commit is contained in:
parent
e2d2d12098
commit
fd2f05446d
|
@ -72,7 +72,7 @@ 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.
|
epan/dissectors/, just like all the other packet-*.c files already in there.
|
||||||
|
|
||||||
Also, please add your dissector file to the corresponding makefiles,
|
Also, please add your dissector file to the corresponding makefiles,
|
||||||
described in section "1.9 Editing Makefile.common and CMakeLists.txt
|
described in section "1.8 Editing Makefile.common and CMakeLists.txt
|
||||||
to add your dissector" below.
|
to add your dissector" below.
|
||||||
|
|
||||||
Dissectors that use the dissector registration API to register with a lower
|
Dissectors that use the dissector registration API to register with a lower
|
||||||
|
@ -2833,15 +2833,17 @@ dissect_PROTO_udp (or dissect_PROTO_other).
|
||||||
To register the distinct dissector functions, consider the following
|
To register the distinct dissector functions, consider the following
|
||||||
example, stolen from packet-dns.c:
|
example, stolen from packet-dns.c:
|
||||||
|
|
||||||
|
#include "packet-tcp.h"
|
||||||
|
|
||||||
dissector_handle_t dns_udp_handle;
|
dissector_handle_t dns_udp_handle;
|
||||||
dissector_handle_t dns_tcp_handle;
|
dissector_handle_t dns_tcp_handle;
|
||||||
dissector_handle_t mdns_udp_handle;
|
dissector_handle_t mdns_udp_handle;
|
||||||
|
|
||||||
dns_udp_handle = create_dissector_handle(dissect_dns_udp,
|
dns_udp_handle = new_create_dissector_handle(dissect_dns_udp,
|
||||||
proto_dns);
|
proto_dns);
|
||||||
dns_tcp_handle = create_dissector_handle(dissect_dns_tcp,
|
dns_tcp_handle = new_create_dissector_handle(dissect_dns_tcp,
|
||||||
proto_dns);
|
proto_dns);
|
||||||
mdns_udp_handle = create_dissector_handle(dissect_mdns_udp,
|
mdns_udp_handle = new_create_dissector_handle(dissect_mdns_udp,
|
||||||
proto_dns);
|
proto_dns);
|
||||||
|
|
||||||
dissector_add_uint("udp.port", UDP_PORT_DNS, dns_udp_handle);
|
dissector_add_uint("udp.port", UDP_PORT_DNS, dns_udp_handle);
|
||||||
|
@ -2853,11 +2855,13 @@ The dissect_dns_udp function does very little work and calls
|
||||||
dissect_dns_common, while dissect_dns_tcp calls tcp_dissect_pdus with a
|
dissect_dns_common, while dissect_dns_tcp calls tcp_dissect_pdus with a
|
||||||
reference to a callback which will be called with reassembled data:
|
reference to a callback which will be called with reassembled data:
|
||||||
|
|
||||||
static void
|
static int
|
||||||
dissect_dns_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
dissect_dns_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
||||||
|
void *data _U_)
|
||||||
{
|
{
|
||||||
tcp_dissect_pdus(tvb, pinfo, tree, dns_desegment, 2,
|
tcp_dissect_pdus(tvb, pinfo, tree, dns_desegment, 2,
|
||||||
get_dns_pdu_len, dissect_dns_tcp_pdu);
|
get_dns_pdu_len, dissect_dns_tcp_pdu, data);
|
||||||
|
return tvb_length(tvb);
|
||||||
}
|
}
|
||||||
|
|
||||||
(The dissect_dns_tcp_pdu function acts similarly to dissect_dns_udp.)
|
(The dissect_dns_tcp_pdu function acts similarly to dissect_dns_udp.)
|
||||||
|
@ -2880,10 +2884,13 @@ The arguments to tcp_dissect_pdus are:
|
||||||
might not be available, so don't refer to any data past that) - the
|
might not be available, so don't refer to any data past that) - the
|
||||||
total length of the PDU, in bytes;
|
total length of the PDU, in bytes;
|
||||||
|
|
||||||
a routine to dissect the pdu that's passed a tvbuff pointer,
|
a new_dissector_t routine to dissect the pdu that's passed a tvbuff
|
||||||
packet_info pointer, and proto_tree pointer, with the tvbuff
|
pointer, packet_info pointer, proto_tree pointer and a void pointer for
|
||||||
containing a possibly-reassembled PDU. (The "reported_length"
|
user data, with the tvbuff containing a possibly-reassembled PDU. (The
|
||||||
of the tvbuff will be the length of the PDU).
|
"reported_length" of the tvbuff will be the length of the PDU).
|
||||||
|
|
||||||
|
a void pointer to user data that is passed to the dissector routine
|
||||||
|
referenced in the previous parameter.
|
||||||
|
|
||||||
2.7.2 Modifying the pinfo struct.
|
2.7.2 Modifying the pinfo struct.
|
||||||
|
|
||||||
|
|
|
@ -978,17 +978,11 @@ static gint *ett[] =
|
||||||
|
|
||||||
#define FRAME_HEADER_LEN 8
|
#define FRAME_HEADER_LEN 8
|
||||||
|
|
||||||
/* The main dissecting routine */
|
|
||||||
static void dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
||||||
{
|
|
||||||
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, FRAME_HEADER_LEN,
|
|
||||||
get_foo_message_len, dissect_foo_message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This method dissects fully reassembled messages */
|
/* This method dissects fully reassembled messages */
|
||||||
static void dissect_foo_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
static int dissect_foo_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
||||||
{
|
{
|
||||||
/* TODO: implement your dissecting code */
|
/* TODO: implement your dissecting code */
|
||||||
|
return tvb_length(tvb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* determine PDU length of protocol foo */
|
/* determine PDU length of protocol foo */
|
||||||
|
@ -998,6 +992,14 @@ static guint get_foo_message_len(packet_info *pinfo, tvbuff_t *tvb, int offset)
|
||||||
return (guint)tvb_get_ntohl(tvb, offset+4); /* e.g. length is at offset 4 */
|
return (guint)tvb_get_ntohl(tvb, offset+4); /* e.g. length is at offset 4 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The main dissecting routine */
|
||||||
|
static int dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
|
||||||
|
{
|
||||||
|
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, FRAME_HEADER_LEN,
|
||||||
|
get_foo_message_len, dissect_foo_message, data);
|
||||||
|
return tvb_length(tvb);
|
||||||
|
}
|
||||||
|
|
||||||
...]]>
|
...]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
@ -1007,16 +1009,17 @@ static guint get_foo_message_len(packet_info *pinfo, tvbuff_t *tvb, int offset)
|
||||||
This function gets called whenever a message has been reassembled.
|
This function gets called whenever a message has been reassembled.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The parameters <parameter>tvb</parameter>, <parameter>pinfo</parameter> and <parameter>tree</parameter>
|
The parameters <parameter>tvb</parameter>, <parameter>pinfo</parameter>, <parameter>tree</parameter>
|
||||||
are just handed over to <function>tcp_dissect_pdus()</function>.
|
and <parameter>data</parameter> are just handed over to <function>tcp_dissect_pdus()</function>.
|
||||||
The 4th parameter is a flag to indicate if the data should be reassembled or not. This could be set
|
The 4th parameter is a flag to indicate if the data should be reassembled or not. This could be set
|
||||||
according to a dissector preference as well.
|
according to a dissector preference as well.
|
||||||
Parameter 5 indicates how much data has at least to be available to be able to determine the length
|
Parameter 5 indicates how much data has at least to be available to be able to determine the length
|
||||||
of the foo message.
|
of the foo message.
|
||||||
Parameter 6 is a function pointer to a method that returns this length. It gets called when at least
|
Parameter 6 is a function pointer to a method that returns this length. It gets called when at least
|
||||||
the number of bytes given in the previous parameter is available.
|
the number of bytes given in the previous parameter is available.
|
||||||
Parameter 7 is a function pointer to your real message dissector.
|
Parameter 7 is a function pointer to your real message dissector.
|
||||||
</para>
|
Parameter 8 is a the data passed in from parent dissector.
|
||||||
|
</para>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
<section id="ChDissectTap">
|
<section id="ChDissectTap">
|
||||||
|
|
Loading…
Reference in New Issue