|
Retro Rocket Kernel
BASIC-Powered Operating System
|
#include "kernel.h"Data Structures | |
| union | ip_frag |
| Structure and bitfields for representing IP fragmentation. Used within an ip_packet_t. More... | |
| union | tos_flags |
| struct | ip_packet |
| Structure for an IP packet. More... | |
| struct | ip_packet_frag_t |
| struct | ip_fragmented_packet_parts_t |
| struct | packet_queue_item_t |
Macros | |
| #define | ETHERNET_TYPE_IP 0x0800 |
| #define | ETHERNET_TYPE_IP6 0x86DD |
Enumerations | |
| enum | ip_type_t { IP_IPV4 = 4 } |
| IP protocol types. More... | |
| enum | ip_proto_t { PROTOCOL_ICMP = 1 , PROTOCOL_TCP = 6 , PROTOCOL_UDP = 17 } |
| Sub-protocols, TCP and UDP. More... | |
Functions | |
| union ip_frag | __attribute__ ((packed)) ip_frag_t |
| Structure and bitfields for representing IP fragmentation. Used within an ip_packet_t. More... | |
| void | get_ip_str (char *ip_str, const uint8_t *ip) |
| Convert network byte order IP to a string form for display. More... | |
| uint32_t | str_to_ip (const char *ip_str) |
| Convert a string IP to host byte order IP address. More... | |
| uint16_t | ip_calculate_checksum (ip_packet_t *packet) |
| Calculate checksum for IP packet. More... | |
| void | ip_send_packet (uint8_t *dst_ip, void *data, uint16_t len, uint8_t protocol) |
| Send IP packet to the ethernet driver. More... | |
| int | gethostaddr (unsigned char *ip) |
| Get the current IP address. This could be allocated by DHCP or statically. More... | |
| void | sethostaddr (const unsigned char *ip) |
| Set the current IP address. More... | |
| void | setdnsaddr (uint32_t dns) |
| Set DNS address This could be allocated by DHCP or statically. More... | |
| void | setgatewayaddr (uint32_t gateway) |
| Set gateway address This could be allocated by DHCP or statically. More... | |
| uint32_t | getdnsaddr () |
| Get DNS address This could be allocated by DHCP or statically. More... | |
| uint32_t | getgatewayaddr () |
| Get gateway address This could be allocated by DHCP or statically. More... | |
| void | setnetmask (uint32_t nm) |
| Set network mask. More... | |
| uint32_t | getnetmask () |
| Get network mask. More... | |
| void | ip_init () |
| Initialise IP protocol. More... | |
| void | ip_idle () |
| Called from the local APIC timer interrupt 50 times a second. Attempts to resolve ARP requests for queued packets that we don't have ARP for yet, and retries ARP requests up to 3 times before dropping packets we cannot route. More... | |
Variables | |
| uint16_t | bits |
| struct { | |
| uint8_t reserved_zero: 1 | |
| uint8_t dont_fragment: 1 | |
| uint8_t more_fragments_follow: 1 | |
| uint8_t fragment_offset_high: 5 | |
| uint8_t fragment_offset_low: 8 | |
| }; | |
| struct { | |
| uint8_t dscp:6 | |
| uint8_t ecn:2 | |
| }; | |
| char | version_ihl_ptr [0] |
| uint8_t | version |
| uint8_t | ihl |
| tos_flags_t | tos |
| uint16_t | length |
| uint16_t | id |
| char | flags_fragment_ptr [0] |
| ip_frag_t | frag |
| uint8_t | ttl |
| uint8_t | protocol |
| uint16_t | header_checksum |
| uint8_t | src_ip [4] |
| uint8_t | dst_ip [4] |
| uint8_t | options [0] |
| uint8_t | data [] |
| #define ETHERNET_TYPE_IP 0x0800 |
| #define ETHERNET_TYPE_IP6 0x86DD |
| enum ip_proto_t |
| enum ip_type_t |
| union ip_frag __attribute__ | ( | (packed) | ) |
Structure and bitfields for representing IP fragmentation. Used within an ip_packet_t.
Structure for an IP packet.
| void get_ip_str | ( | char * | ip_str, |
| const uint8_t * | ip | ||
| ) |
Convert network byte order IP to a string form for display.
| ip_str | character buffer to fill, should be at least 13 bytes |
| ip | raw 4 byte IP |
| uint32_t getdnsaddr | ( | ) |
Get DNS address This could be allocated by DHCP or statically.
| uint32_t getgatewayaddr | ( | ) |
Get gateway address This could be allocated by DHCP or statically.
| int gethostaddr | ( | unsigned char * | ip | ) |
Get the current IP address. This could be allocated by DHCP or statically.
| ip | IP address buffer, should be at least 4 bytes |
| uint32_t getnetmask | ( | ) |
Get network mask.
| uint16_t ip_calculate_checksum | ( | ip_packet_t * | packet | ) |
Calculate checksum for IP packet.
| packet | IP packet structure |
| void ip_idle | ( | ) |
Called from the local APIC timer interrupt 50 times a second. Attempts to resolve ARP requests for queued packets that we don't have ARP for yet, and retries ARP requests up to 3 times before dropping packets we cannot route.
| void ip_init | ( | ) |
Initialise IP protocol.
| void ip_send_packet | ( | uint8_t * | dst_ip, |
| void * | data, | ||
| uint16_t | len, | ||
| uint8_t | protocol | ||
| ) |
Send IP packet to the ethernet driver.
| dst_ip | IP to send the packet to (255.255.255.255 for broadcast) |
| data | raw IP packet to send |
| len | data length |
| protocol | Sub-protocol encapsulated inside the packet, e.g. UDP, TCP |
| void setdnsaddr | ( | uint32_t | dns | ) |
Set DNS address This could be allocated by DHCP or statically.
| dns | DNS address |
| void setgatewayaddr | ( | uint32_t | gateway | ) |
Set gateway address This could be allocated by DHCP or statically.
| dns | Gateway address |
| void sethostaddr | ( | const unsigned char * | ip | ) |
Set the current IP address.
| ip | 4 byte buffer for IP address |
| void setnetmask | ( | uint32_t | nm | ) |
Set network mask.
| nm | network mask |
| uint32_t str_to_ip | ( | const char * | ip_str | ) |
Convert a string IP to host byte order IP address.
| ip_str | ip as string e.g. "127.0.0.1" |
| struct { ... } |
| struct { ... } |
| uint8_t bits |
| uint8_t data[] |
| uint8_t dont_fragment |
| uint8_t dscp |
| uint8_t dst_ip[4] |
| uint8_t ecn |
| char flags_fragment_ptr[0] |
| ip_frag_t frag |
| uint8_t fragment_offset_high |
| uint8_t fragment_offset_low |
| uint16_t header_checksum |
| uint16_t id |
| uint8_t ihl |
| uint16_t length |
| uint8_t more_fragments_follow |
| uint8_t options[0] |
| uint8_t protocol |
| uint8_t reserved_zero |
| uint8_t src_ip[4] |
| tos_flags_t tos |
| uint8_t ttl |
| uint8_t version |
| char version_ihl_ptr[0] |