summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp.go
diff options
context:
space:
mode:
Diffstat (limited to 'packet/bgp.go')
-rw-r--r--packet/bgp.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/packet/bgp.go b/packet/bgp.go
index 86fde0a2..022dcbd5 100644
--- a/packet/bgp.go
+++ b/packet/bgp.go
@@ -2107,18 +2107,25 @@ func flowSpecTcpFlagParser(rf RouteFamily, args []string) (FlowSpecComponentInte
ss = append(ss, v)
}
protos := strings.Join(ss, "|")
- exp := regexp.MustCompile(fmt.Sprintf("^%s ((((%s)\\&)*(%s) )*(((%s)\\&)*(%s)))$", FlowSpecNameMap[FLOW_SPEC_TYPE_TCP_FLAG], protos, protos, protos, protos))
+ exp := regexp.MustCompile(fmt.Sprintf("^%s (not )?(match )?((((%s)\\&)*(%s) )*(((%s)\\&)*(%s)))$", FlowSpecNameMap[FLOW_SPEC_TYPE_TCP_FLAG], protos, protos, protos, protos))
elems := exp.FindStringSubmatch(strings.Join(args, " "))
if len(elems) < 1 {
return nil, fmt.Errorf("invalid flag format")
}
items := make([]*FlowSpecComponentItem, 0)
- for _, v := range strings.Split(elems[1], " ") {
+ op := 0
+ if elems[2] != "" {
+ op |= 0x1
+ }
+ if elems[1] != "" {
+ op |= 0x2
+ }
+ for _, v := range strings.Split(elems[3], " ") {
flag := 0
for _, e := range strings.Split(v, "&") {
flag |= int(TCPFlagValueMap[e])
}
- items = append(items, NewFlowSpecComponentItem(0, flag))
+ items = append(items, NewFlowSpecComponentItem(op, flag))
}
return NewFlowSpecComponent(FLOW_SPEC_TYPE_TCP_FLAG, items), nil
}