summaryrefstree
path: root/system/vendor/etc/wide-dhcpv6/dhcp6c.script
blob: ebd934723ce2a9e93d1c3fcd4dcddef7366568d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/system/bin/sh

# Set dhcp.ipv6.<iface>.dnsN properties that contain the
# DNS server addresses given by the DHCPv6 server.
set_dns_props()
{
    case "${new_domain_name_servers}" in
    "")   return 0;;
    esac

    count=1
    for i in 1 2; do
        setprop dhcp.ipv6.${interface}.dns${i} ""
    done

    count=1
    for dnsaddr in ${new_domain_name_servers}; do
    	case "$count" in
    	    1|2)
                setprop dhcp.ipv6.${interface}.dns${count} ${dnsaddr}
                ;;
        esac
        count=$(($count + 1))
    done
}

unset_dns_props()
{
    for i in 1 2; do
        setprop dhcp.ipv6.${interface}.dns${i} ""
        setprop net.dns.ipv6_${i} ""
    done
}

unset_iana_props()
{
	setprop dhcp.ipv6.${interface}.leasetime ""
	setprop dhcp.ipv6.${interface}.ipaddress ""
}

# For debugging:
setprop dhcp.ipv6.${interface}.reason "${REASON}"

case "${REASON}" in
	REQUEST|CONFIRM|INFOREQ)		
		set_dns_props
		setprop dhcp.ipv6.${interface}.result "ok"
		;;
	RENEW|REBIND)
		set_dns_props
		setprop dhcp.ipv6.${interface}.renewresult "ok"
		;;
	RELEASE)				
		unset_dns_props
		unset_iana_props
		setprop dhcp.ipv6.${interface}.result "released"
		;;
	*)	
		setprop dhcp.ipv6.${interface}.result "failed"
		;;
esac