maccontrol

package
v0.778.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package maccontrol decodes IEEE 802.3 MAC Control frames (EtherType 0x8808) — the Ethernet flow-control and EPON access-control sublayer. Its two flow-control opcodes are recognised L2 denial-of-service surfaces and so join the project's L2-attack decoder family (internal/dtp, vtp, vqp, gxrp, stp):

  • PAUSE (802.3x, opcode 0x0001): a frame to 01:80:c2:00:00:01 tells the upstream port to stop sending for pause_time × 512 bit-times. A flood of PAUSE frames with the maximum quanta (0xFFFF) is the classic switch-port flow-control DoS — it can stall the port indefinitely.
  • PFC / Priority-based Flow Control (802.1Qbb, opcode 0x0101): the per-priority version used in lossless datacenter fabrics (RoCE / FCoE); a PFC storm causes head-of-line blocking and can collapse a converged fabric.

The remaining opcodes are EPON MPCP (Multi-Point Control Protocol): GATE / REPORT / REGISTER_REQ / REGISTER / REGISTER_ACK, the time-slot grant + discovery handshake of an Ethernet PON.

Wrap-vs-native judgement

Native. A MAC Control frame is a 2-byte opcode followed by a small
fixed, opcode-specific body (a pause time, a PFC class-enable vector
+ eight times, or an MPCP timestamp + fields). A byte-field read +
an opcode switch; stdlib only, no new go.mod dep.

Verifiable / no confidently-wrong output

Every opcode body was verified field-for-field against scapy's
MACControl layer (scapy.contrib.mac_control). MAC Control frames are
padded to the 60-byte minimum Ethernet payload; the decoder reads
only the defined opcode fields and reports any non-zero trailing
bytes rather than guessing at them. An unknown opcode is named by
number with its body surfaced as raw hex.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PFCClass

type PFCClass struct {
	Class     int  `json:"class"`
	Enabled   bool `json:"enabled"`
	PauseTime int  `json:"pause_time_quanta"`
}

PFCClass is one priority class of an 802.1Qbb PFC frame.

type Result

type Result struct {
	Opcode     int    `json:"opcode"`
	OpcodeName string `json:"opcode_name"`

	// PAUSE (0x0001).
	PauseTimeQuanta *int `json:"pause_time_quanta,omitempty"`

	// PFC (0x0101).
	PFCClasses []PFCClass `json:"pfc_classes,omitempty"`

	// MPCP (0x0002-0x0006).
	Timestamp           *uint32 `json:"timestamp,omitempty"`
	Flags               *int    `json:"flags,omitempty"`
	FlagsName           string  `json:"flags_name,omitempty"`
	PendingGrants       *int    `json:"pending_grants,omitempty"`
	AssignedPort        *int    `json:"assigned_port,omitempty"`
	SyncTime            *int    `json:"sync_time,omitempty"`
	EchoedAssignedPort  *int    `json:"echoed_assigned_port,omitempty"`
	EchoedSyncTime      *int    `json:"echoed_sync_time,omitempty"`
	EchoedPendingGrants *int    `json:"echoed_pending_grants,omitempty"`

	BodyHex string   `json:"body_hex,omitempty"`
	Notes   []string `json:"notes,omitempty"`
}

Result is the decoded view of a MAC Control frame.

func Decode

func Decode(input string) (*Result, error)

Decode parses a MAC Control frame body (the EtherType-0x8808 payload, i.e. the bytes after the Ethernet header) from hex (whitespace / ':' / '-' / '_' separators and a '0x' prefix tolerated).

Jump to

Keyboard shortcuts

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