2 # dslite.sh - IPv4-in-IPv6 tunnel backend
3 # Copyright (c) 2013 OpenWrt.org
5 [ -n "$INCLUDE_ONLY" ] || {
7 . /lib/functions/network.sh
12 proto_dslite_setup() {
15 local link="dslite-$cfg"
17 local mtu ttl peeraddr ip6addr tunlink zone
18 json_get_vars mtu ttl peeraddr ip6addr tunlink zone
20 [ -z "$peeraddr" ] && {
21 proto_notify_error "$cfg" "MISSING_ADDRESS"
22 proto_block_restart "$cfg"
26 ( proto_add_host_dependency "$cfg" "::" "$tunlink" )
28 [ -z "$ip6addr" ] && {
29 local wanif="$tunlink"
30 if [ -z "$wanif" ] && ! network_find_wan6 wanif; then
31 proto_notify_error "$cfg" "NO_WAN_LINK"
35 if ! network_get_ipaddr6 ip6addr "$wanif"; then
36 proto_notify_error "$cfg" "NO_WAN_LINK"
41 proto_init_update "$link" 1
42 proto_add_ipv4_route "0.0.0.0" 0
43 proto_add_ipv4_address "192.0.0.2" "" "" "192.0.0.1"
46 json_add_string mode ipip6
47 json_add_int mtu "${mtu:-1280}"
48 json_add_int ttl "${ttl:-64}"
49 json_add_string local "$ip6addr"
50 json_add_string remote "$peeraddr"
51 [ -n "$tunlink" ] && json_add_string link "$tunlink"
55 [ -n "$zone" ] && json_add_string zone "$zone"
58 proto_send_update "$cfg"
61 proto_dslite_teardown() {
65 proto_dslite_init_config() {
69 proto_config_add_string "ip6addr"
70 proto_config_add_string "peeraddr"
71 proto_config_add_string "tunlink"
72 proto_config_add_int "mtu"
73 proto_config_add_int "ttl"
74 proto_config_add_string "zone"
77 [ -n "$INCLUDE_ONLY" ] || {