mirror of
https://github.com/soypat/lneto.git
synced 2026-08-21 06:59:04 +00:00
Checksum simplification proposal (#29)
* Simplified checksum calculation and verification * Fixed tests * UDP: using NewBoundedFrame to create a Frame instance limited to the actual frame size. * Minor: renamed some functions * Commented and made more readable consecutive SetCRC calls. * Fixed icmp checksum calculation after rebase * Replaced NewBoundedFrame with explicit validation
This commit is contained in:
+5
-2
@@ -88,6 +88,10 @@ func (i6frm Frame) SetHopLimit(hop uint8) {
|
||||
i6frm.buf[7] = hop
|
||||
}
|
||||
|
||||
func (i6frm Frame) sourceAndDestinationAddr() []byte {
|
||||
return i6frm.buf[8:40]
|
||||
}
|
||||
|
||||
// SourceAddr returns pointer to the sending node unicast IPv6 address in the IP header.
|
||||
func (i6frm Frame) SourceAddr() *[16]byte {
|
||||
return (*[16]byte)(i6frm.buf[8:24])
|
||||
@@ -99,8 +103,7 @@ func (i6frm Frame) DestinationAddr() *[16]byte {
|
||||
}
|
||||
|
||||
func (i6frm Frame) CRCWritePseudo(crc *lneto.CRC791) {
|
||||
crc.Write(i6frm.SourceAddr()[:])
|
||||
crc.Write(i6frm.DestinationAddr()[:])
|
||||
crc.WriteEven(i6frm.sourceAndDestinationAddr())
|
||||
crc.AddUint32(uint32(i6frm.PayloadLength()))
|
||||
crc.AddUint32(uint32(i6frm.NextHeader()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user