1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package flowclass
- import (
- "testing"
- )
- func TestBasicFunctionality(t *testing.T) {
- /*
- Pseudo-Haskell for how I expect this to parse:
- FlowClass
- (SourceClass (Prefix "192.0.2.0/24"))
- (Set DestinationClass [
- (DestinationClass
- (Set Prefix [
- (Prefix "198.51.100.4"),
- (Prefix "203.0.113.208")])
- (IPPInst ICMP Nil)
- )
- (DestinationClass
- (Prefix "198.51.100.1")
- (Set IPPInst [
- (IPPInst TCP
- (TCPParms
- Nil
- (Set Port [(Port 1234), (Port 12345)])
- )
- ),
- (IPPInst UDP (UDPParms Nil (Port 12345)))
- ])
- )
- ])
- */
- str := `
- 192.0.2.0/24 -> {
- {198.51.100.4, 203.0.113.208}:icmp,
- 198.51.100.1 : {
- tcp({1234, 12345}),
- udp(12345),
- },
- }`
- fc := new(FlowClass)
- if err := fc.Compile(str); err != nil {
- t.Errorf("failed to compile flowclass: %v", err)
- }
- }
|