3 * smbstat 2003 Ronnie Sahlberg
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #ifdef HAVE_SYS_TYPES_H
33 # include <sys/types.h>
37 #include <epan/packet_info.h>
39 #include <epan/stat_cmd_args.h>
40 #include <epan/value_string.h>
41 #include <epan/dissectors/packet-afp.h>
43 #include "timestats.h"
45 /* used to keep track of the statistics for an entire program interface */
46 typedef struct _afpstat_t {
52 afpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv)
54 afpstat_t *ss=(afpstat_t *)pss;
55 const afp_request_val *request_val=prv;
59 /* if we havnt seen the request, just ignore it */
64 sp=&(ss->proc[request_val->command]);
66 /* calculate time delta between request and reply */
68 nstime_delta(&deltat, &t, &request_val->req_time);
71 time_stat_update(sp,&deltat, pinfo);
78 afpstat_draw(void *pss)
80 afpstat_t *ss=(afpstat_t *)pss;
84 printf("===================================================================\n");
85 printf("AFP RTT Statistics:\n");
86 printf("Filter: %s\n",ss->filter?ss->filter:"");
87 printf("Commands Calls Min RTT Max RTT Avg RTT\n");
89 /* nothing seen, nothing to do */
90 if(ss->proc[i].num==0){
94 /* scale it to units of 10us.*/
95 td=ss->proc[i].tot.secs;
96 td=td*100000+(int)ss->proc[i].tot.nsecs/10000;
103 printf("%-25s %6d %3d.%05d %3d.%05d %3" G_GINT64_MODIFIER "u.%05" G_GINT64_MODIFIER "u\n",
104 val_to_str(i, CommandCode_vals, "Unknown (%u)"),
106 (int)ss->proc[i].min.secs,ss->proc[i].min.nsecs/10000,
107 (int)ss->proc[i].max.secs,ss->proc[i].max.nsecs/10000,
111 printf("===================================================================\n");
116 afpstat_init(const char *optarg, void* userdata _U_)
120 const char *filter=NULL;
121 GString *error_string;
123 if(!strncmp(optarg,"afp,rtt,",8)){
129 ss=g_malloc(sizeof(afpstat_t));
131 ss->filter=g_strdup(filter);
138 ss->proc[i].min_num=0;
139 ss->proc[i].max_num=0;
140 ss->proc[i].min.secs=0;
141 ss->proc[i].min.nsecs=0;
142 ss->proc[i].max.secs=0;
143 ss->proc[i].max.nsecs=0;
144 ss->proc[i].tot.secs=0;
145 ss->proc[i].tot.nsecs=0;
148 error_string=register_tap_listener("afp", ss, filter, NULL, afpstat_packet, afpstat_draw);
150 /* error, we failed to attach to the tap. clean up */
154 fprintf(stderr, "tshark: Couldn't register afp,rtt tap: %s\n",
156 g_string_free(error_string, TRUE);
162 register_tap_listener_afpstat(void)
164 register_stat_cmd_arg("afp,rtt", afpstat_init,NULL);