odhcp6c: switch to userspace RA-handling and offload address assignment to netifd
[openwrt.git] / package / network / ipv6 / odhcp6c / files / dhcpv6.sh
1 #!/bin/sh
2
3 . /lib/functions.sh
4 . ../netifd-proto.sh
5 init_proto "$@"
6
7 proto_dhcpv6_init_config() {
8         proto_config_add_string "reqaddress"
9         proto_config_add_string "reqprefix"
10         proto_config_add_string "clientid"
11         proto_config_add_string "reqopts"
12         proto_config_add_string "allow_slaaconly"
13 }
14
15 proto_dhcpv6_setup() {
16         local config="$1"
17         local iface="$2"
18
19         local reqaddress reqprefix clientid reqopts allow_slaaconly
20         json_get_vars reqaddress reqprefix clientid reqopts allow_slaaconly
21
22
23         # Configure
24         local opts=""
25         [ -n "$reqaddress" ] && append opts "-N$reqaddress"
26
27         [ -z "$reqprefix" -o "$reqprefix" = "auto" ] && reqprefix=0
28         [ "$reqprefix" != "no" ] && append opts "-P$reqprefix"
29
30         [ -n "$clientid" ] && append opts "-c$clientid"
31
32         [ "$allow_slaaconly" = "1" ] && append opts "-S"
33
34         for opt in $reqopts; do
35                 append opts "-r$opt"
36         done
37
38
39         proto_export "INTERFACE=$config"
40         proto_run_command "$config" odhcp6c \
41                 -s /lib/netifd/dhcpv6.script \
42                 $opts $iface
43 }
44
45 proto_dhcpv6_teardown() {
46         local interface="$1"
47         proto_kill_command "$interface"
48 }
49
50 add_protocol dhcpv6
51