diff options
-rw-r--r-- | packet-portmap.c | 53 | ||||
-rw-r--r-- | packet-rpc.c | 83 | ||||
-rw-r--r-- | packet-rpc.h | 34 |
3 files changed, 100 insertions, 70 deletions
diff --git a/packet-portmap.c b/packet-portmap.c index f48311b219..d10143eb29 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.26 2001/02/06 06:56:19 guy Exp $ + * $Id: packet-portmap.c,v 1.27 2001/02/09 06:49:29 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -206,50 +206,29 @@ int dissect_dump_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, int dissect_callit_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) { - rpc_proc_info_key key; - rpc_proc_info_value *value; - char *procname = NULL; - char procname_static[20]; - old_dissect_function_t *old_dissect_function = NULL; - dissect_function_t *dissect_function = NULL; - - key.prog = tvb_get_ntohl(tvb, offset+0); + guint32 prog, vers, proc; + + prog = tvb_get_ntohl(tvb, offset+0); if ( tree ) { proto_tree_add_uint_format(tree, hf_portmap_prog, tvb, - offset, 4, key.prog, "Program: %s (%u)", - rpc_prog_name(key.prog), key.prog); + offset, 4, prog, "Program: %s (%u)", + rpc_prog_name(prog), prog); } - key.vers = tvb_get_ntohl(tvb, offset+4); + vers = tvb_get_ntohl(tvb, offset+4); if ( tree ) { proto_tree_add_uint(tree, hf_portmap_version, tvb, - offset+4, 4, key.vers); + offset+4, 4, vers); } - key.proc = tvb_get_ntohl(tvb, offset+8); - if ((value = g_hash_table_lookup(rpc_procs,&key)) != NULL) { - if (value->is_old_dissector) - old_dissect_function = value->dissect_call.old; - else - dissect_function = value->dissect_call.new; - procname = value->name; - } - else { - /* happens only with strange program versions or - non-existing dissectors */ -#if 0 - dissect_function = NULL; -#endif - sprintf(procname_static, "proc-%u", key.proc); - procname = procname_static; - } + proc = tvb_get_ntohl(tvb, offset+8); if ( tree ) { proto_tree_add_uint_format(tree, hf_portmap_proc, tvb, - offset+8, 4, key.proc, "Procedure: %s (%u)", - procname, key.proc); + offset+8, 4, proc, "Procedure: %s (%u)", + rpc_proc_name(prog, vers, proc), proc); } if ( tree ) @@ -261,12 +240,12 @@ int dissect_callit_call(tvbuff_t *tvb, int offset, packet_info *pinfo, offset += 16; - /* Call the call dissector to dissect the opaque arguments. - Make the columns non-writable, so it won't change them out - from under us. */ + /* Dissect the arguments for this procedure. + Make the columns non-writable, so the dissector won't change + them out from under us. */ col_set_writable(pinfo->fd, FALSE); - offset = call_dissect_function(tvb, pinfo, tree, offset, - old_dissect_function, dissect_function, NULL); + offset = dissect_rpc_indir_call(tvb, pinfo, tree, offset, prog, + vers, proc); return offset; } diff --git a/packet-rpc.c b/packet-rpc.c index 2b9ac66d08..fddf3b676f 100644 --- a/packet-rpc.c +++ b/packet-rpc.c @@ -2,7 +2,7 @@ * Routines for rpc dissection * Copyright 1999, Uwe Girlich <Uwe.Girlich@philosys.de> * - * $Id: packet-rpc.c,v 1.52 2001/02/06 06:46:10 guy Exp $ + * $Id: packet-rpc.c,v 1.53 2001/02/09 06:49:29 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -178,7 +178,26 @@ static gint ett_rpc_gss_data = -1; static GHashTable *rpc_progs; /* Hash table with info on RPC procedure numbers */ -GHashTable *rpc_procs; +static GHashTable *rpc_procs; + +typedef struct _rpc_proc_info_key { + guint32 prog; + guint32 vers; + guint32 proc; +} rpc_proc_info_key; + +typedef struct _rpc_proc_info_value { + gchar *name; + gboolean is_old_dissector; + union { + old_dissect_function_t *old; + dissect_function_t *new; + } dissect_call; + union { + old_dissect_function_t *old; + dissect_function_t *new; + } dissect_reply; +} rpc_proc_info_value; typedef struct _rpc_prog_info_key { guint32 prog; @@ -190,6 +209,7 @@ typedef struct _rpc_prog_info_value { char* progname; } rpc_prog_info_value; + /***********************************/ /* Hash array with procedure names */ /***********************************/ @@ -266,6 +286,29 @@ rpc_init_proc_table(guint prog, guint vers, const vsff *proc_table) } } +/* return the name associated with a previously registered procedure. */ +char *rpc_proc_name(guint32 prog, guint32 vers, guint32 proc) +{ + rpc_proc_info_key key; + rpc_proc_info_value *value; + char *procname; + static char procname_static[20]; + + key.prog = prog; + key.vers = vers; + key.proc = proc; + + if ((value = g_hash_table_lookup(rpc_procs,&key)) != NULL) + procname = value->name; + else { + /* happens only with strange program versions or + non-existing dissectors */ + sprintf(procname_static, "proc-%u", key.proc); + procname = procname_static; + } + return procname; +} + /*----------------------------------------*/ /* end of Hash array with procedure names */ /*----------------------------------------*/ @@ -988,7 +1031,7 @@ dissect_rpc_authgss_initres(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, } -int +static int call_dissect_function(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, old_dissect_function_t *old_dissect_function, dissect_function_t* dissect_function, const char *progname) @@ -1072,6 +1115,40 @@ dissect_rpc_authgss_priv_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre return offset; } +/* + * Dissect the arguments to an indirect call; used by the portmapper/RPCBIND + * dissector. + */ +int +dissect_rpc_indir_call(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, + int offset, guint32 prog, guint32 vers, guint32 proc) +{ + rpc_proc_info_key key; + rpc_proc_info_value *value; + old_dissect_function_t *old_dissect_function = NULL; + dissect_function_t *dissect_function = NULL; + + key.prog = prog; + key.vers = vers; + key.proc = proc; + if ((value = g_hash_table_lookup(rpc_procs,&key)) != NULL) { + if (value->is_old_dissector) + old_dissect_function = value->dissect_call.old; + else + dissect_function = value->dissect_call.new; + } + else { + /* happens only with strange program versions or + non-existing dissectors */ +#if 0 + dissect_function = NULL; +#endif + } + + offset = call_dissect_function(tvb, pinfo, tree, offset, + old_dissect_function, dissect_function, NULL); + return offset; +} static gboolean dissect_rpc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) diff --git a/packet-rpc.h b/packet-rpc.h index 1f3db02932..d873b78a84 100644 --- a/packet-rpc.h +++ b/packet-rpc.h @@ -1,6 +1,6 @@ /* packet-rpc.h * - * $Id: packet-rpc.h,v 1.24 2001/02/06 06:46:10 guy Exp $ + * $Id: packet-rpc.h,v 1.25 2001/02/09 06:49:29 guy Exp $ * * (c) 1999 Uwe Girlich * @@ -88,41 +88,13 @@ typedef struct _vsff { dissect_function_t *dissect_reply; } vsff; -/* - * These are used by the CALLIT handler for the portmapper dissector. - */ -typedef struct _rpc_proc_info_key { - guint32 prog; - guint32 vers; - guint32 proc; -} rpc_proc_info_key; - -typedef struct _rpc_proc_info_value { - gchar *name; - gboolean is_old_dissector; - union { - old_dissect_function_t *old; - dissect_function_t *new; - } dissect_call; - union { - old_dissect_function_t *old; - dissect_function_t *new; - } dissect_reply; -} rpc_proc_info_value; - -/* Hash table with info on RPC procedure numbers */ -GHashTable *rpc_procs; - extern const value_string rpc_auth_flavor[]; extern void old_rpc_init_proc_table(guint prog, guint vers, const old_vsff *proc_table); extern void rpc_init_proc_table(guint prog, guint vers, const vsff *proc_table); extern void rpc_init_prog(int proto, guint32 prog, int ett); extern char *rpc_prog_name(guint32 prog); -extern int call_dissect_function(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, int offset, - old_dissect_function_t *old_dissect_function, - dissect_function_t* dissect_function, const char *progname); +extern char *rpc_proc_name(guint32 prog, guint32 vers, guint32 proc); extern unsigned int rpc_roundup(unsigned int a); extern int dissect_rpc_bool(const u_char *pd, int offset, frame_data *fd, @@ -150,6 +122,8 @@ extern int dissect_rpc_uint64(const u_char *pd, int offset, frame_data *fd, extern int dissect_rpc_uint64_tvb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int hfindex, int offset); +extern int dissect_rpc_indir_call(tvbuff_t *tvb, packet_info *pinfo, + proto_tree *tree, int offset, guint32 prog, guint32 vers, guint32 proc); #endif /* packet-rpc.h */ |