Exemple #1
0
def create_deafult_network_tlvs_factories():
    return {
        network_layer.TlvType.TARGET_EID:
        network_layer.TargetEidFactory(),
        network_layer.TlvType.MAC_EXTENDED_ADDRESS:
        network_layer.MacExtendedAddressFactory(),
        network_layer.TlvType.RLOC16:
        network_layer.Rloc16Factory(),
        network_layer.TlvType.ML_EID:
        network_layer.MlEidFactory(),
        network_layer.TlvType.STATUS:
        network_layer.StatusFactory(),
        network_layer.TlvType.TIME_SINCE_LAST_TRANSACTION:
        network_layer.TimeSinceLastTransactionFactory(),
        network_layer.TlvType.ROUTER_MASK:
        network_layer.RouterMaskFactory(),
        network_layer.TlvType.ND_OPTION:
        network_layer.NdOptionFactory(),
        network_layer.TlvType.ND_DATA:
        network_layer.NdDataFactory(),
        network_layer.TlvType.THREAD_NETWORK_DATA:
        network_layer.ThreadNetworkDataFactory(
            create_default_network_data_tlvs_factory()),

        # Routing information are distributed in a Thread network by MLE Routing TLV
        # which is in fact MLE Route64 TLV. Thread specificaton v1.1. - Chapter 5.20
        network_layer.TlvType.MLE_ROUTING:
        create_default_mle_tlv_route64_factory()
    }
Exemple #2
0
    def test_should_create_TimeSinceLastTransaction_from_bytearray_when_parse_method_is_called(
            self):
        # GIVEN
        seconds = any_seconds()

        factory = network_layer.TimeSinceLastTransactionFactory()

        data = bytearray(struct.pack(">L", seconds))

        # WHEN
        time_since_last_transaction = factory.parse(io.BytesIO(data),
                                                    common.MessageInfo())

        # THEN
        self.assertTrue(
            isinstance(time_since_last_transaction,
                       network_layer.TimeSinceLastTransaction))
        self.assertEqual(seconds, time_since_last_transaction.seconds)