31 lines
979 B
C
31 lines
979 B
C
#ifndef ICMP_RECV_H
|
|
#define ICMP_RECV_H
|
|
|
|
#include <netinet/in.h>
|
|
#include <sys/types.h>
|
|
|
|
#include "icmp.h"
|
|
#include "internal/icmp_internal.h"
|
|
|
|
/* Validation helpers */
|
|
int recv_validate_params(struct icmp_handle *h, icmp_callback_t cb);
|
|
int recv_handle_receive_error(struct icmp_handle *h);
|
|
|
|
/* Core receive functions */
|
|
ssize_t recv_receive_packet(int fd, void *buffer, size_t buffer_len,
|
|
struct sockaddr_in *from);
|
|
|
|
int recv_parse_packet(const void *buffer, size_t buffer_len, uint8_t *type,
|
|
uint8_t *code, uint8_t *ttl, struct in_addr *src_addr,
|
|
const void **payload, size_t *payload_len, size_t *ip_hdr_len);
|
|
|
|
/* Reply building */
|
|
void recv_build_reply(icmp_reply_t *reply, uint8_t type, uint8_t code,
|
|
uint8_t ttl, struct in_addr src_addr, const void *payload,
|
|
size_t payload_len, const void *buffer, size_t ip_hdr_len);
|
|
|
|
/* Process single packet */
|
|
void recv_process_single_packet(uint8_t *buffer, ssize_t len,
|
|
icmp_callback_t cb, void *userdata);
|
|
|
|
#endif
|