MCPcopy Create free account
hub / github.com/encodeous/nylon / checksumValid

Function checksumValid

polyamide/tun/offload_linux.go:388–398  ·  view source on GitHub ↗
(pkt []byte, iphLen, proto uint8, isV6 bool)

Source from the content-addressed store, hash-verified

386}
387
388func checksumValid(pkt []byte, iphLen, proto uint8, isV6 bool) bool {
389 srcAddrAt := ipv4SrcAddrOffset
390 addrSize := 4
391 if isV6 {
392 srcAddrAt = ipv6SrcAddrOffset
393 addrSize = 16
394 }
395 lenForPseudo := uint16(len(pkt) - int(iphLen))
396 cSum := pseudoHeaderChecksumNoFold(proto, pkt[srcAddrAt:srcAddrAt+addrSize], pkt[srcAddrAt+addrSize:srcAddrAt+addrSize*2], lenForPseudo)
397 return ^checksum(pkt[iphLen:], cSum) == 0
398}
399
400// coalesceResult represents the result of attempting to coalesce two TCP
401// packets.

Callers 2

coalesceUDPPacketsFunction · 0.85
coalesceTCPPacketsFunction · 0.85

Calls 2

checksumFunction · 0.70

Tested by

no test coverage detected