p4gen

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 p4gen provides P4 programmable switch code generation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Header struct {
	Name   string         `json:"name"`
	Fields map[string]int `json:"fields"` // field name → bit width
}

Header represents a P4 header definition.

type Program

type Program struct {
	Protocol string   `json:"protocol"`
	Headers  []Header `json:"headers"`
	Tables   []Table  `json:"tables"`
}

Program represents a P4 program.

func Generate

func Generate(protocol string, fields map[string]int) *Program

Generate generates a P4 program from protocol definition.

func (*Program) Describe

func (p *Program) Describe() string

Describe returns a program description.

func (*Program) ToP4

func (p *Program) ToP4() string

ToP4 generates P4_16 source code.

type Table

type Table struct {
	Name    string   `json:"name"`
	Keys    []string `json:"keys"`
	Actions []string `json:"actions"`
	Size    int      `json:"size"`
}

Table represents a P4 match-action table.

Jump to

Keyboard shortcuts

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