stack

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: GPL-3.0 Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package stack provides multi-layer protocol stack decoding engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encapsulate

func Encapsulate(lib *protocol.Library, layers []struct {
	Protocol string
	Fields   map[string]any
}) ([]byte, error)

Encapsulate wraps data in multiple protocol layers.

Types

type Engine

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

Engine is the multi-layer protocol stack decoder.

func NewEngine

func NewEngine(lib *protocol.Library) *Engine

NewEngine creates a new stack engine with default rules.

func (*Engine) AddRule

func (e *Engine) AddRule(r Rule)

AddRule adds a dispatch rule.

func (*Engine) Decode

func (e *Engine) Decode(startProtocol string, data []byte) ([]Layer, error)

Decode decodes multiple protocol layers from raw data.

type Layer

type Layer struct {
	Protocol string         `json:"protocol"`
	Fields   map[string]any `json:"fields"`
	Bytes    int            `json:"bytes_read"`
}

Layer represents a decoded protocol layer.

type Rule

type Rule struct {
	Field string `json:"field"`
	Value any    `json:"value"`
	Next  string `json:"next_protocol"`
}

Rule defines a protocol dispatch rule.

Jump to

Keyboard shortcuts

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