ArvernOS
Loading...
Searching...
No Matches
net.h File Reference

This module defines network interfaces and drivers. More...

#include <stdbool.h>
#include <stdint.h>
Include dependency graph for net.h:
This graph shows which files directly or indirectly include this file:

Data Structures

struct  net_driver_t
 
struct  net_interface_t
 

Functions

void net_interface_init (uint8_t interface_id, net_driver_t *driver, bool prefer_dhcp, uint8_t ip[4], uint8_t gateway_ip[4], uint8_t dns_ip[4])
 
net_interface_t * net_get_interface (uint8_t interface_id)
 

Detailed Description

This module defines network interfaces and drivers.

In this project, a network driver is an abstraction of a physical device, like an Ethernet card for instance. A network driver defines a set of functions to transmit and receive Layer 2 frames.

A network interface bridges a network driver and configuration together. The current configuration that is needed for a network interface is:

  • its MAC address
  • its IPv4 address
  • the IPv4 address of the gateway
  • the IPv4 address of the primary (and only) DNS server

Yep, it is very IP oriented but that's how we can show nice things :)

Function Documentation

◆ net_get_interface()

net_interface_t * net_get_interface ( uint8_t interface_id)

Returns the network interface for the given ID.

Parameters
interface_idan interface ID
Returns
the network interface if it exists, NULL otherwise

◆ net_interface_init()

void net_interface_init ( uint8_t interface_id,
net_driver_t * driver,
bool prefer_dhcp,
uint8_t ip[4],
uint8_t gateway_ip[4],
uint8_t dns_ip[4] )

Initializes a network interface.

When prefer_dhcp is set to true, DHCP is used. If it fails, the static configuration will be used instead.

Parameters
interface_idan interface ID
drivera network driver
prefer_dhcpwhether to use DHCP
ipa static IPv4 address for the host
gateway_ipa static IPv4 address for the gateway
dns_ipa static IPv4 address for the primary DNS server