-static void print_host (pingobj_iter_t *iter)
-{
- double latency;
- unsigned int sequence;
- int recv_ttl;
- size_t buffer_len;
- size_t data_len;
- ping_context_t *context;
-
- latency = -1.0;
- buffer_len = sizeof (latency);
- ping_iterator_get_info (iter, PING_INFO_LATENCY,
- &latency, &buffer_len);
-
- sequence = 0;
- buffer_len = sizeof (sequence);
- ping_iterator_get_info (iter, PING_INFO_SEQUENCE,
- &sequence, &buffer_len);
-
- recv_ttl = -1;
- buffer_len = sizeof (recv_ttl);
- ping_iterator_get_info (iter, PING_INFO_RECV_TTL,
- &recv_ttl, &buffer_len);
-
- data_len = 0;
- ping_iterator_get_info (iter, PING_INFO_DATA,
- NULL, &data_len);
-
- context = (ping_context_t *) ping_iterator_get_context (iter);
-
-#if USE_NCURSES
-# define HOST_PRINTF(...) wprintw(main_win, __VA_ARGS__)
-#else
-# define HOST_PRINTF(...) printf(__VA_ARGS__)
-#endif
-
- context->req_sent++;
- if (latency > 0.0)
- {
- context->req_rcvd++;
- context->latency_total += latency;
- context->latency_total_square += (latency * latency);
-
- if ((context->latency_max < 0.0) || (context->latency_max < latency))
- context->latency_max = latency;
- if ((context->latency_min < 0.0) || (context->latency_min > latency))
- context->latency_min = latency;
-
- HOST_PRINTF ("%zu bytes from %s (%s): icmp_seq=%u ttl=%i "
- "time=%.2f ms\n",
- data_len,
- context->host, context->addr,
- sequence, recv_ttl, latency);
- }
- else
- {
- HOST_PRINTF ("echo reply from %s (%s): icmp_seq=%u timeout\n",
- context->host, context->addr,
- sequence);
- }
-
-#if USE_NCURSES
- wrefresh (main_win);
- werase (context->window);
- box (context->window, 0, 0);
- mvwprintw (context->window, /* y = */ 0, /* x = */ 5,
- " %s ping statistics ",
- context->host);
- mvwprintw (context->window, /* y = */ 1, /* x = */ 2,
- "%i packets transmitted, %i received, %.2f%% packet "
- "loss, time %.1fms",
- context->req_sent, context->req_rcvd,
- 100.0 * (context->req_sent - context->req_rcvd) / ((double) context->req_sent),
- context->latency_total);
- if (context->req_rcvd != 0)
- {
- double average;
- double deviation;
-
- average = context_get_average (context);
- deviation = context_get_stddev (context);
-
- mvwprintw (context->window, /* y = */ 2, /* x = */ 2,
- "rtt min/avg/max/sdev = %.3f/%.3f/%.3f/%.3f ms",
- context->latency_min,
- average,
- context->latency_max,
- deviation);
- }
- wrefresh (context->window);
-#endif
-}
-
-static void time_normalize (struct timespec *ts)