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: 0

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