Documentation ¶
Index ¶
- Variables
- func PrettyAST(ast *JSONRule) string
- func PrettyASTGroup(ast *JSONGroup) string
- func ToJSON(rule string) (string, error)
- func ToJSONGroup(group string) (string, error)
- type Action
- type Bucket
- type Filter
- type JSONGroup
- type JSONRule
- type Meta
- type Stream
- func (s *Stream) ParseActionBody(act *Action, isFirst bool) error
- func (s *Stream) ParseGroup(result *JSONGroup) error
- func (s *Stream) ParseRule(result *JSONRule) error
- func (s *Stream) ParseRuleAction(result *JSONRule) error
- func (s *Stream) ParseRuleEq(result *JSONRule, stack []*Meta, lhs string) error
- func (s *Stream) ParseRuleSep(result *JSONRule, stack []*Meta) error
- type Token
Constants ¶
This section is empty.
Variables ¶
var TokenNames = []string{
"NT",
"EOF",
"TEXT",
"SPACE",
"COMMA",
"EQUAL",
"CPAR",
}
TokenNames is the array of printable names for Token.
Functions ¶
func PrettyAST ¶
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 ¶
PrettyASTGroup gives back a string from a AST
The syntax is close to the one used by OVS but without the quirks.
func ToJSON ¶
ToJSON transforms a string representing an openflow rule in a string that is the encoding of the rule.got
func ToJSONGroup ¶
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 ¶
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
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream represents a text buffer that can be scanned
func (*Stream) ParseActionBody ¶
ParseActionBody reads the arguments of an action using parenthesis.
func (*Stream) ParseGroup ¶
ParseGroup is the main entry point for the group parser.
func (*Stream) ParseRuleAction ¶
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 ¶
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.)