ft_ping/parsing/sources/target.c

34 lines
1.4 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* target.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/03/30 12:09:48 by rparodi #+# #+# */
/* Updated: 2026/03/30 12:33:54 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "macro.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
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);
}