」 feat: added the verbose mode

This commit is contained in:
2025-08-17 22:30:53 +02:00
parent 3c02e153f7
commit 8c1c83229b
4 changed files with 26 additions and 8 deletions

View File

@ -33,7 +33,7 @@ void sigint(int sig) {
options_t init_opt(args_t *args) {
options_t opt;
opt.verbose = args->opts[VERBOSE] != false ? true : DEFAULT_VERBOSE;
verbose = args->opts[VERBOSE] != false ? true : DEFAULT_VERBOSE;
opt.count = args->arg[COUNT] != -1 ? args->arg[COUNT] : DEFAULT_COUNT;
opt.size = args->arg[SIZE] != -1 ? args->arg[SIZE] : DEFAULT_SIZE;
opt.timeout =
@ -68,10 +68,12 @@ int send_ping(int socket, struct sockaddr_in *dest, options_t opt) {
gettimeofday(&pkt_end, NULL);
if (bytes <= 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
printf("Request timeout for icmp_seq=%d\n", seq);
} else {
fprintf(stderr, "recv failed: %s\n", strerror(errno));
if (verbose) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
printf("Request timeout for icmp_seq=%d\n", seq);
} else {
fprintf(stderr, "recv failed: %s\n", strerror(errno));
}
}
} else
process_icmp(recvbuf, bytes, &addr, seq, &pkt_start,