示例#1
0
    def _strip_wpan_eth_wrapper(self, packet: RawPacket):
        if not hasattr(packet, 'wpan'):
            return

        for layer in packet.layers:
            if layer.layer_name == 'eth':
                packet.layers.remove(layer)
                eth_src = EthAddr(layer.get_field('eth.src'))
                eth_dst = EthAddr(layer.get_field('eth.dst'))
                logging.debug("stripping eth: src=%s, dst=%s", eth_src, eth_dst)
                channel = eth_src[5]
                self.wpan._add_field('wpan.channel', hex(channel))

        return
    def _collect_test_info_after_setup(self):
        """
        Collect test info after setUp
        """
        if not self._do_packet_verification:
            return

        test_info = self._test_info = {
            'testcase': self.test_name,
            'start_time': time.ctime(self._start_time),
            'pcap': '',
            'extaddrs': {},
            'ethaddrs': {},
            'ipaddrs': {},
            'mleids': {},
            'topology': self._initial_topology,
            'backbone': {
                'interface': config.BACKBONE_DOCKER_NETWORK_NAME,
                'prefix': config.BACKBONE_PREFIX,
            },
            'otbr_commit': config.OTBR_COMMIT,
            'domain_prefix': config.DOMAIN_PREFIX,
            'env': {
                'PORT_OFFSET': config.PORT_OFFSET,
            },
        }

        for i, node in self.nodes.items():
            if not node.is_host:
                extaddr = node.get_addr64()
                test_info['extaddrs'][i] = ExtAddr(extaddr).format_octets()

            if node.is_host or node.is_otbr:
                ethaddr = node.get_ether_mac()
                test_info['ethaddrs'][i] = EthAddr(ethaddr).format_octets()
示例#3
0
    def __init__(self, filename):
        self.filename = filename
        with open(filename, 'rt') as fd:
            test_info = json.loads(fd.read())

            self.testcase = test_info.get('testcase', '')
            self._pcap = test_info.get('pcap', 'current.pcap')
            self.topology = self._convert_keys_to_ints(test_info['topology'])
            self.extaddrs = {
                int(k): ExtAddr(v)
                for k, v in test_info.get('extaddrs', {}).items()
            }
            self.ethaddrs = {
                int(k): EthAddr(v)
                for k, v in test_info.get('ethaddrs', {}).items()
            }
            self.ipaddrs = {
                int(k): [Ipv6Addr(x) for x in l]
                for k, l in test_info.get('ipaddrs', {}).items()
            }
            self.mleids = {
                int(k): Ipv6Addr(v)
                for k, v in test_info.get('mleids', {}).items()
            }
            self.rlocs = {
                int(k): Ipv6Addr(v)
                for k, v in test_info.get('rlocs', {}).items()
            }
            self.rloc16s = self._convert_hex_values(
                self._convert_keys_to_ints(test_info.get('rloc16s', {})))
            self.extra_vars = test_info.get('extra_vars', {})
            self.leader_aloc = Ipv6Addr(test_info.get(
                'leader_aloc')) if 'leader_aloc' in test_info else ''
示例#4
0
def _eth_addr(v: Union[LayerFieldsContainer, LayerField]) -> EthAddr:
    """parse the layer field as an Ethernet MAC address"""
    assert not isinstance(v, LayerFieldsContainer) or len(v.fields) == 1, v.fields
    return EthAddr(v.get_default_value())