My Kernel v0.1.0
Collaboration diagram for Networking:

Modules

 Layer 3 - Address Resolution Protocol (ARP)
 TCP/IP Illustrated Vol I - Chapter 4 - ARP RFC 826
 
 Layer 2 - Ethernet
 
 Network Interfaces
 
 Layer 3 - Internet Protocol (IPv4)
 TCP/IP Illustrated Vol I - Chapter 5 - IP RFC 791
 
 Packet
 
 BSD Sockets
 Berkley Sockets implementation.
 

Macros

#define hton(_x)
 Convert an interger to its network representation (big endian)
 
#define ntoh(_x)
 Convert an interger from its network representation to that of the host.
 

Functions

u16 net_internet_checksum (const u16 *addr, size_t size)
 Compute Internet Checksum for size bytes beginning at location addr. More...
 

Detailed Description

Networking

This is the core of the kernel's networking API.

The goal for this API is to follow the OSI model's philosophy and organize things in a hierarchical manner.

There should be one sub-api for each "protocol" of each layer. These functions should only interact with THEIR part of the packet, and call the lower/higher layer API's function to process the next part of the packet.

For example, when sending a TCP packet over ethernet, the codepath should look like so:

packet = packet_new() // create a new packet
tcp_packet_fill(packet) // responsible for adding L4 info
-> ipv4_packet_fill(packet) // same for L3
-> ethernet_packet_fill(packet) // same for L2
struct packet * packet_new(size_t packet_size)
Create a new packet.
Definition: packet.c:8
error_t packet_send(struct packet *packet)
Send the packet.
Definition: packet.c:56
A network packet.
Definition: packet.h:51
Warning
All fields and values inside the network API's structures are in big endian (the standard network endianness). Do not forget to use the ntoh and hton functions when comparing with variables that use the architecture's natural alignment.

Important structures/concepts

TODO: Networking

Function Documentation

◆ net_internet_checksum()

u16 net_internet_checksum ( const u16 *  addr,
size_t  size 
)
See also
RFC1071 - 4.1

Compute Internet Checksum for size bytes beginning at location addr.