+def get_flow_info_from_nat_table(flow_info, flow):
+ m_metadata = get_match_metadata(flow)
+ vpnid = None
+ if m_metadata:
+ metadata = m_metadata['metadata']
+ mask = m_metadata['metadata-mask']
+ lport = get_lport_from_metadata(metadata, mask)
+ if lport:
+ flow_info['lport'] = int(lport, 16)
+ vpnid = get_vpnid_from_metadata(metadata, mask)
+ if vpnid:
+ flow_info['vpnid'] = vpnid
+ if not vpnid:
+ w_metadata = get_instruction_writemeta(flow)
+ metadata = w_metadata['metadata']
+ mask = w_metadata['metadata-mask']
+ vpnid = get_vpnid_from_metadata(metadata, mask)
+ if vpnid:
+ flow_info['vpnid'] = vpnid
+ m_ipv4_dest = get_match_ipv4_dest(flow)
+ m_ipv4_src = get_match_ipv4_src(flow)
+ a_set_ipv4_dest = get_act_set_ipv4_dest(flow)
+ a_set_ipv4_src = get_act_set_ipv4_src(flow)
+ m_ether_src = get_match_ether_src(flow)
+ if flow['table_id'] in [25, 27]:
+ if a_set_ipv4_dest:
+ flow_info['int-ip4'] = a_set_ipv4_dest
+ if m_ipv4_dest:
+ flow_info['ext-ip4'] = m_ipv4_dest
+ m_ether_dest = get_match_ether_dest(flow)
+ if m_ether_dest:
+ flow_info['ext-mac'] = m_ether_dest
+ if flow['table_id'] in [26, 28]:
+ if a_set_ipv4_src:
+ flow_info['ext-ip4'] = a_set_ipv4_src
+ if m_ipv4_src:
+ flow_info['int-ip4'] = m_ipv4_src
+ m_ether_src = get_match_ether_src(flow)
+ if m_ether_src:
+ flow_info['ext-mac'] = m_ether_src
+ return flow_info
+
+