From 4e23ebe167c2cdbacfaf55e0d5f4bd82aea570b7 Mon Sep 17 00:00:00 2001 From: ecpvint Date: Fri, 21 Jun 2024 07:49:53 +0800 Subject: [PATCH] optimization --- ars.h | 2 +- hping2.h | 2 +- release.h | 4 ++-- statistics.c | 25 ++++++++++++------------- waitpacket.c | 16 ++++++++-------- 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/ars.h b/ars.h index 4e32f05..5b923f3 100644 --- a/ars.h +++ b/ars.h @@ -381,7 +381,7 @@ struct ars_layer_info { }; /* ARS layer info table */ -struct ars_layer_info ars_linfo[ARS_TYPE_SIZE]; +//struct ars_layer_info ars_linfo[ARS_TYPE_SIZE]; /* ARS interface managment structure and defines */ #define ARS_IF_UP (1 << 0) diff --git a/hping2.h b/hping2.h index 7947032..3a4f3a3 100644 --- a/hping2.h +++ b/hping2.h @@ -409,7 +409,7 @@ struct delaytable_element { int status; }; -volatile struct delaytable_element delaytable[TABLESIZE]; +//volatile struct delaytable_element delaytable[TABLESIZE]; /* protos */ void nop(void); /* nop */ diff --git a/release.h b/release.h index a7e1586..a62821b 100644 --- a/release.h +++ b/release.h @@ -11,8 +11,8 @@ #ifndef _RELEASE_H #define _RELEASE_H -#define RELEASE_VERSION "3.0.0-koszik" -#define RELEASE_DATE "Sun Apr 16 07:19:17 CEST 2006" +#define RELEASE_VERSION "3.0.1-koszik" +#define RELEASE_DATE __TIME__ #define CONTACTS "" #endif /* _RELEASE_H */ diff --git a/statistics.c b/statistics.c index b715960..6e72d58 100644 --- a/statistics.c +++ b/statistics.c @@ -18,28 +18,27 @@ void print_statistics(int signal_id) { unsigned int lossrate; - + uint32_t losspack=0; #if (defined OSTYPE_LINUX) && (!defined FORCE_LIBPCAP) close_sockpacket(sockpacket); #else close_pcap(); #endif /* OSTYPE_LINUX && !FORCE_LIBPCAP */ - if (recv_pkt > 0) - lossrate = 100 - ((recv_pkt*100)/sent_pkt); - else - if (!sent_pkt) - lossrate = 0; - else - lossrate = 100; + if (recv_pkt > 0){ + losspack=(recv_pktttl, (ntohs(ip->frag_off) ? "DF " : ""), (rel_id ? "=+" : "="), ip_id); if (opt_verbose && !opt_quiet) - printf("tos=%x iplen=%u\n", ip->tos, htons(ip->tot_len)); + printf("tos=%x ip长度=%u\n", ip->tos, htons(ip->tot_len)); } static void @@ -233,7 +233,7 @@ log_ipv6(int status, int sequence) { char tmp[1024]; - printf("len=%d ip=%s ttl=%d ", ip_size, inet_ntop(opt_af, &src6, tmp, sizeof(tmp)), + printf("\033[1;35m长度=%d ip=%s ttl=%d ", ip_size, inet_ntop(opt_af, &src6, tmp, sizeof(tmp)), ip6->hoplimit); if (opt_verbose && !opt_quiet) printf("tc=%x flowlabel=%u\n", (ip6->tc1 << 4) | ip6->tc2, (ip6->flowlabel1 << 16) | ip6->flowlabel2); @@ -304,7 +304,7 @@ void log_traceroute(void *packet, int size, int icmp_code) log_icmp_timeexc(inet_ntop(opt_af, &src6, tmp, sizeof(tmp)), icmp_code); } if (retval != -1) - printf(" hoprtt=%.1f ms", rtt); + printf(" hoprtt=%.1f 毫秒", rtt); if (!opt_tr_keep_ttl) src_ttl++; putchar('\n'); @@ -338,7 +338,7 @@ int recv_icmp(void *packet, size_t size) status = rtt(&icmp_seq, 0, &ms_delay); log_ip(status, icmp_seq); - printf("icmp_seq=%d rtt=%.1f ms\n", icmp_seq, ms_delay); + printf("icmp_seq=%d 往返时间=%.2f 毫秒\n", icmp_seq, ms_delay); if (icmp->type == ICMP_TIMESTAMPREPLY) { if ((size - ICMPHDR_SIZE) >= 12) log_icmp_ts(packet+ICMPHDR_SIZE); @@ -416,7 +416,7 @@ int recv_icmp6(void *packet, size_t size) status = rtt(&icmp_seq, 0, &ms_delay); log_ip(status, icmp_seq); - printf("icmp_seq=%d rtt=%.1f ms\n", icmp_seq, ms_delay); + printf("icmp_seq=%d 往返时间=%.2f 毫秒\n", icmp_seq, ms_delay); notrace = 1; return 1; } @@ -480,7 +480,7 @@ int recv_udp(void *packet, size_t size) status = rtt(&sequence, ntohs(udp.uh_dport), &ms_delay); if (!opt_quiet) { log_ip(status, sequence); - printf("seq=%d rtt=%.1f ms\n", sequence, ms_delay); + printf("seq=%d 往返时间=%.2f 毫秒\n", sequence, ms_delay); } if (opt_incdport && !opt_force_incdport) dst_port++; @@ -545,7 +545,7 @@ int recv_tcp(void *packet, size_t size) if (flags[0] == '\0') strcat(flags, "none"); log_ip(status, sequence); - printf("sport=%d flags=%s seq=%d win=%d rtt=%.1f ms\n", + printf("源端口=%d 标志=%s seq=%d win=%d 往返时间=%.2f 毫秒\n", ntohs(tcp.th_sport), flags, sequence, ntohs(tcp.th_win), ms_delay);