Tvbuffified SMB NETLOGON dissector, from Ronnie Sahlberg.

Fixed up some longstanding bugs (predating the tvbuffification)
discovered during regression testing of the tvbuffification.

svn path=/trunk/; revision=3661
This commit is contained in:
Guy Harris 2001-07-08 11:32:02 +00:00
parent b7a5873eae
commit d47dac785e
6 changed files with 764 additions and 545 deletions

View File

@ -537,6 +537,7 @@ Ronnie Sahlberg <rsahlber@bigpond.net.au> {
MRDISC support
MSNIP support
Tvbuffified ISIS dissector
Tvbuffified SMB NETLOGON dissector
}
Borosa Tomislav <tomislav.borosa@SIEMENS.HR> {

View File

@ -2,10 +2,10 @@
* Common routines for smb packet dissection
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
*
* $Id: packet-smb-common.c,v 1.4 2000/05/11 08:15:44 gram Exp $
* $Id: packet-smb-common.c,v 1.5 2001/07/08 11:32:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
* By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
* Copied from packet-pop.c
@ -25,56 +25,35 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "packet-smb-common.h"
int display_ms_string(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int hf_index)
{
const char *str;
int len;
/* display a string from the tree and return the new offset */
int display_ms_value( char *Name, int len, const u_char *pd, int offset,
frame_data *fd, proto_tree *tree)
{/* display an entry from the tree and return the length */
guint32 Temp32;
if( len == 1)
Temp32 = GBYTE(pd, offset);
else if( len == 2)
Temp32 = GSHORT(pd, offset);
else if( len == 4)
Temp32 = GWORD(pd, offset);
/* XXX - should use tvbuff routines to extract string length */
str = tvb_get_ptr(tvb, offset, 1);
len = strlen(str);
/* this is an error if we didn't hit one of those three */
else
return 0;
proto_tree_add_text( tree, NullTVB, offset, len, "%s: %u", Name, Temp32);
proto_tree_add_string(tree, hf_index, tvb, offset, len, str);
return len;
}
int display_ms_string( char *Name, const u_char *pd, int offset,
frame_data *fd, proto_tree *tree)
{/* display a string from the tree and return the amount to move offset */
proto_tree_add_text( tree, NullTVB, offset, strlen( &pd[offset]) + 1, "%s: %s ",
Name, &pd[offset]);
return strlen( &pd[offset]) + 1;
return offset+len+1;
}
int display_unicode_string( char *Name, const u_char *pd, int offset,
frame_data *fd, proto_tree *tree){
/* display a unicode string from the tree and return amount to move offset */
int display_unicode_string(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int hf_index)
{
/* display a unicode string from the tree and return new offset */
char Temp[100], *OutPtr;
const char *InPtr;
InPtr = &pd[ offset]; /* point to unicode string */
/* this will crash if composite tvbuffs are used */
/* XXX - need tvbuff routine to extract DBCS string lengths */
InPtr = tvb_get_ptr(tvb, offset, 1);
OutPtr = Temp; /* point to temp space */
while ( *InPtr){ /* copy every other byte */
@ -83,73 +62,22 @@ int display_unicode_string( char *Name, const u_char *pd, int offset,
}
*OutPtr = 0; /* terminate out string */
proto_tree_add_text( tree, NullTVB, offset, strlen( Temp) * 2 + 2, "%s: %s ",
Name, Temp);
proto_tree_add_string(tree, hf_index, tvb,
offset, strlen(Temp)*2+2, Temp);
return strlen( Temp) * 2 + 2;
return offset+strlen(Temp)*2+2;
}
int
dissect_smb_unknown(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
/* display data as unknown */
void
dissect_smb_unknown( const u_char *pd, int offset, frame_data *fd,
proto_tree *tree){
guint len;
/* display data as unknown */
len = tvb_length_remaining(tvb, offset);
proto_tree_add_text(tree, NullTVB, offset, END_OF_FRAME, "Data (%u bytes)",
END_OF_FRAME);
proto_tree_add_text(tree, tvb, offset, len, "Data (%u bytes)", len);
return offset+len;
}
void
display_flags( struct flag_array_type *flag_array, int length,
const u_char *pd, int offset, proto_tree *tree){
/* Display a bit fields using the flag_array information. */
/* See packet-smb-common.h for definition of the flag_array structure */
/*** NOTE: currently only handles values that are 1, 2, or 4 octets wide.*/
/*** This should be expanded to handle any bit width. */
/* NOTE: the last entry must have the mask value = 0, this is the end of */
/* array flag */
struct flag_array_type *array_ptr = flag_array;
guint32 flags;
switch (length) {
case 1:
flags = GBYTE( pd, offset);
break;
case 2:
flags = GSHORT( pd, offset);
break;
case 4:
flags = GWORD( pd, offset);
break;
default:
g_assert_not_reached();
return;
}
while( array_ptr->mask) {
proto_tree_add_text( tree, NullTVB, offset, 2, "%s%s%s%s",
decode_boolean_bitfield( flags, array_ptr->mask,
length * 8, "",""),
array_ptr->pre_string,
((flags & array_ptr->mask) ? array_ptr->true_string :
array_ptr->false_string),
array_ptr->post_string);
++array_ptr;
}
}

View File

@ -2,10 +2,10 @@
* Routines for smb packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
* $Id: packet-smb-common.h,v 1.3 2000/08/11 13:34:00 deniel Exp $
* $Id: packet-smb-common.h,v 1.4 2001/07/08 11:32:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
* By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
* Copied from packet-pop.c
@ -51,40 +51,11 @@
#include "smb.h"
#include "alignment.h"
int dissect_smb_unknown(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset);
int display_unicode_string(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, int offset, int hf_index);
#define ShortPacketError proto_tree_add_text(tree, NullTVB, offset, 0, "****FRAME TOO SHORT***"); return;
#define IncAndCheckOffset if ( ++offset > fd->cap_len) {ShortPacketError;}
#define CheckPacketLength(X) if ((offset+X) > fd->cap_len) {ShortPacketError;}
#define MoveAndCheckOffset(X) {int tmp = X; if (( offset + tmp) > fd->cap_len){ ShortPacketError;} else offset += tmp;}
#define UnknowData if (tree) proto_tree_add_text(tree, NullTVB, offset, END_OF_FRAME, "Data (%u bytes)",END_OF_FRAME);
struct flag_array_type {
guint32 mask; /* bit mask to test for bit set */
char *pre_string; /* string for front of description */
char *true_string; /* description string if flag is set */
char *false_string; /* description string if flag is not set */
char *post_string; /* string for end of description */
};
void display_flags( struct flag_array_type *flag_array, int length,
const u_char *pd, int offset, proto_tree *tree);
int display_ms_value( char *Name, int len, const u_char *pd, int offset,
frame_data *fd, proto_tree *tree);
int display_ms_string( char *Name, const u_char *pd, int offset,
frame_data *fd, proto_tree *tree);
int display_unicode_string( char *Name, const u_char *pd, int offset,
frame_data *fd, proto_tree *tree);
void dissect_smb_unknown( const u_char *pd, int offset, frame_data *fd,
proto_tree *tree);
int display_ms_string(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int hf_index);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -2,10 +2,10 @@
* Declaration of outines for SMB net logon packet dissection
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
*
* $Id: packet-smb-logon.h,v 1.1 2001/03/18 03:34:22 guy Exp $
* $Id: packet-smb-logon.h,v 1.2 2001/07/08 11:32:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
* By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
@ -23,8 +23,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _PACKET_SMB_LOGON_H_
#define _PACKET_SMB_LOGON_H_
gboolean
dissect_smb_logon(const u_char *pd, int offset, frame_data *fd,
proto_tree *parent, proto_tree *tree, struct smb_info si,
int max_data, int SMB_offset, int errcode, int dirn,
const u_char *command, int DataOffset, int DataCount);
dissect_smb_logon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
#endif

View File

@ -2,10 +2,10 @@
* Routines for SMB mailslot packet dissection
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
*
* $Id: packet-smb-mailslot.c,v 1.11 2001/03/18 03:34:22 guy Exp $
* $Id: packet-smb-mailslot.c,v 1.12 2001/07/08 11:32:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
* By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
* Copied from packet-pop.c
@ -143,10 +143,11 @@ dissect_mailslot_smb(const u_char *pd, int offset, frame_data *fd,
strncmp(command, "NET", strlen("NET")) == 0) ||
(strcmp(command, "TEMP\\NETLOGON") == 0) ||
(strcmp(command, "MSSP") == 0)){
tvbuff_t *tvb;
packet_info *pinfo = &pi;
tvb = tvb_create_from_top(DataOffset);
return dissect_smb_logon(pd, DataOffset, fd, parent, tree,
si, max_data, SMB_offset, errcode, dirn,
command, DataOffset, DataCount);
return dissect_smb_logon(tvb, pinfo, parent);
}
return TRUE;