Retro Rocket Kernel
BASIC-Powered Operating System
arp.h File Reference
#include "kernel.h"

Data Structures

struct  arp_packet
 
struct  arp_table_entry_t
 

Macros

#define ETHERNET_TYPE_ARP   0x0806
 

Enumerations

enum  arp_packet_type_t { ARP_REQUEST = 1 , ARP_REPLY = 2 }
 

Functions

struct arp_packet __attribute__ ((packed)) arp_packet_t
 
void arp_send_packet (uint8_t *dst_hardware_addr, uint8_t *dst_protocol_addr)
 Send an ARP packet to the ethernet driver. More...
 
int arp_lookup (uint8_t *ret_hardware_addr, uint8_t *ip_addr)
 Lookup a MAC address for an IP address via a blocking ARP request. More...
 
void arp_lookup_add (uint8_t *ret_hardware_addr, uint8_t *ip_addr)
 Cache and ARP entry in the ARP cache. More...
 
void arp_init ()
 Initialise the ARP protocol. More...
 
arp_table_entry_tget_arp_entry (size_t index)
 Get an arp entry object, used by the BASIC interpreter. More...
 
size_t get_arp_table_size ()
 Get the arp table size, used by the BASIC interpreter. More...
 
void arp_prediscover (uint8_t *protocol_addr)
 Precache a local network IP address, to save on doing an ARP lookup later when the user wants to access the resource. Used for the DNS server and gateway addresses. More...
 

Variables

uint16_t hardware_type
 
uint16_t protocol
 
uint8_t hardware_addr_len
 
uint8_t protocol_addr_len
 
uint16_t opcode
 
uint8_t src_hardware_addr [6]
 
uint8_t src_protocol_addr [4]
 
uint8_t dst_hardware_addr [6]
 
uint8_t dst_protocol_addr [4]
 

Detailed Description

Author
Craig Edwards (craig.nosp@m.edwa.nosp@m.rds@b.nosp@m.rain.nosp@m.box.c.nosp@m.c)

Macro Definition Documentation

◆ ETHERNET_TYPE_ARP

#define ETHERNET_TYPE_ARP   0x0806

Enumeration Type Documentation

◆ arp_packet_type_t

Enumerator
ARP_REQUEST 
ARP_REPLY 

Function Documentation

◆ __attribute__()

struct arp_packet __attribute__ ( (packed)  )

◆ arp_init()

void arp_init ( )

Initialise the ARP protocol.

◆ arp_lookup()

int arp_lookup ( uint8_t *  ret_hardware_addr,
uint8_t *  ip_addr 
)

Lookup a MAC address for an IP address via a blocking ARP request.

Parameters
ret_hardware_addrMAC address (filled on return)
ip_addrIP address to request
Returns
int nonzero if ARP request succeeded

◆ arp_lookup_add()

void arp_lookup_add ( uint8_t *  ret_hardware_addr,
uint8_t *  ip_addr 
)

Cache and ARP entry in the ARP cache.

Parameters
ret_hardware_addrMAC address
ip_addrIP address

◆ arp_prediscover()

void arp_prediscover ( uint8_t *  protocol_addr)

Precache a local network IP address, to save on doing an ARP lookup later when the user wants to access the resource. Used for the DNS server and gateway addresses.

◆ arp_send_packet()

void arp_send_packet ( uint8_t *  dst_hardware_addr,
uint8_t *  dst_protocol_addr 
)

Send an ARP packet to the ethernet driver.

Parameters
dst_hardware_addrdestination MAC address
dst_protocol_addrdestination IP address

◆ get_arp_entry()

arp_table_entry_t* get_arp_entry ( size_t  index)

Get an arp entry object, used by the BASIC interpreter.

Parameters
indexindex to find
Returns
arp_table_entry_t* ARP entry

◆ get_arp_table_size()

size_t get_arp_table_size ( )

Get the arp table size, used by the BASIC interpreter.

Returns
size_t the highest index in the ARP cache plus one

Variable Documentation

◆ dst_hardware_addr

uint8_t dst_hardware_addr[6]

◆ dst_protocol_addr

uint8_t dst_protocol_addr[4]

◆ hardware_addr_len

uint8_t hardware_addr_len

◆ hardware_type

uint16_t hardware_type

◆ opcode

uint16_t opcode

◆ protocol

uint16_t protocol

◆ protocol_addr_len

uint8_t protocol_addr_len

◆ src_hardware_addr

uint8_t src_hardware_addr[6]

◆ src_protocol_addr

uint8_t src_protocol_addr[4]