+ 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/unknown encapsulation expected: {0}'
+ .format(encaps_rx))
+