miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Loading...
Searching...
No Matches
syscall_net.c File Reference
#include <miniOS/syscall.h>
#include <miniOS/sched/sched.h>
#include <miniOS/fs/vfs.h>
#include <miniOS/net/net_socket.h>
#include <miniOS/net/lwip_netif.h>
#include <miniOS/net/unix_sock.h>
#include <miniOS/types.h>
#include <string.h>
#include "lwip/udp.h"
#include "lwip/tcp.h"
#include "lwip/raw.h"
#include "lwip/pbuf.h"
#include "lwip/dns.h"
#include "lwip/ip.h"
#include "lwip/ip4_addr.h"
#include "lwip/prot/ip4.h"
#include "lwip/def.h"
#include "syscall_internal.h"
Include dependency graph for syscall_net.c:

Functions

static size_t raw_copy_ipv4_into_ring_slot (net_sock_rx_entry_t *slot, struct pbuf *p)
static err_t sys_tcp_connected_cb (void *arg, struct tcp_pcb *pcb, err_t err)
static err_t sys_tcp_accept_cb (void *arg, struct tcp_pcb *newpcb, err_t err)
static void sys_udp_recv_cb (void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
static u8_t sys_raw_recv_cb (void *arg, struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *addr)
static err_t sys_tcp_recv_cb (void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
int64_t syscall_dispatch_net (uint64_t nr, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5, uint64_t arg6)
void proc_close_all_sockets (struct thread *t)

Variables

static struct tcp_pcb * g_pending_accept_pcb

Function Documentation

◆ proc_close_all_sockets()

void proc_close_all_sockets ( struct thread * t)

proc_close_all_sockets() - Close all open socket file descriptors for a thread. @t: Thread whose sockets should be closed.

Called directly from sched_exit_current() on every exit path (normal SYS_exit, page faults, signals). signal_dispatch() may also call it before sched_exit_current(); the second call is harmless because freed fds have in_use=0 and are silently skipped.

net_sock_free() handles PCB teardown internally (raw_remove/udp_remove/ tcp_abort + null pcb before in_use=0).

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

◆ raw_copy_ipv4_into_ring_slot()

size_t raw_copy_ipv4_into_ring_slot ( net_sock_rx_entry_t * slot,
struct pbuf * p )
static

raw_copy_ipv4_into_ring_slot() - Copy an IPv4 ICMP packet into an rx ring slot.

Assembles the IP header (from ip4_current_header()) plus the ICMP payload from the pbuf into slot->buf. Updates slot->len to the total bytes written. Returns the byte count written (0 on error or if p/slot is NULL).

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

◆ sys_raw_recv_cb()

u8_t sys_raw_recv_cb ( void * arg,
struct raw_pcb * pcb,
struct pbuf * p,
const ip_addr_t * addr )
static

sys_raw_recv_cb() - lwIP RAW receive callback — pure ring producer (D-03).

Delivers every ICMP packet addressed to the local interface into the 2-slot ring without any ID/seq filter. Drops the packet when the ring is full (D-05). Upstream BusyBox ping filters by ID/seq in userspace.

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

◆ sys_tcp_accept_cb()

err_t sys_tcp_accept_cb ( void * arg,
struct tcp_pcb * newpcb,
err_t err )
static
Here is the caller graph for this function:

◆ sys_tcp_connected_cb()

err_t sys_tcp_connected_cb ( void * arg,
struct tcp_pcb * pcb,
err_t err )
static
Here is the caller graph for this function:

◆ sys_tcp_recv_cb()

err_t sys_tcp_recv_cb ( void * arg,
struct tcp_pcb * pcb,
struct pbuf * p,
err_t err )
static

sys_tcp_recv_cb() - lwIP TCP receive callback.

Single-slot semantics (D-05): writes into rx_ring[0] and forces head=0, tail=1. Preserves tcp_recved() flow-control acknowledgement.

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

◆ sys_udp_recv_cb()

void sys_udp_recv_cb ( void * arg,
struct udp_pcb * pcb,
struct pbuf * p,
const ip_addr_t * addr,
u16_t port )
static

sys_udp_recv_cb() - lwIP UDP receive callback.

Single-slot semantics (D-05): writes into rx_ring[0] and forces head=0, tail=1 so net_sock_has_data() returns true. Each callback overwrites the previous entry.

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

◆ syscall_dispatch_net()

int64_t syscall_dispatch_net ( uint64_t nr,
uint64_t arg1,
uint64_t arg2,
uint64_t arg3,
uint64_t arg4,
uint64_t arg5,
uint64_t arg6 )
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ g_pending_accept_pcb

struct tcp_pcb* g_pending_accept_pcb
static