ArvernOS
Loading...
Searching...
No Matches
arp.h File Reference
#include <net/net.h>
#include <stdint.h>
Include dependency graph for arp.h:

Data Structures

struct  arp_packet_t
 

Functions

void arp_request (net_interface_t *interface, uint8_t ip[4])
 
void arp_wait_reply (uint8_t *dst_mac)
 
void arp_receive_packet (net_interface_t *interface, uint8_t *data, uint32_t len)
 

Detailed Description

See also
https://tools.ietf.org/html/rfc826
https://www.saminiir.com/lets-code-tcp-ip-stack-1-ethernet-arp/

The Address Resolution Protocol (ARP) is used for dynamically mapping a local MAC address (Ethernet) to a protocol address (IPv4) by broadcasting a packet to all the machines on the LAN. If one of the machines uses this address, it should send a ARP reply.

This module allows to send a ARP request on a given interface. The current "wait for a response" implementation is not bound to an interface, though, and it is implemented as a busyloop. There is no ARP cache either. Apart from that, it works great!

Function Documentation

◆ arp_receive_packet()

void arp_receive_packet ( net_interface_t * interface,
uint8_t * data,
uint32_t len )

Handles ARP packets that are received on an interface.

Parameters
interfacethe interface that received the ARP packet
datathe data containing the ARP packet
lenthe length of the data

◆ arp_request()

void arp_request ( net_interface_t * interface,
uint8_t ip[4] )

ARP request.

Parameters
interfacethe interface to use to send the ARP request
ipan IPv4 address

◆ arp_wait_reply()

void arp_wait_reply ( uint8_t * dst_mac)

Wait a bit to hopefully get a ARP reply. If a ARP reply is received, the buffer will be updated with the MAC address. Otherwise, the buffer will contain 0 values only.

Parameters
dst_maca pointer to a buffer large enough to receive a MAC address