ipv6: StackIP and StackAsync.Addr refactor (#105)

* apply StackIP changes and internet package test passing

* fix tests and examples

* remove old Reset method on StackIP

* use encapsulate for ipv6

* add TCP over IPv6 tests
This commit is contained in:
Pat Whittingslow
2026-05-09 16:11:31 -03:00
committed by GitHub
parent a430f6c40a
commit bdbd38ab44
22 changed files with 609 additions and 357 deletions
+5 -5
View File
@@ -37,7 +37,7 @@ func TestTCPListener_ConcurrentEcho(t *testing.T) {
err := serverStack.Reset(StackConfig{
Hostname: "Server",
RandSeed: seed,
StaticAddress: serverIP,
StaticAddress4: serverIP.As4(),
MaxActiveTCPPorts: numClients,
HardwareAddress: serverMAC,
MTU: MTU,
@@ -75,11 +75,11 @@ func TestTCPListener_ConcurrentEcho(t *testing.T) {
for i := range clientStacks {
clientMAC := [6]byte{0xaa, 0xbb, 0xcc, 0x00, 0x01, byte(i + 1)}
clientIP := netip.AddrFrom4([4]byte{10, 0, 0, byte(i + 10)})
clientIP := [4]byte{10, 0, 0, byte(i + 10)}
err := clientStacks[i].Reset(StackConfig{
Hostname: fmt.Sprintf("Client%d", i),
RandSeed: int64(seed + i + 1),
StaticAddress: clientIP,
StaticAddress4: clientIP,
MaxActiveTCPPorts: 1,
HardwareAddress: clientMAC,
MTU: MTU,
@@ -185,10 +185,10 @@ func routePacketToClient(pkt []byte, clients []StackAsync) {
if len(pkt) < 20+ethernet.MaxOverheadSize { // 20 min IP header
return
}
dstIP := netip.AddrFrom4([4]byte{pkt[30], pkt[31], pkt[32], pkt[33]})
dstIP := [4]byte{pkt[30], pkt[31], pkt[32], pkt[33]}
for i := range clients {
if clients[i].Addr() == dstIP {
if clients[i].Addr4() == dstIP {
clients[i].IngressEthernet(pkt)
return
}