package checksum
import "gvisor.dev/gvisor/pkg/tcpip/checksum"
Package checksum provides the implementation of the encoding and decoding of network protocol headers.
Index ¶
- Constants
- func Checksum(buf []byte, initial uint16) uint16
- func Combine(a, b uint16) uint16
- func Put(b []byte, xsum uint16)
- type Checksumer
Constants ¶
const Size = 2
Size is the size of a checksum.
The checksum is held in a uint16 which is 2 bytes.
Functions ¶
func Checksum ¶
Checksum calculates the checksum (as defined in RFC 1071) of the bytes in the given byte array. This function uses an optimized version of the checksum algorithm.
The initial checksum must have been computed on an even number of bytes.
func Combine ¶
Combine combines the two uint16 to form their checksum. This is done by adding them and the carry.
Note that checksum a must have been computed on an even number of bytes.
func Put ¶
Put puts the checksum in the provided byte slice.
Types ¶
type Checksumer ¶
type Checksumer struct {
// contains filtered or unexported fields
}
Checksumer calculates checksum defined in RFC 1071.
func (*Checksumer) Add ¶
func (c *Checksumer) Add(b []byte)
Add adds b to checksum.
func (*Checksumer) Checksum ¶
func (c *Checksumer) Checksum() uint16
Checksum returns the latest checksum value.
Source Files ¶
checksum.go checksum_unsafe.go
- Version
- v0.0.0-20250529234927-c8952f75963b (latest)
- Published
- May 29, 2025
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 1 day ago –
Tools for package owners.