• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5from autotest_lib.client.cros import dhcp_packet
6from autotest_lib.client.cros import dhcp_test_base
7
8# Length of time the lease from the DHCP server is valid.
9LEASE_TIME_SECONDS = 60
10# We'll fill in the subnet and give this address to the client.
11INTENDED_IP_SUFFIX = "0.0.0.101"
12
13class network_DhcpNonAsciiParameter(dhcp_test_base.DhcpTestBase):
14    def test_body(self):
15        subnet_mask = self.ethernet_pair.interface_subnet_mask
16        intended_ip = dhcp_test_base.DhcpTestBase.rewrite_ip_suffix(
17                subnet_mask,
18                self.server_ip,
19                INTENDED_IP_SUFFIX)
20        # Two real name servers, and a bogus one to be unpredictable.
21        dns_servers = ["8.8.8.8", "8.8.4.4", "192.168.87.88"]
22        domain_name = "corp.google.com"
23        dns_search_list = [
24                "nyan.cat.google.com",
25                "fail.whale.google.com",
26                "zircon.encrusted.tweezers.google.com",
27                ]
28        # Set a server name that is invalid as ASCII or UTF-8.
29        server_name = "\xff"
30        # This is the pool of information the server will give out to the client
31        # upon request.
32        dhcp_options = {
33                dhcp_packet.OPTION_SERVER_ID : self.server_ip,
34                dhcp_packet.OPTION_SUBNET_MASK : subnet_mask,
35                dhcp_packet.OPTION_IP_LEASE_TIME : LEASE_TIME_SECONDS,
36                dhcp_packet.OPTION_REQUESTED_IP : intended_ip,
37                dhcp_packet.OPTION_DNS_SERVERS : dns_servers,
38                dhcp_packet.OPTION_DOMAIN_NAME : domain_name,
39                dhcp_packet.OPTION_DNS_DOMAIN_SEARCH_LIST : dns_search_list
40                }
41        dhcp_fields = {
42                dhcp_packet.FIELD_LEGACY_SERVER_NAME : server_name
43                }
44        self.negotiate_and_check_lease(dhcp_options, dhcp_fields)
45