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-arcnet.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-arcnet.c')
-rw-r--r-- | epan/dissectors/packet-arcnet.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/epan/dissectors/packet-arcnet.c b/epan/dissectors/packet-arcnet.c index 7622c4cddb..7749aee0e3 100644 --- a/epan/dissectors/packet-arcnet.c +++ b/epan/dissectors/packet-arcnet.c @@ -81,20 +81,18 @@ static int arcnet_len(void) return 1; } -static void +static gboolean capture_arcnet_common(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_, gboolean has_exception) { if (!BYTES_ARE_IN_FRAME(offset, len, 1)) { - ld->other++; - return; + return FALSE; } switch (pd[offset]) { case ARCNET_PROTO_IP_1051: /* No fragmentation stuff in the header */ - capture_ip(pd, offset + 1, len, ld, pseudo_header); - break; + return capture_ip(pd, offset + 1, len, ld, pseudo_header); case ARCNET_PROTO_IP_1201: /* @@ -125,8 +123,7 @@ capture_arcnet_common(const guchar *pd, int offset, int len, packet_counts *ld, */ offset++; if (!BYTES_ARE_IN_FRAME(offset, len, 1)) { - ld->other++; - return; + return FALSE; } if (has_exception && pd[offset] == 0xff) { /* This is an exception packet. The flag value there is the @@ -135,8 +132,7 @@ capture_arcnet_common(const guchar *pd, int offset, int len, packet_counts *ld, type appears after the padding. */ offset += 4; } - capture_ip(pd, offset + 3, len, ld, pseudo_header); - break; + return capture_ip(pd, offset + 3, len, ld, pseudo_header); case ARCNET_PROTO_ARP_1051: case ARCNET_PROTO_ARP_1201: @@ -151,21 +147,22 @@ capture_arcnet_common(const guchar *pd, int offset, int len, packet_counts *ld, break; default: - ld->other++; - break; + return FALSE; } + + return TRUE; } -static void +static gboolean capture_arcnet (const guchar *pd, int offset _U_, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_) { - capture_arcnet_common(pd, 4, len, ld, pseudo_header, FALSE); + return capture_arcnet_common(pd, 4, len, ld, pseudo_header, FALSE); } -static void +static gboolean capture_arcnet_has_exception(const guchar *pd, int offset _U_, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_) { - capture_arcnet_common(pd, 2, len, ld, pseudo_header, TRUE); + return capture_arcnet_common(pd, 2, len, ld, pseudo_header, TRUE); } static void @@ -396,9 +393,6 @@ proto_register_arcnet (void) proto_register_field_array (proto_arcnet, hf, array_length (hf)); proto_register_subtree_array (ett, array_length (ett)); - register_capture_dissector(WTAP_ENCAP_ARCNET_LINUX, capture_arcnet, proto_arcnet); - register_capture_dissector(WTAP_ENCAP_ARCNET, capture_arcnet_has_exception, proto_arcnet); - arcnet_address_type = address_type_dissector_register("AT_ARCNET", "ARCNET Address", arcnet_to_str, arcnet_str_len, arcnet_col_filter_str, arcnet_len, NULL, NULL); } @@ -411,9 +405,11 @@ proto_reg_handoff_arcnet (void) arcnet_handle = create_dissector_handle (dissect_arcnet, proto_arcnet); dissector_add_uint ("wtap_encap", WTAP_ENCAP_ARCNET, arcnet_handle); - arcnet_linux_handle = create_dissector_handle (dissect_arcnet_linux, - proto_arcnet); + arcnet_linux_handle = create_dissector_handle (dissect_arcnet_linux, proto_arcnet); dissector_add_uint ("wtap_encap", WTAP_ENCAP_ARCNET_LINUX, arcnet_linux_handle); + + register_capture_dissector("wtap_encap", WTAP_ENCAP_ARCNET_LINUX, capture_arcnet, proto_arcnet); + register_capture_dissector("wtap_encap", WTAP_ENCAP_ARCNET, capture_arcnet_has_exception, proto_arcnet); data_handle = find_dissector ("data"); } |