aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ax25.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-12-13 16:54:16 -0500
committerMichael Mann <mmann78@netscape.net>2015-12-14 12:17:49 +0000
commit0960ac4dfdbfba5a81c56a49cfc6201ecd8f48e3 (patch)
tree3d88cd321da2fade206b9ccddff22b70ecdfae28 /epan/dissectors/packet-ax25.c
parent9319357f5e27c10f2d29e78fcdf9d323c2af36b0 (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-ax25.c')
-rw-r--r--epan/dissectors/packet-ax25.c27
1 files changed, 10 insertions, 17 deletions
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" );
}