diff options
Diffstat (limited to 'ui/cli/tap-afpstat.c')
-rw-r--r-- | ui/cli/tap-afpstat.c | 101 |
1 files changed, 57 insertions, 44 deletions
diff --git a/ui/cli/tap-afpstat.c b/ui/cli/tap-afpstat.c index e0127f23c6..0682c0c8af 100644 --- a/ui/cli/tap-afpstat.c +++ b/ui/cli/tap-afpstat.c @@ -45,24 +45,24 @@ typedef struct _afpstat_t { static int afpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv) { - afpstat_t *ss=(afpstat_t *)pss; - const afp_request_val *request_val=(const afp_request_val *)prv; + afpstat_t *ss = (afpstat_t *)pss; + const afp_request_val *request_val = (const afp_request_val *)prv; nstime_t t, deltat; - timestat_t *sp=NULL; + timestat_t *sp = NULL; /* if we havnt seen the request, just ignore it */ - if(!request_val){ + if (!request_val) { return 0; } - sp=&(ss->proc[request_val->command]); + sp = &(ss->proc[request_val->command]); /* calculate time delta between request and reply */ - t=pinfo->fd->abs_ts; + t = pinfo->fd->abs_ts; nstime_delta(&deltat, &t, &request_val->req_time); - if(sp){ - time_stat_update(sp,&deltat, pinfo); + if (sp) { + time_stat_update(sp, &deltat, pinfo); } return 1; @@ -71,35 +71,35 @@ afpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const voi static void afpstat_draw(void *pss) { - afpstat_t *ss=(afpstat_t *)pss; + afpstat_t *ss = (afpstat_t *)pss; guint32 i; guint64 td; printf("\n"); printf("===================================================================\n"); printf("AFP SRT Statistics:\n"); - printf("Filter: %s\n",ss->filter?ss->filter:""); + printf("Filter: %s\n", ss->filter ? ss->filter : ""); printf("Commands Calls Min SRT Max SRT Avg SRT\n"); - for(i=0;i<256;i++){ + for (i=0; i<256; i++) { /* nothing seen, nothing to do */ - if(ss->proc[i].num==0){ + if (ss->proc[i].num == 0) { continue; } /* scale it to units of 10us.*/ - td=ss->proc[i].tot.secs; - td=td*100000+(int)ss->proc[i].tot.nsecs/10000; - if(ss->proc[i].num){ - td/=ss->proc[i].num; + td = ss->proc[i].tot.secs; + td = td*100000+(int)ss->proc[i].tot.nsecs/10000; + if (ss->proc[i].num) { + td /= ss->proc[i].num; } else { - td=0; + td = 0; } printf("%-25s %6d %3d.%05d %3d.%05d %3" G_GINT64_MODIFIER "u.%05" G_GINT64_MODIFIER "u\n", - val_to_str_ext(i, &CommandCode_vals_ext, "Unknown (%u)"), - ss->proc[i].num, - (int)ss->proc[i].min.secs,ss->proc[i].min.nsecs/10000, - (int)ss->proc[i].max.secs,ss->proc[i].max.nsecs/10000, - td/100000, td%100000 + val_to_str_ext(i, &CommandCode_vals_ext, "Unknown (%u)"), + ss->proc[i].num, + (int)ss->proc[i].min.secs, ss->proc[i].min.nsecs/10000, + (int)ss->proc[i].max.secs, ss->proc[i].max.nsecs/10000, + td/100000, td%100000 ); } printf("===================================================================\n"); @@ -107,40 +107,40 @@ afpstat_draw(void *pss) static void -afpstat_init(const char *opt_arg, void* userdata _U_) +afpstat_init(const char *opt_arg, void *userdata _U_) { afpstat_t *ss; guint32 i; - const char *filter=NULL; + const char *filter = NULL; GString *error_string; - if(!strncmp(opt_arg,"afp,srt,",8)){ - filter=opt_arg+8; + if (!strncmp(opt_arg, "afp,srt,", 8)) { + filter = opt_arg+8; } else { - filter=NULL; + filter = NULL; } - ss=g_new(afpstat_t,1); - if(filter){ - ss->filter=g_strdup(filter); + ss = g_new(afpstat_t, 1); + if (filter) { + ss->filter = g_strdup(filter); } else { - ss->filter=NULL; + ss->filter = NULL; } - for(i=0;i<256;i++){ - ss->proc[i].num=0; - ss->proc[i].min_num=0; - ss->proc[i].max_num=0; - ss->proc[i].min.secs=0; - ss->proc[i].min.nsecs=0; - ss->proc[i].max.secs=0; - ss->proc[i].max.nsecs=0; - ss->proc[i].tot.secs=0; - ss->proc[i].tot.nsecs=0; + for (i=0; i<256; i++) { + ss->proc[i].num = 0; + ss->proc[i].min_num = 0; + ss->proc[i].max_num = 0; + ss->proc[i].min.secs = 0; + ss->proc[i].min.nsecs = 0; + ss->proc[i].max.secs = 0; + ss->proc[i].max.nsecs = 0; + ss->proc[i].tot.secs = 0; + ss->proc[i].tot.nsecs = 0; } - error_string=register_tap_listener("afp", ss, filter, 0, NULL, afpstat_packet, afpstat_draw); - if(error_string){ + error_string = register_tap_listener("afp", ss, filter, 0, NULL, afpstat_packet, afpstat_draw); + if (error_string) { /* error, we failed to attach to the tap. clean up */ g_free(ss->filter); g_free(ss); @@ -155,5 +155,18 @@ afpstat_init(const char *opt_arg, void* userdata _U_) void register_tap_listener_afpstat(void) { - register_stat_cmd_arg("afp,srt", afpstat_init,NULL); + register_stat_cmd_arg("afp,srt", afpstat_init, NULL); } + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 8 + * tab-width: 8 + * indent-tabs-mode: t + * End: + * + * vi: set shiftwidth=8 tabstop=8 noexpandtab: + * :indentSize=8:tabSize=8:noTabs=false: + */ |