nftables: bump to 2014-09-30, disable gmp
[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 renew_handler=1
9
10 proto_config_add_string 'reqaddress:or("try","force","none")'
11 proto_config_add_string 'reqprefix:or("auto","no",range(0, 64))'
12 proto_config_add_string clientid
13 proto_config_add_string 'reqopts:list(uinteger)'
14 proto_config_add_string 'noslaaconly:bool'
15 proto_config_add_string 'forceprefix:bool'
16 proto_config_add_string 'norelease:bool'
17 proto_config_add_string 'ip6prefix:ip6addr'
18 proto_config_add_string iface_dslite
19 proto_config_add_string zone_dslite
20 proto_config_add_string iface_map
21 proto_config_add_string zone_map
22 proto_config_add_string zone
23 proto_config_add_string 'ifaceid:ip6addr'
24 proto_config_add_string 'sourcerouting:bool'
25 proto_config_add_string "userclass"
26 proto_config_add_string "vendorclass"
27 proto_config_add_boolean delegate
28 proto_config_add_int "soltimeout"
29 }
30
31 proto_dhcpv6_setup() {
32 local config="$1"
33 local iface="$2"
34
35 local reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite iface_map ifaceid sourcerouting userclass vendorclass delegate zone_dslite zone_map zone soltimeout
36 json_get_vars reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite iface_map ifaceid sourcerouting userclass vendorclass delegate zone_dslite zone_map zone soltimeout
37
38
39 # Configure
40 local opts=""
41 [ -n "$reqaddress" ] && append opts "-N$reqaddress"
42
43 [ -z "$reqprefix" -o "$reqprefix" = "auto" ] && reqprefix=0
44 [ "$reqprefix" != "no" ] && append opts "-P$reqprefix"
45
46 [ -n "$clientid" ] && append opts "-c$clientid"
47
48 [ "$noslaaconly" = "1" ] && append opts "-S"
49
50 [ "$forceprefix" = "1" ] && append opts "-F"
51
52 [ "$norelease" = "1" ] && append opts "-k"
53
54 [ -n "$ifaceid" ] && append opts "-i$ifaceid"
55
56 [ -n "$vendorclass" ] && append opts "-V$vendorclass"
57
58 [ -n "$userclass" ] && append opts "-u$userclass"
59
60 for opt in $reqopts; do
61 append opts "-r$opt"
62 done
63
64 append opts "-t${soltimeout:-120}"
65
66 [ -n "$ip6prefix" ] && proto_export "USERPREFIX=$ip6prefix"
67 [ -n "$iface_dslite" ] && proto_export "IFACE_DSLITE=$iface_dslite"
68 [ -n "$iface_map" ] && proto_export "IFACE_MAP=$iface_map"
69 [ "$sourcerouting" != "0" ] && proto_export "SOURCE_ROUTING=1"
70 [ "$delegate" = "0" ] && proto_export "IFACE_DSLITE_DELEGATE=0"
71 [ "$delegate" = "0" ] && proto_export "IFACE_MAP_DELEGATE=0"
72 [ -n "$zone_dslite" ] && proto_export "ZONE_DSLITE=$zone_dslite"
73 [ -n "$zone_map" ] && proto_export "ZONE_MAP=$zone_map"
74 [ -n "$zone" ] && proto_export "ZONE=$zone"
75
76 proto_export "INTERFACE=$config"
77 proto_run_command "$config" odhcp6c \
78 -s /lib/netifd/dhcpv6.script \
79 $opts $iface
80 }
81
82 proto_dhcpv6_renew() {
83 local interface="$1"
84 # SIGUSR1 forces odhcp6c to renew its lease
85 local sigusr1="$(kill -l SIGUSR1)"
86 [ -n "$sigusr1" ] && proto_kill_command "$interface" $sigusr1
87 }
88
89 proto_dhcpv6_teardown() {
90 local interface="$1"
91 proto_kill_command "$interface"
92 }
93
94 add_protocol dhcpv6
95