Files
ft_ping/srcs/includes/ft_ping.h
2025-04-25 19:35:48 +02:00

49 lines
837 B
C

#ifndef FT_PING_H
# define FT_PING_H
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <byteswap.h>
#include <fcntl.h>
#define PACKET_DATA_LENGTH 40
#define HELP_MESSAGE " [OPTION...] HOST ...\n\
Send ICMP ECHO_REQUEST packets to network hosts.\n"
typedef struct s_settings
{
char *host;
int count; // -c (--count)
int timeout; // -w (--timeout)
short flood; // -f (--flood)
short no_resolve; //-n (--numeric)
int ttl; // --ttl
short stop;
short err;
} t_settings;
typedef struct s_icmp_echo
{
uint8_t type;
uint8_t code;
uint16_t checksum;
uint16_t identifier;
uint16_t sequence;
struct timeval time;
uint8_t data[40];
} t_icmp_echo;
t_icmp_echo prepare_icmp_echo(uint16_t sequence, uint16_t identifier);
#endif