l4

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const ErrInvalidChksum common.ErrMsg = "Invalid L4 checksum"
View Source
const (
	UDPLen = 8
)

Variables

This section is empty.

Functions

func CalcCSum

func CalcCSum(h L4Header, addr, pld common.RawBytes) (common.RawBytes, error)

func CheckCSum

func CheckCSum(h L4Header, addr, pld common.RawBytes) error

func SetCSum

func SetCSum(h L4Header, addr, pld common.RawBytes) error

Types

type L4Header

type L4Header interface {
	fmt.Stringer
	L4Type() common.L4ProtocolType
	L4Len() int
	SetPldLen(int)
	GetCSum() common.RawBytes
	SetCSum(common.RawBytes)
	Copy() L4Header
	Write(common.RawBytes) error
	Pack(csum bool) (common.RawBytes, error)
	Validate(plen int) error
	Reverse()
}

type TCP

type TCP struct{}

func (*TCP) String

func (t *TCP) String() string

type UDP

type UDP struct {
	SrcPort  uint16
	DstPort  uint16
	TotalLen uint16
	Checksum common.RawBytes `struct:"[2]byte"`
}

func UDPFromRaw

func UDPFromRaw(b common.RawBytes) (*UDP, error)

func (*UDP) Copy

func (u *UDP) Copy() L4Header

func (*UDP) GetCSum

func (u *UDP) GetCSum() common.RawBytes

func (*UDP) L4Len

func (u *UDP) L4Len() int

func (*UDP) L4Type

func (u *UDP) L4Type() common.L4ProtocolType

func (*UDP) Pack

func (u *UDP) Pack(csum bool) (common.RawBytes, error)

func (*UDP) Parse

func (u *UDP) Parse(b common.RawBytes) error

func (*UDP) Reverse

func (u *UDP) Reverse()

func (*UDP) SetCSum

func (u *UDP) SetCSum(csum common.RawBytes)

func (*UDP) SetPldLen

func (u *UDP) SetPldLen(pldLen int)

func (*UDP) String

func (u *UDP) String() string

func (*UDP) Validate

func (u *UDP) Validate(plen int) error

func (*UDP) Write

func (u *UDP) Write(b common.RawBytes) error

Directories

Path Synopsis
Package mock_l4 is a generated GoMock package.
Package mock_l4 is a generated GoMock package.

Jump to

Keyboard shortcuts

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