🏗️」 wip: wtf is this

This commit is contained in:
2025-08-15 18:11:48 +02:00
parent f71753ffa8
commit 4c6fc1ecb1
11 changed files with 243 additions and 31 deletions

47
src/ping/send_ping.c Normal file
View File

@ -0,0 +1,47 @@
#include "help.h"
#include <opt_parse.h>
#include <ping.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
void sigint(int sig) {
printf("--- %s ping statistics ---", address);
printf("%d packets transmitted, %d packets received, %f%% packet loss",
tx_count, rx_count, (tx_count - rx_count / 2.0) * 100);
printf("round-trip min/avg/max/stddev = %d/%d/%d/%d");
}
options_t init_opt(args_t *args) {
options_t opt;
opt.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 =
args->arg[TIMEOUT] != -1 ? args->arg[TIMEOUT] : DEFAULT_TIMEOUT;
opt.interval =
args->arg[INTERVAL] != -1 ? args->arg[INTERVAL] : DEFAULT_INTERVAL;
opt.linger = args->arg[LINGER] != -1 ? args->arg[LINGER] : DEFAULT_LINGER;
return opt;
}
int send_ping(args_t *args) {
options_t opt = init_opt(args);
struct timeval loop_start;
struct timeval loop_end;
gettimeofday(&loop_start, 0);
while () {
}
return EXIT_SUCCESS;
}