- # Check whether received packet contains layers Ether, IP and ICMP
- if ether is None:
- raise RuntimeError('ICMP echo Rx timeout')
+ if ether.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 whether received packet contains layers IP/IPv6 and
+ # ICMP/ICMPv6EchoRequest
+ if encaps_rx:
+ if encaps_rx == 'Dot1q':
+ if not vlan1_rx:
+ vlan1_rx = vlan1
+ if not ether.haslayer(Dot1Q):
+ raise RuntimeError('Not VLAN tagged Eth frame received:\n{0}'.
+ format(ether.__repr__()))
+ elif ether[Dot1Q].vlan != int(vlan1_rx):
+ raise RuntimeError('Ethernet frame with wrong VLAN tag ({}) '
+ 'received ({} expected):\n{}'.
+ format(ether[Dot1Q].vlan, vlan1_rx,
+ ether.__repr__()))
+ elif encaps_rx == 'Dot1ad':
+ if not vlan1_rx:
+ vlan1_rx = vlan1
+ if not vlan2_rx:
+ vlan2_rx = vlan2
+ # TODO
+ raise RuntimeError('Encapsulation {0} not implemented yet.'.
+ format(encaps_rx))
+ else:
+ raise RuntimeError('Unsupported encapsulation expected: {0}'.
+ format(encaps_rx))