LRX21M.vC1O-0
[GitHub/mt8127/ttab-system.git] / system / etc / wide-dhcpv6 / dhcp6c.script
CommitLineData
d05bb22f
S
1#!/system/bin/sh
2
3# Set dhcp.ipv6.<iface>.dnsN properties that contain the
4# DNS server addresses given by the DHCPv6 server.
5set_dns_props()
6{
7 case "${new_domain_name_servers}" in
8 "") return 0;;
9 esac
10
11 count=1
12 for i in 1 2; do
13 setprop dhcp.ipv6.${interface}.dns${i} ""
14 done
15
16 count=1
17 for dnsaddr in ${new_domain_name_servers}; do
18 case "$count" in
19 1|2)
20 setprop dhcp.ipv6.${interface}.dns${count} ${dnsaddr}
21 ;;
22 esac
23 count=$(($count + 1))
24 done
25}
26
27unset_dns_props()
28{
29 for i in 1 2; do
30 setprop dhcp.ipv6.${interface}.dns${i} ""
31 setprop net.dns.ipv6_${i} ""
32 done
33}
34
35unset_iana_props()
36{
37 setprop dhcp.ipv6.${interface}.leasetime ""
38 setprop dhcp.ipv6.${interface}.ipaddress ""
39}
40
41# For debugging:
42setprop dhcp.ipv6.${interface}.reason "${REASON}"
43
44case "${REASON}" in
45 REQUEST|CONFIRM|INFOREQ)
46 set_dns_props
47 setprop dhcp.ipv6.${interface}.result "ok"
48 ;;
49 RENEW|REBIND)
50 set_dns_props
51 setprop dhcp.ipv6.${interface}.renewresult "ok"
52 ;;
53 RELEASE)
54 unset_dns_props
55 unset_iana_props
56 setprop dhcp.ipv6.${interface}.result "released"
57 ;;
58 *)
59 setprop dhcp.ipv6.${interface}.result "failed"
60 ;;
61esac