diff options
author | Gilbert Ramirez <gram@alumni.rice.edu> | 2000-10-06 10:11:40 +0000 |
---|---|---|
committer | Gilbert Ramirez <gram@alumni.rice.edu> | 2000-10-06 10:11:40 +0000 |
commit | e69b5278aaddce2af02174afe0515adceb841973 (patch) | |
tree | 8cb476c958c815d3d73d4ac79ffeb15df28484d8 /tethereal.c | |
parent | e735d485aee9d56723dea97fae3064cf4bdd7e9a (diff) |
Implement epan_dissect_new() and epan_dissect_free(). These are the
"top-level" dissectors that libepan-users call, instead of dissect_packet().
The epan_dissect_t holds the tvbuff after dissection so that the tvbuff's
memory is not cleared until after the proto_tree is freed. (I might stuff
the proto_tree into the epan_dissect_t, too).
What remains of dissect_packet() in packet.c handles the tvbuff initialiation.
The real meat of dissect_packet() is now in dissect_frame(), in packet-frame.c
This means that "packet.c" is no longer a dissector, os it is no longer
passed to make-reg-dotc.
Once dissect_fddi() gets two wrapper functions (dissect_fddi_swapped()
and dissect_fddi_nonswapped()), the a dissector handoff routine could
be used instead of the switch statement in dissect_frame(). I'd register
a field like "wtap.encap"
svn path=/trunk/; revision=2478
Diffstat (limited to 'tethereal.c')
-rw-r--r-- | tethereal.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tethereal.c b/tethereal.c index bbcb539532..3190fcd340 100644 --- a/tethereal.c +++ b/tethereal.c @@ -1,6 +1,6 @@ /* tethereal.c * - * $Id: tethereal.c,v 1.48 2000/09/27 04:54:33 gram Exp $ + * $Id: tethereal.c,v 1.49 2000/10/06 10:10:50 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -883,16 +883,18 @@ wtap_dispatch_cb_write(u_char *user, const struct wtap_pkthdr *phdr, int offset, proto_tree *protocol_tree; int err; gboolean passed; + epan_dissect_t *edt; cf->count++; if (cf->rfcode) { fill_in_fdata(&fdata, cf, phdr, pseudo_header, offset); protocol_tree = proto_tree_create_root(); - dissect_packet(pseudo_header, buf, &fdata, protocol_tree); + edt = epan_dissect_new(pseudo_header, buf, &fdata, protocol_tree); passed = dfilter_apply(cf->rfcode, protocol_tree, buf, fdata.cap_len); } else { protocol_tree = NULL; passed = TRUE; + edt = NULL; } if (passed) { /* XXX - do something if this fails */ @@ -900,6 +902,8 @@ wtap_dispatch_cb_write(u_char *user, const struct wtap_pkthdr *phdr, int offset, } if (protocol_tree != NULL) proto_tree_free(protocol_tree); + if (edt != NULL) + epan_dissect_free(edt); } static void @@ -912,6 +916,7 @@ wtap_dispatch_cb_print(u_char *user, const struct wtap_pkthdr *phdr, int offset, proto_tree *protocol_tree; gboolean passed; print_args_t print_args; + epan_dissect_t *edt; cf->count++; @@ -926,7 +931,7 @@ wtap_dispatch_cb_print(u_char *user, const struct wtap_pkthdr *phdr, int offset, protocol_tree = proto_tree_create_root(); else protocol_tree = NULL; - dissect_packet(pseudo_header, buf, &fdata, protocol_tree); + edt = epan_dissect_new(pseudo_header, buf, &fdata, protocol_tree); if (cf->rfcode) passed = dfilter_apply(cf->rfcode, protocol_tree, buf, fdata.cap_len); if (passed) { @@ -975,6 +980,8 @@ wtap_dispatch_cb_print(u_char *user, const struct wtap_pkthdr *phdr, int offset, if (protocol_tree != NULL) proto_tree_free(protocol_tree); + epan_dissect_free(edt); + proto_tree_is_visible = FALSE; } |