Max OS 0.3
Loading...
Searching...
No Matches
ethernetframe.h
Go to the documentation of this file.
1
11#ifndef MAXOS_NET_ETHERNETFRAME_H
12#define MAXOS_NET_ETHERNETFRAME_H
13
14#include <cstdint>
15#include <common/map.h>
18
19
20namespace MaxOS::net {
21
29 typedef struct PACKED EthernetFrameHeader {
30
31 uint64_t destination_mac : 48;
32 uint64_t source_mac : 48;
33
34 uint16_t type;
35
36 } ethernet_frame_header_t;
37
45 typedef struct PACKED EthernetFrameFooter {
46
47 uint32_t checksum;
48
49 } ethernet_frame_footer_t;
50
51 class EthernetFrameHandler;
52
58 friend class EthernetFrameHandler;
59
60 protected:
62 uint16_t handled_type;
63
64 public:
67
68 virtual bool handle_ethernetframe_payload(uint8_t* ethernetframe_payload, uint32_t size);
69 void send(uint64_t destination, uint8_t* data, uint32_t size);
70 };
71
94}
95
96
97#endif //MAXOS_NET_ETHERNETFRAME_H
A stream that strings can be written to.
Stores the left, top, width and height of a rectangle.
Definition rectangle.h:22
Handles the events that are triggered by the Ethernet Driver.
Definition ethernet.h:73
Driver for the Ethernet Controller, manages the sending and receiving of data, the mac address,...
Definition ethernet.h:89
Handles incoming Ethernet Frames and routes them to the appropriate payload handlers.
void send_ethernet_frame(uint64_t destination_mac, uint16_t frame_type, uint8_t *data, uint32_t size)
send an packet via the backend driver
void connect_handler(EthernetFramePayloadHandler *handler)
connect a handler to the frame handler
drivers::ethernet::MediaAccessControlAddress get_mac()
Get the MAC address of this device.
common::Map< uint16_t, EthernetFramePayloadHandler * > frame_handlers
The map of frame handlers by type.
bool data_received(uint8_t *data, uint32_t size) override
Handle the received packet.
drivers::ethernet::EthernetDriver * ethernet_driver
The driver this frame handler is using.
common::OutputStream * error_messages
The output stream for error messages.
Handles a specific type of Ethernet Frame payload.
~EthernetFramePayloadHandler()
Destroy the EtherFrameHandler:: EtherFrameHandler object, Removes it from the handler list.
void send(uint64_t destination, uint8_t *data, uint32_t size)
send an packet via the backend driver
uint16_t handled_type
The Ethernet frame type this handler handles.
virtual bool handle_ethernetframe_payload(uint8_t *ethernetframe_payload, uint32_t size)
Handle the received ethernet frame payload.
EthernetFrameHandler * frame_handler
The Ethernet frame handler this payload handler is connected to.
Defines an EthernetDriver class for managing Ethernet communication, including sending and receiving ...
uint64_t MediaAccessControlAddress
Used to make MAC addresses more readable.
Definition ethernet.h:21
Defines a Map class for storing key-value pairs.
Defines a MemoryManager class for handling memory allocation and deallocation.
Structure the raw data. This is the footer of an Ethernet Frame.
uint32_t checksum
checksum of the payload
Structure the raw data. This is the header of an Ethernet Frame.
uint64_t destination_mac
The mac address of the target (Big Endian)
uint16_t type
The type (Big Endian) 0x0800 = IPv4, 0x0806 = ARP, 0x86DD = IPv6.
uint64_t source_mac
The mac address of the sender (Big Endian)