feat(parsing/sources): adding the target parsing part
This commit is contained in:
parent
c50154379c
commit
8fb5ab6f12
1 changed files with 34 additions and 0 deletions
34
parsing/sources/target.c
Normal file
34
parsing/sources/target.c
Normal 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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue