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() {
17 local mtu ttl peeraddr ip6addr tunlink zone weakif
18 json_get_vars mtu ttl peeraddr ip6addr tunlink zone weakif
20 [ -z "$peeraddr" ] && {
21 proto_notify_error "$cfg" "MISSING_ADDRESS"
22 proto_block_restart "$cfg"
26 ( proto_add_host_dependency "$cfg" "::" "$tunlink" )
28 peeraddr=$(resolveip -6 $peeraddr)
29 if [ -z "$peeraddr" ]; then
31 peeraddr=$(resolveip -6 $peeraddr)
32 if [ -z "$peeraddr" ]; then
33 proto_notify_error "$cfg" "AFTR_DNS_FAIL"
37 peeraddr="${peeraddr%% *}"
39 [ -z "$ip6addr" ] && {
40 local wanif="$tunlink"
41 if [ -z "$wanif" ] && ! network_find_wan6 wanif; then
42 proto_notify_error "$cfg" "NO_WAN_LINK"
46 if ! network_get_ipaddr6 ip6addr "$wanif"; then
47 [ -z "$weakif" ] && weakif="lan"
48 if ! network_get_ipaddr6 ip6addr "$weakif"; then
49 proto_notify_error "$cfg" "NO_WAN_LINK"
55 proto_init_update "$link" 1
56 proto_add_ipv4_route "0.0.0.0" 0
57 proto_add_ipv4_address "192.0.0.2" "" "" "192.0.0.1"
60 json_add_string mode ipip6
61 json_add_int mtu "${mtu:-1280}"
62 json_add_int ttl "${ttl:-64}"
63 json_add_string local "$ip6addr"
64 json_add_string remote "$peeraddr"
65 [ -n "$tunlink" ] && json_add_string link "$tunlink"
69 [ -n "$zone" ] && json_add_string zone "$zone"
71 json_add_array firewall
73 json_add_string type nat
74 json_add_string target ACCEPT
79 proto_send_update "$cfg"
82 proto_dslite_teardown() {
86 proto_dslite_init_config() {
90 proto_config_add_string "ip6addr"
91 proto_config_add_string "peeraddr"
92 proto_config_add_string "tunlink"
93 proto_config_add_int "mtu"
94 proto_config_add_int "ttl"
95 proto_config_add_string "zone"
96 proto_config_add_string "weakif"
99 [ -n "$INCLUDE_ONLY" ] || {