diff options
author | Guy Harris <guy@alum.mit.edu> | 2002-02-26 11:55:39 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2002-02-26 11:55:39 +0000 |
commit | 193b8c9bfbd15afde08076ee1dc09abf914b9abe (patch) | |
tree | f9dc3f0b5ba0d6e395231161279cca2f2f326a53 /packet-eap.c | |
parent | fa431b988f316fe5ff99b107242a50b2cb99b2e3 (diff) |
Allow dissectors to be registered as "old-style" or "new-style"
dissectors. "Old-style" dissectors return nothing. "New-style"
dissectors return one of:
a positive integer, giving the number of bytes worth of data in
the tvbuff that it considered to be part of the PDU in the
tvbuff;
zero, if it didn't consider the data in the tvbuff to be a PDU
for its protocol;
a negative integer, giving the number of additional bytes worth
of data in needs to get the complete PDU (for use with
fragmentation/segmentation when the length of the PDU isn't
known to the protocol atop the one the dissector is dissecting).
Have "call_dissector()" return the return value of new-style dissectors,
and the length of the tvbuff handed to it for old-style dissectors.
Have "dissector_try_port()" return FALSE if the subdissector is a
new-style dissector and returned 0.
Make the EAP dissector a new-style dissector, and have a "EAP fragment"
dissector that is also a new-style dissector and handles fragmentation
of EAP messages (as happens above, for example, RADIUS). Also, clean up
some signed vs. unsigned comparison problems.
Reassemble EAP-Message AVPs in RADIUS.
svn path=/trunk/; revision=4811
Diffstat (limited to 'packet-eap.c')
-rw-r--r-- | packet-eap.c | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/packet-eap.c b/packet-eap.c index 8a66b9627f..c66b9fa494 100644 --- a/packet-eap.c +++ b/packet-eap.c @@ -2,7 +2,7 @@ * Routines for EAP Extensible Authentication Protocol dissection * RFC 2284 * - * $Id: packet-eap.c,v 1.14 2002/02/26 00:51:41 guy Exp $ + * $Id: packet-eap.c,v 1.15 2002/02/26 11:55:37 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -79,14 +79,15 @@ static const value_string eap_type_vals[] = { { 0, NULL } }; -static void -dissect_eap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +static int +dissect_eap_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, + gboolean fragmented) { guint8 eap_code; guint8 eap_id; guint16 eap_len; guint8 eap_type; - guint len; + gint len; proto_tree *ti; proto_tree *eap_tree = NULL; @@ -103,9 +104,17 @@ dissect_eap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) eap_len = tvb_get_ntohs(tvb, 2); len = eap_len; - /* at least for now, until we get defragmentation support */ - if (len>tvb_length(tvb)) - len=tvb_length(tvb); + if (fragmented) { + /* + * This is an EAP fragment inside, for example, RADIUS. If we don't + * have all of the packet data, return the negative of the amount of + * additional data we need. + */ + int reported_len = tvb_reported_length_remaining(tvb, 0); + + if (reported_len < len) + return -(len - reported_len); + } if (tree) { ti = proto_tree_add_item(tree, proto_eap, tvb, 0, len, FALSE); @@ -133,8 +142,8 @@ dissect_eap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_uint(eap_tree, hf_eap_type, tvb, 4, 1, eap_type); if (len > 5) { - guint offset = 5; - guint size = len - offset; + int offset = 5; + gint size = len - offset; switch (eap_type) { @@ -181,6 +190,20 @@ dissect_eap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } } } + + return tvb_length(tvb); +} + +static int +dissect_eap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + return dissect_eap_data(tvb, pinfo, tree, FALSE); +} + +static int +dissect_eap_fragment(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + return dissect_eap_data(tvb, pinfo, tree, TRUE); } void @@ -209,7 +232,8 @@ proto_register_eap(void) proto_register_field_array(proto_eap, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - register_dissector("eap", dissect_eap, proto_eap); + new_register_dissector("eap", dissect_eap, proto_eap); + new_register_dissector("eap_fragment", dissect_eap_fragment, proto_eap); } void |