From 167999e61e4cae6350754f99ecb21f9671b5278b Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 22 Jan 2000 05:49:08 +0000 Subject: [PATCH] Give "dissect_rpc_string()" an extra "char **" argument; if it's non-null, it returns through that argument a pointer to the displayed version of the string, otherwise it just frees that string. Use that to put, in the tree item for READDIR and READDIRPLUS reply directory entry items, the file name from the directory entry. svn path=/trunk/; revision=1521 --- packet-bootparams.c | 14 ++++++------- packet-mount.c | 4 ++-- packet-nfs.c | 48 +++++++++++++++++++++++++++++++-------------- packet-portmap.c | 10 +++++----- packet-rpc.c | 29 ++++++++++++++++++--------- packet-rpc.h | 4 ++-- packet-ypserv.c | 27 +++++++++++++------------ 7 files changed, 83 insertions(+), 53 deletions(-) diff --git a/packet-bootparams.c b/packet-bootparams.c index dfec26e5ec..8d3d97a194 100644 --- a/packet-bootparams.c +++ b/packet-bootparams.c @@ -1,7 +1,7 @@ /* packet-bootparams.c * Routines for bootparams dissection * - * $Id: packet-bootparams.c,v 1.7 2000/01/07 22:05:30 guy Exp $ + * $Id: packet-bootparams.c,v 1.8 2000/01/22 05:49:07 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -90,8 +90,8 @@ int dissect_getfile_call(const u_char *pd, int offset, frame_data *fd, { if ( tree ) { - offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_host); - offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_fileid); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_host,NULL); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_fileid,NULL); } return offset; @@ -103,9 +103,9 @@ int dissect_getfile_reply(const u_char *pd, int offset, frame_data *fd, { if ( tree ) { - offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_host); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_host,NULL); offset = dissect_bp_address(pd,offset,fd,tree,hf_bootparams_hostaddr); - offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_filepath); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_filepath,NULL); } return offset; @@ -129,8 +129,8 @@ int dissect_whoami_reply(const u_char *pd, int offset, frame_data *fd, { if ( tree ) { - offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_host); - offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_domain); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_host,NULL); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_domain,NULL); offset = dissect_bp_address(pd,offset,fd,tree,hf_bootparams_routeraddr); } diff --git a/packet-mount.c b/packet-mount.c index bb68bd0cb7..af2bc96ecc 100644 --- a/packet-mount.c +++ b/packet-mount.c @@ -1,7 +1,7 @@ /* packet-mount.c * Routines for mount dissection * - * $Id: packet-mount.c,v 1.9 2000/01/07 22:05:32 guy Exp $ + * $Id: packet-mount.c,v 1.10 2000/01/22 05:49:07 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -99,7 +99,7 @@ dissect_mount_dirpath_call(const u_char *pd, int offset, frame_data *fd, { if ( tree ) { - offset = dissect_rpc_string(pd,offset,fd,tree,hf_mount_path); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_mount_path,NULL); } return offset; diff --git a/packet-nfs.c b/packet-nfs.c index 3e18772cab..eba7f06f62 100644 --- a/packet-nfs.c +++ b/packet-nfs.c @@ -2,7 +2,7 @@ * Routines for nfs dissection * Copyright 1999, Uwe Girlich * - * $Id: packet-nfs.c,v 1.19 2000/01/18 11:56:15 girlich Exp $ + * $Id: packet-nfs.c,v 1.20 2000/01/22 05:49:04 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -473,9 +473,10 @@ dissect_sattr(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, ch /* RFC 1094, Page 17 */ int -dissect_filename(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int hf) +dissect_filename(const u_char *pd, int offset, frame_data *fd, + proto_tree *tree, int hf, char **string_ret) { - offset = dissect_rpc_string(pd,offset,fd,tree,hf); + offset = dissect_rpc_string(pd,offset,fd,tree,hf,string_ret); return offset; } @@ -484,7 +485,7 @@ dissect_filename(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int dissect_path(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int hf) { - offset = dissect_rpc_string(pd,offset,fd,tree,hf); + offset = dissect_rpc_string(pd,offset,fd,tree,hf,NULL); return offset; } @@ -534,7 +535,7 @@ dissect_diropargs(const u_char *pd, int offset, frame_data *fd, proto_tree *tree } offset = dissect_fhandle (pd,offset,fd,diropargs_tree,"dir"); - offset = dissect_filename(pd,offset,fd,diropargs_tree,hf_nfs_name); + offset = dissect_filename(pd,offset,fd,diropargs_tree,hf_nfs_name,NULL); /* now we know, that diropargs is shorter */ if (diropargs_item) { @@ -782,6 +783,7 @@ dissect_readdir_entry(const u_char* pd, int offset, frame_data* fd, proto_tree* int old_offset = offset; guint32 fileid; guint32 cookie; + char *name; if (tree) { entry_item = proto_tree_add_item(tree, hf_nfs_readdir_entry, @@ -790,14 +792,21 @@ dissect_readdir_entry(const u_char* pd, int offset, frame_data* fd, proto_tree* entry_tree = proto_item_add_subtree(entry_item, ett_nfs_readdir_entry); } - if (!BYTES_ARE_IN_FRAME(offset, 4)) return offset; + if (!BYTES_ARE_IN_FRAME(offset, 4)) { + proto_item_set_text(entry_item, "Entry: "); + return offset; + } fileid = EXTRACT_UINT(pd, offset + 0); if (entry_tree) proto_tree_add_item(entry_tree, hf_nfs_readdir_entry_fileid, offset+0, 4, fileid); offset += 4; - offset = dissect_filename(pd, offset, fd, entry_tree, hf_nfs_readdir_entry_name); + offset = dissect_filename(pd, offset, fd, entry_tree, + hf_nfs_readdir_entry_name, &name); + proto_item_set_text(entry_item, "Entry: file ID %u, name %s", + fileid, name); + g_free(name); if (!BYTES_ARE_IN_FRAME(offset, 4)) return offset; cookie = EXTRACT_UINT(pd, offset + 0); @@ -968,9 +977,10 @@ char* name) /* RFC 1813, Page 15 */ int -dissect_filename3(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int hf) +dissect_filename3(const u_char *pd, int offset, frame_data *fd, + proto_tree *tree, int hf, char **string_ret) { - offset = dissect_rpc_string(pd,offset,fd,tree,hf); + offset = dissect_rpc_string(pd,offset,fd,tree,hf,string_ret); return offset; } @@ -979,7 +989,7 @@ dissect_filename3(const u_char *pd, int offset, frame_data *fd, proto_tree *tree int dissect_nfspath3(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int hf) { - offset = dissect_rpc_string(pd,offset,fd,tree,hf); + offset = dissect_rpc_string(pd,offset,fd,tree,hf,NULL); return offset; } @@ -1898,7 +1908,7 @@ dissect_diropargs3(const u_char *pd, int offset, frame_data *fd, proto_tree *tre } offset = dissect_nfs_fh3 (pd, offset, fd, diropargs3_tree, "dir"); - offset = dissect_filename3(pd, offset, fd, diropargs3_tree, hf_nfs_name); + offset = dissect_filename3(pd, offset, fd, diropargs3_tree, hf_nfs_name,NULL); /* now we know, that diropargs3 is shorter */ if (diropargs3_item) { @@ -2496,6 +2506,7 @@ dissect_entry3(const u_char* pd, int offset, frame_data* fd, proto_tree* tree) proto_item* entry_item = NULL; proto_tree* entry_tree = NULL; int old_offset = offset; + char *name; if (tree) { entry_item = proto_tree_add_item(tree, hf_nfs_readdir_entry, @@ -2506,8 +2517,11 @@ dissect_entry3(const u_char* pd, int offset, frame_data* fd, proto_tree* tree) offset = dissect_fileid3(pd, offset, fd, entry_tree, "fileid"); - offset = dissect_filename3(pd, offset, fd, entry_tree, hf_nfs_readdir_entry_name); - + offset = dissect_filename3(pd, offset, fd, entry_tree, + hf_nfs_readdir_entry_name, &name); + proto_item_set_text(entry_item, "Entry: name %s", name); + g_free(name); + offset = dissect_cookie3(pd, offset, fd, entry_tree, "cookie"); /* now we know, that a readdir entry is shorter */ @@ -2582,6 +2596,7 @@ dissect_entryplus3(const u_char* pd, int offset, frame_data* fd, proto_tree* tre proto_item* entry_item = NULL; proto_tree* entry_tree = NULL; int old_offset = offset; + char *name; if (tree) { entry_item = proto_tree_add_item(tree, hf_nfs_readdir_entry, @@ -2592,8 +2607,11 @@ dissect_entryplus3(const u_char* pd, int offset, frame_data* fd, proto_tree* tre offset = dissect_fileid3(pd, offset, fd, entry_tree, "fileid"); - offset = dissect_filename3(pd, offset, fd, entry_tree, hf_nfs_readdirplus_entry_name); - + offset = dissect_filename3(pd, offset, fd, entry_tree, + hf_nfs_readdirplus_entry_name, &name); + proto_item_set_text(entry_item, "Entry: name %s", name); + g_free(name); + offset = dissect_cookie3(pd, offset, fd, entry_tree, "cookie"); offset = dissect_post_op_attr(pd, offset, fd, entry_tree, "name_attributes"); diff --git a/packet-portmap.c b/packet-portmap.c index 0a30a988c0..60698d1b17 100644 --- a/packet-portmap.c +++ b/packet-portmap.c @@ -1,7 +1,7 @@ /* packet-portmap.c * Routines for portmap dissection * - * $Id: packet-portmap.c,v 1.11 2000/01/07 22:05:35 guy Exp $ + * $Id: packet-portmap.c,v 1.12 2000/01/22 05:49:06 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -285,9 +285,9 @@ int dissect_rpcb(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, offset+0, 4, version); offset += 4; - offset = dissect_rpc_string(pd, offset, fd, rpcb_tree, hf_portmap_rpcb_netid); - offset = dissect_rpc_string(pd, offset, fd, rpcb_tree, hf_portmap_rpcb_addr); - offset = dissect_rpc_string(pd, offset, fd, rpcb_tree, hf_portmap_rpcb_owner); + offset = dissect_rpc_string(pd, offset, fd, rpcb_tree, hf_portmap_rpcb_netid,NULL); + offset = dissect_rpc_string(pd, offset, fd, rpcb_tree, hf_portmap_rpcb_addr,NULL); + offset = dissect_rpc_string(pd, offset, fd, rpcb_tree, hf_portmap_rpcb_owner,NULL); /* now we know, that rpcb is shorter */ if (rpcb_item) { @@ -313,7 +313,7 @@ int dissect_rpcb3_getaddr_call(const u_char *pd, int offset, frame_data *fd, int dissect_rpcb3_getaddr_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { - offset = dissect_rpc_string(pd, offset, fd, tree, hf_portmap_uaddr); + offset = dissect_rpc_string(pd, offset, fd, tree, hf_portmap_uaddr,NULL); return offset; } diff --git a/packet-rpc.c b/packet-rpc.c index 3fa36dbf2d..24aaa3c8e3 100644 --- a/packet-rpc.c +++ b/packet-rpc.c @@ -2,7 +2,7 @@ * Routines for rpc dissection * Copyright 1999, Uwe Girlich * - * $Id: packet-rpc.c,v 1.25 2000/01/07 22:05:36 guy Exp $ + * $Id: packet-rpc.c,v 1.26 2000/01/22 05:49:06 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -404,8 +404,10 @@ char* name, char* type) } -int -dissect_rpc_opaque_data(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int hfindex, int string_data) +static int +dissect_rpc_opaque_data(const u_char *pd, int offset, frame_data *fd, + proto_tree *tree, int hfindex, gboolean string_data, + char **string_buffer_ret) { proto_item *string_item = NULL; proto_tree *string_tree = NULL; @@ -557,24 +559,33 @@ dissect_rpc_opaque_data(const u_char *pd, int offset, frame_data *fd, proto_tree } if (string_buffer != NULL) g_free (string_buffer ); - if (string_buffer_print != NULL) g_free (string_buffer_print); + if (string_buffer_print != NULL) { + if (string_buffer_ret != NULL) + *string_buffer_ret = string_buffer_print; + else + g_free (string_buffer_print); + } return offset; } int -dissect_rpc_string(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int hfindex) +dissect_rpc_string(const u_char *pd, int offset, frame_data *fd, + proto_tree *tree, int hfindex, char **string_buffer_ret) { - offset = dissect_rpc_opaque_data(pd, offset, fd, tree, hfindex, 1); + offset = dissect_rpc_opaque_data(pd, offset, fd, tree, hfindex, TRUE, + string_buffer_ret); return offset; } int -dissect_rpc_data(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int hfindex) +dissect_rpc_data(const u_char *pd, int offset, frame_data *fd, + proto_tree *tree, int hfindex) { - offset = dissect_rpc_opaque_data(pd, offset, fd, tree, hfindex, 0); + offset = dissect_rpc_opaque_data(pd, offset, fd, tree, hfindex, FALSE, + NULL); return offset; } @@ -622,7 +633,7 @@ dissect_rpc_auth( const u_char *pd, int offset, frame_data *fd, proto_tree *tree offset += 4; offset = dissect_rpc_string(pd,offset,fd, - tree,hf_rpc_auth_machinename); + tree,hf_rpc_auth_machinename,NULL); if (!BYTES_ARE_IN_FRAME(offset,4)) return; uid = EXTRACT_UINT(pd,offset+0); diff --git a/packet-rpc.h b/packet-rpc.h index 2b7d1edc3b..3b23a9c348 100644 --- a/packet-rpc.h +++ b/packet-rpc.h @@ -1,5 +1,5 @@ /* packet-rpc.h (c) 1999 Uwe Girlich */ -/* $Id: packet-rpc.h,v 1.11 1999/12/14 11:40:27 girlich Exp $ */ +/* $Id: packet-rpc.h,v 1.12 2000/01/22 05:49:08 guy Exp $ */ #ifndef __PACKET_RPC_H__ #define __PACKET_RPC_H__ @@ -100,7 +100,7 @@ extern unsigned int rpc_roundup(unsigned int a); extern int dissect_rpc_bool(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int hfindex); extern int dissect_rpc_string(const u_char *pd, int offset, frame_data *fd, - proto_tree *tree, int hfindex); + proto_tree *tree, int hfindex, char **string_buffer_ret); extern int dissect_rpc_data(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int hfindex); extern int dissect_rpc_uint32(const u_char *pd, int offset, frame_data *fd, diff --git a/packet-ypserv.c b/packet-ypserv.c index 45dc3056ab..62121a0cd6 100644 --- a/packet-ypserv.c +++ b/packet-ypserv.c @@ -1,7 +1,7 @@ /* packet-ypserv.c * Routines for ypserv dissection * - * $Id: packet-ypserv.c,v 1.7 2000/01/07 22:05:42 guy Exp $ + * $Id: packet-ypserv.c,v 1.8 2000/01/22 05:49:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -53,7 +53,7 @@ int dissect_domain_call(const u_char *pd, int offset, frame_data *fd, { if ( tree ) { - offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_domain); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_domain,NULL); } return offset; @@ -80,9 +80,9 @@ int dissect_next_call(const u_char *pd, int offset, frame_data *fd, { if ( tree ) { - offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_domain); - offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_map); - offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_key); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_domain,NULL); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_map,NULL); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_key,NULL); } return offset; @@ -93,8 +93,8 @@ int dissect_first_call(const u_char *pd, int offset, frame_data *fd, { if ( tree ) { - offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_domain); - offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_map); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_domain,NULL); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_map,NULL); } return offset; @@ -105,9 +105,9 @@ int dissect_match_call(const u_char *pd, int offset, frame_data *fd, { if ( tree ) { - offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_domain); - offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_map); - offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_key); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_domain,NULL); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_map,NULL); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_key,NULL); } return offset; @@ -124,7 +124,7 @@ int dissect_match_reply(const u_char *pd, int offset, frame_data *fd, offset, 4, pntohl(&pd[offset])); offset += 4; - offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_value); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_value,NULL); } return offset; @@ -141,8 +141,9 @@ int dissect_firstnext_reply(const u_char *pd, int offset, frame_data *fd, offset, 4, pntohl(&pd[offset])); offset += 4; - offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_value); - offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_key); } + offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_value,NULL); + offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_key,NULL); + } return offset; }