19 lines
434 B
C
19 lines
434 B
C
#include "icmp.h"
|
|
#include "icmp_types.h"
|
|
#include <arpa/inet.h>
|
|
#include <stdint.h>
|
|
|
|
int
|
|
icmp_send_echo(icmp_handle_t *h, struct in_addr dest, uint16_t id,
|
|
uint16_t seq, uint8_t ttl)
|
|
{
|
|
union {
|
|
struct { uint16_t id; uint16_t seq; } echo;
|
|
uint32_t raw;
|
|
} hdr_rest;
|
|
|
|
hdr_rest.echo.id = htons(id);
|
|
hdr_rest.echo.seq = htons(seq);
|
|
return icmp_send_raw(h, ICMP_TYPE_ECHO_REQUEST, 0, hdr_rest.raw,
|
|
NULL, 0, dest, ttl);
|
|
}
|