Skip to content

AROSTCP

Nick Andrews edited this page Mar 6, 2026 · 12 revisions

AROSTCP -- Core Network Stack

This document covers the AmiTCP-derived core network stack: protocols, kernel infrastructure, BSD socket API (slots 1-50), IPv6 support, configuration services, and command-line utilities.

For Roadshow bsdsocket.library extensions (slots 51-138), see Roadshow TODO. For Miami compatibility library, see Miami TODO.

Last updated against codebase: March 2026.


Core Protocol Support -- IMPLEMENTED

Protocol Status Key Files
IPv4 Complete netinet/ip_input.c, ip_output.c, in.c, in_pcb.c
IPv6 Complete netinet6/ip6_input.c, ip6_output.c, in6.c, in6_pcb.c
TCP (v4+v6) Complete netinet/tcp_input.c (2166), tcp_output.c (769), tcp_usrreq.c
UDP (v4+v6) Complete netinet/udp_usrreq.c, netinet6/udp6_usrreq.c
ICMP Complete netinet/ip_icmp.c
ICMPv6 Complete netinet6/icmp6.c (548 lines)
Raw IP (v4+v6) Complete netinet/raw_ip.c
ARP Complete net/sana2arp.c

TCP Congestion Control & Modern Extensions -- IMPLEMENTED

The TCP stack implements modern congestion control algorithms, all enabled by default:

Feature RFC Status Details
SACK (Selective ACK) RFC 2018 Complete Negotiation via TF_SACK_PERMIT, block parsing/generation, MAX_SACK_BLKS limit
NewReno Fast Recovery RFC 3782 Complete Partial ACK detection via snd_recover, TF_IN_FASTRECOV state tracking
ECN (Explicit Congestion Notification) RFC 3168 Complete CE codepoint detection, ECE/CWR handshake, IP ECT(0) marking

Defaults: tcp_do_sack = 1, tcp_do_newreno = 1 (both enabled in tcp_subr.c).

Key implementation points:

  • SACK negotiation occurs during SYN exchange; SACK blocks are generated from the reassembly queue
  • NewReno replaces legacy Reno -- a single packet loss in a window triggers partial ACK handling instead of full slow-start
  • ECN negotiation uses TH_ECE|TH_CWR flags in SYN; congestion-experienced packets trigger ECE signaling to the sender

Network Interface Layer -- IMPLEMENTED

Feature Status Key Files
SANA-II device integration Complete net/if_sana.c, sana2config.c (see note below)
Loopback interface Complete net/if_loop.c
Interface management Complete net/if.c
Routing table (radix tree) Complete net/route.c (611 lines), net/radix.c (710 lines)
PF_ROUTE routing socket Complete net/rtsock.c (886 lines)
BPF (packet capture/filter) Complete net/bpf.c (493 lines), net/bpf_filter.c (401 lines)
Packet filter framework Complete net/pfil.c (147 lines, conditional on ENABLE_PACKET_FILTER)
IP Filter / firewall Complete net/ipfilter.c (566 lines, rule engine, NAT support)

SANA-II Request Allocation: By default, sana2config.c allocates 16 I/O requests per interface (the original AmiTCP value). On non-m68k architectures, SANA2_LARGEREQALLOCS is automatically defined, enabling larger request pools for higher throughput.


BSD Socket API (Slots 1-50) -- IMPLEMENTED

The core bsdsocket.library function table provides 50 slots for standard AmiTCP BSD socket operations. All are fully implemented.

Slot Function Slot Function
1 socket 26 ReleaseCopyOfSocket
2 bind 27 Errno
3 listen 28 SetErrnoPtr
4 accept 29 Inet_NtoA
5 connect 30 inet_addr
6 sendto 31 Inet_LnaOf
7 send 32 Inet_NetOf
8 recvfrom 33 Inet_MakeAddr
9 recv 34 inet_network
10 shutdown 35 gethostbyname
11 setsockopt 36 gethostbyaddr
12 getsockopt 37 getnetbyname
13 getsockname 38 getnetbyaddr
14 getpeername 39 getservbyname
15 IoctlSocket 40 getservbyport
16 CloseSocket 41 getprotobyname
17 WaitSelect 42 getprotobynumber
18 SetSocketSignals 43 Syslog
19 getdtablesize 44 Dup2Socket
20 ObtainSocket 45 sendmsg
21 ReleaseSocket 46 recvmsg
22 ReleaseCopyOfSocket 47 gethostname
23 Errno 48 gethostid
24 SetErrnoPtr 49 SocketBaseTagList
25 ObtainSocket 50 GetSocketEvents

Implementation files: api/amiga_libcalls.c (address conversion), api/gethostnamadr.c (name resolution), api/getxbyy.c (service/protocol/network lookups), kern/uipc_socket.c + uipc_socket2.c (socket core).

SO_REUSEPORT vs SO_REUSEADDR Semantics

BSD-standard behavior is implemented in netinet/in_pcb.c:

  • Multicast addresses: SO_REUSEADDR is treated as SO_REUSEPORT (allows full duplication)
  • Unicast addresses: SO_REUSEPORT required on both sockets for shared binds
  • This matches FreeBSD/macOS semantics; differs from Linux where SO_REUSEADDR alone enables UDP port sharing

IPv6 Control Plane -- IMPLEMENTED

IPPROTO_IPV6 Socket Options -- FUNCTIONAL

ip6_ctloutput() in netinet6/in6_proto.c (lines 261-508) implements real option handling with backing kernel state for both PRCO_SETOPT and PRCO_GETOPT.

  • IPV6_JOIN_GROUP -- calls in6_joingroup_inp() -> in6_addmulti() -> MLD report
  • IPV6_LEAVE_GROUP -- calls in6_leavegroup_inp() -> in6_delmulti() -> MLD done
  • IPV6_MULTICAST_IF -- sets im6o->im6o_multicast_ifp
  • IPV6_MULTICAST_HOPS -- sets im6o->im6o_multicast_hlim (validated 0-255 or -1)
  • IPV6_MULTICAST_LOOP -- sets im6o->im6o_multicast_loop
  • IPV6_V6ONLY -- sets inp->in6p_v6only
  • IPV6_RECVPKTINFO -- sets/clears IN6P_PKTINFO flag
  • IPV6_TCLASS -- sets inp->in6p_tclass
  • IPV6_UNICAST_HOPS -- sets inp->in6p_hops
  • IPV6_HOPLIMIT -- NOT HANDLED (get/set hop limit ancillary data)

NDP (Neighbor Discovery Protocol) -- IMPLEMENTED

Feature Status Key Files
Neighbor Discovery Complete netinet6/nd6.c (1007 lines), nd6_nbr.c (750), nd6_rtr.c (906)
DAD (Duplicate Address Detection) Complete netinet6/nd6.c (nd6_dad_start/timer)
SLAAC (Stateless Auto-config) Complete netinet6/nd6_rtr.c (RA processing, prefix handling)
Router Discovery Complete netinet6/nd6_rtr.c (RS/RA)

IPv6 Multicast -- IMPLEMENTED

Full multicast stack with MLD protocol support.

  • Per-socket IPv6 group membership list (struct ip6_moptions, max 20 groups)
  • Per-interface multicast group table (struct in6_multi linked list, in6_multihead)
  • MLD (Multicast Listener Discovery) -- MLDv1 per RFC 2710 (netinet6/mld6.c, 386 lines)
    • Query/Report/Done message handling
    • Per-group state machine (IDLE/LAZY/SLEEPING/AWAKENING)
    • Report timer with random delay
    • Report suppression on hearing other reports
    • Unsolicited reports on join, Done on leave
    • ff02::1 (all-nodes) exemption per RFC 2710 Section 6
  • SANA-II multicast MAC registration (sana_add_mcast6 / sana_del_mcast6)
  • IPv6 multicast output (ip6_output.c -- interface selection, hop limit, loopback)

IoctlSocket() -- IPv6 Ioctls -- IMPLEMENTED

IPv6 address management ioctls are handled in in6_control():

  • SIOCGIFADDR_IN6 -- get IPv6 interface address
  • SIOCAIFADDR_IN6 -- add/configure IPv6 interface address
  • SIOCDIFADDR_IN6 -- delete IPv6 interface address
  • SIOCGIFDSTADDR_IN6 -- get destination address (point-to-point)
  • SIOCGIFNETMASK_IN6 -- get network mask
  • SIOCGLIFADDR -- enumerate addresses (used by getifaddrs)

Configuration & Services -- IMPLEMENTED

Feature Status Key Files
DHCPv4 client Complete kern/amiga_dhcp.c (external dhclient launcher)
DHCPv6 client Complete kern/amiga_dhcp.c (conditional on INET6 && DHCP6)
Network database Complete kern/amiga_netdb.c
ARexx interface Complete kern/amiga_rexx.c
GUI configuration Complete kern/amiga_gui.c
Logging / debug Complete kern/amiga_log.c, kern/subr_prf.c
RC file configuration Complete kern/amiga_rc.c, amiga_config.c

Firewall Preferences Application -- IMPLEMENTED

A Zune/MUI preferences application at AROS/workbench/prefs/firewall/ provides a GUI for managing IP filter and NAT rules.

Feature Description
Filter rules editor Add, edit, remove, reorder IP filter rules (ipf.rules)
NAT rules editor Add, edit, remove NAT/redirect rules (ipnat.rules)
Sub-window editing Rule parameters edited in separate pop-up windows with Use/Cancel
Theme-aware buttons Probes for THEME:Images/Gadgets/ icons; falls back to text buttons
Locale support Full FlexCat catalog localization (49 string entries)
PrefsEditor subclass Integrates with AROS Prefs framework (Save/Use/Cancel semantics)

Configuration files: Reads/writes ENV:AROSTCP/ipf.rules and ENV:AROSTCP/ipnat.rules, with ENVARC copies for persistence.

Source files: main.c, fweditor.c (MUI editor class), filter.c (filter rule I/O), nat.c (NAT rule I/O), prefsdata.c (orchestration), locale.c, args.c.

Utility Location
arp common/C/arp.c
ifconfig common/C/ifconfig.c
ping common/C/ping.c
route common/C/route.c
netstat common/C/netstat/ (inet, inet6, route, if, mbuf stats)
traceroute common/C/traceroute/
nslookup common/C/nslookup/ (interactive mode)
hostname common/C/hostname.c
resolve common/C/resolve.c
logger common/C/logger.c
whoami common/C/whoami.c
ipf common/C/ipf/ (IP Filter rule management)
ipnat common/C/ipnat/ (NAT rule management)
ip common/C/ip/ (iproute2-style network tool, see below)

The ip Command

The ip utility (v1.0) provides a Linux iproute2-inspired command-line interface for network management on AROS, adapted to the BSD/SANA-II kernel APIs.

Usage: ip [-V] [-s] [-d] [-r] [-f family] [-4|-6|-0] OBJECT [COMMAND]

Object Aliases Description
link l Display/manage network interfaces (flags, MTU, state, link-layer addresses)
addr address, a Display/manage interface addresses (IPv4 + IPv6 with prefix lengths)
route r Display routing tables (parsed from kernel routing messages)
neigh neighbor, n Display neighbor cache (ARP for IPv4, NDP for IPv6)
maddr maddress Display multicast group memberships
mroute Display multicast routing cache
rule ru Policy routing rules (stub -- AROS lacks RPDB)
netns Network namespaces (stub -- AROS lacks namespaces)

Source files: ip.c (main dispatcher), ip_link.c, ip_addr.c, ip_route.c, ip_neigh.c, ip_maddr.c, ip_stub.c, ip_util.c (formatting helpers).


Kernel Source File Reference

kern/ (Core Kernel)

File Description
amiga_main.c Stack initialization & main event loop
uipc_socket.c Socket creation/management core logic
uipc_socket2.c Socket additional operations & queuing
uipc_domain.c Protocol domain/family registration
uipc_mbuf.c Memory buffer (mbuf) allocation & manipulation
kern_malloc.c Kernel memory allocator
kern_subr.c Kernel subroutines (sleep, wakeup, etc.)
kern_synch.c Amiga-specific synchronization primitives
amiga_config.c Configuration file parsing for network setup
amiga_netdb.c Name database (hosts, services) caching
amiga_time.c Time management & timers
amiga_log.c Logging subsystem
amiga_rexx.c ARexx command interface
amiga_dhcp.c DHCP client implementation (v4 + v6)
amiga_cx.c Commodities Exchange interface
amiga_gui.c GUI components for configuration
accesscontrol.c Access control lists
subr_prf.c Printf-style formatting utilities

netinet/ (IPv4 Core)

File Description
in_proto.c IPv4 protocol family/domain initialization
ip_input.c IPv4 packet reception & routing
ip_output.c IPv4 packet transmission & fragmentation
ip_icmp.c ICMP (ping, error messages)
in_pcb.c Protocol control blocks (TCP/UDP connection state)
in_cksum.c IPv4/TCP checksum calculation
in_cksum_sse2.c Optimized SSE2 checksum
in.c IPv4 address utilities & interface configuration
tcp_input.c TCP segment reception & state machine (2166 lines; SACK/NewReno/ECN)
tcp_output.c TCP segment transmission (769 lines; SACK option generation, ECN marking)
tcp_usrreq.c TCP user request processing
tcp_subr.c TCP support routines (511 lines; default enables for SACK/NewReno)
tcp_timer.c TCP retransmit & keepalive timers (314 lines)
tcp_debug.c TCP debug tracing
udp_usrreq.c UDP datagram handling
raw_ip.c Raw IPv4 socket support

netinet6/ (IPv6)

File Description
ip6_input.c IPv6 packet reception & routing (273 lines)
ip6_output.c IPv6 packet transmission, multicast output (298 lines)
in6.c IPv6 address management, ioctls, multicast (788 lines)
in6_pcb.c IPv6 PCB bind/connect/lookup (223 lines)
in6_proto.c IPv6 protocol switch, ip6_ctloutput (512 lines)
in6_cksum.c IPv6 checksum calculation
in6_cksum_sse2.c Optimized SSE2 IPv6 checksum
icmp6.c ICMPv6 echo, parameter problem, time exceeded (548 lines)
nd6.c Neighbor cache, NUD, ND option parsing (1007 lines)
nd6_nbr.c NS/NA processing, DAD (750 lines)
nd6_rtr.c RS/RA processing, SLAAC, prefix management (906 lines)
mld6.c MLDv1 multicast listener discovery (386 lines)
udp6_usrreq.c UDP over IPv6

net/ (Generic Network Layer)

File Description
if.c Network interface management
if_sana.c SANA-II device driver integration
if_loop.c Loopback interface
route.c Routing table management (611 lines)
rtsock.c PF_ROUTE routing socket (886 lines)
radix.c Radix tree for route lookups (710 lines)
raw_cb.c Raw socket control blocks
raw_usrreq.c Raw socket user requests
netisr.c Network interrupt scheduler
sana2arp.c ARP (Address Resolution Protocol)
sana2config.c SANA-II device configuration (16 reqs default; larger with SANA2_LARGEREQALLOCS)
sana2copybuff.c Buffer copying utilities
sana2perror.c SANA-II error reporting
bpf.c Berkeley Packet Filter, packet capture (493 lines)
bpf_filter.c BPF packet filtering VM/interpreter (401 lines)
pfil.c Packet filter hooks framework (147 lines)
ipfilter.c IP packet filtering rules engine (566 lines)

Core Stack Remaining Backlog

  1. Implement IPV6_HOPLIMIT socket option (ancillary data for received hop limit)

Clone this wiki locally