Annotation of embedaddon/hping2/statistics.c, revision 1.1.1.1

1.1       misho       1: /* 
                      2:  * $smu-mark$ 
                      3:  * $name: statistics.c$ 
                      4:  * $author: Salvatore Sanfilippo <antirez@invece.org>$ 
                      5:  * $copyright: Copyright (C) 1999 by Salvatore Sanfilippo$ 
                      6:  * $license: This software is under GPL version 2 of license$ 
                      7:  * $date: Fri Nov  5 11:55:50 MET 1999$ 
                      8:  * $rev: 8$ 
                      9:  */ 
                     10: 
                     11: #include <stdlib.h>
                     12: #include <stdio.h>
                     13: 
                     14: #include "hping2.h"
                     15: #include "globals.h"
                     16: 
                     17: void   print_statistics(int signal_id)
                     18: {
                     19:        unsigned int lossrate;
                     20: 
                     21: #if (defined OSTYPE_LINUX) && (!defined FORCE_LIBPCAP)
                     22:        close_sockpacket(sockpacket);
                     23: #else
                     24:        close_pcap();
                     25: #endif /* OSTYPE_LINUX && !FORCE_LIBPCAP */
                     26: 
                     27:        if (recv_pkt > 0)
                     28:                lossrate = 100 - ((recv_pkt*100)/sent_pkt);
                     29:        else
                     30:                if (!sent_pkt)
                     31:                        lossrate = 0;
                     32:                else
                     33:                        lossrate = 100;
                     34: 
                     35:        fprintf(stderr, "\n--- %s hping statistic ---\n", targetname);
                     36:        fprintf(stderr, "%d packets tramitted, %d packets received, "
                     37:                        "%d%% packet loss\n", sent_pkt, recv_pkt, lossrate);
                     38:        if (out_of_sequence_pkt)
                     39:                fprintf(stderr, "%d out of sequence packets received\n",
                     40:                        out_of_sequence_pkt);
                     41:        fprintf(stderr, "round-trip min/avg/max = %.1f/%.1f/%.1f ms\n",
                     42:                rtt_min, rtt_avg, rtt_max);
                     43: 
                     44:        /* manage exit code */
                     45:        if (opt_tcpexitcode)
                     46:        {
                     47:                exit(tcp_exitcode);
                     48:        }
                     49:        else
                     50:        {
                     51:                if (recv_pkt)
                     52:                        exit(0);
                     53:                else
                     54:                        exit(1);
                     55:        }
                     56: };

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>