Documentation ¶
Index ¶
- Variables
- func Visit(node Node, visitor func(node Node, next func() error) error) error
- type Address
- type AddressMatch
- type AsnRangeMatch
- type Boolean
- type BpsRangeMatch
- type BranchNode
- type ByteRangeMatch
- type CidRangeMatch
- type DirectionalMatchGroup
- type DscpKey
- type DscpMatch
- type DurationRangeMatch
- type EcnKey
- type EcnMatch
- type EtypeKey
- type EtypeMatch
- type Expression
- type FlowDirectionMatch
- type IPTosRangeMatch
- type IcmpMatch
- type IfSpeedRangeMatch
- type InterfaceMatch
- type LocalPrefRangeMatch
- type MedRangeMatch
- type NetsizeRangeMatch
- type NextHopAsnMatch
- type NextHopMatch
- type Node
- type NormalizedMatch
- type Number
- type NumericRange
- type PacketRangeMatch
- type PassesThroughListMatch
- type PortRangeMatch
- type PpsRangeMatch
- type ProtoKey
- type ProtoMatch
- type RangeEnd
- type RegularMatchGroup
- type RemoteCountryMatch
- type RouterMatch
- type RpkiKey
- type RpkiMatch
- type SamplingRateRangeMatch
- type Statement
- type StatusKey
- type StatusMatch
- type String
- type TcpFlagsKey
- type TcpFlagsMatch
- type VrfRangeMatch
Constants ¶
This section is empty.
Variables ¶
var ( EcnMagicMap = map[string]uint64{ "ce": 0b11, "ect1": 0b01, "ect0": 0b10, } EtypeMagicMap = map[string]uint64{ "ipv4": 0x0800, "arp": 0x0806, "ipv6": 0x86DD, } ProtoMagicMap = map[string]uint64{"icmp": 1, "tcp": 6, "udp": 17, "icmpv6": 58, "ipip": 94, "vrrp": 112} StatusMagicMap = map[string]uint64{ "forwarded": 0b01000000, "dropped": 0b10000000, "acldeny": 0b10000001, "acldrop": 0b10000010, "unroutable": 0b10000011, "consumed": 0b11000000, "policerdrop": 0b10001010, } TcpFlagsMagicMap = map[string]uint64{ "fin": 0b000000001, "finack": 0b000010001, "syn": 0b000000010, "rst": 0b000000100, "psh": 0b000001000, "ack": 0b000010000, "urg": 0b000100000, "synack": 0b000010010, "cwr": 0b010000000, "ece": 0b100000000, } DscpMagicMap = map[string]uint64{ "default": 0b000000, } RpkiMagicMap = map[string]uint64{"unknown": 0, "valid": 1, "notfound": 2, "invalid": 3, } )
Functions ¶
Types ¶
type AddressMatch ¶
type AddressMatch struct { BranchNode Address *net.IP `@Address` Mask *Number `( "/" @Number)?` }
type AsnRangeMatch ¶
type AsnRangeMatch struct{ NumericRange }
type BpsRangeMatch ¶
type BpsRangeMatch struct{ NumericRange }
type BranchNode ¶
Branch Nodes have this struct embedded, as these fields can be used to pass evaluation results from children.
type ByteRangeMatch ¶
type ByteRangeMatch struct{ NumericRange }
type CidRangeMatch ¶
type CidRangeMatch struct{ NumericRange }
type DirectionalMatchGroup ¶
type DirectionalMatchGroup struct { BranchNode Direction *String `@Direction?` Address *AddressMatch `( "address" @@` Interface *InterfaceMatch `| ("iface"|"interface") @@` Port *PortRangeMatch `| "port" @@` Asn *AsnRangeMatch `| "asn" @@` Netsize *NetsizeRangeMatch `| "netsize" @@` Cid *CidRangeMatch `| "cid" @@` Vrf *VrfRangeMatch `| "vrf" @@ )` }
Directional Matches: * anything that has further sub commands or accepts fancy data * no direction * several dedicated Match structs for different data types and sub commands
type DscpMatch ¶
type DscpMatch struct { BranchNode Dscp *Number ` @Number` // first 6 bits of iptos DscpKey *DscpKey `| @DscpMagic` }
type DurationRangeMatch ¶
type DurationRangeMatch struct{ NumericRange }
type EcnMatch ¶
type EcnMatch struct { BranchNode Ecn *Number ` @Number` // last 2 bits of iptos EcnKey *EcnKey `| @EcnMagic` }
type EtypeMatch ¶
type EtypeMatch struct { BranchNode Etype *Number ` @Number` EtypeKey *EtypeKey `| @EtypeMagic` }
type Expression ¶
type Expression struct { BranchNode Left *Statement `(@@ (` Conjunction *String `@Conjunction` Right *Expression `@@ )?)?` }
The overall structure of this grammar. Expressions are made up of statements in conjunction with more expressions. A statement consists of any matcher or a subexpression in parenthesis and is optionally negated.
func Parse ¶
func Parse(input string) (*Expression, error)
type FlowDirectionMatch ¶
type FlowDirectionMatch struct { BranchNode FlowDirection *String `@("incoming"|"outgoing")` }
type IPTosRangeMatch ¶
type IPTosRangeMatch struct{ NumericRange }
type IcmpMatch ¶
type IcmpMatch struct { BranchNode Type *Number ` ( "type" @Number )` Code *Number `| ( "code" @Number )` }
type IfSpeedRangeMatch ¶
type IfSpeedRangeMatch struct{ NumericRange }
type InterfaceMatch ¶
type InterfaceMatch struct { BranchNode SnmpId *Number ` ( "id"? @Number )` Name *String `| ( "name" @String )` Description *String `| ( "desc" @String )` Speed *IfSpeedRangeMatch `| ("speed" @@)` }
type LocalPrefRangeMatch ¶
type LocalPrefRangeMatch struct{ NumericRange }
type MedRangeMatch ¶
type MedRangeMatch struct{ NumericRange }
type NetsizeRangeMatch ¶
type NetsizeRangeMatch struct{ NumericRange }
type NextHopAsnMatch ¶
type NextHopAsnMatch struct { BranchNode Asn *uint32 `@Number` }
type NextHopMatch ¶
type NextHopMatch struct { BranchNode Address *net.IP `@Address` }
type Node ¶
type Node interface {
// contains filtered or unexported methods
}
Node is an interface implemented by all AST nodes
type NormalizedMatch ¶
type NormalizedMatch struct { BranchNode Normalized bool `@"normalized"` }
type NumericRange ¶
type NumericRange struct { BranchNode Lower *Number `(@Number` Upper *RangeEnd `"-" @Number) |` Unary *String `( @Unary?` Number *Number ` @Number )` }
type PacketRangeMatch ¶
type PacketRangeMatch struct{ NumericRange }
type PassesThroughListMatch ¶
type PassesThroughListMatch struct { BranchNode Numbers []Number `@Number @Number*` }
type PortRangeMatch ¶
type PortRangeMatch struct{ NumericRange }
type PpsRangeMatch ¶
type PpsRangeMatch struct{ NumericRange }
type ProtoMatch ¶
type ProtoMatch struct { BranchNode Proto *Number ` @Number` ProtoKey *ProtoKey `| @ProtoMagic` }
type RangeEnd ¶
type RangeEnd Number
FIXME: pseudo "negative" Number used by the printer visitor only, for emitting a "-" between children
type RegularMatchGroup ¶
type RegularMatchGroup struct { BranchNode Router *RouterMatch `"router" @@` NextHop *NextHopMatch `| "nexthop" @@` NextHopAsn *NextHopAsnMatch `| "nexthopasn" @@` Bytes *ByteRangeMatch `| "bytes" @@` Packets *PacketRangeMatch `| "packets" @@` RemoteCountry *RemoteCountryMatch `| "country" @@` FlowDirection *FlowDirectionMatch `| "direction"? @@` Normalized *NormalizedMatch `| @@` Duration *DurationRangeMatch `| "duration" @@` Etype *EtypeMatch `| "etype" @@` Proto *ProtoMatch `| "proto" @@` Status *StatusMatch `| "status" @@` TcpFlags *TcpFlagsMatch `| "tcpflags" @@` IPTos *IPTosRangeMatch `| "iptos" @@` Dscp *DscpMatch `| "dscp" @@` Ecn *EcnMatch `| "ecn" @@` SamplingRate *SamplingRateRangeMatch `| "samplingrate" @@` Icmp *IcmpMatch `| "icmp" @@` Bps *BpsRangeMatch `| "bps" @@` Pps *PpsRangeMatch `| "pps" @@` PassesThrough *PassesThroughListMatch `| "passes-through" @@` Med *MedRangeMatch `| "med" @@` LocalPref *LocalPrefRangeMatch `| "localpref" @@` Rpki *RpkiMatch `| "rpki" @@` }
Regular Matches: * anything that has further sub commands or accepts fancy data * no direction * several dedicated Match structs for different data types and sub commands
type RemoteCountryMatch ¶
type RemoteCountryMatch struct { BranchNode CountryCode *String `@CountryCode` }
type RouterMatch ¶
type RouterMatch struct { BranchNode Address *net.IP `@Address` }
type RpkiMatch ¶
type RpkiMatch struct { BranchNode RpkiKey *RpkiKey `@RpkiMagic` }
type SamplingRateRangeMatch ¶
type SamplingRateRangeMatch struct{ NumericRange }
type Statement ¶
type Statement struct { BranchNode Negated *Boolean `@Negation? (` DirectionalMatch *DirectionalMatchGroup ` @@` RegularMatch *RegularMatchGroup `| @@` SubExpression *Expression `| "(" @@ ")" )` }
type StatusMatch ¶
type StatusMatch struct { BranchNode Status *Number ` @Number` StatusKey *StatusKey `| @StatusMagic` }
type TcpFlagsKey ¶
type TcpFlagsKey Number
func (*TcpFlagsKey) Capture ¶
func (o *TcpFlagsKey) Capture(values []string) error
type TcpFlagsMatch ¶
type TcpFlagsMatch struct { BranchNode TcpFlags *Number ` @Number` TcpFlagsKey *TcpFlagsKey `| @TcpFlagsMagic` }
type VrfRangeMatch ¶
type VrfRangeMatch struct{ NumericRange }