Add ICMPv4 and lneto.StackNode and deprecate internet.StackNode (#65)

* begin adding icmp client

* rely on anon structs

* add tests

* tests passing

* icmp fleshed out

* rework icmp to include ip addr

* rename StackAsync.Demux/Encapsulate to RecvEthernet and SendEthernet

* remove legacy unreachable TCP tests

* remove uses of deprecated internet.StackNode in preference of lneto.StackNode

* documentation

* rename methods to signal no I/O happening
This commit is contained in:
Pat Whittingslow
2026-04-09 09:07:16 -03:00
committed by GitHub
parent 22c7e6c9d8
commit ec44889896
26 changed files with 679 additions and 209 deletions
+4 -4
View File
@@ -159,15 +159,15 @@ func kernelLoop(ctx context.Context, server *StackAsync, clients []StackAsync) {
}
// Process server outgoing -> route to appropriate client based on dest IP.
if n, _ := server.Encapsulate(buf, -1, 0); n > 0 {
if n, _ := server.EgressEthernet(buf); n > 0 {
routePacketToClient(buf[:n], clients)
}
// Process each client outgoing in randomized order.
rng.Shuffle(len(order), func(i, j int) { order[i], order[j] = order[j], order[i] })
for _, idx := range order {
if n, _ := clients[idx].Encapsulate(buf, -1, 0); n > 0 {
server.Demux(buf[:n], 0) // All clients talk to server.
if n, _ := clients[idx].EgressEthernet(buf); n > 0 {
server.IngressEthernet(buf[:n]) // All clients talk to server.
}
}
@@ -184,7 +184,7 @@ func routePacketToClient(pkt []byte, clients []StackAsync) {
for i := range clients {
if clients[i].Addr() == dstIP {
clients[i].Demux(pkt, 0)
clients[i].IngressEthernet(pkt)
return
}
}