• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2014-2018 Oracle and/or its affiliates. All Rights Reserved.
4# Copyright (c) 2018 Petr Vorel <pvorel@suse.cz>
5# Copyright (c) International Business Machines  Corp., 2001
6#
7# Author:       Manoj Iyer, manjo@mail.utexas.edu
8# Author:       Alexey Kodanev alexey.kodanev@oracle.com
9
10dhcp_name="dhcpd"
11
12. dhcp_lib.sh
13
14setup_dhcpd_conf()
15{
16	if [ -f /etc/dhcpd.conf ]; then
17		DHCPD_CONF="/etc/dhcpd.conf"
18	elif [ -f /etc/dhcp/dhcpd.conf ]; then
19		DHCPD_CONF="/etc/dhcp/dhcpd.conf"
20	else
21		tst_brk TBROK "failed to find dhcpd.conf"
22	fi
23
24	mv $DHCPD_CONF dhcpd.conf
25	[ $? -ne 0 ] && tst_brk TBROK "failed to backup dhcpd.conf"
26
27	mv tst_dhcpd.conf $DHCPD_CONF
28	[ $? -ne 0 ] && tst_brk TBROK "failed to create dhcpd.conf"
29}
30
31start_dhcpd()
32{
33	touch tst_hdcpd.lease
34	dhcpd -lf tst_hdcpd.lease -$TST_IPVER $iface0 > tst_dhcpd.err 2>&1
35}
36
37start_dhcp()
38{
39	cat > tst_dhcpd.conf <<-EOF
40	ddns-update-style none;
41	update-static-leases off;
42	subnet 10.1.1.0 netmask 255.255.255.0 {
43		range 10.1.1.100 10.1.1.100;
44		default-lease-time 60;
45		max-lease-time 60;
46	}
47	EOF
48	setup_dhcpd_conf
49	start_dhcpd
50}
51
52start_dhcp6()
53{
54	cat > tst_dhcpd.conf <<-EOF
55	ddns-update-style none;
56	update-static-leases off;
57	subnet6 fd00:1:1:2::/64 {
58		range6 fd00:1:1:2::100 fd00:1:1:2::100;
59		default-lease-time 60;
60		max-lease-time 60;
61	}
62	EOF
63	setup_dhcpd_conf
64	start_dhcpd
65}
66
67cleanup_dhcp()
68{
69	[ -f dhcpd.conf ] && mv dhcpd.conf $DHCPD_CONF
70}
71
72print_dhcp_log()
73{
74	cat tst_dhcpd.err
75}
76
77print_dhcp_version()
78{
79	dhcpd --version 2>&1
80}
81
82tst_run
83