Pass in the "smb_info" structure a pointer to the "smb_saved_info_t"
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 18 Nov 2001 02:51:20 +0000 (02:51 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 18 Nov 2001 02:51:20 +0000 (02:51 +0000)
structure, so that it can be updated by subdissectors; this way the
updates affect the structure immediately, and don't get lost if the
subdissector later throws an exception.

Use "tvb_reported_length()" to check for an interim mailslot reply;
"tvb_length()" could give the wrong answer if a short snapshot length
was given in the capture.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4218 f5534014-38df-0310-8fa8-9805f1628bb7

packet-smb-mailslot.c
packet-smb-pipe.c
packet-smb.c
smb.h

index a05f3b17cddc2c6a8f2271584e0c81664df75b95..4d5004198fa800a6dfeafeb2047170e8aafc2c70 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for SMB mailslot packet dissection
  * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
  *
- * $Id: packet-smb-mailslot.c,v 1.21 2001/11/18 01:46:50 guy Exp $
+ * $Id: packet-smb-mailslot.c,v 1.22 2001/11/18 02:51:19 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -72,13 +72,15 @@ dissect_mailslot_smb(tvbuff_t *total_tvb, tvbuff_t *setup_tvb,
                     tvbuff_t *tvb, const char *mailslot,
                     packet_info *pinfo, proto_tree *parent_tree)
 {
-       smb_info_t *smb_info = pinfo->private_data;
-       smb_transact_info_t *tri = smb_info->extra_info;
+       smb_info_t *smb_info;
+       smb_transact_info_t *tri;
+       int             trans_subcmd;
        proto_tree      *tree = 0;
        proto_item      *item;
        guint16         opcode;
        int             offset = 0;
        int             len;
+       gboolean        dissected;
 
        if (!proto_is_protocol_enabled(proto_smb_msp)) {
                return FALSE;
@@ -89,27 +91,35 @@ dissect_mailslot_smb(tvbuff_t *total_tvb, tvbuff_t *setup_tvb,
                col_set_str(pinfo->fd, COL_PROTOCOL, "SMB Mailslot");
        }
 
-       if ((tvb==NULL) || (tvb_length(tvb)<=0)) {
+       if ((tvb==NULL) || (tvb_reported_length(tvb)==0)) {
                /* Interim reply */
                col_set_str(pinfo->fd, COL_INFO, "Interim reply");
                return TRUE;
        }
 
+       smb_info = pinfo->private_data;
+       if (smb_info->sip != NULL)
+               tri = smb_info->sip->extra_info;
+       else
+               tri = NULL;
+
        /* check which mailslot this is about */
+       trans_subcmd=MAILSLOT_UNKNOWN;
        if(smb_info->request){
-               tri->trans_subcmd=MAILSLOT_UNKNOWN;
                if(strncmp(mailslot,"BROWSE",6) == 0){
-                       tri->trans_subcmd=MAILSLOT_BROWSE;
+                       trans_subcmd=MAILSLOT_BROWSE;
                } else if(strncmp(mailslot,"LANMAN",6) == 0){
-                       tri->trans_subcmd=MAILSLOT_LANMAN;
+                       trans_subcmd=MAILSLOT_LANMAN;
                } else if(strncmp(mailslot,"NET",3) == 0){
-                       tri->trans_subcmd=MAILSLOT_NET;
+                       trans_subcmd=MAILSLOT_NET;
                } else if(strncmp(mailslot,"TEMP\\NETLOGON",13) == 0){
-                       tri->trans_subcmd=MAILSLOT_TEMP_NETLOGON;
+                       trans_subcmd=MAILSLOT_TEMP_NETLOGON;
                } else if(strncmp(mailslot,"MSSP",4) == 0){
-                       tri->trans_subcmd=MAILSLOT_MSSP;
+                       trans_subcmd=MAILSLOT_MSSP;
                }
-       }               
+       }
+       if (tri != NULL)
+               tri->trans_subcmd = trans_subcmd;
 
        /* do the opcode field */
        opcode = tvb_get_letohs(setup_tvb, offset);
@@ -149,21 +159,29 @@ dissect_mailslot_smb(tvbuff_t *total_tvb, tvbuff_t *setup_tvb,
                offset += len;
        }
 
-       switch(tri->trans_subcmd){
+       dissected = FALSE;
+       switch(trans_subcmd){
        case MAILSLOT_BROWSE:
-               return dissect_mailslot_browse(tvb, pinfo, parent_tree);
+               dissected = dissect_mailslot_browse(tvb, pinfo, parent_tree);
                break;
        case MAILSLOT_LANMAN:
-               return dissect_mailslot_lanman(tvb, pinfo, parent_tree);
+               dissected = dissect_mailslot_lanman(tvb, pinfo, parent_tree);
                break;
        case MAILSLOT_NET:
        case MAILSLOT_TEMP_NETLOGON:
        case MAILSLOT_MSSP:
-               return dissect_smb_logon(tvb, pinfo, parent_tree);
+               dissected = dissect_smb_logon(tvb, pinfo, parent_tree);
                break;
-       default:
-               return FALSE;
        }
+       if (!dissected) {
+               /*
+                * We dissected the mailslot header, but not the
+                * message; dissect the latter as data, but indicate
+                * that we successfully dissected the mailslot stuff.
+                */
+               dissect_data(tvb, 0, pinfo, parent_tree);
+       }
+       return TRUE;
 }
 
 void
index ba0f94c4fa925e3c8b8d481c876e8ce4b4358a99..29eba32e0a7923e73b26bca6bc6556cd304db2e8 100644 (file)
@@ -8,7 +8,7 @@ XXX  Fixme : shouldnt show [malformed frame] for long packets
  * significant rewrite to tvbuffify the dissector, Ronnie Sahlberg and
  * Guy Harris 2001
  *
- * $Id: packet-smb-pipe.c,v 1.42 2001/11/18 01:46:50 guy Exp $
+ * $Id: packet-smb-pipe.c,v 1.43 2001/11/18 02:51:19 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -365,7 +365,7 @@ add_detail_level(tvbuff_t *tvb, int offset, int count, packet_info *pinfo,
     proto_tree *tree, int convert, int hf_index)
 {
        struct smb_info *smb_info = pinfo->private_data;
-       smb_transact_info_t *trp = smb_info->extra_info;
+       smb_transact_info_t *trp = smb_info->sip->extra_info;
        guint16 level;
 
        level = tvb_get_letohs(tvb, offset);
@@ -1821,7 +1821,7 @@ dissect_response_data(tvbuff_t *tvb, packet_info *pinfo, int convert,
     const struct lanman_desc *lanman, gboolean has_ent_count,
     guint16 ent_count)
 {
-       smb_transact_info_t *trp = smb_info->extra_info;
+       smb_transact_info_t *trp = smb_info->sip->extra_info;
        const item_list_t *resp_data_list;
        int offset, start_offset;
        const item_t *resp_data;
@@ -1947,7 +1947,7 @@ dissect_pipe_lanman(tvbuff_t *t_tvb, tvbuff_t *p_tvb, tvbuff_t *d_tvb,
                    packet_info *pinfo, proto_tree *parent_tree)
 {
        smb_info_t *smb_info = pinfo->private_data;
-       smb_transact_info_t *trp = smb_info->extra_info;
+       smb_transact_info_t *trp = smb_info->sip->extra_info;
        int offset = 0, start_offset;
        guint16 cmd;
        guint16 status;
@@ -2203,13 +2203,18 @@ gboolean
 dissect_pipe_smb(tvbuff_t *t_tvb, tvbuff_t *p_tvb, tvbuff_t *d_tvb,
                 const char *pipe, packet_info *pinfo, proto_tree *tree)
 {
-       smb_info_t *smb_info = pinfo->private_data;
-       smb_transact_info_t *tri = smb_info->extra_info;
+       smb_info_t *smb_info;
+       smb_transact_info_t *tri;
 
        if (!proto_is_protocol_enabled(proto_smb_lanman))
                return FALSE;
        pinfo->current_proto = "LANMAN";
 
+       smb_info = pinfo->private_data;
+       if (smb_info->sip != NULL)
+               tri = smb_info->sip->extra_info;
+       else
+               tri = NULL;
        if(smb_info->request){
                if(strncmp(pipe,"LANMAN",6) == 0){
                        tri->trans_subcmd=PIPE_LANMAN;
@@ -2219,6 +2224,13 @@ dissect_pipe_smb(tvbuff_t *t_tvb, tvbuff_t *p_tvb, tvbuff_t *d_tvb,
                }
        }
 
+       if (tri == NULL) {
+               /*
+                * We don't know what type of pipe transaction this
+                * was, so indicate that we didn't dissect it.
+                */
+               return FALSE;
+       }
        switch(tri->trans_subcmd){
        case PIPE_LANMAN:
                return dissect_pipe_lanman(t_tvb, p_tvb, d_tvb, pinfo, tree);
index fa69f3fc8b2353a861b86029628034092ce4bf44..fa3aa1f94f2b80d179491133f70af1d97347b282 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for smb packet dissection
  * Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
  *
- * $Id: packet-smb.c,v 1.155 2001/11/18 01:46:50 guy Exp $
+ * $Id: packet-smb.c,v 1.156 2001/11/18 02:51:19 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -664,11 +664,6 @@ static const gchar *get_unicode_or_ascii_string(tvbuff_t *tvb,
  * The information we need to save about a request in order to show the
  * frame number of the request in the dissection of the reply.
  */
-typedef struct {
-       guint32 frame_req, frame_res;
-       void *extra_info;
-} smb_saved_info_t;
-
 static GMemChunk *smb_saved_info_chunk = NULL;
 static int smb_saved_info_init_count = 200;
 
@@ -6068,7 +6063,7 @@ dissect_nt_trans_data_request(tvbuff_t *tvb, packet_info *pinfo, int offset, pro
        smb_nt_transact_info_t *nti;
 
        si = (smb_info_t *)pinfo->private_data;
-       nti = si->extra_info;
+       nti = si->sip->extra_info;
 
        if(parent_tree){
                item = proto_tree_add_text(parent_tree, tvb, offset, len,
@@ -6125,7 +6120,7 @@ dissect_nt_trans_param_request(tvbuff_t *tvb, packet_info *pinfo, int offset, pr
        const char *fn;
 
        si = (smb_info_t *)pinfo->private_data;
-       nti = si->extra_info;
+       nti = si->sip->extra_info;
 
        if(parent_tree){
                item = proto_tree_add_text(parent_tree, tvb, offset, len,
@@ -6246,7 +6241,7 @@ dissect_nt_trans_setup_request(tvbuff_t *tvb, packet_info *pinfo, int offset, pr
        int old_offset = offset;
 
        si = (smb_info_t *)pinfo->private_data;
-       nti = si->extra_info;
+       nti = si->sip->extra_info;
 
        if(parent_tree){
                item = proto_tree_add_text(parent_tree, tvb, offset, len,
@@ -6311,12 +6306,14 @@ dissect_nt_transaction_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr
        guint8 wc, sc;
        guint32 pc=0, po=0, pd, dc=0, od=0, dd;
        smb_info_t *si;
+       smb_saved_info_t *sip;
        nt_trans_data ntd;
        guint16 bc;
        int padcnt;
        smb_nt_transact_info_t *nti;
 
        si = (smb_info_t *)pinfo->private_data;
+       sip = si->sip;
 
        WORD_COUNT;
 
@@ -6412,15 +6409,26 @@ dissect_nt_transaction_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr
        /* function */
        if(wc>=19){
                /* primary request */
-               if(!pinfo->fd->flags.visited){
-                       /* 
-                        * Allocate a new smb_nt_transact_info_t structure.
+               if (!si->unidir) {
+                       if(!pinfo->fd->flags.visited){
+                               /* 
+                                * Allocate a new smb_nt_transact_info_t
+                                * structure.
+                                */
+                               nti = g_mem_chunk_alloc(smb_nt_transact_info_chunk);
+                               nti->subcmd = -1;
+                               sip->extra_info = nti;
+                       } else
+                               nti = sip->extra_info;
+               } else {
+                       /*
+                        * This is a unidirectional message, for
+                        * which there will be no reply; don't
+                        * bother allocating an "smb_nt_transact_info_t"
+                        * structure for it.
                         */
-                       nti = g_mem_chunk_alloc(smb_nt_transact_info_chunk);
-                       nti->subcmd = -1;
-                       si->extra_info = nti;
-               } else
-                       nti = si->extra_info;
+                       nti = NULL;
+               }
                nti->subcmd = tvb_get_letohs(tvb, offset);
                proto_tree_add_uint(tree, hf_smb_nt_trans_subcmd, tvb, offset, 2, nti->subcmd);
                if(check_col(pinfo->fd, COL_INFO)){
@@ -6498,7 +6506,10 @@ dissect_nt_trans_data_response(tvbuff_t *tvb, packet_info *pinfo, int offset, pr
        smb_nt_transact_info_t *nti;
 
        si = (smb_info_t *)pinfo->private_data;
-       nti = si->extra_info;
+       if (si->sip != NULL)
+               nti = si->sip->extra_info;
+       else
+               nti = NULL;
 
        if(parent_tree){
                if(nti != NULL){
@@ -6561,7 +6572,10 @@ dissect_nt_trans_param_response(tvbuff_t *tvb, packet_info *pinfo, int offset, p
        smb_nt_transact_info_t *nti;
 
        si = (smb_info_t *)pinfo->private_data;
-       nti = si->extra_info;
+       if (si->sip != NULL)
+               nti = si->sip->extra_info;
+       else
+               nti = NULL;
 
        if(parent_tree){
                if(nti != NULL){
@@ -6714,7 +6728,10 @@ dissect_nt_trans_setup_response(tvbuff_t *tvb, packet_info *pinfo, int offset, p
        smb_nt_transact_info_t *nti;
 
        si = (smb_info_t *)pinfo->private_data;
-       nti = si->extra_info;
+       if (si->sip != NULL)
+               nti = si->sip->extra_info;
+       else
+               nti = NULL;
 
        if(parent_tree){
                if(nti != NULL){
@@ -6767,7 +6784,10 @@ dissect_nt_transaction_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t
        int padcnt;
 
        si = (smb_info_t *)pinfo->private_data;
-       nti = si->extra_info;
+       if (si->sip != NULL)
+               nti = si->sip->extra_info;
+       else
+               nti = NULL;
 
        /* primary request */
        if(nti != NULL){
@@ -7567,7 +7587,7 @@ dissect_transaction2_request_parameters(tvbuff_t *tvb, packet_info *pinfo,
        int old_offset = offset;
 
        si = (smb_info_t *)pinfo->private_data;
-       t2i = si->extra_info;
+       t2i = si->sip->extra_info;
 
        if(parent_tree){
                item = proto_tree_add_text(parent_tree, tvb, offset, bc,
@@ -8632,7 +8652,7 @@ dissect_qpi_loi_vals(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
        }
        
        si = (smb_info_t *)pinfo->private_data;
-       t2i = si->extra_info;
+       t2i = si->sip->extra_info;
        switch(t2i->info_level){
        case 1:         /*Info Standard*/
        case 2:         /*Info Query EA Size*/
@@ -8708,7 +8728,7 @@ dissect_transaction2_request_data(tvbuff_t *tvb, packet_info *pinfo,
        int old_offset = offset;
 
        si = (smb_info_t *)pinfo->private_data;
-       t2i = si->extra_info;
+       t2i = si->sip->extra_info;
 
        if(parent_tree){
                item = proto_tree_add_text(parent_tree, tvb, offset, dc,
@@ -8785,6 +8805,7 @@ dissect_transaction_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
        guint8 wc, sc=0;
        int so=0;
        guint16 od=0, tf, po=0, pc=0, dc=0, pd, dd=0;
+       guint16 subcmd;
        guint32 to;
        int an_len;
        const char *an = NULL;
@@ -8928,26 +8949,40 @@ dissect_transaction_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
                        switch(si->cmd){
 
                        case 0x32:
-                               if(!pinfo->fd->flags.visited){
-                                       /* 
-                                        * Allocate a new smb_transact2_info_t
-                                        * structure.
+                               if (!si->unidir) {
+                                       if(!pinfo->fd->flags.visited){
+                                               /* 
+                                                * Allocate a new
+                                                * smb_transact2_info_t
+                                                * structure.
+                                                */
+                                               t2i = g_mem_chunk_alloc(smb_transact2_info_chunk);
+                                               t2i->subcmd = -1;
+                                               t2i->info_level = -1;
+                                               si->sip->extra_info = t2i;
+                                       } else
+                                               t2i = si->sip->extra_info;
+                               } else {
+                                       /*
+                                        * This is a unidirectional message,
+                                        * for which there will be no reply;
+                                        * don't bother allocating an
+                                        * "smb_transact2_info_t"
+                                        * structure for it.
                                         */
-                                       t2i = g_mem_chunk_alloc(smb_transact2_info_chunk);
-                                       t2i->subcmd = -1;
-                                       t2i->info_level = -1;
-                                       si->extra_info = t2i;
-                               } else
-                                       t2i = si->extra_info;
+                                       t2i = NULL;
+                               }
                                /* TRANSACTION2 only has one setup word and
                                   that is the subcommand code. */
-                               t2i->subcmd = tvb_get_letohs(tvb, offset);
+                               subcmd = tvb_get_letohs(tvb, offset);
+                               if (!si->unidir)
+                                       t2i->subcmd = subcmd;
                                proto_tree_add_uint(tree, hf_smb_trans2_subcmd,
-                                   tvb, offset, 2, t2i->subcmd);
+                                   tvb, offset, 2, subcmd);
 
                                if (check_col(pinfo->fd, COL_INFO)) {
                                        col_append_fstr(pinfo->fd, COL_INFO, " %s",
-                                           val_to_str(t2i->subcmd, trans2_cmd_vals, 
+                                           val_to_str(subcmd, trans2_cmd_vals, 
                                                "Unknown (0x%02x)"));
                                }
                                break;
@@ -9066,28 +9101,40 @@ dissect_transaction_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
                                s_tvb = NULL;
                        }
 
-                       if(!pinfo->fd->flags.visited){
-                               /* 
-                                * Allocate a new smb_transact_info_t
-                                * structure.
+                       if (!si->unidir) {
+                               if(!pinfo->fd->flags.visited){
+                                       /* 
+                                        * Allocate a new smb_transact_info_t
+                                        * structure.
+                                        */
+                                       tri = g_mem_chunk_alloc(smb_transact_info_chunk);
+                                       tri->subcmd = -1;
+                                       tri->lanman_cmd = 0;
+                                       tri->param_descrip = NULL;
+                                       tri->data_descrip = NULL;
+                                       tri->aux_data_descrip = NULL;
+                                       tri->info_level = -1;
+                                       si->sip->extra_info = tri;
+                               } else
+                                       tri = si->sip->extra_info;
+                       } else {
+                               /*
+                                * This is a unidirectional message, for
+                                * which there will be no reply; don't
+                                * bother allocating an "smb_transact_info_t"
+                                * structure for it.
                                 */
-                               tri = g_mem_chunk_alloc(smb_transact_info_chunk);
-                               tri->subcmd = -1;
-                               tri->lanman_cmd = 0;
-                               tri->param_descrip = NULL;
-                               tri->data_descrip = NULL;
-                               tri->aux_data_descrip = NULL;
-                               tri->info_level = -1;
-                               si->extra_info = tri;
-                       } else
-                               tri = si->extra_info;
+                               tri = NULL;
+                       }
                        dissected_trans = FALSE;
                        if(strncmp("\\PIPE\\", an, 6) == 0){
-                               tri->subcmd=TRANSACTION_PIPE;
+                               if (!si->unidir)
+                                       tri->subcmd=TRANSACTION_PIPE;
                                dissected_trans = dissect_pipe_smb(t_tvb,
                                    p_tvb, d_tvb, an+6, pinfo, top_tree);
                        } else if(strncmp("\\MAILSLOT\\", an, 10) == 0){
-                               tri->subcmd=TRANSACTION_MAILSLOT;
+                               if (!si->unidir)
+                                       tri->subcmd=TRANSACTION_MAILSLOT;
                                dissected_trans = dissect_mailslot_smb(t_tvb,
                                    s_tvb, d_tvb, an+10, pinfo, top_tree);
                        } else {
@@ -9134,7 +9181,7 @@ dissect_4_3_4_1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
        smb_transact2_info_t *t2i;
 
        si = (smb_info_t *)pinfo->private_data;
-       t2i = si->extra_info;
+       t2i = si->sip->extra_info;
 
        if(parent_tree){
                item = proto_tree_add_text(parent_tree, tvb, offset, *bcp, "%s",
@@ -9216,7 +9263,7 @@ dissect_4_3_4_2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
        smb_transact2_info_t *t2i;
 
        si = (smb_info_t *)pinfo->private_data;
-       t2i = si->extra_info;
+       t2i = si->sip->extra_info;
 
        if(parent_tree){
                item = proto_tree_add_text(parent_tree, tvb, offset, *bcp, "%s",
@@ -9305,7 +9352,7 @@ dissect_4_3_4_4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
        int padcnt;
 
        si = (smb_info_t *)pinfo->private_data;
-       t2i = si->extra_info;
+       t2i = si->sip->extra_info;
 
        if(parent_tree){
                item = proto_tree_add_text(parent_tree, tvb, offset, *bcp, "%s",
@@ -9418,7 +9465,7 @@ dissect_4_3_4_5(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
        int padcnt;
 
        si = (smb_info_t *)pinfo->private_data;
-       t2i = si->extra_info;
+       t2i = si->sip->extra_info;
 
        if(parent_tree){
                item = proto_tree_add_text(parent_tree, tvb, offset, *bcp, "%s",
@@ -9536,7 +9583,7 @@ dissect_4_3_4_6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
        int padcnt;
 
        si = (smb_info_t *)pinfo->private_data;
-       t2i = si->extra_info;
+       t2i = si->sip->extra_info;
 
        if(parent_tree){
                item = proto_tree_add_text(parent_tree, tvb, offset, *bcp, "%s",
@@ -9672,7 +9719,7 @@ dissect_4_3_4_7(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
        int padcnt;
 
        si = (smb_info_t *)pinfo->private_data;
-       t2i = si->extra_info;
+       t2i = si->sip->extra_info;
 
        if(parent_tree){
                item = proto_tree_add_text(parent_tree, tvb, offset, *bcp, "%s",
@@ -9755,7 +9802,7 @@ dissect_ff2_response_data(tvbuff_t * tvb, packet_info * pinfo,
        }
        
        si = (smb_info_t *)pinfo->private_data;
-       t2i = si->extra_info;
+       t2i = si->sip->extra_info;
        switch(t2i->info_level){
        case 1:         /*Info Standard*/
                offset = dissect_4_3_4_1(tvb, pinfo, tree, offset, bcp,
@@ -9883,7 +9930,7 @@ dissect_qfsi_vals(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
        }
        
        si = (smb_info_t *)pinfo->private_data;
-       t2i = si->extra_info;
+       t2i = si->sip->extra_info;
        switch(t2i->info_level){
        case 1:         /* SMB_INFO_ALLOCATION */
                /* filesystem id */
@@ -10042,7 +10089,10 @@ dissect_transaction2_response_data(tvbuff_t *tvb, packet_info *pinfo,
        gboolean trunc;
 
        si = (smb_info_t *)pinfo->private_data;
-       t2i = si->extra_info;
+       if (si->sip != NULL)
+               t2i = si->sip->extra_info;
+       else
+               t2i = NULL;
 
        if(parent_tree){
                if (t2i != NULL && t2i->subcmd != -1) {
@@ -10169,7 +10219,10 @@ dissect_transaction2_response_parameters(tvbuff_t *tvb, packet_info *pinfo, prot
        int old_offset = offset;
 
        si = (smb_info_t *)pinfo->private_data;
-       t2i = si->extra_info;
+       if (si->sip != NULL)
+               t2i = si->sip->extra_info;
+       else
+               t2i = NULL;
 
        if(parent_tree){
                if (t2i != NULL && t2i->subcmd != -1) {
@@ -10358,7 +10411,10 @@ dissect_transaction_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
        switch(si->cmd){
        case 0x32:
                /* transaction2 */
-               t2i = si->extra_info;
+               if (si->sip != NULL)
+                       t2i = si->sip->extra_info;
+               else
+                       t2i = NULL;
                if (t2i == NULL) {
                        /*
                         * We didn't see the matching request, so we don't
@@ -10544,7 +10600,10 @@ dissect_transaction_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
                        }
 
                        dissected_trans = FALSE;
-                       tri = si->extra_info;
+                       if (si->sip != NULL)
+                               tri = si->sip->extra_info;
+                       else
+                               tri = NULL;
                        if (tri != NULL) {
                                switch(tri->subcmd){
 
@@ -12516,7 +12575,7 @@ dissect_smb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
                conversation_t *conversation;
                conv_tables_t *ct;
 
-               si.unidir=TRUE;
+               si.unidir = FALSE;
 
                /* first we try to find which conversation this packet is 
                   part of 
@@ -12632,28 +12691,23 @@ dissect_smb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
                }
        }
 
+       /*
+        * Pass the "sip" on to subdissectors through "si".
+        */
+       si.sip = sip;
+
        if (sip != NULL) {
                /*
-                * Fill in "si" with stuff from "*sip".
-                */
-               si.frame_req = sip->frame_req;
-               si.frame_res = sip->frame_res;
-               si.extra_info = sip->extra_info;
-       } else {
-               /*
-                * Mark that stuff as unknown.
+                * Put in fields for the frame number of the frame to which
+                * this is a response or the frame with the response to this
+                * frame - if we know the frame number (i.e., it's not 0).
                 */
-               si.frame_req = 0;
-               si.frame_res = 0;
-               si.extra_info = NULL;
-       }
-       if(si.request){
-               if(si.frame_res){
-                       proto_tree_add_uint(htree, hf_smb_response_in, tvb, 0, 0, si.frame_res);
-               }
-       } else {
-               if(si.frame_req){
-                       proto_tree_add_uint(htree, hf_smb_response_to, tvb, 0, 0, si.frame_req);
+               if(si.request){
+                       if (sip->frame_res != 0)
+                               proto_tree_add_uint(htree, hf_smb_response_in, tvb, 0, 0, sip->frame_res);
+               } else {
+                       if (sip->frame_req != 0)
+                               proto_tree_add_uint(htree, hf_smb_response_to, tvb, 0, 0, sip->frame_req);
                }
        }
 
@@ -12751,18 +12805,6 @@ dissect_smb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
        pinfo->private_data = &si;
         dissect_smb_command(tvb, pinfo, parent_tree, offset, tree, si.cmd);
 
-       /*
-        * If we have saved info for this SMB, fill it in from the
-        * stuff in "si".
-        * XXX - do this only if we freshly allocated the saved info?
-        * If not, it already has what we need.
-        */
-       if (sip != NULL) {
-               sip->frame_req = si.frame_req;
-               sip->frame_res = si.frame_res;
-               sip->extra_info = si.extra_info;
-       }
-
        /* Append error info from this packet to info string. */
        if (!si.request && check_col(pinfo->fd, COL_INFO)) {
                if (flags2 & 0x4000) {
diff --git a/smb.h b/smb.h
index d44b50f4b44ae574a48918c33ec344a40738940a..df4e747419b4d623f5079d1f6ae6252aa578e66c 100644 (file)
--- a/smb.h
+++ b/smb.h
@@ -2,7 +2,7 @@
  * Defines for smb packet dissection
  * Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
  *
- * $Id: smb.h,v 1.20 2001/11/18 01:46:51 guy Exp $
+ * $Id: smb.h,v 1.21 2001/11/18 02:51:20 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
 #define SMB_LMapi_SetUserInfo     0x0072
 #define SMB_LMapi_UserPasswordSet 0x0073
 
+/*
+ * The information we need to save about a request in order to show the
+ * frame number of the request in the dissection of the reply.
+ */
+typedef struct {
+       guint32 frame_req, frame_res;
+       void *extra_info;
+} smb_saved_info_t;
+
 /*
  * The information we need to save about a Transaction request in order
  * to dissect the reply; this includes information for use by the
@@ -654,10 +663,9 @@ typedef struct smb_info {
   int cmd, mid;
   gboolean unicode;            /* Are strings in this SMB Unicode? */
   gboolean request;            /* Is this a request? */
-  guint32 frame_req, frame_res;
   gboolean unidir;
   int info_count;
-  void *extra_info;            /* extra info for transactions */
+  smb_saved_info_t *sip;       /* smb_saved_info_t, if any, for this */
 } smb_info_t;
 
 #endif