diff options
author | Michael Mann <mmann78@netscape.net> | 2015-12-13 16:54:16 -0500 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2015-12-14 12:17:49 +0000 |
commit | 0960ac4dfdbfba5a81c56a49cfc6201ecd8f48e3 (patch) | |
tree | 3d88cd321da2fade206b9ccddff22b70ecdfae28 /epan/dissectors/packet-enc.c | |
parent | 9319357f5e27c10f2d29e78fcdf9d323c2af36b0 (diff) |
Create capture dissector tables.
They are modeled after dissection dissector tables, but for the moment, don't have/need the flexibility. They are intended to be much simpler/faster than full dissection.
The two most used/needed are "wtap_encap" and "ethertype", so they were the basis of starting to use and test capture dissector table API. Others may be added in the future.
The "capture dissector" function signature needed a bit of tweeking to handling "claiming" of a packet.
The current application of this is capture functions returning TRUE if they affected a "type" of packet count. Returning FALSE ends up considering the packet an "other" type.
Change-Id: I81d06a6ccb2c03665f087258a46b9d78d513d6cd
Reviewed-on: https://code.wireshark.org/review/12607
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-enc.c')
-rw-r--r-- | epan/dissectors/packet-enc.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/epan/dissectors/packet-enc.c b/epan/dissectors/packet-enc.c index 327f68db61..029fd2baad 100644 --- a/epan/dissectors/packet-enc.c +++ b/epan/dissectors/packet-enc.c @@ -65,31 +65,25 @@ static int hf_enc_flags = -1; static gint ett_enc = -1; -static void +static gboolean capture_enc(const guchar *pd, int offset _U_, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_) { guint32 af; - if (!BYTES_ARE_IN_FRAME(0, len, (int)BSD_ENC_HDRLEN)) { - ld->other++; - return; - } + if (!BYTES_ARE_IN_FRAME(0, len, (int)BSD_ENC_HDRLEN)) + return FALSE; af = pntoh32(pd + offsetof(struct enchdr, af)); switch (af) { case BSD_AF_INET: - capture_ip(pd, BSD_ENC_HDRLEN, len, ld, pseudo_header); - break; + return capture_ip(pd, BSD_ENC_HDRLEN, len, ld, pseudo_header); case BSD_AF_INET6_BSD: - capture_ipv6(pd, BSD_ENC_HDRLEN, len, ld, pseudo_header); - break; - - default: - ld->other++; - break; + return capture_ipv6(pd, BSD_ENC_HDRLEN, len, ld, pseudo_header); } + + return FALSE; } static const value_string af_vals[] = { @@ -181,8 +175,6 @@ proto_register_enc(void) "ENC", "enc"); proto_register_field_array(proto_enc, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - - register_capture_dissector(WTAP_ENCAP_ENC, capture_enc, proto_enc); } void @@ -196,6 +188,8 @@ proto_reg_handoff_enc(void) enc_handle = create_dissector_handle(dissect_enc, proto_enc); dissector_add_uint("wtap_encap", WTAP_ENCAP_ENC, enc_handle); + + register_capture_dissector("wtap_encap", WTAP_ENCAP_ENC, capture_enc, proto_enc); } /* |