def setUp(self): self.relayed_solicit_message = RelayForwardMessage( hop_count=1, link_address=IPv6Address('2001:db8:ffff:1::1'), peer_address=IPv6Address('fe80::3631:c4ff:fe3c:b2f1'), options=[ RelayMessageOption(relayed_message=RelayForwardMessage( hop_count=0, link_address=IPv6Address('::'), peer_address=IPv6Address('fe80::3631:c4ff:fe3c:b2f1'), options=[ RelayMessageOption(relayed_message=SolicitMessage( transaction_id=bytes.fromhex('f350d6'), options=[ ElapsedTimeOption(elapsed_time=0), ClientIdOption(duid=LinkLayerDUID(hardware_type=1, link_layer_address=bytes.fromhex('3431c43cb2f1'))), IANAOption(iaid=bytes.fromhex('c43cb2f1')), IAPDOption(iaid=bytes.fromhex('c43cb2f1')), OptionRequestOption(requested_options=[ OPTION_DNS_SERVERS, ]), ], )), InterfaceIdOption(interface_id=b'Fa2/3'), RemoteIdOption(enterprise_number=9, remote_id=bytes.fromhex('020023000001000a0003000100211c7d486e')), ]) ), InterfaceIdOption(interface_id=b'Gi0/0/0'), RemoteIdOption(enterprise_number=9, remote_id=bytes.fromhex('020000000000000a0003000124e9b36e8100')), RelayIdOption(duid=LinkLayerDUID(hardware_type=1, link_layer_address=bytes.fromhex('121212121212'))), ], )
def test_absent_option_echo_request(self): relayed_solicit_message = RelayForwardMessage( hop_count=1, link_address=IPv6Address('2001:db8:ffff:1::1'), peer_address=IPv6Address('fe80::3631:c4ff:fe3c:b2f1'), options=[ RelayMessageOption(relayed_message=SolicitMessage( transaction_id=bytes.fromhex('f350d6'), options=[ ElapsedTimeOption(elapsed_time=0), ClientIdOption(duid=LinkLayerDUID(hardware_type=1, link_layer_address=bytes.fromhex('3431c43cb2f1'))), IANAOption(iaid=bytes.fromhex('c43cb2f1')), ], )), EchoRequestOption(requested_options=[OPTION_SUBSCRIBER_ID]), UnknownOption(option_type=65535), InterfaceIdOption(interface_id=b'Fa2/3'), RemoteIdOption(enterprise_number=9, remote_id=bytes.fromhex('020023000001000a0003000100211c7d486e')), ] ) bundle = TransactionBundle(incoming_message=relayed_solicit_message, received_over_multicast=True) self.message_handler.handle(bundle, StatisticsSet()) self.assertIsInstance(bundle.outgoing_message, RelayReplyMessage) self.assertEqual(len(bundle.outgoing_message.options), 2) self.assertIsInstance(bundle.outgoing_message.options[0], InterfaceIdOption) self.assertIsInstance(bundle.outgoing_message.options[1], RelayMessageOption)
def decode_remote_id(remote_id_str: str) -> RemoteIdOption: """ Decode remote id from a string. :param remote_id_str: The remote-id string :return: The remote-id option """ parts = remote_id_str.split(':', maxsplit=1) enterprise_number = int(parts[0]) remote_id = bytes.fromhex(parts[1]) return RemoteIdOption(enterprise_number, remote_id)
def create_remote_id_query(options) -> LQQueryOption: """ Create query option for remote-id query. :param options: Options from the main argument parser :return: The Leasequery """ return LQQueryOption(QUERY_BY_REMOTE_ID, options.link_address, [ RemoteIdOption(int(options.enterprise_nr), bytes.fromhex(options.remote_id)) ])
OptionRequestOption(requested_options=[ OPTION_DNS_SERVERS, OPTION_NTP_SERVER, OPTION_SNTP_SERVERS, OPTION_IA_PD, OPTION_IA_NA, OPTION_VENDOR_OPTS, OPTION_SOL_MAX_RT, OPTION_INF_MAX_RT, ]), VendorClassOption(enterprise_number=872), ], )), InterfaceIdOption(interface_id=b'Fa2/3'), RemoteIdOption(enterprise_number=9, remote_id=bytes.fromhex( '020023000001000a0003000100211c7d486e')), ])), InterfaceIdOption(interface_id=b'Gi0/0/0'), RemoteIdOption( enterprise_number=9, remote_id=bytes.fromhex('020000000000000a0003000124e9b36e8100')), ], ) relayed_solicit_packet = codecs.decode( '0c0120010db8ffff0001000000000000' '0001fe800000000000003631c4fffe3c' 'b2f1000900c20c000000000000000000' '0000000000000000fe80000000000000' '3631c4fffe3cb2f10009007901f350d6'
def test_bad_option_length(self): with self.assertRaisesRegex(ValueError, 'longer than the available buffer'): RemoteIdOption.parse(bytes.fromhex('0025000a00009d10'))
def setUp(self): self.option_bytes = bytes.fromhex('0025000800009d100123abcd') self.option_object = RemoteIdOption(40208, bytes.fromhex('0123abcd')) self.parse_option()