tcp

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package tcp implements the TCP header support in Lucius.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChecksumIPv4

func ChecksumIPv4(tcpHeader, tcpPayload, ipSrc, ipDst []byte) uint

ChecksumIPv4 computes the TCP header checksum for IP4 packets. The checksum is computed over the TCP header, TCP payload and the source and destination IP addresses. A couple of notes: 1. It is assumed that the checksum in the TCP header is already zeroed. 2. The IP addresses can be padded. As the IPv4 addresses are padded, we need to truncate them.

func ChecksumIPv6

func ChecksumIPv6(tcpHeader, tcpPayload, ipSrc, ipDst []byte) uint

ChecksumIPv6 computes the TCP header checksum for IP6 packets. The checksum is computed over the TCP header, TCP payload and the source and destination IP addresses. A couple of notes: 1. It is assumed that the checksum in the TCP header is already zeroed. 2. It is assumed that the IPv6 addresses are the correct padded, we need to truncate them.

Types

type TCP

type TCP struct {
	// contains filtered or unexported fields
}

A TCP represents a TCP header in the packet. It can parse, query and operate on the TCP header (including TCP extensions). However it cannot add a new TCP header to a packet and it cannot interpret, add or remove TCP extensions. All TCP payload is considered OPAQUE.

func (*TCP) Field

func (tcp *TCP) Field(id fwdpacket.FieldID) ([]byte, error)

Field finds bytes within the TCP header.

func (*TCP) Header

func (tcp *TCP) Header() []byte

Header returns the TCP header as a slice of bytes.

func (TCP) ID

ID returns the TCP protocol header ID.

func (TCP) Modify

func (TCP) Modify(fwdpb.PacketHeaderId) error

Modify returns an error as the TCP header does not support adding extensions.

func (*TCP) Rebuild

func (tcp *TCP) Rebuild() error

Rebuild update the TCP header checksum using the update L3. The checksum is computed over the TCP header, the Opaque payload and various IP fields corresponding to the innermost IP header.

func (*TCP) Remove

func (tcp *TCP) Remove(id fwdpb.PacketHeaderId) error

Remove removes the TCP header.

func (TCP) Trailer

func (TCP) Trailer() []byte

Trailer returns the no trailing bytes.

func (*TCP) UpdateField

func (tcp *TCP) UpdateField(id fwdpacket.FieldID, op int, arg []byte) (bool, error)

UpdateField sets bytes within the TCP header.

Jump to

Keyboard shortcuts

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