jsonof

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2021 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TokenNames = []string{
	"NT",
	"EOF",
	"TEXT",
	"SPACE",
	"COMMA",
	"EQUAL",
	"CPAR",
}

TokenNames is the array of printable names for Token.

Functions

func PrettyAST

func PrettyAST(ast *JSONRule) string

PrettyAST gives back a string from a AST

The syntax is close to the one used by OVS but without the quirks. The most significant differences are: move, load, set_field, enqueue (as regular actions) and fields in learn actions (using := instead of =).

func PrettyASTGroup

func PrettyASTGroup(ast *JSONGroup) string

PrettyASTGroup gives back a string from a AST

The syntax is close to the one used by OVS but without the quirks.

func ToJSON

func ToJSON(rule string) (string, error)

ToJSON transforms a string representing an openflow rule in a string that is the encoding of the rule.got

func ToJSONGroup

func ToJSONGroup(group string) (string, error)

ToJSONGroup transforms a string representing an openflow group in a string that is the encoding of the group.

Types

type Action

type Action struct {
	Action    string    `json:"Function"`            // Action name
	Arguments []*Action `json:"Arguments,omitempty"` // Arguments if it exists
	Key       string    `json:"Key,omitempty"`       // Key for aguments such as k=v
}

Action represents an atomic action in an openflow rule

type Bucket

type Bucket struct {
	ID      uint      `json:"Id"`             // id of bucket
	Meta    []*Meta   `json:"Meta,omitempty"` // anything that is not an action
	Actions []*Action `json:"Actions"`        // action list
}

Bucket is the representation of a bucket in an openflow group

type Filter

type Filter struct {
	Key   string `json:"Key"`            // left hand side
	Value string `json:"Value"`          // right hand side
	Mask  string `json:"Mask,omitempty"` // mask if used
}

Filter is an elementary filter in an openflow rule

type JSONGroup

type JSONGroup struct {
	GroupID uint      `json:"GroupId"`        // id of the group
	Type    string    `json:"Type"`           // group type
	Meta    []*Meta   `json:"Meta,omitempty"` // anything that is not a bucket
	Buckets []*Bucket `json:"Buckets"`        // buckets
	UUID    string    `json:"-"`              // UUID used by skydive
}

JSONGroup is an openflow group ready for JSON export

func ToASTGroup

func ToASTGroup(group string) (*JSONGroup, error)

ToASTGroup transforms a string representing an openflow rule in an abstract syntax tree of the rule

type JSONRule

type JSONRule struct {
	Cookie    uint64    `json:"Cookie"`         // cookie value of the rule
	Table     int       `json:"Table"`          // table containing the rule
	Priority  int       `json:"Priority"`       // priority of rule
	Meta      []*Meta   `json:"Meta,omitempty"` // anything that is not a filter.
	Filters   []*Filter `json:"Filters"`        // all the filter
	Actions   []*Action `json:"Actions"`        // all the actions
	UUID      string    `json:"-"`              // UUID used by skydive
	RawFilter string    `json:"-"`              // Kept to be respawned
}

JSONRule is an openflow rule ready for JSON export

func ToAST

func ToAST(rule string) (*JSONRule, error)

ToAST transforms a string representing an openflow rule in an abstract syntax tree of the rule

type Meta

type Meta struct {
	Key   string `json:"Key"`   // key
	Value string `json:"Value"` // raw value
}

Meta is anything not a filter or an action always as a pair key/value

type Stream

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

Stream represents a text buffer that can be scanned

func NewStream

func NewStream(r io.Reader) *Stream

NewStream returns a new instance of Stream.

func (*Stream) ParseActionBody

func (s *Stream) ParseActionBody(act *Action, isFirst bool) error

ParseActionBody reads the arguments of an action using parenthesis.

func (*Stream) ParseGroup

func (s *Stream) ParseGroup(result *JSONGroup) error

ParseGroup is the main entry point for the group parser.

func (*Stream) ParseRule

func (s *Stream) ParseRule(result *JSONRule) error

ParseRule is the main entry point for the rule parser.

func (*Stream) ParseRuleAction

func (s *Stream) ParseRuleAction(result *JSONRule) error

ParseRuleAction implements the state of the parser while reading an action list. We only expect text separated by commas and ending of EOF.

func (*Stream) ParseRuleEq

func (s *Stream) ParseRuleEq(result *JSONRule, stack []*Meta, lhs string) error

ParseRuleEq implements the state of the rule parser waiting for an equal sign or a break signifying a next block (happens with filter abbreviations like ip, tcp, etc.)

func (*Stream) ParseRuleSep

func (s *Stream) ParseRuleSep(result *JSONRule, stack []*Meta) error

ParseRuleSep implements the state of the parser afer an x=y, a break is expected but it may be either a

type Token

type Token int

Token is a lexical entity

Jump to

Keyboard shortcuts

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