/* tap-rpcstat.c
* rpcstat 2002 Ronnie Sahlberg
*
- * $Id: tap-rpcstat.c,v 1.5 2002/10/31 22:16:01 guy Exp $
+ * $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* It serves as an example on how to use the tap api.
*/
+/* With MSVC and a libethereal.dll this file needs to import some variables
+ in a special way. Therefore _NEED_VAR_IMPORT_ is defined. */
+#define _NEED_VAR_IMPORT_
+
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h>
#include "epan/packet_info.h"
#include "tap.h"
-#include "packet-rpc.h"
+#include <epan/dissectors/packet-rpc.h>
#include "register.h"
/* used to keep track of statistics for a specific procedure */
delta.secs--;
}
- if((rp->max.secs==0)
- && (rp->max.nsecs==0) ){
+ if(rp->num==0){
rp->max.secs=delta.secs;
rp->max.nsecs=delta.nsecs;
}
- if((rp->min.secs==0)
- && (rp->min.nsecs==0) ){
+ if(rp->num==0){
rp->min.secs=delta.secs;
rp->min.nsecs=delta.nsecs;
}
rp->tot.nsecs-=1000000000;
rp->tot.secs++;
}
+
rp->num++;
return 1;
/* When called, this function will create a new instance of rpcstat.
* program and version are whick onc-rpc program/version we want to
* collect statistics for.
- * This function is called from tethereal when it parses the -Z rpc, arguments
+ * This function is called from tethereal when it parses the -z rpc, arguments
* and it creates a new instance to store statistics in and registers this
* new instance for the rpc tap.
*/
int program, version;
int pos=0;
char *filter=NULL;
+ GString *error_string;
if(sscanf(optarg,"rpc,rtt,%d,%d,%n",&program,&version,&pos)==2){
if(pos){
exit(1);
}
-
rs=g_malloc(sizeof(rpcstat_t));
rs->prog=rpc_prog_name(program);
rs->program=program;
rpc_max_proc=-1;
g_hash_table_foreach(rpc_procs, (GHFunc)rpcstat_find_procs, NULL);
if(rpc_min_proc==-1){
- fprintf(stderr,"tethereal: Invalid -Z rpc,rrt,%d,%d\n",rpc_program,rpc_version);
+ fprintf(stderr,"tethereal: Invalid -z rpc,rrt,%d,%d\n",rpc_program,rpc_version);
fprintf(stderr," Program:%d version:%d is not supported by tethereal.\n", rpc_program, rpc_version);
exit(1);
}
*
*/
- if(register_tap_listener("rpc", rs, filter, rpcstat_reset, rpcstat_packet, rpcstat_draw)){
+ error_string=register_tap_listener("rpc", rs, filter, rpcstat_reset, rpcstat_packet, rpcstat_draw);
+ if(error_string){
/* error, we failed to attach to the tap. clean up */
g_free(rs->procedures);
g_free(rs->filter);
g_free(rs);
- fprintf(stderr,"tethereal: rpcstat_init() failed to attach to tap.\n");
+ fprintf(stderr, "tethereal: Couldn't register rpc,rtt tap: %s\n",
+ error_string->str);
+ g_string_free(error_string, TRUE);
exit(1);
}
}
void
register_tap_listener_rpcstat(void)
{
- register_ethereal_tap("rpc,rtt,", rpcstat_init, NULL, NULL);
+ register_ethereal_tap("rpc,rtt,", rpcstat_init);
}