aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-tr.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-tr.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-tr.c')
-rw-r--r--epan/dissectors/packet-tr.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/epan/dissectors/packet-tr.c b/epan/dissectors/packet-tr.c
index bebdfdfc3a..2227d6ff8e 100644
--- a/epan/dissectors/packet-tr.c
+++ b/epan/dissectors/packet-tr.c
@@ -246,7 +246,7 @@ int check_for_old_linux(const guchar * pd)
static void
add_ring_bridge_pairs(int rcf_len, tvbuff_t*, proto_tree *tree);
-void
+gboolean
capture_tr(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_) {
int source_routed = 0;
@@ -260,10 +260,8 @@ capture_tr(const guchar *pd, int offset, int len, packet_counts *ld, const union
guint8 trn_fc; /* field control field */
const guint8 *trn_shost; /* source host */
- if (!BYTES_ARE_IN_FRAME(offset, len, TR_MIN_HEADER_LEN)) {
- ld->other++;
- return;
- }
+ if (!BYTES_ARE_IN_FRAME(offset, len, TR_MIN_HEADER_LEN))
+ return FALSE;
if ((x = check_for_old_linux(pd)))
{
@@ -359,20 +357,13 @@ capture_tr(const guchar *pd, int offset, int len, packet_counts *ld, const union
offset += actual_rif_bytes + TR_MIN_HEADER_LEN;
- /* The package is either MAC or LLC */
+ /* The package is either MAC (0) or LLC (1)*/
switch (frame_type) {
- /* MAC */
- case 0:
- ld->other++;
- break;
case 1:
- capture_llc(pd, offset, len, ld, pseudo_header);
- break;
- default:
- /* non-MAC, non-LLC, i.e., "Reserved" */
- ld->other++;
- break;
+ return capture_llc(pd, offset, len, ld, pseudo_header);
}
+
+ return FALSE;
}
@@ -801,7 +792,6 @@ proto_register_tr(void)
&fix_linux_botches);
register_dissector("tr", dissect_tr, proto_tr);
- register_capture_dissector(WTAP_ENCAP_TOKEN_RING, capture_tr, proto_tr);
tr_tap=register_tap("tr");
register_conversation_table(proto_tr, TRUE, tr_conversation_packet, tr_hostlist_packet);
@@ -822,6 +812,8 @@ proto_reg_handoff_tr(void)
tr_handle = find_dissector("tr");
dissector_add_uint("wtap_encap", WTAP_ENCAP_TOKEN_RING, tr_handle);
dissector_add_uint("sflow_245.header_protocol", SFLOW_245_HEADER_TOKENRING, tr_handle);
+
+ register_capture_dissector("wtap_encap", WTAP_ENCAP_TOKEN_RING, capture_tr, proto_tr);
}
/*