passive MAC learning and ARP cache revamp (#96)

* begin working on arp cache

* fix little things

* rework arp cache priority

* fix test

* keep working on ARP

* push changes before thinking about ip prefix issue

* add passive peer MAC setting

* patch egress mac with correct ethernet CRCs

* consolidate subnet learning in subnetTable type

* add tests and fix subnet table bug
This commit is contained in:
Pat Whittingslow
2026-04-24 23:34:53 -03:00
committed by GitHub
parent 67c42aa136
commit aa77403a2b
10 changed files with 619 additions and 284 deletions
+9
View File
@@ -39,6 +39,8 @@ type StackEthernet struct {
gwmac [6]byte
mtu uint16
acceptMulticast bool
onSend func(p []byte)
// crcupdate set when crc32 has been configured to be appended.
crcupdate func(crc uint32, p []byte) uint32
}
@@ -63,6 +65,10 @@ func (ls *StackEthernet) HardwareAddr6() [6]byte {
return ls.mac
}
func (ls *StackEthernet) OnEncapsulate(cb func([]byte)) {
ls.onSend = cb
}
// Reset6 resets the stack with the given parameters.
//
// Deprecated: Use [StackEthernet.Configure] instead.
@@ -194,6 +200,9 @@ func (ls *StackEthernet) Encapsulate(carrierData []byte, offsetToIP, offsetToFra
dst[n] = 0
n++
}
if ls.onSend != nil {
ls.onSend(dst[:n])
}
if ls.crcupdate != nil {
crc := ls.crcupdate(0, carrierData[offsetToFrame:offsetToFrame+n])
binary.LittleEndian.PutUint32(carrierData[offsetToFrame+n:], crc)