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