My Kernel v0.1.0
Collaboration diagram for Network Interfaces:

Data Structures

struct  net_interface
 A network interface. More...
 
struct  subnet
 An interface subnet. More...
 

Functions

struct net_interfacenet_interface_new (struct ethernet_device *, const char *)
 Create a new network interface.
 
error_t net_interface_add_subnet (struct net_interface *, __be ipv4_t, uint8_t cidr)
 Add a new subnet to a network interface.
 
const struct subnetnet_interface_find_subnet (__be ipv4_t)
 Find the first subnet that contains the specified address. More...
 
struct net_interfacenet_interface_find (__be ipv4_t)
 Find the interface by source IP address.
 

Detailed Description

Interfaces

Network interfaces are a layer just above the network device, used for packet routing. It associates subnets to network devices, allowing us to retreive which network device should be used depending on the destination address.

An interface can correspond to only ONE network device, but can have multiple subnet masks.

Routing - Subnet

A subnet is used to match the destination IP when sending a packet.

Each subnet contains a source IP, and a subnet mask. If the destination is in the subnet's range, then its source IP is used as the packet's source address and the packet is sent through the subnet's containing interface's network device.

Function Documentation

◆ net_interface_find_subnet()

const struct subnet * net_interface_find_subnet ( __be  ipv4_t)
Returns
The matching subnet or NULL