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

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