16#include <aquila/errno.h>
26 if (
len <
sizeof(*icmp) +
sizeof(*ih))
29 size_t hlen = (ih->
ver_ihl & 0xf) * 4;
113 size_t quote = (ih->
ver_ihl & 0xf) * 4 + 8;
118 struct icmp_hdr *icmp = netbuf_put(nb,
sizeof(*icmp) + quote);
125 memcpy(icmp + 1, ih, quote);
static void icmp_unreachable_input(struct netif *netif, struct icmp_hdr *icmp, size_t len)
Handles a "destination unreachable" about a datagram we sent: the UDP socket that sent it gets the er...
uint16_t inet_checksum(const void *data, size_t len)
Computes the Internet checksum (RFC 1071): the ones' complement of the ones' complement sum of the da...
struct inet_sock * inet_sock_find(struct netif *netif, uint8_t proto, uint32_t local, uint16_t port, uint32_t remote, uint16_t remote_port)
Finds the socket that a received datagram is for: a socket connected to its sender first,...
void icmp_input(struct netif *netif, struct netbuf *nb, uint32_t src, uint32_t dst)
Takes in an ICMP message that IPv4 received.
#define ICMP_ECHO_REQUEST
int ipv4_is_local(uint32_t ip)
Says whether an address is one of ours: a loopback address, or an interface's.
void icmp_unreachable(struct netif *netif, const struct ipv4_hdr *ih, int code)
Tells the sender of a datagram that it couldn't get where it was sent.
void inet_sock_error(struct inet_sock *sock, int err)
Gives a socket an error (from ICMP), which its next call reports.
int ipv4_output(struct netif *netif, uint32_t src, uint32_t dst, uint8_t proto, struct netbuf *nb)
Sends a packet through an interface: adds its IPv4 header and sends it to dst, or to the gateway if d...
void inet_sock_deliver(struct inet_sock *sock, struct netbuf *nb)
Queues a received datagram on its socket, and wakes up its readers.
#define ICMP_UNREACH_PORT
void * memcpy(void *dst, const void *src, size_t n)
Copies n bytes; dst and src must not overlap.
void netbuf_free(struct netbuf *nb)
Frees a netbuf.
struct netbuf * netbuf_alloc(void)
Allocates a netbuf, empty, with room for the headers that will be put in front of its data.
An ICMP message's header.
A network interface (net/netif.c): a device that sends and receives Ethernet frames,...
struct netif::@020302303320120142126121344055047003105154122231 stats