make timeout work, add setcap makefile rule
This commit is contained in:
10
srcs/icmp.c
10
srcs/icmp.c
@ -6,7 +6,7 @@
|
||||
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/24 22:49:22 by tomoron #+# #+# */
|
||||
/* Updated: 2025/08/13 16:35:29 by tomoron ### ########.fr */
|
||||
/* Updated: 2025/08/24 17:08:44 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include "includes/ft_ping.h"
|
||||
@ -63,14 +63,15 @@ t_icmp_echo prepare_icmp_echo(uint16_t sequence, uint16_t identifier)
|
||||
return(packet);
|
||||
}
|
||||
|
||||
t_waitlist *send_icmp(t_settings *set, struct addrinfo *host, uint16_t *seq, struct timeval *last, t_stats *stats)
|
||||
t_waitlist *send_icmp(t_settings *set, struct addrinfo *host, uint16_t *seq, t_stats *stats)
|
||||
{
|
||||
t_icmp_echo packet;
|
||||
t_waitlist *ret;
|
||||
size_t len;
|
||||
|
||||
if(timediff(last) < set->interval)
|
||||
if(timediff(&set->last_send_time) < set->interval)
|
||||
return (0);
|
||||
gettimeofday(&set->last_send_time, 0);
|
||||
packet = prepare_icmp_echo(*seq, set->id);
|
||||
len = sendto(set->socket, &packet, sizeof(t_icmp_echo), MSG_DONTWAIT, host->ai_addr, host->ai_addrlen);
|
||||
if(len == (size_t)-1)
|
||||
@ -79,11 +80,10 @@ t_waitlist *send_icmp(t_settings *set, struct addrinfo *host, uint16_t *seq, str
|
||||
set->err = 1;
|
||||
g_stop = 1;
|
||||
}
|
||||
gettimeofday(last, 0);
|
||||
ret = malloc(sizeof(t_waitlist));
|
||||
if(!ret)
|
||||
return(0);
|
||||
ret->time = *last;
|
||||
ret->time = set->last_send_time;
|
||||
ret->seq = *seq;
|
||||
ret->next = 0;
|
||||
stats->sent++;
|
||||
|
Reference in New Issue
Block a user