fix make file parsing can get arguments values

This commit is contained in:
2025-04-25 23:08:19 +02:00
parent 77668368ab
commit 149ab9e725
3 changed files with 126 additions and 24 deletions

View File

@ -8,28 +8,44 @@
#include <unistd.h>
#include <arpa/inet.h>
#include <byteswap.h>
#include <ctype.h>
#include <stdlib.h>
#include <fcntl.h>
#define PACKET_DATA_LENGTH 40
#define HELP_MESSAGE " [OPTION...] HOST ...\n\
Send ICMP ECHO_REQUEST packets to network hosts.\n"
Send ICMP ECHO_REQUEST packets to network hosts.\n\
\n\
-c, --count=NUMBER stop after sending NUMBER packets\n\
-n, --numeric do not resolve host addresses\n\
--ttl=N specify N as time-to-live\n\
-w, --timeout=N stop after N seconds\n\
\n\
-f, --flood flood ping (root only)\n\
-?, --help give this help list\n"
typedef struct s_host_list
{
char *host;
struct s_host_list *next;
} t_host_list;
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
t_host_list *hosts;
int count; // -c (--count)
int timeout; // -w (--timeout)
short flood; // -f (--flood)
short no_resolve; //-n (--numeric)
int ttl; // --ttl
short stop;
short err;
short stop;
short err;
} t_settings;
} t_settings;
typedef struct s_icmp_echo
@ -41,7 +57,7 @@ typedef struct s_icmp_echo
uint16_t sequence;
struct timeval time;
uint8_t data[40];
} t_icmp_echo;
} t_icmp_echo;
t_icmp_echo prepare_icmp_echo(uint16_t sequence, uint16_t identifier);