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
() {
18 local mtu ttl peeraddr ip6addr tunlink zone weakif
19 json_get_vars mtu ttl peeraddr ip6addr tunlink zone weakif
21 [ -z "$peeraddr" ] && {
22 proto_notify_error
"$cfg" "MISSING_ADDRESS"
23 proto_block_restart
"$cfg"
27 ( proto_add_host_dependency
"$cfg" "::" "$tunlink" )
29 remoteip6
=$
(resolveip
-6 $peeraddr)
30 if [ -z "$remoteip6" ]; then
32 remoteip6
=$
(resolveip
-6 $peeraddr)
33 if [ -z "$remoteip6" ]; then
34 proto_notify_error
"$cfg" "AFTR_DNS_FAIL"
38 peeraddr
="${remoteip6%% *}"
40 [ -z "$ip6addr" ] && {
41 local wanif
="$tunlink"
42 if [ -z "$wanif" ] && ! network_find_wan6 wanif
; then
43 proto_notify_error
"$cfg" "NO_WAN_LINK"
47 if ! network_get_ipaddr6 ip6addr
"$wanif"; then
48 [ -z "$weakif" ] && weakif
="lan"
49 if ! network_get_ipaddr6 ip6addr
"$weakif"; then
50 proto_notify_error
"$cfg" "NO_WAN_LINK"
56 proto_init_update
"$link" 1
57 proto_add_ipv4_route
"0.0.0.0" 0
58 proto_add_ipv4_address
"192.0.0.2" "" "" "192.0.0.1"
61 json_add_string mode ipip6
62 json_add_int mtu
"${mtu:-1280}"
63 json_add_int ttl
"${ttl:-64}"
64 json_add_string
local "$ip6addr"
65 json_add_string remote
"$peeraddr"
66 [ -n "$tunlink" ] && json_add_string link
"$tunlink"
70 [ -n "$zone" ] && json_add_string zone
"$zone"
72 json_add_array firewall
74 json_add_string
type nat
75 json_add_string target ACCEPT
80 proto_send_update
"$cfg"
83 proto_dslite_teardown
() {
87 proto_dslite_init_config
() {
91 proto_config_add_string
"ip6addr"
92 proto_config_add_string
"peeraddr"
93 proto_config_add_string
"tunlink"
94 proto_config_add_int
"mtu"
95 proto_config_add_int
"ttl"
96 proto_config_add_string
"zone"
97 proto_config_add_string
"weakif"
100 [ -n "$INCLUDE_ONLY" ] ||
{