Give each stream its own ethertype steered to its own rx queue

This commit is contained in:
flamingcow
2026-07-25 19:08:11 -07:00
parent 0af94219a7
commit 7e77d22f36
4 changed files with 232 additions and 96 deletions
+19 -17
View File
@@ -8,7 +8,7 @@ import (
)
const (
etherType = 0x88b5
etherBase = 0x88b5
ethHdrLen = 14
hdrLen = 24
hdrMagic = 0x43424c54
@@ -75,16 +75,17 @@ func patternIndex(name string) (int, error) {
}
type frameSpec struct {
patIdx int
ref []byte
crcFor map[int]uint32
dstMAC [6]byte
srcMAC [6]byte
sizes []int
maxSize int
patIdx int
ref []byte
crcFor map[int]uint32
dstMAC [6]byte
srcMAC [6]byte
etherType uint16
sizes []int
maxSize int
}
func newFrameSpec(patIdx int, dst, src [6]byte, sizes []int) *frameSpec {
func newFrameSpec(patIdx int, dst, src [6]byte, etherType uint16, sizes []int) *frameSpec {
maxSize := 0
for _, s := range sizes {
if s > maxSize {
@@ -98,20 +99,21 @@ func newFrameSpec(patIdx int, dst, src [6]byte, sizes []int) *frameSpec {
crcFor[s] = crc32.Checksum(ref[:s-minFrame], crcTable)
}
return &frameSpec{
patIdx: patIdx,
ref: ref,
crcFor: crcFor,
dstMAC: dst,
srcMAC: src,
sizes: sizes,
maxSize: maxSize,
patIdx: patIdx,
ref: ref,
crcFor: crcFor,
dstMAC: dst,
srcMAC: src,
etherType: etherType,
sizes: sizes,
maxSize: maxSize,
}
}
func (f *frameSpec) prefill(buf []byte) {
copy(buf[0:6], f.dstMAC[:])
copy(buf[6:12], f.srcMAC[:])
binary.BigEndian.PutUint16(buf[12:14], etherType)
binary.BigEndian.PutUint16(buf[12:14], f.etherType)
copy(buf[minFrame:], f.ref)
}