xref: /aosp_15_r20/external/ltp/testcases/network/dhcp/dnsmasq_tests.sh (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
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 <[email protected]>
5#
6# Author: Alexey Kodanev [email protected]
7
8start_dhcp()
9{
10	dnsmasq $common_opt \
11	        --dhcp-range=10.1.1.100,10.1.1.100,255.255.255.0,2m \
12	        --dhcp-option=option:router --dhcp-option=option:dns-server
13}
14
15start_dhcp6()
16{
17	# check that dnsmasq supports IPv6
18	dnsmasq --dhcp-range=fd00::1,fd00::1 --test > /dev/null 2>&1 || \
19		tst_brk TCONF "dnsmasq doesn't support DHCPv6"
20
21	dnsmasq $common_opt \
22	        --dhcp-range=fd00:1:1:2::100,fd00:1:1:2::100 --enable-ra \
23	        --dhcp-option=option6:dns-server
24}
25
26cleanup_dhcp()
27{
28	rm -f $log
29}
30
31print_dhcp_version()
32{
33	dnsmasq --version | head -2
34}
35
36dhcp_name="dnsmasq"
37. dhcp_lib.sh
38
39lease_dir="/var/lib/misc"
40tst_selinux_enforced && lease_dir="/var/lib/dnsmasq"
41
42log="/var/log/dnsmasq.tst.log"
43
44lease_file="$lease_dir/dnsmasq.tst.leases"
45
46common_opt="--no-hosts --no-resolv --dhcp-authoritative \
47	--log-facility=$log --interface=$iface0 \
48	--dhcp-leasefile=$lease_file --port=0 --conf-file= "
49
50tst_run
51