「✨」 feat: added the verbose mode
This commit is contained in:
@ -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,
|
||||
|
Reference in New Issue
Block a user