mirror of
https://github.com/soypat/lneto.git
synced 2026-08-12 19:03:42 +00:00
add ipv6 to xnet.StackAsync (#107)
* add ipv6 to xnet.StackAsync * dns improvements * improve DNS workings of StackAsync * add tentative ICMPv6 * work on prefixes and fix some small bugs, plan UDP/TCP6 * fix bugs in StackAsync and ipv4.Prefix.Contains * update arpsubtable * completely remove legacy internet.StackIP for StackIPv4/v6 * ipv4/ipv6 tcp/udp * add TCP6/UDP6 dialing APIs * add xnet.Stack6 interface * more ipv6 integration into StackAsync; various tweaks to lneto and documentation+TODOs * add stack6 tests * replace netip.Prefix with ipv4.Prefix where it makes sense
This commit is contained in:
+13
-13
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
func TestBasicStack(t *testing.T) {
|
||||
rng := rand.New(rand.NewSource(1))
|
||||
var sbCl, sbSv StackIP
|
||||
var sbCl, sbSv StackIPv4
|
||||
var connCl, connSv tcp.Conn
|
||||
setupClientServer(t, rng, &sbCl, &sbSv, &connCl, &connSv)
|
||||
var buf [2048]byte
|
||||
@@ -37,13 +37,13 @@ func TestBasicStack(t *testing.T) {
|
||||
|
||||
func TestBasicStack2(t *testing.T) {
|
||||
rng := rand.New(rand.NewSource(1))
|
||||
var sbCl, sbSv StackIP
|
||||
var sbCl, sbSv StackIPv4
|
||||
var connCl, connSv tcp.Conn
|
||||
setupClientServerEstablished(t, rng, &sbCl, &sbSv, &connCl, &connSv)
|
||||
|
||||
}
|
||||
|
||||
func expectExchange(t *testing.T, from, to *StackIP, buf []byte) {
|
||||
func expectExchange(t *testing.T, from, to lneto.StackNode, buf []byte) {
|
||||
t.Helper()
|
||||
n, err := from.Encapsulate(buf, 0, 0)
|
||||
if err != nil {
|
||||
@@ -58,13 +58,13 @@ func expectExchange(t *testing.T, from, to *StackIP, buf []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
func setupClientServerEstablished(t *testing.T, rng *rand.Rand, client, server *StackIP, connClient, connServer *tcp.Conn) {
|
||||
func setupClientServerEstablished(t *testing.T, rng *rand.Rand, client, server *StackIPv4, connClient, connServer *tcp.Conn) {
|
||||
t.Helper()
|
||||
setupClientServer(t, rng, client, server, connClient, connServer)
|
||||
testClientServerEstablish(t, client, server, connClient, connServer)
|
||||
}
|
||||
|
||||
func testClientServerEstablish(t *testing.T, client, server *StackIP, connClient, connServer *tcp.Conn) {
|
||||
func testClientServerEstablish(t *testing.T, client, server lneto.StackNode, connClient, connServer *tcp.Conn) {
|
||||
t.Helper()
|
||||
var buf [2048]byte
|
||||
nextToSend := client
|
||||
@@ -93,7 +93,7 @@ func testClientServerEstablish(t *testing.T, client, server *StackIP, connClient
|
||||
|
||||
func TestBasicStack6(t *testing.T) {
|
||||
rng := rand.New(rand.NewSource(1))
|
||||
var sbCl, sbSv StackIP
|
||||
var sbCl, sbSv StackIPv6
|
||||
var connCl, connSv tcp.Conn
|
||||
setupClientServer6(t, rng, &sbCl, &sbSv, &connCl, &connSv)
|
||||
var buf [2048]byte
|
||||
@@ -119,13 +119,13 @@ func TestBasicStack6(t *testing.T) {
|
||||
|
||||
func TestBasicStack6Established(t *testing.T) {
|
||||
rng := rand.New(rand.NewSource(1))
|
||||
var sbCl, sbSv StackIP
|
||||
var sbCl, sbSv StackIPv6
|
||||
var connCl, connSv tcp.Conn
|
||||
setupClientServer6(t, rng, &sbCl, &sbSv, &connCl, &connSv)
|
||||
testClientServerEstablish(t, &sbCl, &sbSv, &connCl, &connSv)
|
||||
}
|
||||
|
||||
func setupClientServer6(t *testing.T, rng *rand.Rand, client, server *StackIP, connClient, connServer *tcp.Conn) {
|
||||
func setupClientServer6(t *testing.T, rng *rand.Rand, client, server *StackIPv6, connClient, connServer *tcp.Conn) {
|
||||
t.Helper()
|
||||
_ = rng
|
||||
const maxNodes = 1
|
||||
@@ -134,10 +134,10 @@ func setupClientServer6(t *testing.T, rng *rand.Rand, client, server *StackIP, c
|
||||
clip6 := netip.AddrFrom16([16]byte{0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2}) // 2001:db8::2
|
||||
svip := netip.AddrPortFrom(svip6, 80)
|
||||
clip := netip.AddrPortFrom(clip6, 1337)
|
||||
if err := server.Reset(new(lneto.Validator), 0, maxNodes); err != nil {
|
||||
if err := server.Reset(new(lneto.Validator), maxNodes); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := client.Reset(new(lneto.Validator), 0, maxNodes); err != nil {
|
||||
if err := client.Reset(new(lneto.Validator), maxNodes); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
server.SetAddr6(svip6.As16())
|
||||
@@ -172,14 +172,14 @@ func setupClientServer6(t *testing.T, rng *rand.Rand, client, server *StackIP, c
|
||||
}
|
||||
}
|
||||
|
||||
func setupClientServer(t *testing.T, rng *rand.Rand, client, server *StackIP, connClient, connServer *tcp.Conn) {
|
||||
func setupClientServer(t *testing.T, rng *rand.Rand, client, server *StackIPv4, connClient, connServer *tcp.Conn) {
|
||||
const maxNodes = 1
|
||||
bufsize := 2048
|
||||
// Ensure buffer sizes are OK with reused buffers.
|
||||
svip := netip.AddrPortFrom(netip.AddrFrom4([4]byte{192, 168, 1, 0}), 80)
|
||||
clip := netip.AddrPortFrom(netip.AddrFrom4([4]byte{192, 168, 1, 1}), 1337)
|
||||
server.Reset(new(lneto.Validator), maxNodes, 0)
|
||||
client.Reset(new(lneto.Validator), maxNodes, 0)
|
||||
server.Reset(new(lneto.Validator), maxNodes)
|
||||
client.Reset(new(lneto.Validator), maxNodes)
|
||||
server.SetAddr4(svip.Addr().As4())
|
||||
client.SetAddr4(clip.Addr().As4())
|
||||
err := connServer.Configure(tcp.ConnConfig{
|
||||
|
||||
Reference in New Issue
Block a user