From 0960ac4dfdbfba5a81c56a49cfc6201ecd8f48e3 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Sun, 13 Dec 2015 16:54:16 -0500 Subject: 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 Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- epan/dissectors/packet-ax25.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'epan/dissectors/packet-ax25.c') diff --git a/epan/dissectors/packet-ax25.c b/epan/dissectors/packet-ax25.c index 1539379ac7..03d28b09f3 100644 --- a/epan/dissectors/packet-ax25.c +++ b/epan/dissectors/packet-ax25.c @@ -254,7 +254,7 @@ dissect_ax25( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* return tvb_captured_length(tvb); } -void +gboolean capture_ax25( const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_) { guint8 control; @@ -262,10 +262,7 @@ capture_ax25( const guchar *pd, int offset, int len, packet_counts *ld, const un int l_offset; if ( ! BYTES_ARE_IN_FRAME( offset, len, AX25_HEADER_SIZE ) ) - { - ld->other++; - return; - } + return FALSE; l_offset = offset; l_offset += AX25_ADDR_LEN; /* step over dst addr point at src addr */ @@ -277,7 +274,7 @@ capture_ax25( const guchar *pd, int offset, int len, packet_counts *ld, const un /* decode the pid field (if appropriate) */ if ( XDLC_IS_INFORMATION( control ) ) - { + { l_offset += 1; /* step over control byte point at pid */ pid = pd[ l_offset ]; @@ -285,19 +282,15 @@ capture_ax25( const guchar *pd, int offset, int len, packet_counts *ld, const un switch ( pid & 0x0ff ) { case AX25_P_NETROM : - capture_netrom( pd, l_offset, len, ld, pseudo_header ); - break; + return capture_netrom( pd, l_offset, len, ld, pseudo_header ); case AX25_P_IP : - capture_ip( pd, l_offset, len, ld, pseudo_header ); - break; + return capture_ip( pd, l_offset, len, ld, pseudo_header ); case AX25_P_ARP : ld->arp++; - break; - default : - ld->other++; - break; + return TRUE; } - } + } + return FALSE; } void @@ -435,8 +428,6 @@ proto_register_ax25(void) proto_register_field_array( proto_ax25, hf, array_length(hf ) ); proto_register_subtree_array(ett, array_length(ett ) ); - register_capture_dissector(WTAP_ENCAP_AX25, capture_ax25, proto_ax25); - /* Register dissector table for protocol IDs */ ax25_dissector_table = register_dissector_table("ax25.pid", "AX.25 protocol ID", FT_UINT8, BASE_HEX, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE); } @@ -447,6 +438,8 @@ proto_reg_handoff_ax25(void) dissector_add_uint("wtap_encap", WTAP_ENCAP_AX25, ax25_handle); dissector_add_uint("ip.proto", IP_PROTO_AX25, ax25_handle); + register_capture_dissector("wtap_encap", WTAP_ENCAP_AX25, capture_ax25, proto_ax25); + data_handle = find_dissector( "data" ); } -- cgit v1.2.3