mirror of
https://github.com/soypat/lneto.git
synced 2026-09-11 00:59:30 +00:00
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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user