14#include <aquila/socket.h>
17#define ETHER_TYPE_IPV4 0x0800
18#define ETHER_TYPE_ARP 0x0806
41#define IP_PROTO_ICMP 1
43#define IP_PROTO_UDP 17
60#define ICMP_ECHO_REPLY 0
62#define ICMP_ECHO_REQUEST 8
64#define ICMP_UNREACH_HOST 1
65#define ICMP_UNREACH_PORT 3
int ether_output(struct netif *netif, const uint8_t dst[6], uint16_t type, struct netbuf *nb)
Sends a frame: adds its Ethernet header and gives it to the interface.
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...
void inet_sockaddr_put(struct sockaddr *addr, socklen_t *len, uint32_t ip, uint16_t port)
Writes an AF_INET address, cut to *len bytes if it doesn't fit.
int inet_ifioctl(int request, void *argp)
Handles an interface ioctl() request on an AF_INET socket.
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.
struct netif * ipv4_route(uint32_t dst)
Chooses the interface to send a packet to dst through: the one whose link it is on,...
void arp_update(struct netif *netif, uint32_t ip, const uint8_t mac[6])
Records an address's hardware address, replacing the oldest entry if the table is full,...
int arp_resolve(struct netif *netif, uint32_t ip, struct netbuf *nb)
Holds a packet until the hardware address of its next hop is known, and asks for it.
void ether_input(struct netif *netif, struct netbuf *nb)
Takes in a frame that an interface received, and passes it to ARP or IPv4.
void ipv4_input(struct netif *netif, struct netbuf *nb, const uint8_t src_mac[6])
Takes in an IPv4 packet that an interface received, and passes it to its protocol.
int ipv4_send(uint32_t dst, uint8_t proto, struct netbuf *nb)
Sends a packet to dst, through the interface its route says.
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.
uint16_t inet_checksum_pseudo(uint32_t src, uint32_t dst, uint8_t proto, const void *data, size_t len)
Computes the Internet checksum of data with the IPv4 pseudo-header before it (the addresses,...
uint32_t ipv4_source(struct netif *netif, uint32_t dst)
Chooses the source address of a packet to dst sent through netif.
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.
void udp_input(struct netif *netif, struct netbuf *nb, const struct ipv4_hdr *ih)
Takes in a UDP datagram that IPv4 received, and delivers it to its socket.
int arp_lookup(struct netif *netif, uint32_t ip, uint8_t mac[6])
Looks up an address's hardware address.
void arp_input(struct netif *netif, struct netbuf *nb)
Takes in an ARP packet: the sender's address is recorded, and a request for our address is answered.
int inet_sockaddr_get(const struct sockaddr *addr, socklen_t len, uint32_t *ip, uint16_t *port)
Reads an AF_INET address.
unsigned short int uint16_t
An ARP packet, for IPv4 over Ethernet.
An Ethernet frame's header.
An ICMP message's header.
A network interface (net/netif.c): a device that sends and receives Ethernet frames,...