![]() |
Max OS 0.3
|
Handles IPv4 packets over Ethernet frames. More...
#include <ipv4.h>
Static Public Member Functions | |
| static uint16_t | checksum (const uint16_t *data, uint32_t length_in_bytes) |
| Creates a checksum for the given data. | |
| 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. | |
| static SubnetMask | create_subnet_mask (uint8_t digit1, uint8_t digit2, uint8_t digit3, uint8_t digit4) |
| Creates a subnet mask from four digits. | |
Protected Member Functions | |
| void | register_ipv_4_address_resolver (IPV4AddressResolver *ipv4_resolver) |
| Registers an IP address resolver. | |
Protected Attributes | |
| common::Map< uint8_t, IPV4PayloadHandler * > | ipv_4_payload_handlers |
| Map of IP protocol numbers to their payload handlers. | |
| IPV4AddressResolver * | resolver = nullptr |
| The IP address resolver. | |
| common::OutputStream * | error_messages |
| Stream to output error messages to. | |
| InternetProtocolAddress | own_internet_protocol_address |
| The IP address of this device. | |
| InternetProtocolAddress | default_gateway_internet_protocol_address |
| The IP address of the default gateway. | |
| SubnetMask | subnet_mask |
| The subnet mask. | |
Protected Attributes inherited from MaxOS::net::EthernetFramePayloadHandler | |
| EthernetFrameHandler * | frame_handler |
| The Ethernet frame handler this payload handler is connected to. | |
| uint16_t | handled_type |
| The Ethernet frame type this handler handles. | |
Friends | |
| class | IPV4AddressResolver |
| InternetProtocolHandler::InternetProtocolHandler | ( | EthernetFrameHandler * | backend, |
| InternetProtocolAddress | own_internet_protocol_address, | ||
| InternetProtocolAddress | default_gateway_internet_protocol_address, | ||
| SubnetMask | subnet_mask, | ||
| common::OutputStream * | error_messages | ||
| ) |
Construct a new Internet Protocol Handler object.
| backend | The backend Ethernet frame handler. |
| own_internet_protocol_address | The IP address of this device. |
| default_gateway_internet_protocol_address | The IP address of the default gateway. |
| subnet_mask | The subnet mask. |
| error_messages | Where to write error messages. |
Definition at line 110 of file ipv4.cpp.
References default_gateway_internet_protocol_address, error_messages, own_internet_protocol_address, and subnet_mask.
|
static |
Creates a checksum for the given data.
| data | The data to create a checksum for. |
| length_in_bytes | The length of the data in bytes. |
Definition at line 249 of file ipv4.cpp.
Referenced by handle_ethernetframe_payload(), MaxOS::net::InternetControlMessageProtocol::handle_internet_protocol_payload(), MaxOS::net::InternetControlMessageProtocol::request_echo_reply(), send_internet_protocol_packet(), and MaxOS::net::TransmissionControlProtocolHandler::send_transmission_control_protocol_packet().
| void InternetProtocolHandler::connect_ipv_4_payload_handler | ( | IPV4PayloadHandler * | ipv_4_payload_handler | ) |
Connects an IP protocol payload handler.
| ipv_4_payload_handler | The payload handler to connect. |
Definition at line 363 of file ipv4.cpp.
References ipv_4_payload_handlers.
Referenced by MaxOS::net::IPV4PayloadHandler::IPV4PayloadHandler().
|
static |
Creates an IP address from four digits.
| digit1 | The first digit. |
| digit2 | The second digit. |
| digit3 | The third digit. |
| digit4 | The fourth digit. |
Definition at line 292 of file ipv4.cpp.
Referenced by create_subnet_mask(), and parse().
|
static |
Creates a subnet mask from four digits.
| digit1 | The first digit. |
| digit2 | The second digit. |
| digit3 | The third digit. |
| digit4 | The fourth digit. |
Definition at line 336 of file ipv4.cpp.
References create_internet_protocol_address().
| InternetProtocolAddress InternetProtocolHandler::get_internet_protocol_address | ( | ) | const |
Gets the IP address of this device.
Definition at line 345 of file ipv4.cpp.
References own_internet_protocol_address.
Referenced by MaxOS::net::TransmissionControlProtocolHandler::connect(), MaxOS::net::UserDatagramProtocolHandler::connect(), MaxOS::net::AddressResolutionProtocol::handle_ethernetframe_payload(), handle_ethernetframe_payload(), MaxOS::net::TransmissionControlProtocolHandler::listen(), MaxOS::net::UserDatagramProtocolHandler::listen(), MaxOS::net::AddressResolutionProtocol::request_mac_address(), and send_internet_protocol_packet().
| MediaAccessControlAddress InternetProtocolHandler::get_media_access_control_address | ( | ) |
Gets the MAC address of this device.
Definition at line 354 of file ipv4.cpp.
References MaxOS::net::EthernetFramePayloadHandler::frame_handler, and MaxOS::net::EthernetFrameHandler::get_mac().
Referenced by MaxOS::net::AddressResolutionProtocol::handle_ethernetframe_payload().
|
overridevirtual |
Called when an IP packet is received.
| ethernetframe_payload | The payload of the IP packet. |
| size | The size of the IP packet. |
Reimplemented from MaxOS::net::EthernetFramePayloadHandler.
Definition at line 130 of file ipv4.cpp.
References checksum(), error_messages, get_internet_protocol_address(), ipv_4_payload_handlers, and MaxOS::common::OutputStream::write().
|
static |
Parses a string representation of an IP address.
| address | The string representation of the IP address. |
Definition at line 306 of file ipv4.cpp.
References create_internet_protocol_address().
|
protected |
Registers an IP address resolver.
| ipv4_resolver | The resolver to register. |
Definition at line 276 of file ipv4.cpp.
References resolver.
Referenced by MaxOS::net::IPV4AddressResolver::IPV4AddressResolver().
| void InternetProtocolHandler::send_internet_protocol_packet | ( | uint32_t | dst_ip_be, |
| uint8_t | protocol, | ||
| const uint8_t * | data, | ||
| uint32_t | size | ||
| ) |
Sends an IP packet.
| dst_ip_be | The destination IP address. |
| protocol | The protocol of the IP packet. |
| data | The payload of the IP packet. |
| size | The size of the IP packet. |
Definition at line 190 of file ipv4.cpp.
References checksum(), default_gateway_internet_protocol_address, MaxOS::net::EthernetFramePayloadHandler::frame_handler, get_internet_protocol_address(), MaxOS::net::EthernetFramePayloadHandler::handled_type, MaxOS::memory::MemoryManager::kfree(), MaxOS::memory::MemoryManager::kmalloc(), own_internet_protocol_address, MaxOS::net::IPV4AddressResolver::resolve(), resolver, MaxOS::net::EthernetFrameHandler::send_ethernet_frame(), and subnet_mask.
Referenced by MaxOS::net::IPV4PayloadHandler::send().
|
friend |
|
protected |
The IP address of the default gateway.
Definition at line 97 of file ipv4.h.
Referenced by InternetProtocolHandler(), and send_internet_protocol_packet().
|
protected |
Stream to output error messages to.
Definition at line 94 of file ipv4.h.
Referenced by handle_ethernetframe_payload(), and InternetProtocolHandler().
|
protected |
Map of IP protocol numbers to their payload handlers.
Definition at line 91 of file ipv4.h.
Referenced by connect_ipv_4_payload_handler(), and handle_ethernetframe_payload().
|
protected |
The IP address of this device.
Definition at line 96 of file ipv4.h.
Referenced by get_internet_protocol_address(), InternetProtocolHandler(), and send_internet_protocol_packet().
|
protected |
The IP address resolver.
Definition at line 93 of file ipv4.h.
Referenced by register_ipv_4_address_resolver(), and send_internet_protocol_packet().
|
protected |
The subnet mask.
Definition at line 98 of file ipv4.h.
Referenced by InternetProtocolHandler(), and send_internet_protocol_packet().