driver.net¶
Layer-1 network interface and protocol stack initialisation.
Overview¶
This unit is the base of the Asuro network stack. It holds the registered transmit and receive callbacks for the single active network interface card, dispatches outgoing frames to the NIC, and passes incoming frames to the registered layer-2 handler. It also initialises all higher protocol layers and provides timestamped logging helpers.
Dependencies¶
driver.net.typesdriver.net.proto.eth2driver.net.proto.arpdriver.net.proto.ipv4driver.net.proto.icmpdriver.net.proto.tcpdriver.net.proto.udpdriver.net.proto.dhcpdriver.timer.rtcsyslog
Functions and Procedures¶
init¶
Initialises all protocol layers in order: ETH2, ARP, IPv4, ICMP, TCP, UDP, DHCP. Must be called once during system startup before any network operation.registerNetworkCard¶
Registers the first NIC that calls in. Stores the send callback and the hardware MAC address. Only the first call has effect; subsequent calls are ignored.registerNextLayer¶
Registers the layer-2 receive handler. Called bydriver.net.proto.eth2 during its initialisation.
send¶
Passes a raw frame to the registered NIC send callback.recv¶
Called by the NIC driver when a frame arrives. Allocates aTPacketContext, fills the data pointer and length, calls the registered NextLayer receive callback, then frees the context.
getMAC¶
Returns the MAC address of the registered NIC.isRegistered¶
Returnstrue if a NIC has been registered via registerNetworkCard.
writeToLog / writeToLogLn¶
Writes a message to the system log prefixed with the current RTC timestamp (HH:MM:SS format).writeToLogLn appends a newline.
Notes¶
- The network stack supports only a single active NIC at a time. Multiple NIC registrations are silently discarded.
TPacketContextis allocated on the heap for each received frame and freed after the receive chain returns; protocol handlers must not retain pointers to the context.