Max OS 0.3
Loading...
Searching...
No Matches
arp.h
Go to the documentation of this file.
1
9#ifndef MAXOS_NET_ARP_H
10#define MAXOS_NET_ARP_H
11
12#include <cstdint>
13
14#include <net/ipv4.h>
15
16
17namespace MaxOS::net {
18
26 typedef struct PACKED ARPMessage {
27
28 uint16_t hardware_type;
29 uint16_t protocol;
32
33 uint16_t command;
34
35 uint64_t src_mac : 48;
36 uint32_t src_ip;
37 uint64_t dst_mac : 48;
38 uint32_t dst_ip;
39
40
41 } arp_message_t;
42
48
49 private:
51 InternetProtocolHandler* internet_protocol_handler;
52 common::OutputStream* error_messages;
53
54 public:
55 AddressResolutionProtocol(EthernetFrameHandler* ethernet_frame_handler, InternetProtocolHandler* internet_protocol_handler, common::OutputStream* error_messages);
57
58 bool handle_ethernetframe_payload(uint8_t* etherframe_payload, uint32_t size) final;
59
62 void store(InternetProtocolAddress internet_protocol_address, drivers::ethernet::MediaAccessControlAddress media_access_control_address) final;
63 };
64
65}
66
67
68#endif //MAXOS_NET_ARP_H
A stream that strings can be written to.
Stores the left, top, width and height of a rectangle.
Definition rectangle.h:22
Handles ARP requests and replies.
Definition arp.h:47
void request_mac_address(InternetProtocolAddress address)
Request the MAC address of a given IP address.
Definition arp.cpp:95
drivers::ethernet::MediaAccessControlAddress resolve(InternetProtocolAddress address) final
Get the MAC address from an IP via ARP.
Definition arp.cpp:128
void store(InternetProtocolAddress internet_protocol_address, drivers::ethernet::MediaAccessControlAddress media_access_control_address) final
store a mapping of an IP address to a MAC address.
Definition arp.cpp:155
bool handle_ethernetframe_payload(uint8_t *etherframe_payload, uint32_t size) final
Called when an ARP packet is received.
Definition arp.cpp:41
Handles incoming Ethernet Frames and routes them to the appropriate payload handlers.
Handles a specific type of Ethernet Frame payload.
Resolves IP addresses to MAC addresses.
Definition ipv4.h:53
Handles IPv4 packets over Ethernet frames.
Definition ipv4.h:85
uint64_t MediaAccessControlAddress
Used to make MAC addresses more readable.
Definition ethernet.h:21
Defines classes and structures for handling Internet Protocol version 4 (IPv4) packets.
uint32_t InternetProtocolAddress
An IPv4 address.
Definition ipv4.h:18
An ARP message.
Definition arp.h:26
uint16_t hardware_type
The type of device that sent the ARP message (1 = Ethernet)
Definition arp.h:28
uint64_t src_mac
The MAC address of the sender.
Definition arp.h:35
uint16_t protocol
The protocol being used (0x0800 = IPv4)
Definition arp.h:29
uint8_t protocol_address_size
The size of the protocol address (4 for IPv4)
Definition arp.h:31
uint32_t dst_ip
The IP address of the target.
Definition arp.h:38
uint16_t command
The ARP command (1 = request, 2 = reply)
Definition arp.h:33
uint8_t hardware_address_size
The size of the hardware address (6 for MAC)
Definition arp.h:30
uint32_t src_ip
The IP address of the sender.
Definition arp.h:36
uint64_t dst_mac
The MAC address of the target.
Definition arp.h:37