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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 #include <epan/packet_info.h>
34 #include <epan/stat_cmd_args.h>
35 #include <epan/value_string.h>
36 #include <epan/dissectors/packet-afp.h>
37 #include "epan/timestats.h"
39 void register_tap_listener_afpstat(void);
41 /* used to keep track of the statistics for an entire program interface */
42 typedef struct _afpstat_t
{
48 afpstat_packet(void *pss
, packet_info
*pinfo
, epan_dissect_t
*edt _U_
, const void *prv
)
50 afpstat_t
*ss
=(afpstat_t
*)pss
;
51 const afp_request_val
*request_val
=(const afp_request_val
*)prv
;
55 /* if we havnt seen the request, just ignore it */
60 sp
=&(ss
->proc
[request_val
->command
]);
62 /* calculate time delta between request and reply */
64 nstime_delta(&deltat
, &t
, &request_val
->req_time
);
67 time_stat_update(sp
,&deltat
, pinfo
);
74 afpstat_draw(void *pss
)
76 afpstat_t
*ss
=(afpstat_t
*)pss
;
80 printf("===================================================================\n");
81 printf("AFP SRT Statistics:\n");
82 printf("Filter: %s\n",ss
->filter
?ss
->filter
:"");
83 printf("Commands Calls Min SRT Max SRT Avg SRT\n");
85 /* nothing seen, nothing to do */
86 if(ss
->proc
[i
].num
==0){
90 /* scale it to units of 10us.*/
91 td
=ss
->proc
[i
].tot
.secs
;
92 td
=td
*100000+(int)ss
->proc
[i
].tot
.nsecs
/10000;
99 printf("%-25s %6d %3d.%05d %3d.%05d %3" G_GINT64_MODIFIER
"u.%05" G_GINT64_MODIFIER
"u\n",
100 val_to_str_ext(i
, &CommandCode_vals_ext
, "Unknown (%u)"),
102 (int)ss
->proc
[i
].min
.secs
,ss
->proc
[i
].min
.nsecs
/10000,
103 (int)ss
->proc
[i
].max
.secs
,ss
->proc
[i
].max
.nsecs
/10000,
107 printf("===================================================================\n");
112 afpstat_init(const char *opt_arg
, void* userdata _U_
)
116 const char *filter
=NULL
;
117 GString
*error_string
;
119 if(!strncmp(opt_arg
,"afp,srt,",8)){
125 ss
=g_new(afpstat_t
,1);
127 ss
->filter
=g_strdup(filter
);
134 ss
->proc
[i
].min_num
=0;
135 ss
->proc
[i
].max_num
=0;
136 ss
->proc
[i
].min
.secs
=0;
137 ss
->proc
[i
].min
.nsecs
=0;
138 ss
->proc
[i
].max
.secs
=0;
139 ss
->proc
[i
].max
.nsecs
=0;
140 ss
->proc
[i
].tot
.secs
=0;
141 ss
->proc
[i
].tot
.nsecs
=0;
144 error_string
=register_tap_listener("afp", ss
, filter
, 0, NULL
, afpstat_packet
, afpstat_draw
);
146 /* error, we failed to attach to the tap. clean up */
150 fprintf(stderr
, "tshark: Couldn't register afp,srt tap: %s\n",
152 g_string_free(error_string
, TRUE
);
158 register_tap_listener_afpstat(void)
160 register_stat_cmd_arg("afp,srt", afpstat_init
,NULL
);