My Kernel v0.1.0
arp.h
Go to the documentation of this file.
1
13#ifndef KERNEL_NET_ARP_H
14#define KERNEL_NET_ARP_H
15
16#include <kernel/net/ethernet.h>
17#include <kernel/net/ipv4.h>
18
20#define ARP_PACKET_SIZE \
21 (sizeof(struct ethernet_header) + sizeof(struct arp_header))
22
29 __be uint16_t hw_type;
30 __be uint16_t prot_type;
31 uint8_t hw_length;
32 uint8_t prot_length;
33 __be uint16_t operation;
35 __be ipv4_t src_ip;
37 __be ipv4_t dst_ip;
38};
39
43};
44
49};
50
56static inline size_t arp_header_size(struct arp_header *hdr)
57{
58 return sizeof(*hdr);
59}
60
65 error_t arp_add(__be ipv4_t, mac_address_t);
66
71const mac_address_t *arp_get(__be ipv4_t);
72
74error_t arp_receive_packet(struct packet *);
75
77error_t arp_send_packet(struct arp_header *);
78
79#endif /* KERNEL_NET_ARP_H */
80
arp_hw_type
The different accepted types of hardware addresses.
Definition: arp.h:41
error_t arp_add(__be ipv4_t, mac_address_t)
Add a new entry inside the ARP table.
Definition: arp.c:60
error_t arp_receive_packet(struct packet *)
Handle a received ARP packet.
Definition: arp.c:105
static size_t arp_header_size(struct arp_header *hdr)
Compute the size of an ARP header.
Definition: arp.h:56
arp_operation
The different ARP operations.
Definition: arp.h:46
error_t arp_send_packet(struct arp_header *)
Send an ARP request/reply.
Definition: arp.c:87
const mac_address_t * arp_get(__be ipv4_t)
Retreive the MAC address associated with an IPv4 address.
Definition: arp.c:48
@ ARP_HW_ETHERNET
Ethernet MAC address.
Definition: arp.h:42
@ ARP_REPLY
Reply. Sent back to the sender if a match was found.
Definition: arp.h:48
@ ARP_REQUEST
Request. Sent first to try and find a MAC address.
Definition: arp.h:47
uint8_t mac_address_t[ETHERNET_ADDR_SIZE]
Represents an ethernet MAC address.
Definition: ethernet.h:29
IPv4 - Internet Protocol.
Structure of the page fault's error code https://wiki.osdev.org/Exceptions#Page_Fault.
Definition: mmu.c:587
An ARP header.
Definition: arp.h:28
__be ipv4_t dst_ip
Recipient's protocol address.
Definition: arp.h:37
mac_address_t src_mac
Sender's hardware address.
Definition: arp.h:34
uint8_t hw_length
Hardware address length.
Definition: arp.h:31
__be uint16_t operation
Definition: arp.h:33
__be ipv4_t src_ip
Sender's protocol address.
Definition: arp.h:35
uint8_t prot_length
Protocol address length.
Definition: arp.h:32
__be uint16_t hw_type
Hardware Address type.
Definition: arp.h:29
mac_address_t dst_mac
Recipient's hardware address (or broadcast)
Definition: arp.h:36
__be uint16_t prot_type
Protocol address type.
Definition: arp.h:30
A network packet.
Definition: packet.h:51