🏗️」 wip: kinda working

This commit is contained in:
2025-08-15 23:49:43 +02:00
parent 057fb25cf7
commit 162de73a21
5 changed files with 114 additions and 18 deletions

View File

@ -1,10 +1,14 @@
#pragma once
#include "bits/types/struct_timeval.h"
#include "help.h"
#include "opt_parse.h"
#include "netinet/in.h"
#include <help.h>
#include <opt_parse.h>
#include <bits/types/struct_timeval.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/socket.h>
#include <sys/types.h>
extern char *exec_name;
extern int tx_count;
@ -21,6 +25,7 @@ typedef struct {
uint16_t interval;
} options_t;
// TODO: implement the verbose mode !!!
#define DEFAULT_VERBOSE false
#define DEFAULT_SIZE 64
@ -29,4 +34,14 @@ typedef struct {
#define DEFAULT_COUNT -1
#define DEFAULT_LINGER 10
int send_ping(args_t *args);
int send_ping(int socket, struct sockaddr_in *dest, args_t *args);
int init_socket(args_t *args);
void init_packet(char *buf, int seq, uint32_t size);
int send_icmp(int socket, char *buf, struct sockaddr_in *addr, uint32_t size);
int receive_icmp(int socket, char *buf, uint32_t size,
struct sockaddr_in *addr);
void process_icmp(char *buf, int bytes, struct sockaddr_in *addr, int seq,
struct timeval *tv_start, struct timeval *tv_end);
// Internal
unsigned short get_checksum(unsigned short *addr, int count);

View File

@ -1,15 +1,30 @@
#pragma once
void append_time(double time);
#include <ping.h>
#include <sys/types.h>
void append_time(double time);
/**
* @brief Can be used to get the avarage rtt
*/
double get_avg_rtt(void);
/**
* @brief Can be used to get the
* @brief Can be used to get the min rtt
*/
double get_min_rtt(void);
/**
* @brief Can be used to get the max rtt
*/
double get_max_rtt(void);
/**
* @brief Can be used to get the stddev rtt
*/
double get_stddev_rtt(void);
/**
* @brief Can be used to check if the timeout in passed
*/
bool check_for_timeout(struct timeval start, options_t opt);
void print_stats(void);