feat(parsing/sources): adding the target parsing part

This commit is contained in:
Raphael 2026-03-30 14:03:58 +02:00
parent c50154379c
commit 8fb5ab6f12
No known key found for this signature in database

34
parsing/sources/target.c Normal file
View file

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 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);
}