checksum

package
v0.0.0-...-5166d26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2024 License: Apache-2.0, MIT Imports: 3 Imported by: 41

Documentation

Overview

Package checksum provides the implementation of the encoding and decoding of network protocol headers.

Index

Constants

View Source
const Size = 2

Size is the size of a checksum.

The checksum is held in a uint16 which is 2 bytes.

Variables

This section is empty.

Functions

func Checksum

func Checksum(buf []byte, initial uint16) uint16

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

func Combine(a, b uint16) uint16

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

func Put(b []byte, xsum uint16)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL