9#ifndef MAXOS_NET_IPV4_H
10#define MAXOS_NET_IPV4_H
47 class InternetProtocolHandler;
113 static uint16_t
checksum(
const uint16_t* data, uint32_t length_in_bytes);
A stream that strings can be written to.
Stores the left, top, width and height of a rectangle.
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.
virtual void store(InternetProtocolAddress internet_protocol_address, drivers::ethernet::MediaAccessControlAddress media_access_control_address)
Stores an IP address to MAC address mapping. (Default, does nothing, override for use)
virtual drivers::ethernet::MediaAccessControlAddress resolve(InternetProtocolAddress address)
Resolves an IP address to a MAC address. (Default, returns broadcast address, override for use)
Handles the payload of a specific IP protocol.
virtual bool handle_internet_protocol_payload(net::InternetProtocolAddress src_ip_be, net::InternetProtocolAddress dst_ip_be, uint8_t *internetprotocol_payload, uint32_t size)
Called when an IP packet is received. (Deafult, does nothing, overide for use)
void send(InternetProtocolAddress destination_ip, uint8_t *payload_data, uint32_t size)
Sends an IP packet.
uint8_t ip_protocol
The IP protocol this handler handles.
InternetProtocolHandler * internet_protocol_handler
The Internet protocol handler this payload handler is connected to.
Handles IPv4 packets over Ethernet frames.
SubnetMask subnet_mask
The subnet mask.
static SubnetMask create_subnet_mask(uint8_t digit1, uint8_t digit2, uint8_t digit3, uint8_t digit4)
Creates a subnet mask from four digits.
common::OutputStream * error_messages
Stream to output error messages to.
InternetProtocolAddress get_internet_protocol_address() const
Gets the IP address of this device.
common::Map< uint8_t, IPV4PayloadHandler * > ipv_4_payload_handlers
Map of IP protocol numbers to their payload handlers.
void connect_ipv_4_payload_handler(IPV4PayloadHandler *ipv_4_payload_handler)
Connects an IP protocol payload handler.
IPV4AddressResolver * resolver
The IP address resolver.
static InternetProtocolAddress create_internet_protocol_address(uint8_t digit1, uint8_t digit2, uint8_t digit3, uint8_t digit4)
Creates an IP address from four digits.
static InternetProtocolAddress parse(string address)
Parses a string representation of an IP address.
InternetProtocolAddress default_gateway_internet_protocol_address
The IP address of the default gateway.
bool handle_ethernetframe_payload(uint8_t *ethernetframe_payload, uint32_t size) override
Called when an IP packet is received.
void send_internet_protocol_packet(uint32_t dst_ip_be, uint8_t protocol, const uint8_t *data, uint32_t size)
Sends an IP packet.
drivers::ethernet::MediaAccessControlAddress get_media_access_control_address()
Gets the MAC address of this device.
static uint16_t checksum(const uint16_t *data, uint32_t length_in_bytes)
Creates a checksum for the given data.
InternetProtocolAddress own_internet_protocol_address
The IP address of this device.
void register_ipv_4_address_resolver(IPV4AddressResolver *ipv4_resolver)
Registers an IP address resolver.
uint64_t MediaAccessControlAddress
Used to make MAC addresses more readable.
Defines classes for handling Ethernet Frames and their payloads.
uint32_t SubnetMask
A subnet mask.
uint32_t InternetProtocolAddress
An IPv4 address.