miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Loading...
Searching...
No Matches
lwip_netif.c File Reference

lwIP netif initialization and poll driver for miniOS. More...

#include <miniOS/net/lwip_netif.h>
#include <miniOS/net/lwip_port.h>
#include <miniOS/net/net_config.h>
#include <string.h>
#include "lwip/init.h"
#include "lwip/dns.h"
#include "lwip/netif.h"
#include "lwip/ip4_addr.h"
#include "lwip/timeouts.h"
#include "lwip/pbuf.h"
#include "lwip/etharp.h"
#include "netif/ethernet.h"
Include dependency graph for lwip_netif.c:

Functions

static err_t miniOS_netif_linkoutput (struct netif *netif, struct pbuf *p)
 linkoutput callback: transmit a pbuf chain via lwip_port_tx().
static err_t miniOS_netif_init (struct netif *netif)
 netif initialization callback called by netif_add().
static void miniOS_lwip_rx_callback (netdev_t *dev, lwip_port_frame_kind_t kind, const void *frame, size_t frame_len, const ethernet_frame_info_t *info, void *ctx)
 RX callback wired into lwip_port_attach().
static void miniOS_lwip_timeout_cb (uint32_t elapsed_ms, void *ctx)
 Timeout callback wired into lwip_port_attach().
void lwip_netif_init (void)
 Initialize lwIP stack and register eth0 netif.
void lwip_netif_poll (void)
 Poll the network interface and drive lwIP timers.

Variables

static struct netif g_lwip_netif

Detailed Description

lwIP netif initialization and poll driver for miniOS.

Bridges the lwip_port Ethernet seam to lwIP's netif layer. Operates in NO_SYS=1 mode — no threading, no tcpip_thread.

Function Documentation

◆ lwip_netif_init()

void lwip_netif_init ( void )

Initialize lwIP stack and register eth0 netif.

Calls lwip_init(), netif_add() with QEMU static IPv4 config from net_config_get_active(), wires the RX callback to ethernet_input(), and calls lwip_port_attach() to connect the Ethernet seam. Must be called after net_observe_init() and before any socket operations.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lwip_netif_poll()

void lwip_netif_poll ( void )

Poll the network interface and drive lwIP timers.

Calls lwip_port_poll() then sys_check_timeouts(). Must be called regularly (every ~10ms) to keep TCP retransmit and ARP aging alive. Also calls lwip_port_poll_timeouts(10) to feed the timeout accumulator.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ miniOS_lwip_rx_callback()

void miniOS_lwip_rx_callback ( netdev_t * dev,
lwip_port_frame_kind_t kind,
const void * frame,
size_t frame_len,
const ethernet_frame_info_t * info,
void * ctx )
static

RX callback wired into lwip_port_attach().

Receives classified Ethernet frames from lwip_port and feeds them into lwIP's ethernet_input() for ARP and IPv4 processing. Unsupported frames (LWIP_PORT_FRAME_UNSUPPORTED) are silently dropped.

T-42-02-01: drops frame when pbuf_alloc returns NULL (pool exhausted). T-42-02-04: NULL ctx guard is defensive; ctx is always &g_lwip_netif.

Here is the caller graph for this function:

◆ miniOS_lwip_timeout_cb()

void miniOS_lwip_timeout_cb ( uint32_t elapsed_ms,
void * ctx )
static

Timeout callback wired into lwip_port_attach().

Called by lwip_port_poll_timeouts() when the elapsed threshold is reached. Drives lwIP's internal timers (TCP retransmit, ARP aging, etc.).

Here is the caller graph for this function:

◆ miniOS_netif_init()

err_t miniOS_netif_init ( struct netif * netif)
static

netif initialization callback called by netif_add().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ miniOS_netif_linkoutput()

err_t miniOS_netif_linkoutput ( struct netif * netif,
struct pbuf * p )
static

linkoutput callback: transmit a pbuf chain via lwip_port_tx().

Flattens the pbuf chain into a contiguous frame buffer before TX. Frames exceeding 1514 bytes (max Ethernet payload) are rejected with ERR_MEM to satisfy threat T-42-02-02 (oversized frame in linkoutput).

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ g_lwip_netif

struct netif g_lwip_netif
static