add ethernet tx FCS to StackAsyncConfig

This commit is contained in:
soypat
2026-01-29 19:14:40 +01:00
parent 360628f1b8
commit c518b7e7fe
+18 -10
View File
@@ -53,14 +53,15 @@ type StackAsync struct {
}
type StackConfig struct {
StaticAddress netip.Addr
DNSServer netip.Addr
NTPServer netip.Addr
Hostname string
MaxTCPConns int
RandSeed int64
HardwareAddress [6]byte
MTU uint16
StaticAddress netip.Addr
DNSServer netip.Addr
NTPServer netip.Addr
Hostname string
MaxTCPConns int
RandSeed int64
HardwareAddress [6]byte
MTU uint16
EthernetTxCRC32Update func(crc uint32, b []byte) uint32
}
func (s *StackAsync) Hostname() string {
@@ -91,7 +92,6 @@ func (s *StackAsync) Reset(cfg StackConfig) error {
s.mu.Lock()
defer s.mu.Unlock()
mac := cfg.HardwareAddress
mtu := cfg.MTU
addr := cfg.StaticAddress
s.prng = uint32(cfg.RandSeed)
if s.prng == 0 {
@@ -104,7 +104,15 @@ func (s *StackAsync) Reset(cfg StackConfig) error {
return errors.New("IPv6 unsupported as of yet")
}
const linkNodes = 2 // ARP and IP nodes
err := s.link.Reset6(mac, ethernet.BroadcastAddr(), int(mtu), linkNodes)
ecfg := internet.StackEthernetConfig{
MTU: int(cfg.MTU),
MaxNodes: linkNodes,
MAC: mac,
Gateway: ethernet.BroadcastAddr(),
AppendCRC32: cfg.EthernetTxCRC32Update != nil,
CRC32Update: cfg.EthernetTxCRC32Update,
}
err := s.link.Configure(ecfg)
if err != nil {
return err
}