- if is_ipv4:
- check_ipv4(pkt_recv, src_tun, dst_ip, src_ip, sa_in)
- else:
- check_ipv6(pkt_recv, src_tun, dst_ip, src_ip, sa_in)
+ if rx_pkt_recv.haslayer(ICMPv6ND_NS):
+ # read another packet in the queue if the current one is ICMPv6ND_NS
+ continue
+ else:
+ # otherwise process the current packet
+ break
+
+ check_ip(rx_pkt_recv, ip_layer, src_ip, dst_ip)
+
+ rx_ip_pkt = ip_layer(src=dst_ip, dst=src_ip, proto=61) if ip_layer == IP \
+ else ip_layer(src=dst_ip, dst=src_ip)
+ rx_pkt_send = (Ether(src=rx_dst_mac, dst=rx_src_mac) /
+ rx_ip_pkt)
+
+ rx_txq.send(rx_pkt_send)
+
+ while True:
+ tx_pkt_recv = tx_rxq.recv(2, sent_packets)
+
+ if tx_pkt_recv is None:
+ raise RuntimeError('ESP packet Rx timeout')
+
+ if rx_pkt_recv.haslayer(ICMPv6ND_NS):
+ # read another packet in the queue if the current one is ICMPv6ND_NS
+ continue
+ else:
+ # otherwise process the current packet
+ break
+
+ check_ipsec(tx_pkt_recv, ip_layer, src_tun, dst_ip, src_ip, sa_in)