*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* This module provides icmpv6 echo request/reply SRT statistics to tshark.
* doc/README.tapping.
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
#include <stdio.h>
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
#include <string.h>
#include "epan/packet_info.h"
#include <epan/tap.h>
static void
icmpv6stat_reset(void *tapdata)
{
- icmpv6stat_t *icmpv6stat = tapdata;
+ icmpv6stat_t *icmpv6stat = (icmpv6stat_t *)tapdata;
g_slist_free(icmpv6stat->rt_list);
memset(icmpv6stat, 0, sizeof(icmpv6stat_t));
static int
icmpv6stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *data)
{
- icmpv6stat_t *icmpv6stat = tapdata;
- const icmp_transaction_t *trans = data;
- double *rt;
+ icmpv6stat_t *icmpv6stat = (icmpv6stat_t *)tapdata;
+ const icmp_transaction_t *trans = (const icmp_transaction_t *)data;
+ double resp_time, *rt;
if (trans == NULL)
return 0;
if (trans->resp_frame) {
- rt = g_malloc(sizeof(double));
+ resp_time = nstime_to_msec(&trans->resp_time);
+ rt = g_new(double,1);
if (rt == NULL)
return 0;
- *rt = trans->resp_time;
- icmpv6stat->rt_list = g_slist_insert_sorted(icmpv6stat->rt_list, rt, compare_doubles);
+ *rt = resp_time;
+ icmpv6stat->rt_list = g_slist_prepend(icmpv6stat->rt_list, rt);
icmpv6stat->num_resps++;
- if (icmpv6stat->min_msecs > trans->resp_time) {
+ if (icmpv6stat->min_msecs > resp_time) {
icmpv6stat->min_frame = trans->resp_frame;
- icmpv6stat->min_msecs = trans->resp_time;
+ icmpv6stat->min_msecs = resp_time;
}
- if (icmpv6stat->max_msecs < trans->resp_time) {
+ if (icmpv6stat->max_msecs < resp_time) {
icmpv6stat->max_frame = trans->resp_frame;
- icmpv6stat->max_msecs = trans->resp_time;
+ icmpv6stat->max_msecs = resp_time;
}
- icmpv6stat->tot_msecs += trans->resp_time;
+ icmpv6stat->tot_msecs += resp_time;
} else if (trans->rqst_frame)
icmpv6stat->num_rqsts++;
else
*/
static void compute_stats(icmpv6stat_t *icmpv6stat, double *mean, double *med, double *sdev)
{
- GSList *slist = icmpv6stat->rt_list;
+ GSList *slist;
double diff;
double sq_diff_sum = 0.0;
+ icmpv6stat->rt_list = g_slist_sort(icmpv6stat->rt_list, compare_doubles);
+ slist = icmpv6stat->rt_list;
+
if (icmpv6stat->num_resps == 0 || slist == NULL) {
*mean = 0.0;
*med = 0.0;
static void
icmpv6stat_draw(void *tapdata)
{
- icmpv6stat_t *icmpv6stat = tapdata;
+ icmpv6stat_t *icmpv6stat = (icmpv6stat_t *)tapdata;
unsigned int lost;
double mean, sdev, med;
if (strstr(optarg, "icmpv6,srt,"))
filter = optarg + strlen("icmpv6,srt,");
- icmpv6stat = g_try_malloc(sizeof(icmpv6stat_t));
+ icmpv6stat = (icmpv6stat_t *)g_try_malloc(sizeof(icmpv6stat_t));
if (icmpv6stat == NULL) {
fprintf(stderr, "tshark: g_try_malloc() fatal error.\n");
exit(1);