Home | History | Annotate | Download | only in network_DhcpClasslessStaticRoute
      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 
      5 from autotest_lib.client.cros import dhcp_packet
      6 from autotest_lib.client.cros import dhcp_test_base
      7 
      8 # Length of time the lease from the DHCP server is valid.
      9 LEASE_TIME_SECONDS = 60
     10 # We'll fill in the subnet and give this address to the client.
     11 INTENDED_IP_SUFFIX = "0.0.0.101"
     12 # Set the router IP address based on the created prefix.
     13 ROUTER_IP_SUFFIX = "0.0.0.254"
     14 
     15 class network_DhcpClasslessStaticRoute(dhcp_test_base.DhcpTestBase):
     16     def test_body(self):
     17         subnet_mask = self.ethernet_pair.interface_subnet_mask
     18         intended_ip = dhcp_test_base.DhcpTestBase.rewrite_ip_suffix(
     19                 subnet_mask,
     20                 self.server_ip,
     21                 INTENDED_IP_SUFFIX)
     22         router_ip = dhcp_test_base.DhcpTestBase.rewrite_ip_suffix(
     23                 subnet_mask,
     24                 self.server_ip,
     25                 ROUTER_IP_SUFFIX)
     26         # Two real name servers, and a bogus one to be unpredictable.
     27         dns_servers = ["8.8.8.8", "8.8.4.4", "192.168.87.88"]
     28         domain_name = "corp.google.com"
     29         dns_search_list = [
     30                 "nyan.cat.google.com",
     31                 "fail.whale.google.com",
     32                 "zircon.encrusted.tweezers.google.com",
     33                 ]
     34 
     35         # This is the pool of information the server will give out to the client
     36         # upon request.
     37         dhcp_options = {
     38                 dhcp_packet.OPTION_SERVER_ID : self.server_ip,
     39                 dhcp_packet.OPTION_SUBNET_MASK : subnet_mask,
     40                 dhcp_packet.OPTION_IP_LEASE_TIME : LEASE_TIME_SECONDS,
     41                 dhcp_packet.OPTION_REQUESTED_IP : intended_ip,
     42                 dhcp_packet.OPTION_DNS_SERVERS : dns_servers,
     43                 dhcp_packet.OPTION_DOMAIN_NAME : domain_name,
     44                 dhcp_packet.OPTION_DNS_DOMAIN_SEARCH_LIST : dns_search_list,
     45                 dhcp_packet.OPTION_CLASSLESS_STATIC_ROUTES : [
     46                          (0, "0.0.0.0", router_ip),
     47                          (24, "192.168.100.200", "192.168.80.254")
     48                          ]
     49                 }
     50         self.negotiate_and_check_lease(dhcp_options)
     51