aa7a2e1b0888ce6e8b188cbe2937ddd6a9dc7f33
[openwrt/staging/chunkeey.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:or("try","force","none")'
9 proto_config_add_string 'reqprefix:or("auto","no",range(0, 64))'
10 proto_config_add_string clientid
11 proto_config_add_string 'reqopts:list(uinteger)'
12 proto_config_add_string 'noslaaconly:bool'
13 proto_config_add_string 'forceprefix:bool'
14 proto_config_add_string 'norelease:bool'
15 proto_config_add_string 'ip6prefix:ip6addr'
16 proto_config_add_string iface_dslite
17 proto_config_add_string 'ifaceid:ip6addr'
18 proto_config_add_string 'sourcerouting:bool'
19 proto_config_add_string "userclass"
20 proto_config_add_string "vendorclass"
21 proto_config_add_boolean delegate
22 }
23
24 proto_dhcpv6_setup() {
25 local config="$1"
26 local iface="$2"
27
28 local reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite ifaceid sourcerouting userclass vendorclass delegate
29 json_get_vars reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite ifaceid sourcerouting userclass vendorclass delegate
30
31
32 # Configure
33 local opts=""
34 [ -n "$reqaddress" ] && append opts "-N$reqaddress"
35
36 [ -z "$reqprefix" -o "$reqprefix" = "auto" ] && reqprefix=0
37 [ "$reqprefix" != "no" ] && append opts "-P$reqprefix"
38
39 [ -n "$clientid" ] && append opts "-c$clientid"
40
41 [ "$noslaaconly" = "1" ] && append opts "-S"
42
43 [ "$forceprefix" = "1" ] && append opts "-F"
44
45 [ "$norelease" = "1" ] && append opts "-k"
46
47 [ -n "$ifaceid" ] && append opts "-i$ifaceid"
48
49 [ -n "$vendorclass" ] && append opts "-V$vendorclass"
50
51 [ -n "$userclass" ] && append opts "-u$userclass"
52
53 for opt in $reqopts; do
54 append opts "-r$opt"
55 done
56
57 [ -n "$ip6prefix" ] && proto_export "USERPREFIX=$ip6prefix"
58 [ -n "$iface_dslite" ] && proto_export "IFACE_DSLITE=$iface_dslite"
59 [ "$sourcerouting" != "0" ] && proto_export "SOURCE_ROUTING=1"
60 [ "$delegate" = "0" ] && proto_export "IFACE_DSLITE_DELEGATE=0"
61
62 proto_export "INTERFACE=$config"
63 proto_run_command "$config" odhcp6c \
64 -s /lib/netifd/dhcpv6.script \
65 $opts $iface
66 }
67
68 proto_dhcpv6_teardown() {
69 local interface="$1"
70 proto_kill_command "$interface"
71 }
72
73 add_protocol dhcpv6
74