fwstate

package
v0.0.0-...-8912547 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckStateExists

func CheckStateExists(
	cpModule *C.struct_cp_module,
	proto layers.IPProtocol,
	srcPort uint16,
	dstPort uint16,
	srcAddr string,
	dstAddr string,
) bool

CheckStateExists checks if a state exists in the fwmap

func GetCurrentTime

func GetCurrentTime() uint64

GetCurrentTime returns current time in nanoseconds

func GetLayerCount

func GetLayerCount(cpModule *C.struct_cp_module) (uint32, uint32)

GetLayerCount returns the number of layers in both IPv4 and IPv6 maps

func GetStateDeadline

func GetStateDeadline(
	cpModule *C.struct_cp_module,
	proto layers.IPProtocol,
	srcPort uint16,
	dstPort uint16,
	srcAddr string,
	dstAddr string,
) uint64

GetStateDeadline returns the deadline of a state entry

func InsertNewLayer

func InsertNewLayer(cpModule *C.struct_cp_module)

InsertNewLayer inserts a new layer using the C API

func TrimStaleLayers

func TrimStaleLayers(cpModule *C.struct_cp_module, now uint64)

TrimStaleLayers trims stale layers using the C API

Types

type CursorResult

type CursorResult struct {
	Idx      uint32
	Proto    uint16
	SrcPort  uint16
	DstPort  uint16
	SrcAddr  uint32
	DstAddr  uint32
	Flags    uint8
	External bool

	CreatedAt   uint64
	UpdatedAt   uint64
	PktForward  uint64
	PktBackward uint64
}

CursorResult holds data from a single cursor entry, copied into Go memory.

type StateValueSnapshot

type StateValueSnapshot struct {
	Found           bool
	External        bool
	FlagsRaw        uint8
	CreatedAt       uint64
	UpdatedAt       uint64
	PacketsForward  uint64
	PacketsBackward uint64
	Deadline        uint64
}

StateValueSnapshot is a Go-side snapshot of a fw_state_value entry.

func GetStateValue

func GetStateValue(
	cpModule *C.struct_cp_module,
	proto layers.IPProtocol,
	srcPort uint16,
	dstPort uint16,
	srcAddr string,
	dstAddr string,
) StateValueSnapshot

GetStateValue reads the raw fw_state_value for a given 5-tuple via layermap_get_value_and_deadline. Returns Found=false if the state does not exist.

type SyncFrameOption

type SyncFrameOption func(*C.struct_fw_state_sync_frame)

SyncFrameOption is a functional option for createSyncFrame

func WithFrameFib

func WithFrameFib(fib uint8) SyncFrameOption

WithFrameFib sets fib (direction marker: 0 = forward, 1 = backward)

func WithFrameFlags

func WithFrameFlags(flags uint8) SyncFrameOption

WithFrameFlags sets raw flags byte in the sync frame. `flags` is a union exposed to cgo as [1]byte, so we write through it directly.

Jump to

Keyboard shortcuts

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