optimization
Some checks are pending
C/C++ CI / build (push) Waiting to run

This commit is contained in:
ecpvint 2024-06-21 07:49:53 +08:00
parent 701987af2c
commit 4e23ebe167
5 changed files with 24 additions and 25 deletions

2
ars.h
View File

@ -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)

View File

@ -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 */

View File

@ -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 "<koszik@atw.hu>"
#endif /* _RELEASE_H */

View File

@ -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)
if (recv_pkt > 0){
losspack=(recv_pkt<sent_pkt)?recv_pkt/sent_pkt:0;
lossrate = 100 - ((recv_pkt*100)/sent_pkt);
else
if (!sent_pkt)
lossrate = 0;
else
lossrate = 100;
}else{
losspack=!sent_pkt?0:sent_pkt;
lossrate=!sent_pkt?0:100;
}
fprintf(stderr, "\n--- %s hping statistic ---\n", targetname);
fprintf(stderr, "%d packets transmitted, %d packets received, "
"%d%% packet loss\n", sent_pkt, recv_pkt, lossrate);
fprintf(stderr, "\n--- %s 统计 ---\n", targetname);
fprintf(stderr, "发送: %d|收到: %d|%d%% 丢包率|丢了 %d 个包\n", sent_pkt, recv_pkt, lossrate,losspack);
if (out_of_sequence_pkt)
fprintf(stderr, "%d out of sequence packets received\n",
fprintf(stderr, "已收到 %d 个乱序数据包\n",
out_of_sequence_pkt);
fprintf(stderr, "round-trip min/avg/max = %.1f/%.1f/%.1f ms\n",
fprintf(stderr, "往返时间:\n最小:%.1f 毫秒\n平均: %.1f 毫秒\n最大:%.1f 毫秒\n",
rtt_min, rtt_avg, rtt_max);
/* manage exit code */

View File

@ -220,12 +220,12 @@ log_ipv4(int status, int sequence)
rel_id = relativize_id(sequence, &ip_id);
else
rel_id = 0;
printf("len=%d ip=%s ttl=%d %sid%s%d ", ip_size, inet_ntoa(src),
printf("\033[1;36m长度=%d ip=%s ttl=%d %sid%s%d ", ip_size, inet_ntoa(src),
ip->ttl,
(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);