def test_v6_relay_interface_one_subnet_not_matching_id():

    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::1-2001:db8:1::10')
    srv_control.set_conf_parameter_subnet('interface-id', '"xyz"', '0')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_option_content('Response', '9', None, 'Relayed', 'Message')
    srv_msg.response_check_include_option('Relayed Message', None, '1')
    srv_msg.response_check_include_option('Relayed Message', None, '2')
    srv_msg.response_check_include_option('Relayed Message', None, '3')
    srv_msg.response_check_option_content('Relayed Message', '3', None, 'sub-option', '13')
    srv_msg.response_check_suboption_content('Relayed Message',
                                             '13',
                                             '3',
                                             None,
                                             'statuscode',
                                             '2')

    references.references_check('Kea')
예제 #2
0
def test_v6_mac_in_dhcp6_client_link_addr_1():
    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.add_line({"mac-sources": ["client-link-addr-option"]})
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_does_include('Client', 'client-link-layer-addr')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ADVERTISE')

    misc.test_procedure()
    srv_msg.client_copy_option('IA_NA')
    srv_msg.client_copy_option('server-id')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_send_msg('REQUEST')

    srv_msg.client_does_include('RelayAgent', 'client-link-layer-addr')
    srv_msg.client_sets_value('RelayAgent', 'peeraddr', '$(CLI_LINK_LOCAL)')
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    srv_msg.lease_file_contains(',$(CLI_MAC)')
    srv_msg.log_contains('Hardware addr: $(CLI_MAC)')
예제 #3
0
def test_v6_mac_in_dhcp6_subscriber_id_2():
    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.add_line({"mac-sources": ["rfc4580"]})
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ADVERTISE')

    misc.test_procedure()
    srv_msg.client_copy_option('IA_NA')
    srv_msg.client_copy_option('server-id')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_send_msg('REQUEST')

    srv_msg.client_sets_value('RelayAgent', 'subscriber_id', '0a0027000002')
    srv_msg.client_does_include('RelayAgent', 'subscriber-id')
    srv_msg.client_sets_value('RelayAgent', 'peeraddr', 'fe80::800:27ff:fe00:2')
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    srv_msg.lease_file_contains(',0a:00:27:00:00:02')
    srv_msg.log_contains('Hardware addr: 0a:00:27:00:00:02')
def test_v6_relay_relayaddress_within_subnet():

    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::1-2001:db8:1::10')
    srv_control.add_line_to_subnet('0', ',"relay": {"ip-address": "3000::2005"}')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'linkaddr', '2001:db8:1::100')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_option_content('Response', '9', None, 'Relayed', 'Message')
    srv_msg.response_check_include_option('Relayed Message', None, '1')
    srv_msg.response_check_include_option('Relayed Message', None, '2')
    srv_msg.response_check_include_option('Relayed Message', None, '3')
    srv_msg.response_check_option_content('Relayed Message', '3', None, 'sub-option', '5')
    srv_msg.response_check_suboption_content('Relayed Message',
                                             '5',
                                             '3',
                                             None,
                                             'addr',
                                             '2001:db8:1::1')
예제 #5
0
def test_v6_relay_message_information_request_reply():
    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_requests_option(7)
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ADVERTISE')

    misc.test_procedure()
    srv_msg.client_copy_option('server-id')
    srv_msg.client_send_msg('INFOREQUEST')

    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    # Response MUST include REPLY message.

    references.references_check('RFC3315')
예제 #6
0
def test_v6_relay_message_unicast_global():

    misc.test_setup()
    srv_control.config_srv_subnet_with_iface('$(SERVER_IFACE)',
                                             '$(SRV_IPV6_ADDR_GLOBAL)',
                                             '3000::/64',
                                             '3000::1-3000::ff')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_requests_option('7')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.unicast_addres('GLOBAL', None)
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')

    references.references_check('RFC3315')
예제 #7
0
def test_v6_relay_invalid_options_reconfigure_accept():

    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    # add options to relay message
    srv_msg.client_does_include('RelayAgent', 'reconfigure-accept')
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_dont_wait_for_message()

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)

    references.references_check('RFC3315')
예제 #8
0
def test_flex_options_supersede_string():
    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:1::/64',
                                  '2001:db8:1::1-2001:db8:1::1')
    srv_control.config_srv_opt('new-posix-timezone',
                               'EST5EDT4\\,M3.2.0/02:00\\,M11.1.0/02:00')
    srv_control.add_hooks('libdhcp_flex_option.so')

    h_param = {
        "options": [{
            "code": 41,
            "supersede":
            "ifelse(relay6[0].peeraddr == 3000::1005,'EST5EDT4\\,M3.2.0/02:00\\,M11.1.0/02:00','')",
            "csv-format": True
        }]
    }
    world.dhcp_cfg["hooks-libraries"][0]["parameters"] = h_param

    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_requests_option(41)
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'peeraddr', '3000::1005')
    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    srv_msg.response_check_option_content(9, 'Relayed', 'Message')
    srv_msg.response_check_include_option(41)
    srv_msg.response_check_option_content(
        41, 'optdata', r'EST5EDT4,M3.2.0/02:00,M11.1.0/02:00')

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_requests_option(41)
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'peeraddr', '3000::1')
    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    srv_msg.response_check_option_content(9, 'Relayed', 'Message')
    srv_msg.response_check_include_option(41)
    srv_msg.response_check_option_content(
        41, 'optdata', r'EST5EDT4,M3.2.0/02:00,M11.1.0/02:00')
예제 #9
0
def test_v6_relay_relayaddress_interface_id_just_one_matching_3():

    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:1::/64',
                                  '2001:db8:1::1-2001:db8:1::10')
    srv_control.set_conf_parameter_subnet('interface-id', 'xyz', 0)
    srv_control.add_line_to_subnet(0, {"relay": {"ip-address": "3000::1005"}})
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'linkaddr', '2001:db8:1::1000')
    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    srv_msg.response_check_option_content(9, 'Relayed', 'Message')
    srv_msg.response_check_include_option(1)
    srv_msg.response_check_include_option(2)
    srv_msg.response_check_include_option(3)
    srv_msg.response_check_option_content(3,
                                          'sub-option',
                                          5,
                                          expect_include=False)
    srv_msg.response_check_option_content(3, 'sub-option', 13)
    srv_msg.response_check_suboption_content(13, 3, 'statuscode', 2)
예제 #10
0
def test_v6_options_rsoo_custom_option_list_default_option_65():

    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1')
    srv_control.set_conf_parameter_subnet('interface-id', 'abc', 0)
    srv_control.set_conf_parameter_global('relay-supplied-options', ["12"])
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_sets_value('RelayAgent', 'erpdomain', 'relay-supplied.domain.com')
    srv_msg.client_does_include('Relay-Supplied-Option', 'erp-local-domain-name')
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.client_does_include('RelayAgent', 'rsoo')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    srv_msg.response_check_option_content(9, 'Relayed', 'Message')
    srv_msg.response_check_include_option(1)
    srv_msg.response_check_include_option(2)
    srv_msg.response_check_include_option(3)
    srv_msg.response_check_option_content(3, 'sub-option', 5)
    srv_msg.response_check_include_option(65)
    srv_msg.response_check_option_content(65, 'erpdomain', 'relay-supplied.domain.com.')

    references.references_check('RFC642')
예제 #11
0
def test_v6_relay_relayaddress_within_subnet():

    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:1::/64',
                                  '2001:db8:1::1-2001:db8:1::10')
    srv_control.add_line_to_subnet(0, {"relay": {"ip-address": "3000::2005"}})
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'linkaddr', '2001:db8:1::100')
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    srv_msg.response_check_option_content(9, 'Relayed', 'Message')
    srv_msg.response_check_include_option(1)
    srv_msg.response_check_include_option(2)
    srv_msg.response_check_include_option(3)
    srv_msg.response_check_option_content(3, 'sub-option', 5)
    srv_msg.response_check_suboption_content(5, 3, 'addr', '2001:db8:1::1')
예제 #12
0
def test_v6_relay_interface_one_subnet_not_matching_id():

    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:1::/64',
                                  '2001:db8:1::1-2001:db8:1::10')
    srv_control.set_conf_parameter_subnet('interface-id', 'xyz', 0)
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    srv_msg.response_check_option_content(9, 'Relayed', 'Message')
    srv_msg.response_check_include_option(1)
    srv_msg.response_check_include_option(2)
    srv_msg.response_check_include_option(3)
    srv_msg.response_check_option_content(3, 'sub-option', 13)
    srv_msg.response_check_suboption_content(13, 3, 'statuscode', 2)

    references.references_check('Kea')
def test_v6_relay_encapsulate_8lvl():

    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward(8)

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    # Response MUST include ADVERTISE message.

    # TODO: we should check these 8 levels in RELAYREPLY
    # RFC allows up to 8 levels of nesting

    references.references_check('RFC3315')
예제 #14
0
def test_v6_relay_invalid_options_reconfigure_accept():

    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    # add options to relay message
    srv_msg.client_does_include('RelayAgent', None, 'reconfigure-accept')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_dont_wait_for_message()

    misc.test_procedure()
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')

    references.references_check('RFC3315')
예제 #15
0
def test_v6_mac_in_dhcp6_docsic_cmts():
    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.add_line({"mac-sources": ["docsis-cmts"]})
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ADVERTISE')

    misc.test_procedure()
    srv_msg.client_copy_option('IA_NA')
    srv_msg.client_copy_option('server-id')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_send_msg('REQUEST')

    srv_msg.client_sets_value('RelayAgent', 'enterprisenum', '4491')
    srv_msg.client_does_include('RelayAgent', 'vendor-class')
    srv_msg.add_vendor_suboption('RelayAgent', 1026, '00:f5:f4:00:f2:01')
    srv_msg.client_does_include('RelayAgent', 'vendor-specific-info')
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    srv_msg.lease_file_contains(',00:f5:f4:00:f2:01')
    srv_msg.log_contains('Hardware addr: 00:f5:f4:00:f2:01')
def test_v6_relay_relayaddress_not_matching():

    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:1::/64',
                                  '2001:db8:1::1-2001:db8:1::10')
    srv_control.add_line_to_subnet('0',
                                   ',"relay": {"ip-address": "3000::2005"}')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'linkaddr', '2001:db8:2::100')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_option_content('Response', '9', None, 'Relayed',
                                          'Message')
    srv_msg.response_check_include_option('Relayed Message', None, '1')
    srv_msg.response_check_include_option('Relayed Message', None, '2')
    srv_msg.response_check_include_option('Relayed Message', None, '3')
    srv_msg.response_check_option_content('Relayed Message', '3', None,
                                          'sub-option', '13')
    srv_msg.response_check_suboption_content('Relayed Message', '13', '3',
                                             None, 'statuscode', '2')
예제 #17
0
def test_v6_relay_message_information_request_reply():
    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_requests_option('7')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE')

    misc.test_procedure()
    srv_msg.client_copy_option('server-id')
    srv_msg.client_send_msg('INFOREQUEST')

    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    # Response MUST include REPLY message.

    references.references_check('RFC3315')
예제 #18
0
def test_v6_relay_message_unicast_global():

    misc.test_setup()
    srv_control.config_srv_subnet_with_iface('$(SERVER_IFACE)',
                                             '$(SRV_IPV6_ADDR_GLOBAL)',
                                             '3000::/64', '3000::1-3000::ff')
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_requests_option(7)
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.unicast_addres('GLOBAL', None)
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)

    references.references_check('RFC3315')
예제 #19
0
def test_v6_relay_encapsulate_12lvl():

    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_requests_option(7)
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward(12)

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    # Response MUST include ADVERTISE message.

    # TODO: we should check these 12 levels in RELAYREPLY
    # kea probably should rejected this msg as RFC says 8 levels are allowed

    references.references_check('RFC3315')
def test_v6_relay_interface_two_subnets():

    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:1::/64',
                                  '2001:db8:1::1-2001:db8:1::10')
    srv_control.set_conf_parameter_subnet('interface-id', '"abc"', '0')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:2::/64', '2001:db8:2::1-2001:db8:2::10')
    srv_control.set_conf_parameter_subnet('interface-id', '"xyz"', '1')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_option_content('Response', '9', None, 'Relayed',
                                          'Message')
    srv_msg.response_check_include_option('Relayed Message', None, '1')
    srv_msg.response_check_include_option('Relayed Message', None, '2')
    srv_msg.response_check_include_option('Relayed Message', None, '3')
    srv_msg.response_check_option_content('Relayed Message', '3', None,
                                          'sub-option', '5')
    srv_msg.response_check_suboption_content('Relayed Message', '5', '3', None,
                                             'addr', '2001:db8:1::1')

    misc.test_procedure()
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'xyz')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_option_content('Response', '9', None, 'Relayed',
                                          'Message')
    srv_msg.response_check_include_option('Relayed Message', None, '1')
    srv_msg.response_check_include_option('Relayed Message', None, '2')
    srv_msg.response_check_include_option('Relayed Message', None, '3')
    srv_msg.response_check_option_content('Relayed Message', '3', None,
                                          'sub-option', '5')
    srv_msg.response_check_suboption_content('Relayed Message', '5', '3', None,
                                             'addr', '2001:db8:2::1')

    references.references_check('Kea')
예제 #21
0
def test_hook_v6_network_cmds_add_on_relay_addr():
    misc.test_setup()
    srv_control.config_srv_subnet('$(EMPTY)', '$(EMPTY)')
    srv_control.config_srv_opt('preference', '123')
    srv_control.config_srv_opt('domain-search',
                               'domain1.example.com,domain2.isc.org')
    srv_control.open_control_channel()
    srv_control.add_hooks('libdhcp_subnet_cmds.so')
    srv_control.build_and_send_config_files('SSH', 'config-file')

    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:66:55:44:33:22:11')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_include_option('Response', None, '2')
    srv_msg.response_check_include_option('Response', None, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option',
                                          '13')
    srv_msg.response_check_suboption_content('Response', '13', '3', None,
                                             'statuscode', '2')

    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network6-add","arguments":{"shared-networks":[{"name": "name-abc","relay":{"ip-address":"2001:db8::abcd"},"preferred-lifetime": 3000,"rebind-timer": 2000,"renew-timer": 1000,"valid-lifetime": 4000,"subnet6":[{"id":1,"pools": [{"pool": "2001:db8:1::1-2001:db8:1::10"}],"preferred-lifetime": 3000,"rebind-timer": 2000,"renew-timer": 1000,"reservation-mode": "all","subnet": "2001:db8:1::/64","valid-lifetime": 4000}]}]}}'
    )
    srv_msg.send_ctrl_cmd_via_socket(
        '{"command":"network6-get","arguments":{"name": "name-abc"}}')
    srv_msg.forge_sleep('5', 'seconds')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'interface-abc')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.client_sets_value('RelayAgent', 'linkaddr', '2001:db8::abcd')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_option_content('Response', '9', None, 'Relayed',
                                          'Message')
    srv_msg.response_check_include_option('Relayed Message', None, '1')
    srv_msg.response_check_include_option('Relayed Message', None, '2')
    srv_msg.response_check_include_option('Relayed Message', None, '3')
    srv_msg.response_check_option_content('Relayed Message', '3', None,
                                          'sub-option', '5')
예제 #22
0
def test_v6_movingclient_4():

    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::1-2001:db8:1::ff')
    srv_control.config_srv_another_subnet_no_interface('2001:db8:2::/64',
                                                       '2001:db8:2::1-2001:db8:2::10')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_sets_value('Client', 'ia_id', '1000')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE')
    srv_msg.response_check_include_option('Response', None, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_save_option('IA_NA')
    srv_msg.client_save_option('server-id')
    srv_msg.client_add_saved_option('DONT ')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_send_msg('REQUEST')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'xyz')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.client_sets_value('RelayAgent', 'linkaddr', '2001:db8:1::1000')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_option_content('Response', '9', None, 'Relayed', 'Message')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_sets_value('Client', 'ia_id', '1000')
    srv_msg.client_add_saved_option('DONT ')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_send_msg('RENEW')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.client_sets_value('RelayAgent', 'linkaddr', '2001:db8:2::2000')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_option_content('Response', '9', None, 'Relayed', 'Message')
    srv_msg.response_check_include_option('Relayed Message', None, '1')
    srv_msg.response_check_include_option('Relayed Message', None, '2')
예제 #23
0
def test_hook_v6_network_cmds_add_on_relay_addr():
    misc.test_setup()
    srv_control.config_srv_subnet('$(EMPTY)', '$(EMPTY)')
    srv_control.config_srv_opt('preference', '123')
    srv_control.config_srv_opt('domain-search', 'domain1.example.com,domain2.isc.org')
    srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket')
    srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_subnet_cmds.so')
    srv_control.build_and_send_config_files('SSH', 'config-file')

    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE')
    srv_msg.response_check_include_option('Response', None, '1')
    srv_msg.response_check_include_option('Response', None, '2')
    srv_msg.response_check_include_option('Response', None, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '13')
    srv_msg.response_check_suboption_content('Response', '13', '3', None, 'statuscode', '2')

    srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket',
                                            '{"command":"network6-add","arguments":{"shared-networks":[{"name": "name-abc","relay":{"ip-address":"2001:db8::abcd"},"preferred-lifetime": 3000,"rebind-timer": 2000,"renew-timer": 1000,"valid-lifetime": 4000,"subnet6":[{"id":1,"pools": [{"pool": "2001:db8:1::1-2001:db8:1::10"}],"preferred-lifetime": 3000,"rebind-timer": 2000,"renew-timer": 1000,"reservation-mode": "all","subnet": "2001:db8:1::/64","valid-lifetime": 4000}]}]}}')
    srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket',
                                            '{"command":"network6-get","arguments":{"name": "name-abc"}}')
    srv_msg.forge_sleep('5', 'seconds')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'interface-abc')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.client_sets_value('RelayAgent', 'linkaddr', '2001:db8::abcd')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_option_content('Response', '9', None, 'Relayed', 'Message')
    srv_msg.response_check_include_option('Relayed Message', None, '1')
    srv_msg.response_check_include_option('Relayed Message', None, '2')
    srv_msg.response_check_include_option('Relayed Message', None, '3')
    srv_msg.response_check_option_content('Relayed Message', '3', None, 'sub-option', '5')
예제 #24
0
def test_v6_mac_in_dhcp6_docsic_cmts():
    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.run_command('"mac-sources": [ "docsis-cmts" ]')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE')

    misc.test_procedure()
    srv_msg.client_copy_option('IA_NA')
    srv_msg.client_copy_option('server-id')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_send_msg('REQUEST')

    srv_msg.client_sets_value('RelayAgent', 'enterprisenum', '4491')
    srv_msg.client_does_include('RelayAgent', None, 'vendor-class')
    srv_msg.add_vendor_suboption('RelayAgent', '1026', '00:f5:f4:00:f2:01')
    srv_msg.client_does_include('RelayAgent', None, 'vendor-specific-info')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-leases6.csv',
                               None,
                               ',00:f5:f4:00:f2:01')
    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea.log',
                               None,
                               'Hardware addr: 00:f5:f4:00:f2:01')
예제 #25
0
def test_v6_options_rsoo_custom_option_list_default_option_65():

    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1')
    srv_control.set_conf_parameter_subnet('interface-id', '"abc"', '0')
    srv_control.set_conf_parameter_global('relay-supplied-options', '["12"]')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_sets_value('RelayAgent', 'erpdomain', 'relay-supplied.domain.com')
    srv_msg.client_does_include('Relay-Supplied-Option', None, 'erp-local-domain-name')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.client_does_include('RelayAgent', None, 'rsoo')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_option_content('Response', '9', None, 'Relayed', 'Message')
    srv_msg.response_check_include_option('Relayed Message', None, '1')
    srv_msg.response_check_include_option('Relayed Message', None, '2')
    srv_msg.response_check_include_option('Relayed Message', None, '3')
    srv_msg.response_check_option_content('Relayed Message', '3', None, 'sub-option', '5')
    srv_msg.response_check_include_option('Relayed Message', None, '65')
    srv_msg.response_check_option_content('Relayed Message',
                                          '65',
                                          None,
                                          'erpdomain',
                                          'relay-supplied.domain.com.')

    references.references_check('RFC642')
예제 #26
0
def test_v6_relay_invalid_with_server_id():
    # add just serverid

    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    # add options to relay message
    srv_msg.client_sets_value('RelayAgent',
                              'server_id',
                              '00:01:00:01:52:7b:a8:f0:08:00:27:58:f1:e8')
    srv_msg.client_does_include('RelayAgent', None, 'server-id')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_dont_wait_for_message()

    misc.test_procedure()
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')

    references.references_check('RFC3315')
예제 #27
0
def test_v6_mac_in_dhcp6_subscriber_id_2():
    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.run_command('"mac-sources": [ "rfc4580" ]')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE')

    misc.test_procedure()
    srv_msg.client_copy_option('IA_NA')
    srv_msg.client_copy_option('server-id')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_send_msg('REQUEST')

    srv_msg.client_sets_value('RelayAgent', 'subscriber_id', '0a0027000002')
    srv_msg.client_does_include('RelayAgent', None, 'subscriber-id')
    srv_msg.client_sets_value('RelayAgent', 'peeraddr', 'fe80::800:27ff:fe00:2')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea-leases6.csv',
                               None,
                               ',0a:00:27:00:00:02')
    srv_msg.file_contains_line('$(SOFTWARE_INSTALL_DIR)/var/kea/kea.log',
                               None,
                               'Hardware addr: 0a:00:27:00:00:02')
예제 #28
0
def test_v6_hooks_flexid_pgsql_1():
    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.add_line({"host-reservation-identifiers": ["duid", "flex-id"]})
    srv_control.add_hooks('libdhcp_flex_id.so')
    srv_control.add_parameter_to_hook(1, 'identifier-expression', 'relay6[0].option[18].hex')

    srv_control.enable_db_backend_reservation('PostgreSQL')
    srv_control.new_db_backend_reservation('PostgreSQL', 'flex-id', '706f727431323334')
    srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'PostgreSQL', 1)
    srv_control.update_db_backend_reservation('dhcp6_subnet_id', 1, 'PostgreSQL', 1)
    srv_control.ipv6_address_db_backend_reservation('3000::f', '$(EMPTY)', 'PostgreSQL', 1)
    srv_control.upload_db_reservation('PostgreSQL')

    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')
    # Pause the Test.

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'port1234')
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    srv_msg.response_check_option_content(9, 'Relayed', 'Message')
    srv_msg.response_check_include_option(1)
    srv_msg.response_check_include_option(2)
    srv_msg.response_check_include_option(3)
    srv_msg.response_check_option_content(3, 'sub-option', 5)

    srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::f')
예제 #29
0
def test_v6_options_rsoo_custom_option_list_server_has_option_configured_also():

    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1')
    srv_control.set_conf_parameter_subnet('interface-id', '"abc"', '0')
    srv_control.set_conf_parameter_global('relay-supplied-options', '["12"]')
    srv_control.config_srv_opt('unicast', '3000::1')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_requests_option('12')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_sets_value('RelayAgent', 'srvaddr', '2000::1')
    srv_msg.client_does_include('Relay-Supplied-Option', None, 'server-unicast')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.client_does_include('RelayAgent', None, 'rsoo')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_option_content('Response', '9', None, 'Relayed', 'Message')
    srv_msg.response_check_include_option('Relayed Message', None, '1')
    srv_msg.response_check_include_option('Relayed Message', None, '2')
    srv_msg.response_check_include_option('Relayed Message', None, '3')
    srv_msg.response_check_option_content('Relayed Message', '3', None, 'sub-option', '5')
    srv_msg.response_check_include_option('Relayed Message', None, '12')
    srv_msg.response_check_option_content('Relayed Message', '12', 'NOT ', 'srvaddr', '2000::1')
    srv_msg.response_check_option_content('Relayed Message', '12', None, 'srvaddr', '3000::1')

    references.references_check('RFC642')
예제 #30
0
def test_v6_options_rsoo_default_option():

    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:a::/64', '2001:db8:a::1-2001:db8:a::1')
    srv_control.set_conf_parameter_subnet('interface-id', '"abc"', '0')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_sets_value('RelayAgent', 'erpdomain', 'relay-supplied.domain.com')
    srv_msg.client_does_include('Relay-Supplied-Option', None, 'erp-local-domain-name')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.client_does_include('RelayAgent', None, 'rsoo')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_option_content('Response', '9', None, 'Relayed', 'Message')
    srv_msg.response_check_include_option('Relayed Message', None, '1')
    srv_msg.response_check_include_option('Relayed Message', None, '2')
    srv_msg.response_check_include_option('Relayed Message', None, '3')
    srv_msg.response_check_option_content('Relayed Message', '3', None, 'sub-option', '5')
    srv_msg.response_check_include_option('Relayed Message', None, '65')
    srv_msg.response_check_option_content('Relayed Message',
                                          '65',
                                          None,
                                          'erpdomain',
                                          'relay-supplied.domain.com.')

    references.references_check('RFC642')
예제 #31
0
def test_v6_relay_message_unicast_local():

    misc.test_setup()
    # Server is configured with 3000::/64 subnet with 3000::1-3000::ff pool.
    srv_control.config_srv_subnet_with_iface('$(SERVER_IFACE)',
                                             '$(SRV_IPV6_ADDR_LINK_LOCAL)',
                                             '3000::/64',
                                             '3000::1-3000::ff')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.unicast_addres(None, 'LINK_LOCAL')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_dont_wait_for_message()
    srv_msg.response_check_include_option('Response', None, '9')

    misc.test_procedure()
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')

    references.references_check('RFC3315')
예제 #32
0
def test_v6_relay_message_solicit_advertise():

    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    # Response option 9 MUST contain message 2.
    # message 2 - Advertise

    references.references_check('RFC3315')
예제 #33
0
def test_v6_relay_message_solicit_reply():

    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', None, 'rapid-commit')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    # Response MUST include REPLY message.

    references.references_check('RFC3315')
예제 #34
0
def test_v6_relay_message_solicit_advertise():

    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    # Response option 9 MUST contain message 2.
    # message 2 - Advertise

    references.references_check('RFC3315')
예제 #35
0
def test_v6_hooks_flexid_1():
    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.host_reservation_in_subnet('hostname',
                                           'reserved-hostname',
                                           0,
                                           'flex-id',
                                           '\'port1234\'')
    srv_control.host_reservation_in_subnet_add_value(0, 0, 'ip-address', '3000::f')
    srv_control.add_line({"host-reservation-identifiers": ["duid", "flex-id"]})
    srv_control.add_hooks('libdhcp_flex_id.so')
    srv_control.add_parameter_to_hook(1,
                                      'identifier-expression',
                                      'substring(relay6[0].option[18].hex,0,8)')
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'port1234')
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    srv_msg.response_check_option_content(9, 'Relayed', 'Message')
    srv_msg.response_check_include_option(1)
    srv_msg.response_check_include_option(2)
    srv_msg.response_check_include_option(3)
    srv_msg.response_check_option_content(3, 'sub-option', 5)
    # Relayed Message sub-option 5 from option 3 MUST contain address 2001:db8:1::1.
    srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::f')
예제 #36
0
def test_v6_relay_invalid_with_server_id():
    # add just serverid

    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    # add options to relay message
    srv_msg.client_sets_value('RelayAgent', 'server_id',
                              '00:01:00:01:52:7b:a8:f0:08:00:27:58:f1:e8')
    srv_msg.client_does_include('RelayAgent', 'server-id')
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_dont_wait_for_message()

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)

    references.references_check('RFC3315')
예제 #37
0
def test_prefix_delegation_onlyPD_relay():

    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::3')
    srv_control.config_srv_prefix('2001:db8:1::', 0, 90, 92)
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'IA-PD')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    srv_msg.response_check_include_option(9)
    # add test after Scapy fix

    references.references_check('RFC')
def test_prefix_delegation_onlyPD_relay():

    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::3')
    srv_control.config_srv_prefix('2001:db8:1::', '0', '90', '92')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', None, 'IA-PD')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_include_option('Response', None, '9')
    # add test after Scapy fix

    references.references_check('RFC')
예제 #39
0
def test_v6_relay_interface_two_subnets_same_interface_id():

    misc.test_setup()
    # that is basically misconfiguration!
    srv_control.config_srv_subnet('2001:db8:1::/64',
                                  '2001:db8:1::1-2001:db8:1::1')
    srv_control.set_conf_parameter_subnet('interface-id', 'abc', 0)
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:2::/64', '2001:db8:2::11-2001:db8:2::20')
    srv_control.set_conf_parameter_subnet('interface-id', 'abc', 1)
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    #  just saving server-id - start
    misc.test_procedure()
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ADVERTISE')

    misc.test_procedure()
    srv_msg.client_save_option('server-id')
    #  just saving server-id - end

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    srv_msg.response_check_option_content(9, 'Relayed', 'Message')
    srv_msg.response_check_include_option(1)
    srv_msg.response_check_include_option(2)
    srv_msg.response_check_include_option(3)
    srv_msg.response_check_option_content(3, 'sub-option', 5)
    srv_msg.response_check_suboption_content(5, 3, 'addr', '2001:db8:1::1')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_sets_value('Client', 'IA_Address', '2001:db8:1::1')
    srv_msg.client_does_include('Client', 'IA_Address')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_add_saved_option('DONT ')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_send_msg('REQUEST')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    srv_msg.response_check_option_content(9, 'Relayed', 'Message')
    srv_msg.response_check_include_option(1)
    srv_msg.response_check_include_option(2)
    srv_msg.response_check_include_option(3)
    srv_msg.response_check_option_content(3, 'sub-option', 5)
    srv_msg.response_check_suboption_content(5, 3, 'addr', '2001:db8:1::1')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:f6:f5:f4:33:22:01')
    srv_msg.client_does_include('Client', 'client-id')
    srv_msg.client_does_include('Client', 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'RELAYREPLY')
    srv_msg.response_check_include_option(18)
    srv_msg.response_check_include_option(9)
    srv_msg.response_check_option_content(9, 'Relayed', 'Message')
    srv_msg.response_check_include_option(1)
    srv_msg.response_check_include_option(2)
    srv_msg.response_check_include_option(3)
    srv_msg.response_check_option_content(3, 'sub-option', 13)
    srv_msg.response_check_suboption_content(13, 3, 'statuscode', 2)

    references.references_check('Kea')
예제 #40
0
def test_v6_movingclient_4():

    misc.test_setup()
    srv_control.config_srv_subnet('2001:db8:1::/64',
                                  '2001:db8:1::1-2001:db8:1::ff')
    srv_control.config_srv_another_subnet_no_interface(
        '2001:db8:2::/64', '2001:db8:2::1-2001:db8:2::10')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_sets_value('Client', 'ia_id', '1000')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE')
    srv_msg.response_check_include_option('Response', None, '3')
    srv_msg.response_check_option_content('Response', '3', None, 'sub-option',
                                          '5')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_save_option('IA_NA')
    srv_msg.client_save_option('server-id')
    srv_msg.client_add_saved_option('DONT ')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_send_msg('REQUEST')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'xyz')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.client_sets_value('RelayAgent', 'linkaddr', '2001:db8:1::1000')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_option_content('Response', '9', None, 'Relayed',
                                          'Message')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID',
                              '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_sets_value('Client', 'ia_id', '1000')
    srv_msg.client_add_saved_option('DONT ')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_send_msg('RENEW')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.client_sets_value('RelayAgent', 'linkaddr', '2001:db8:2::2000')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_option_content('Response', '9', None, 'Relayed',
                                          'Message')
    srv_msg.response_check_include_option('Relayed Message', None, '1')
    srv_msg.response_check_include_option('Relayed Message', None, '2')
예제 #41
0
def send_request_and_check_reply(duid=None,
                                 req_ia=None,
                                 interface_id=None,
                                 exp_ia_na_t1=None,
                                 exp_ia_na_t2=None,
                                 exp_ia_na_status_code=None,
                                 exp_ia_na_iaaddr_addr=None,
                                 exp_ia_na_iaaddr_preflft=None,
                                 exp_ia_na_iaaddr_validlft=None,
                                 exp_ia_pd_iaprefix_prefix=None,
                                 exp_ia_pd_iaprefix_plen=None):
    # send REQUEST
    misc.test_procedure()
    if duid is not None:
        srv_msg.client_sets_value('Client', 'DUID', duid)
    # if client_id is not None:
    #     srv_msg.client_does_include_with_value('client_id', client_id)
    # if server_id is not None:
    #     srv_msg.client_copy_option('server_id')
    # if requested_addr is not None:
    #     srv_msg.client_does_include_with_value('requested_addr', requested_addr)
    # if ciaddr is not None:
    #     srv_msg.client_sets_value('Client', 'ciaddr', ciaddr)
    # srv_msg.client_requests_option('1')
    if req_ia == 'IA-NA':
        srv_msg.client_copy_option('IA_NA')
    if req_ia == 'IA-PD':
        srv_msg.client_copy_option('IA_PD')
    srv_msg.client_copy_option('server-id')
    #srv_msg.client_save_option('server-id')
    #srv_msg.client_add_saved_option('DONT ')
    srv_msg.client_does_include('Client', None, 'client-id')

    srv_msg.client_send_msg('REQUEST')

    if interface_id is not None:
        srv_msg.client_sets_value('RelayAgent', 'ifaceid', interface_id)
        #srv_msg.client_does_include('RelayAgent', None, 'interface-id')
        srv_msg.create_relay_forward()


    # srv_msg.response_check_include_option('Response', None, '1')
    # srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
    # srv_msg.response_check_include_option('Response', None, '54')
    # srv_msg.response_check_option_content('Response', '54', None, 'value', '$(SRV4_ADDR)')
    # srv_msg.response_check_include_option('Response', None, '51')
    # if exp_renew_timer is not None:
    #     missing = 'NOT ' if exp_renew_timer == 'missing' else None
    #     srv_msg.response_check_include_option('Response', missing, '58')
    #     if not missing:
    #         srv_msg.response_check_option_content('Response', '58', None, 'value', exp_renew_timer)
    # if exp_rebind_timer is not None:
    #     missing = 'NOT ' if exp_rebind_timer == 'missing' else None
    #     srv_msg.response_check_include_option('Response', missing, '59')
    #     if not missing:
    #         srv_msg.response_check_option_content('Response', '59', None, 'value', exp_rebind_timer)

    # if exp_client_id is not None:
    #     if exp_client_id == 'missing':
    #         srv_msg.response_check_include_option('Response', 'NOT ', '61')
    #     else:
    #         srv_msg.response_check_include_option('Response', None, '61')
    #         srv_msg.response_check_option_content('Response', '61', None, 'value', exp_client_id)

    # if exp_next_server is not None:
    #     srv_msg.response_check_content('Response', None, 'siaddr', exp_next_server)
    # if exp_server_hostname is not None:
    #     srv_msg.response_check_content('Response', None, 'sname', exp_server_hostname)
    # if exp_boot_file_name is not None:
    #     srv_msg.response_check_content('Response', None, 'file', exp_boot_file_name)

    _send_and_check_response(req_ia,
                             'REPLY',
                             exp_ia_na_t1,
                             exp_ia_na_t2,
                             exp_ia_na_status_code,
                             exp_ia_na_iaaddr_addr,
                             exp_ia_na_iaaddr_preflft,
                             exp_ia_na_iaaddr_validlft,
                             exp_ia_pd_iaprefix_prefix,
                             exp_ia_pd_iaprefix_plen,
                             False)  # exp_rapid_commit=False
예제 #42
0
def send_solicit_and_check_response(duid=None, relay_addr=None, req_ia='IA-NA', rapid_commit=False,
                                    interface_id=None,
                                    exp_ia_na_t1=None,
                                    exp_ia_na_t2=None,
                                    exp_ia_na_status_code=None,
                                    exp_ia_na_iaaddr_addr=None,
                                    exp_ia_na_iaaddr_preflft=None,
                                    exp_ia_na_iaaddr_validlft=None,
                                    exp_ia_pd_iaprefix_prefix=None,
                                    exp_ia_pd_iaprefix_plen=None):
    # send SOLICIT
    misc.test_procedure()
    srv_msg.client_requests_option('1')
    if duid is not None:
        srv_msg.client_sets_value('Client', 'DUID', duid)
    #if client_id is not None:
    #    srv_msg.client_does_include_with_value('client_id', client_id)
    srv_msg.client_does_include('Client', None, 'client-id')
    if req_ia is not None:
        srv_msg.client_does_include('Client', None, req_ia)

    if rapid_commit:
        srv_msg.client_does_include('Client', None, 'rapid-commit')

    srv_msg.client_send_msg('SOLICIT')

    # add relay agent stuff
    if relay_addr is not None:
        srv_msg.client_sets_value('RelayAgent', 'linkaddr', relay_addr)

    if interface_id is not None:
        srv_msg.client_sets_value('RelayAgent', 'ifaceid', interface_id)
        #srv_msg.client_does_include('RelayAgent', None, 'interface-id')

    if relay_addr is not None or interface_id is not None:
        srv_msg.create_relay_forward()

    # check response
    if relay_addr is not None:
        exp_msg_type = 'RELAYREPLY'
    elif rapid_commit:
        exp_msg_type = 'REPLY'
    else:
        exp_msg_type = 'ADVERTISE'

    _send_and_check_response(req_ia,
                             exp_msg_type,
                             exp_ia_na_t1,
                             exp_ia_na_t2,
                             exp_ia_na_status_code,
                             exp_ia_na_iaaddr_addr,
                             exp_ia_na_iaaddr_preflft,
                             exp_ia_na_iaaddr_validlft,
                             exp_ia_pd_iaprefix_prefix,
                             exp_ia_pd_iaprefix_plen,
                             rapid_commit)

    # srv_msg.response_check_include_option('Response', None, '1')
    # srv_msg.response_check_include_option('Response', None, '54')
    # srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
    # srv_msg.response_check_option_content('Response', '54', None, 'value', '$(SRV4_ADDR)')

    # if exp_client_id is not None:
    #     if exp_client_id == 'missing':
    #         srv_msg.response_check_include_option('Response', 'NOT ', '61')
    #     else:
    #         srv_msg.response_check_include_option('Response', None, '61')
    #         srv_msg.response_check_option_content('Response', '61', None, 'value', exp_client_id)

    #return rcvd_yiaddr
    return None
예제 #43
0
파일: dhcp4_scen.py 프로젝트: Streder/forge
def send_solicit_and_check_response(duid=None, relay_addr=None, req_ia='IA-NA', rapid_commit=False,
                                    interface_id=None,
                                    exp_ia_na_t1=None,
                                    exp_ia_na_t2=None,
                                    exp_ia_na_status_code=None,
                                    exp_ia_na_iaaddr_addr=None,
                                    exp_ia_na_iaaddr_preflft=None,
                                    exp_ia_na_iaaddr_validlft=None,
                                    exp_ia_pd_iaprefix_prefix=None,
                                    exp_ia_pd_iaprefix_plen=None,
                                    req_opts=None,
                                    exp_option=None,
                                    no_exp_option=None):
    # send SOLICIT
    misc.test_procedure()
    srv_msg.client_requests_option(1)
    if duid is not None:
        srv_msg.client_sets_value('Client', 'DUID', duid)
    #if client_id is not None:
    #    srv_msg.client_does_include_with_value('client_id', client_id)
    srv_msg.client_does_include('Client', 'client-id')
    if req_ia is not None:
        srv_msg.client_does_include('Client', req_ia)
    if req_opts is not None:
        for opt in req_opts:
            srv_msg.client_requests_option(opt)

    if rapid_commit:
        srv_msg.client_does_include('Client', 'rapid-commit')

    srv_msg.client_send_msg('SOLICIT')

    # add relay agent stuff
    if relay_addr is not None:
        srv_msg.client_sets_value('RelayAgent', 'linkaddr', relay_addr)

    if interface_id is not None:
        srv_msg.client_sets_value('RelayAgent', 'ifaceid', interface_id)
        srv_msg.client_does_include('RelayAgent', 'interface-id')

    if relay_addr is not None or interface_id is not None:
        srv_msg.create_relay_forward()

    # check response
    if relay_addr is not None or interface_id is not None:
        exp_msg_type = 'RELAYREPLY'
    elif rapid_commit:
        exp_msg_type = 'REPLY'
    else:
        exp_msg_type = 'ADVERTISE'

    _send_and_check_response(req_ia,
                             exp_msg_type,
                             exp_ia_na_t1,
                             exp_ia_na_t2,
                             exp_ia_na_status_code,
                             exp_ia_na_iaaddr_addr,
                             exp_ia_na_iaaddr_preflft,
                             exp_ia_na_iaaddr_validlft,
                             exp_ia_pd_iaprefix_prefix,
                             exp_ia_pd_iaprefix_plen,
                             rapid_commit,
                             exp_option,
                             no_exp_option)

    # srv_msg.response_check_include_option(1)
    # srv_msg.response_check_include_option(54)
    # srv_msg.response_check_option_content(1, 'value', '255.255.255.0')
    # srv_msg.response_check_option_content(54, 'value', '$(SRV4_ADDR)')

    # if exp_client_id is not None:
    #     if exp_client_id == 'missing':
    #         srv_msg.response_check_include_option(61, expect_include=False)
    #     else:
    #         srv_msg.response_check_include_option(61)
    #         srv_msg.response_check_option_content(61, 'value', exp_client_id)

    #return rcvd_yiaddr
    return None
예제 #44
0
파일: dhcp4_scen.py 프로젝트: Streder/forge
def send_request_and_check_reply(duid=None,
                                 req_ia=None,
                                 interface_id=None,
                                 exp_ia_na_t1=None,
                                 exp_ia_na_t2=None,
                                 exp_ia_na_status_code=None,
                                 exp_ia_na_iaaddr_addr=None,
                                 exp_ia_na_iaaddr_preflft=None,
                                 exp_ia_na_iaaddr_validlft=None,
                                 exp_ia_pd_iaprefix_prefix=None,
                                 exp_ia_pd_iaprefix_plen=None,
                                 req_opts=None,
                                 exp_option=None,
                                 no_exp_option=None):
    # send REQUEST
    misc.test_procedure()
    world.sender_type = "Client"
    if duid is not None:
        srv_msg.client_sets_value('Client', 'DUID', duid)
    # if client_id is not None:
    #     srv_msg.client_does_include_with_value('client_id', client_id)
    # if server_id is not None:
    #     srv_msg.client_copy_option('server_id')
    # if requested_addr is not None:
    #     srv_msg.client_does_include_with_value('requested_addr', requested_addr)
    # if ciaddr is not None:
    #     srv_msg.client_sets_value('Client', 'ciaddr', ciaddr)
    # srv_msg.client_requests_option(1)
    if req_ia == 'IA-NA':
        srv_msg.client_copy_option('IA_NA')
    if req_ia == 'IA-PD':
        srv_msg.client_copy_option('IA_PD')
    srv_msg.client_copy_option('server-id')
    #srv_msg.client_save_option('server-id')
    #srv_msg.client_add_saved_option('DONT ')
    srv_msg.client_does_include('Client', 'client-id')
    if req_opts is not None:
        for opt in req_opts:
            srv_msg.client_requests_option(opt)

    srv_msg.client_send_msg('REQUEST')

    if interface_id is not None:
        srv_msg.client_sets_value('RelayAgent', 'ifaceid', interface_id)
        srv_msg.client_does_include('RelayAgent', 'interface-id')
        srv_msg.create_relay_forward()

    # srv_msg.response_check_include_option(1)
    # srv_msg.response_check_option_content(1, 'value', '255.255.255.0')
    # srv_msg.response_check_include_option(54)
    # srv_msg.response_check_option_content(54, 'value', '$(SRV4_ADDR)')
    # srv_msg.response_check_include_option(51)
    # if exp_renew_timer is not None:
    #     missing = 'NOT ' if exp_renew_timer == 'missing' else None
    #     srv_msg.response_check_include_option('Response', missing, 58)
    #     if not missing:
    #         srv_msg.response_check_option_content(58, 'value', exp_renew_timer)
    # if exp_rebind_timer is not None:
    #     missing = 'NOT ' if exp_rebind_timer == 'missing' else None
    #     srv_msg.response_check_include_option('Response', missing, 59)
    #     if not missing:
    #         srv_msg.response_check_option_content(59, 'value', exp_rebind_timer)

    # if exp_client_id is not None:
    #     if exp_client_id == 'missing':
    #         srv_msg.response_check_include_option(61, expect_include=False)
    #     else:
    #         srv_msg.response_check_include_option(61)
    #         srv_msg.response_check_option_content(61, 'value', exp_client_id)

    # if exp_next_server is not None:
    #     srv_msg.response_check_content('siaddr', exp_next_server)
    # if exp_server_hostname is not None:
    #     srv_msg.response_check_content('sname', exp_server_hostname)
    # if exp_boot_file_name is not None:
    #     srv_msg.response_check_content('file', exp_boot_file_name)

    if interface_id is not None:
        exp_msg_type = 'RELAYREPLY'
    else:
        exp_msg_type = 'REPLY'

    _send_and_check_response(req_ia,
                             exp_msg_type,
                             exp_ia_na_t1,
                             exp_ia_na_t2,
                             exp_ia_na_status_code,
                             exp_ia_na_iaaddr_addr,
                             exp_ia_na_iaaddr_preflft,
                             exp_ia_na_iaaddr_validlft,
                             exp_ia_pd_iaprefix_prefix,
                             exp_ia_pd_iaprefix_plen,
                             False,  # exp_rapid_commit=False
                             exp_option,
                             no_exp_option)
예제 #45
0
def test_2019_6472_client_id():
    misc.test_setup()
    srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff')
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'IA-PD')
    srv_msg.client_does_include('Client', 'client-id')

    # let's get one exchange correct to save server-id
    correct_id = "\x00\x19\x00\x0c\x27\xfe\x0c\x00\xff\x6f\x95\x00\x00\x02\x00\x00"
    srv_msg.send_raw_message(msg_type='SOLICIT', raw_append=correct_id)
    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ADVERTISE')
    srv_msg.client_save_option('server-id')

    # All messages below are send with too long client-id, and should remain unanswered
    misc.test_procedure()
    srv_msg.client_does_include('Client', 'IA-PD')
    srv_msg.client_send_msg('SOLICIT')

    invalid_data = "\x00\x01\x01\x2C\x00\x04\x00\x01\x5d\x31\xce\x05\x08\x00\x27\x6d\xee\x67" + 800 * "\x12"
    srv_msg.send_raw_message(raw_append=invalid_data)
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()
    srv_msg.send_wait_for_message('MUST', None, expect_response=False)

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'IA-PD')
    srv_msg.client_add_saved_option('DONT ')

    invalid_data = "\x00\x01\x01\x2C\x00\x04\x00\x01\x5d\x31\xce\x05\x08\x00\x27\x6d\xee\x67" + 800 * "\x12"
    srv_msg.send_raw_message(msg_type='REQUEST', raw_append=invalid_data)
    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, expect_response=False)

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'IA-PD')
    srv_msg.client_add_saved_option('DONT ')
    srv_msg.client_send_msg('REQUEST')

    invalid_data = "\x00\x01\x01\x2C\x00\x04\x00\x01\x5d\x31\xce\x05\x08\x00\x27\x6d\xee\x67" + 800 * "\x12"
    srv_msg.send_raw_message(raw_append=invalid_data)
    misc.pass_criteria()
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()
    srv_msg.send_wait_for_message('MUST', None, expect_response=False)

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'IA-PD')

    invalid_data = "\x00\x01\x01\x2C\x00\x04\x00\x01\x5d\x31\xce\x05\x08\x00\x27\x6d\xee\x67" + 800 * "\x12"
    srv_msg.send_raw_message(msg_type='REBIND', raw_append=invalid_data)
    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, expect_response=False)

    misc.test_procedure()
    srv_msg.client_does_include('Client', 'IA-PD')
    srv_msg.client_send_msg('REBIND')

    invalid_data = "\x00\x01\x01\x2C\x00\x04\x00\x01\x5d\x31\xce\x05\x08\x00\x27\x6d\xee\x67" + 800 * "\x12"
    srv_msg.send_raw_message(raw_append=invalid_data)
    misc.pass_criteria()
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()
    srv_msg.send_wait_for_message('MUST', None, expect_response=False)

    misc.test_procedure()
    srv_msg.client_add_saved_option('DONT ')
    srv_msg.client_does_include('Client', 'IA-PD')

    invalid_data = "\x00\x01\x01\x2C\x00\x04\x00\x01\x5d\x31\xce\x05\x08\x00\x27\x6d\xee\x67" + 800 * "\x12"
    srv_msg.send_raw_message(msg_type='RENEW', raw_append=invalid_data)
    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, expect_response=False)

    misc.test_procedure()
    srv_msg.client_add_saved_option('DONT ')
    srv_msg.client_does_include('Client', 'IA-PD')
    srv_msg.client_send_msg('RENEW')

    invalid_data = "\x00\x01\x01\x2C\x00\x04\x00\x01\x5d\x31\xce\x05\x08\x00\x27\x6d\xee\x67" + 800 * "\x12"
    srv_msg.send_raw_message(raw_append=invalid_data)
    misc.pass_criteria()
    srv_msg.client_does_include('RelayAgent', 'interface-id')
    srv_msg.create_relay_forward()
    srv_msg.send_wait_for_message('MUST', None, expect_response=False)
예제 #46
0
def test_v6_relay_interface_two_subnets_same_interface_id():

    misc.test_setup()
    # that is basically misconfiguration!
    srv_control.config_srv_subnet('2001:db8:1::/64', '2001:db8:1::1-2001:db8:1::1')
    srv_control.set_conf_parameter_subnet('interface-id', '"abc"', '0')
    srv_control.config_srv_another_subnet_no_interface('2001:db8:2::/64',
                                                       '2001:db8:2::11-2001:db8:2::20')
    srv_control.set_conf_parameter_subnet('interface-id', '"abc"', '1')
    srv_control.build_and_send_config_files('SSH', 'config-file')
    srv_control.start_srv('DHCP', 'started')

    #  just saving server-id - start
    misc.test_procedure()
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE')

    misc.test_procedure()
    srv_msg.client_save_option('server-id')
    #  just saving server-id - end

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_option_content('Response', '9', None, 'Relayed', 'Message')
    srv_msg.response_check_include_option('Relayed Message', None, '1')
    srv_msg.response_check_include_option('Relayed Message', None, '2')
    srv_msg.response_check_include_option('Relayed Message', None, '3')
    srv_msg.response_check_option_content('Relayed Message', '3', None, 'sub-option', '5')
    srv_msg.response_check_suboption_content('Relayed Message',
                                             '5',
                                             '3',
                                             None,
                                             'addr',
                                             '2001:db8:1::1')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01')
    srv_msg.client_sets_value('Client', 'IA_Address', '2001:db8:1::1')
    srv_msg.client_does_include('Client', None, 'IA_Address')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_add_saved_option('DONT ')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_send_msg('REQUEST')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_option_content('Response', '9', None, 'Relayed', 'Message')
    srv_msg.response_check_include_option('Relayed Message', None, '1')
    srv_msg.response_check_include_option('Relayed Message', None, '2')
    srv_msg.response_check_include_option('Relayed Message', None, '3')
    srv_msg.response_check_option_content('Relayed Message', '3', None, 'sub-option', '5')
    srv_msg.response_check_suboption_content('Relayed Message',
                                             '5',
                                             '3',
                                             None,
                                             'addr',
                                             '2001:db8:1::1')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:33:22:01')
    srv_msg.client_does_include('Client', None, 'client-id')
    srv_msg.client_does_include('Client', None, 'IA-NA')
    srv_msg.client_send_msg('SOLICIT')

    srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'abc')
    srv_msg.client_does_include('RelayAgent', None, 'interface-id')
    srv_msg.create_relay_forward()

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', None, 'RELAYREPLY')
    srv_msg.response_check_include_option('Response', None, '18')
    srv_msg.response_check_include_option('Response', None, '9')
    srv_msg.response_check_option_content('Response', '9', None, 'Relayed', 'Message')
    srv_msg.response_check_include_option('Relayed Message', None, '1')
    srv_msg.response_check_include_option('Relayed Message', None, '2')
    srv_msg.response_check_include_option('Relayed Message', None, '3')
    srv_msg.response_check_option_content('Relayed Message', '3', None, 'sub-option', '13')
    srv_msg.response_check_suboption_content('Relayed Message',
                                             '13',
                                             '3',
                                             None,
                                             'statuscode',
                                             '2')

    references.references_check('Kea')