diff --git a/parsing/sources/target.c b/parsing/sources/target.c new file mode 100644 index 0000000..43762b6 --- /dev/null +++ b/parsing/sources/target.c @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* target.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/30 12:09:48 by rparodi #+# #+# */ +/* Updated: 2026/03/30 12:33:54 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "macro.h" +#include +#include +#include +#include +#include +#include +#include + +void check_target(const char *target) { + struct addrinfo hints = {0}, *res; + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_RAW; + hints.ai_protocol = IPPROTO_ICMP; + + int err = getaddrinfo(target, NULL, &hints, &res); + if (err != 0) { + ERROR_LOG("ft_ping: unknown host"); + exit(EXIT_FAILURE); + } + freeaddrinfo(res); +}