forked from osmocom/wireshark
"get_netbios_name()" can never return a negative number as the name
type, so "netbios_add_name()" doesn't need to check for it doing so (yes, the tvbuff stuff *does* catch "get_netbios_name()" running past the end of the packet, and causes an exception to be thrown). Get rid of the check, and get rid of "netbios_add_name()"s return value. In "dissect_nbipx_dg()", always call the SMB dissector if there's data left in the packet, regardless of whether the "tree" argument is null or not; subdissectors should always be called, so they can build any internal state on the first pass through the capture, and so that they can fill in the Protocol and Info columns. svn path=/trunk/; revision=2899
This commit is contained in:
parent
254179eec8
commit
903a3db8c1
|
@ -2,7 +2,7 @@
|
|||
* Routines for NetBIOS over IPX packet disassembly
|
||||
* Gilbert Ramirez <gram@xiexie.org>
|
||||
*
|
||||
* $Id: packet-nbipx.c,v 1.35 2001/01/10 10:36:02 guy Exp $
|
||||
* $Id: packet-nbipx.c,v 1.36 2001/01/15 04:39:28 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -236,7 +236,7 @@ dissect_nbipx_ns(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
static void
|
||||
dissect_nbipx_dg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||
{
|
||||
proto_tree *nbipx_tree;
|
||||
proto_tree *nbipx_tree = NULL;
|
||||
proto_item *ti;
|
||||
int offset = 0;
|
||||
guint8 conn_control;
|
||||
|
@ -273,31 +273,31 @@ dissect_nbipx_dg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
proto_tree_add_text(cc_tree, tvb, offset, 1, "%s",
|
||||
decode_boolean_bitfield(conn_control, 0x08, 8,
|
||||
"Resend", "No resend"));
|
||||
offset += 1;
|
||||
}
|
||||
offset += 1;
|
||||
|
||||
packet_type = tvb_get_guint8(tvb, offset);
|
||||
packet_type = tvb_get_guint8(tvb, offset);
|
||||
if (tree) {
|
||||
proto_tree_add_text(nbipx_tree, tvb, offset, 1,
|
||||
"Packet Type: %s (%02X)",
|
||||
val_to_str(packet_type, nbipx_data_stream_type_vals, "Unknown"),
|
||||
packet_type);
|
||||
offset += 1;
|
||||
}
|
||||
offset += 1;
|
||||
|
||||
if (!netbios_add_name("Receiver's Name", tvb, offset,
|
||||
nbipx_tree))
|
||||
return;
|
||||
offset += NETBIOS_NAME_LEN;
|
||||
if (tree)
|
||||
netbios_add_name("Receiver's Name", tvb, offset, nbipx_tree);
|
||||
offset += NETBIOS_NAME_LEN;
|
||||
|
||||
if (!netbios_add_name("Sender's Name", tvb, offset,
|
||||
nbipx_tree))
|
||||
return;
|
||||
offset += NETBIOS_NAME_LEN;
|
||||
if (tree)
|
||||
netbios_add_name("Sender's Name", tvb, offset, nbipx_tree);
|
||||
offset += NETBIOS_NAME_LEN;
|
||||
|
||||
if (tvb_offset_exists(tvb, offset)) {
|
||||
next_tvb = tvb_new_subset(tvb, offset, -1, -1);
|
||||
tvb_compat(next_tvb, &next_pd, &next_offset);
|
||||
dissect_smb(next_pd, next_offset, pinfo->fd, tree,
|
||||
tvb_length(next_tvb));
|
||||
}
|
||||
if (tvb_offset_exists(tvb, offset)) {
|
||||
next_tvb = tvb_new_subset(tvb, offset, -1, -1);
|
||||
tvb_compat(next_tvb, &next_pd, &next_offset);
|
||||
dissect_smb(next_pd, next_offset, pinfo->fd, tree,
|
||||
tvb_length(next_tvb));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -416,12 +416,10 @@ dissect_nwlink_dg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
decode_boolean_bitfield(name_type_flag, 0x01, 8,
|
||||
"Name deregistered", "Name not deregistered"));
|
||||
|
||||
if (!netbios_add_name("Group name", tvb, offset+36,
|
||||
nbipx_tree))
|
||||
return;
|
||||
if (!netbios_add_name("Node name", tvb, offset+52,
|
||||
nbipx_tree))
|
||||
return;
|
||||
netbios_add_name("Group name", tvb, offset+36,
|
||||
nbipx_tree);
|
||||
netbios_add_name("Node name", tvb, offset+52,
|
||||
nbipx_tree);
|
||||
proto_tree_add_text(nbipx_tree, tvb, offset+33, 1,
|
||||
"Packet Type: %s (%02X)",
|
||||
val_to_str(packet_type, nwlink_data_stream_type_vals, "Unknown"),
|
||||
|
@ -436,12 +434,10 @@ dissect_nwlink_dg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
proto_tree_add_text(nbipx_tree, tvb, offset+34, 2,
|
||||
"Message ID: 0x%04x",
|
||||
tvb_get_letohs(tvb, offset+34));
|
||||
if (!netbios_add_name("Requested name", tvb, offset+36,
|
||||
nbipx_tree))
|
||||
return;
|
||||
if (!netbios_add_name("Source name", tvb, offset+52,
|
||||
nbipx_tree))
|
||||
return;
|
||||
netbios_add_name("Requested name", tvb, offset+36,
|
||||
nbipx_tree);
|
||||
netbios_add_name("Source name", tvb, offset+52,
|
||||
nbipx_tree);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* derived from the packet-nbns.c
|
||||
*
|
||||
* $Id: packet-netbios.c,v 1.29 2001/01/09 06:31:39 guy Exp $
|
||||
* $Id: packet-netbios.c,v 1.30 2001/01/15 04:39:28 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -272,7 +272,7 @@ netbios_name_type_descr(int name_type)
|
|||
return val_to_str(name_type, name_type_vals, "Unknown");
|
||||
}
|
||||
|
||||
gboolean netbios_add_name(char* label, tvbuff_t *tvb, int offset,
|
||||
void netbios_add_name(char* label, tvbuff_t *tvb, int offset,
|
||||
proto_tree *tree)
|
||||
|
||||
{/* add a name field display tree. Display the name and station type in sub-tree */
|
||||
|
@ -285,17 +285,7 @@ gboolean netbios_add_name(char* label, tvbuff_t *tvb, int offset,
|
|||
|
||||
/* decode the name field */
|
||||
name_type = get_netbios_name( tvb, offset, name_str);
|
||||
|
||||
/*$$$ do I need this or does tvbuffer take care of this ? */
|
||||
if (name_type < 0) {
|
||||
/*
|
||||
* Name goes past end of captured data in packet.
|
||||
*/
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
name_type_str = netbios_name_type_descr(name_type);
|
||||
|
||||
tf = proto_tree_add_text( tree, tvb, offset, NETBIOS_NAME_LEN,
|
||||
"%s: %s<%02x> (%s)", label, name_str, name_type, name_type_str);
|
||||
|
||||
|
@ -304,8 +294,6 @@ gboolean netbios_add_name(char* label, tvbuff_t *tvb, int offset,
|
|||
15, name_str, "%s", name_str);
|
||||
proto_tree_add_uint_format( field_tree, hf_netb_name_type, tvb, offset + 15, 1, name_type,
|
||||
"0x%02x (%s)", name_type, name_type_str);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -564,8 +552,8 @@ static void dissect_netb_name_in_conflict( tvbuff_t *tvb, int offset,
|
|||
|
||||
{/* Handle the NAME IN CONFLICT command */
|
||||
|
||||
if (!netbios_add_name("Name In Conflict", tvb, offset + NB_RECVER_NAME, tree))
|
||||
return;
|
||||
netbios_add_name("Name In Conflict", tvb, offset + NB_RECVER_NAME,
|
||||
tree);
|
||||
netbios_add_name("Sender's Name", tvb, offset + NB_SENDER_NAME, tree);
|
||||
}
|
||||
|
||||
|
@ -596,9 +584,7 @@ static void dissect_netb_status_query( tvbuff_t *tvb, int offset, proto_tree *t
|
|||
}
|
||||
nb_data2("Length of status buffer: %u", 2, tvb, offset, tree);
|
||||
nb_resp_corrl( tvb, offset, tree);
|
||||
if (!netbios_add_name("Receiver's Name", tvb, offset + NB_RECVER_NAME,
|
||||
tree))
|
||||
return;
|
||||
netbios_add_name("Receiver's Name", tvb, offset + NB_RECVER_NAME, tree);
|
||||
netbios_add_name("Sender's Name", tvb, offset + NB_SENDER_NAME,
|
||||
tree);
|
||||
}
|
||||
|
@ -610,9 +596,7 @@ static void dissect_netb_datagram( tvbuff_t *tvb, int offset, proto_tree *tree)
|
|||
|
||||
{/* Handle the DATAGRAM command */
|
||||
|
||||
if (!netbios_add_name("Receiver's Name", tvb, offset + NB_RECVER_NAME,
|
||||
tree))
|
||||
return;
|
||||
netbios_add_name("Receiver's Name", tvb, offset + NB_RECVER_NAME, tree);
|
||||
/* Weird. In some datagrams, this is 10 octets of 0, followed
|
||||
by a MAC address.... */
|
||||
|
||||
|
@ -658,8 +642,7 @@ static void dissect_netb_name_query( tvbuff_t *tvb, int offset, proto_tree *tre
|
|||
}
|
||||
nb_call_name_type( tvb, offset, tree);
|
||||
nb_resp_corrl( tvb, offset, tree);
|
||||
if (!netbios_add_name("Query Name", tvb, offset + NB_RECVER_NAME, tree))
|
||||
return;
|
||||
netbios_add_name("Query Name", tvb, offset + NB_RECVER_NAME, tree);
|
||||
if (local_session_number != 0) {
|
||||
netbios_add_name("Sender's Name", tvb, offset + NB_SENDER_NAME,
|
||||
tree);
|
||||
|
@ -711,9 +694,8 @@ static void dissect_netb_add_name_resp( tvbuff_t *tvb, int offset,
|
|||
}
|
||||
|
||||
nb_xmit_corrl( tvb, offset, tree);
|
||||
if (!netbios_add_name("Name to be added", tvb, offset + NB_RECVER_NAME,
|
||||
tree))
|
||||
return;
|
||||
netbios_add_name("Name to be added", tvb, offset + NB_RECVER_NAME,
|
||||
tree);
|
||||
netbios_add_name("Name to be added", tvb, offset + NB_SENDER_NAME,
|
||||
tree);
|
||||
}
|
||||
|
@ -746,9 +728,7 @@ static void dissect_netb_name_resp( tvbuff_t *tvb, int offset,
|
|||
nb_xmit_corrl( tvb, offset, tree);
|
||||
if (local_session_number != 0x00 && local_session_number != 0xFF)
|
||||
nb_resp_corrl(tvb, offset, tree);
|
||||
if (!netbios_add_name("Receiver's Name", tvb, offset + NB_RECVER_NAME,
|
||||
tree))
|
||||
return;
|
||||
netbios_add_name("Receiver's Name", tvb, offset + NB_RECVER_NAME, tree);
|
||||
if (local_session_number != 0x00 && local_session_number != 0xFF) {
|
||||
netbios_add_name("Sender's Name", tvb, offset + NB_SENDER_NAME,
|
||||
tree);
|
||||
|
@ -792,9 +772,7 @@ static void dissect_netb_status_resp( tvbuff_t *tvb, int offset, proto_tree *tr
|
|||
decode_numeric_bitfield(data2, 0x3FFF, 2*8,
|
||||
"Status data length = %u"));
|
||||
nb_xmit_corrl( tvb, offset, tree);
|
||||
if (!netbios_add_name("Receiver's Name", tvb, offset + NB_RECVER_NAME,
|
||||
tree))
|
||||
return;
|
||||
netbios_add_name("Receiver's Name", tvb, offset + NB_RECVER_NAME, tree);
|
||||
netbios_add_name("Sender's Name", tvb, offset + NB_SENDER_NAME,
|
||||
tree);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* derived from the packet-nbns.c
|
||||
*
|
||||
* $Id: packet-netbios.h,v 1.8 2000/11/10 21:09:49 guy Exp $
|
||||
* $Id: packet-netbios.h,v 1.9 2001/01/15 04:39:28 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -39,7 +39,7 @@ extern int process_netbios_name(const u_char *name_ptr, char *name_ret);
|
|||
extern int get_netbios_name(tvbuff_t *tvb, int offset,
|
||||
char *name_ret);
|
||||
extern char *netbios_name_type_descr(int name_type);
|
||||
extern gboolean netbios_add_name( char* label, tvbuff_t *tvb, int offset,
|
||||
extern void netbios_add_name( char* label, tvbuff_t *tvb, int offset,
|
||||
proto_tree *tree);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue