Check the header version on arrival and say what the error window actually spans
This commit is contained in:
@@ -11,6 +11,7 @@ const (
|
||||
ethHdrLen = 14
|
||||
hdrLen = 20
|
||||
hdrMagic = 0x43424c54
|
||||
hdrVer = 1
|
||||
minFrame = ethHdrLen + hdrLen
|
||||
maxFrame = 9216
|
||||
|
||||
@@ -138,7 +139,7 @@ func headerCheck(h []byte) uint16 {
|
||||
func putHeader(buf []byte, patIdx int, stream uint16, seq uint64, payLen int) {
|
||||
h := buf[ethHdrLen:]
|
||||
binary.BigEndian.PutUint32(h[0:4], hdrMagic)
|
||||
h[4] = 1
|
||||
h[4] = hdrVer
|
||||
h[5] = byte(patIdx)
|
||||
binary.BigEndian.PutUint16(h[6:8], stream)
|
||||
binary.BigEndian.PutUint64(h[8:16], seq)
|
||||
@@ -176,6 +177,11 @@ func parseHeader(buf []byte) (parsed, hdrStatus) {
|
||||
if binary.BigEndian.Uint16(h[hdrCheckOff:]) != headerCheck(h) {
|
||||
return p, hdrDamaged
|
||||
}
|
||||
// Both halves are the same build, so the only way this differs is a checksum
|
||||
// that happened to agree over damaged bytes.
|
||||
if h[4] != hdrVer {
|
||||
return p, hdrDamaged
|
||||
}
|
||||
p.patIdx = int(h[5])
|
||||
p.stream = binary.BigEndian.Uint16(h[6:8])
|
||||
p.seq = binary.BigEndian.Uint64(h[8:16])
|
||||
|
||||
Reference in New Issue
Block a user