diff options
author | gram <gram@f5534014-38df-0310-8fa8-9805f1628bb7> | 2002-01-05 04:12:17 +0000 |
---|---|---|
committer | gram <gram@f5534014-38df-0310-8fa8-9805f1628bb7> | 2002-01-05 04:12:17 +0000 |
commit | d653645a4ae59f7f9fd848e4c8fa1ee2b0db821b (patch) | |
tree | ac264635defc42eb14ee180db1b32d9b5032458c /packet-ncp2222.inc | |
parent | 9b5d5163cfdcd3df55a46ac11d5045052cf47550 (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.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4484 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'packet-ncp2222.inc')
-rw-r--r-- | packet-ncp2222.inc | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/packet-ncp2222.inc b/packet-ncp2222.inc index b97ee7a150..e1cb842ec2 100644 --- a/packet-ncp2222.inc +++ b/packet-ncp2222.inc @@ -7,7 +7,7 @@ * * Gilbert Ramirez <gram@alumni.rice.edu> * - * $Id: packet-ncp2222.inc,v 1.6 2001/12/10 00:25:31 guy Exp $ + * $Id: packet-ncp2222.inc,v 1.7 2002/01/05 04:12:14 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -182,15 +182,19 @@ dissect_ncp_request(tvbuff_t *tvb, packet_info *pinfo, let the user select that conversation to be displayed.) */ conversation = find_conversation(&pinfo->src, &pinfo->dst, PT_NCP, nw_connection, nw_connection, 0); + if (conversation == NULL) { /* It's not part of any conversation - create a new one. */ conversation = conversation_new(&pinfo->src, &pinfo->dst, PT_NCP, nw_connection, nw_connection, 0); } - ncp_hash_insert(conversation, sequence, 0x2222, ncp_rec); + ncp_hash_insert(conversation, sequence, ncp_rec); } if (ncp_tree) { + conversation = find_conversation(&pinfo->src, &pinfo->dst, + PT_NCP, nw_connection, nw_connection, 0); + switch (type) { case 0x1111: ; /* nothing */ @@ -247,23 +251,27 @@ dissect_ncp_reply(tvbuff_t *tvb, packet_info *pinfo, conversation_t *conversation; const ncp_record *ncp_rec = NULL; - guint16 ncp_type; gboolean found_request = FALSE; guint8 completion_code; guint length; ptvcursor_t *ptvc = NULL; const char *error_string; - /* Find the conversation whence the request would have come. */ - conversation = find_conversation(&pinfo->src, &pinfo->dst, - PT_NCP, nw_connection, nw_connection, 0); - if (conversation != NULL) { - /* find the record telling us the request made that caused - this reply */ - found_request = ncp_hash_lookup(conversation, sequence, - &ncp_type, &ncp_rec); + if (!pinfo->fd->flags.visited) { + /* Find the conversation whence the request would have come. */ + conversation = find_conversation(&pinfo->src, &pinfo->dst, + PT_NCP, nw_connection, nw_connection, 0); + if (conversation != NULL) { + /* find the record telling us the request made that caused + this reply */ + ncp_rec = ncp_hash_lookup(conversation, sequence); + p_add_proto_data(pinfo->fd, proto_ncp, (void*) ncp_rec); + } + /* else... we haven't seen an NCP Request for that conversation and sequence. */ + } + else { + ncp_rec = p_get_proto_data(pinfo->fd, proto_ncp); } - /* else... we haven't seen an NCP Request for that conversation and sequence. */ /* A completion code of 0 always means OK. Non-zero means failure, * but each non-zero value has a different meaning. And the same value @@ -317,7 +325,7 @@ dissect_ncp_reply(tvbuff_t *tvb, packet_info *pinfo, if (completion_code != 0 && tvb_length(tvb) == 8) { return; } - + /*printf("func=0x%x subfunc=0x%x\n", ncp_rec->func, ncp_rec->subfunc);*/ ptvc = ptvcursor_new(ncp_tree, tvb, 8); process_ptvc_record(ptvc, ncp_rec->reply_ptvc); ptvcursor_free(ptvc); |