• 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_DhcpNegotiationSuccess(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                "corgie.google.com",
25                "lies.google.com",
26                "that.is.a.tasty.burger.google.com",
27                ]
28        # This is the pool of information the server will give out to the client
29        # upon request.
30        dhcp_options = {
31                dhcp_packet.OPTION_SERVER_ID : self.server_ip,
32                dhcp_packet.OPTION_SUBNET_MASK : subnet_mask,
33                dhcp_packet.OPTION_IP_LEASE_TIME : LEASE_TIME_SECONDS,
34                dhcp_packet.OPTION_REQUESTED_IP : intended_ip,
35                dhcp_packet.OPTION_DNS_SERVERS : dns_servers,
36                dhcp_packet.OPTION_DOMAIN_NAME : domain_name,
37                dhcp_packet.OPTION_DNS_DOMAIN_SEARCH_LIST : dns_search_list,
38                }
39        self.negotiate_and_check_lease(dhcp_options)
40