- match = flowRe.match(line)
- if not match:
- OVELog("Could not decode flow record '"+line+"'. Abandoning")
- return retVal
- else:
- tunnel, inport, vlan, pcp, srcmac, destmac, type, proto, tos, srcip, destip, srcport, destport, packets, bytes, used, actions = match.groups()
- tunnel = int(tunnel)
- inport = int(inport)
- vlan = int(vlan)
- type = cls.ETHERTYPE_TRANS.get(type, type)
- proto = cls.ETHERPROTO_TRANS.get(proto, proto)
- srcport = int(srcport)
- destport = int(destport)
- packets = long(packets)
- bytes = long(bytes)
- # Order below needs to match that in flowDecodeHeadings
- retVal.append((type, proto, inport, vlan, srcmac, destmac, srcip, destip, srcport, destport, packets, bytes, used, tos, pcp, tunnel, actions))
+ fields = {}
+ for name, val in re.findall(r'([a-zA-Z0-9_+]+)\(([^)]+)\)', line):
+ if '=' in val:
+ for setting in val.split(','):
+ k,v = setting.split('=')
+ fields['%s.%s' % (name, k)] = v
+ else:
+ fields[name] = val
+ for setting in re.split(', ', line)[1:]:
+ if ':' in setting:
+ k,v = setting.split(':')
+ fields[k] = v
+
+ tun_id = fields.get('tun_id', '')
+ in_port = int(fields.get('in_port', 0))
+ eth_src = fields.get('eth.src', '')
+ eth_dst = fields.get('eth.dst', '')
+ vlan_vid = int(fields.get('vlan.vid', 0))
+ vlan_pcp = int(fields.get('vlan.pcp', 0))
+ eth_type = fields.get('eth_type', '')
+ ip_src = fields.get('ipv4.src', fields.get('ipv6.src', ''))
+ ip_dst = fields.get('ipv4.dst', fields.get('ipv6.dst', ''))
+ ip_proto = fields.get('ipv4.proto', fields.get('ipv6.proto', ''))
+ ip_tos = fields.get('ipv4.tos', fields.get('ipv6.tos', ''))
+ tp_src = fields.get('tcp.src', fields.get('udp.src', fields.get('arp.sip', fields.get('icmp.type', fields.get('icmpv6.type', '')))))
+ tp_dst = fields.get('tcp.dst', fields.get('udp.dst', fields.get('arp.tip', fields.get('icmp.code', fields.get('icmpv6.code', '')))))
+
+ packets = fields.get('packets', '')
+ bytes = fields.get('bytes', '')
+ actions = fields.get('actions', '')
+ used = fields.get('used', '')
+
+ # Order below needs to match that in flowDecodeHeadings
+ retVal.append((eth_type, ip_proto, in_port, vlan_vid, eth_src, eth_dst, ip_src, ip_dst, tp_src, tp_dst, packets, bytes, used, ip_tos, vlan_pcp, tun_id, actions))