diff options
author | Gilbert Ramirez <gram@alumni.rice.edu> | 2002-01-05 04:12:17 +0000 |
---|---|---|
committer | Gilbert Ramirez <gram@alumni.rice.edu> | 2002-01-05 04:12:17 +0000 |
commit | 0b9b02c6ea4bbf4a7792aa1493b507fd68e8a87b (patch) | |
tree | ac264635defc42eb14ee180db1b32d9b5032458c /epan | |
parent | 3ed03cadf65462aa5253098f0df781022cb3a0ed (diff) |
Long NCP traces can easily have many packets whose "uniqueness"
variables wrap-around. Since the request/reply packets are related via
a hash based on these uniqueness variables, long NCP traces can
have mis-matches reqeust/reply records.
Thus, only do the hash-lookup for the reply packet during the first
sequential scan of the trace file. Once the pertinent info is found,
store it in the packet's private data area.
Since the memory allocated for the hash and for the structures that make
up the keys are no longer needed after the first sequential run through
the trace file, arrange to free that memory after the first sequential
run. Similar to the register_init_routine() that allows dissectors
to register callbacks for calling *before* a capture file is loaded,
set up a register_postseq_cleanup_routine() function that allows
dissectors to register callbacks for calling *after* the first
sequential run-through of the trace file is made. This is not
a *final* cleanup callback, since Ethereal will still have that trace file
open for random-access reading.
I didn't have tethereal call postseq_cleanup_all_protocols() since
tethereal doesn't keep the trace file open for random-access reading.
I could easily be swayed to make tethereal call that function, however.
svn path=/trunk/; revision=4484
Diffstat (limited to 'epan')
-rw-r--r-- | epan/packet.c | 33 | ||||
-rw-r--r-- | epan/packet.h | 11 | ||||
-rw-r--r-- | epan/plugins.c | 3 |
3 files changed, 44 insertions, 3 deletions
diff --git a/epan/packet.c b/epan/packet.c index 6ef976a430..2d240d166f 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -1,7 +1,7 @@ /* packet.c * Routines for packet disassembly * - * $Id: packet.c,v 1.55 2001/12/18 19:09:03 gram Exp $ + * $Id: packet.c,v 1.56 2002/01/05 04:12:16 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -150,6 +150,37 @@ init_all_protocols(void) g_slist_foreach(init_routines, &call_init_routine, NULL); } + +/* Allow protocols to register a "cleanup" routine to be + * run after the initial sequential run through the packets. + * Note that the file can still be open after this; this is not + * the final cleanup. */ +static GSList *postseq_cleanup_routines; + +void +register_postseq_cleanup_routine(void (*func)(void)) +{ + postseq_cleanup_routines = g_slist_append(postseq_cleanup_routines, + func); +} + +/* Call all the registered "postseq_cleanup" routines. */ +static void +call_postseq_cleanup_routine(gpointer routine, gpointer dummy) +{ + void (*func)(void) = routine; + + (*func)(); +} + +void +postseq_cleanup_all_protocols(void) +{ + g_slist_foreach(postseq_cleanup_routines, + &call_postseq_cleanup_routine, NULL); +} + + /* Creates the top-most tvbuff and calls dissect_frame() */ void dissect_packet(epan_dissect_t *edt, union wtap_pseudo_header *pseudo_header, diff --git a/epan/packet.h b/epan/packet.h index 5d4a048c75..ad7b86da0c 100644 --- a/epan/packet.h +++ b/epan/packet.h @@ -1,7 +1,7 @@ /* packet.h * Definitions for packet disassembly structures and routines * - * $Id: packet.h,v 1.48 2001/12/18 19:09:03 gram Exp $ + * $Id: packet.h,v 1.49 2002/01/05 04:12:16 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -223,6 +223,15 @@ extern void register_init_routine(void (*func)(void)); /* Call all the registered "init" routines. */ extern void init_all_protocols(void); +/* Allow protocols to register a "cleanup" routine to be + * run after the initial sequential run through the packets. + * Note that the file can still be open after this; this is not + * the final cleanup. */ +extern void register_postseq_cleanup_routine(void (*func)(void)); + +/* Call all the registered "postseq_cleanup" routines. */ +extern void postseq_cleanup_all_protocols(void); + /* * Dissectors should never modify the packet data. */ diff --git a/epan/plugins.c b/epan/plugins.c index 1e3730dd01..e2b6779330 100644 --- a/epan/plugins.c +++ b/epan/plugins.c @@ -1,7 +1,7 @@ /* plugins.c * plugin routines * - * $Id: plugins.c,v 1.44 2001/12/03 10:00:21 guy Exp $ + * $Id: plugins.c,v 1.45 2002/01/05 04:12:16 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -293,6 +293,7 @@ init_plugins(const char *plugin_dir) patable.p_col_set_str = col_set_str; patable.p_register_init_routine = register_init_routine; + patable.p_register_postseq_cleanup_routine = register_postseq_cleanup_routine; patable.p_conversation_new = conversation_new; patable.p_find_conversation = find_conversation; patable.p_match_strval = match_strval; |