3 [ -n "$INCLUDE_ONLY" ] ||
{
5 .
/lib
/functions
/network.sh
17 json_get_vars mtu zone ikey okey
19 [ -z "$zone" ] && zone
="wan"
21 proto_init_update
"$link" 1
24 json_add_string mode
"$mode"
25 json_add_int mtu
"${mtu:-1280}"
26 json_add_string
local "$local"
27 json_add_string remote
"$remote"
28 [ -n "$tunlink" ] && json_add_string link
"$tunlink"
29 json_add_string info
"${ikey:-0},${okey:-0}"
33 [ -n "$zone" ] && json_add_string zone
"$zone"
36 proto_send_update
"$cfg"
44 json_get_vars df ipaddr peeraddr tunlink
46 [ -z "$peeraddr" ] && {
47 proto_notify_error
"$cfg" "MISSING_ADDRESS"
48 proto_block_restart
"$cfg"
52 ( proto_add_host_dependency
"$cfg" "$peeraddr" "$tunlink" )
55 local wanif
="$tunlink"
56 if [ -z $wanif ] && ! network_find_wan wanif
; then
57 proto_notify_error
"$cfg" "NO_WAN_LINK"
61 if ! network_get_ipaddr ipaddr
"$wanif"; then
62 proto_notify_error
"$cfg" "NO_WAN_LINK"
67 vti_generic_setup
$cfg $mode $ipaddr $peeraddr "vti-$cfg"
73 vti_setup
$cfg "vtiip"
80 local ip6addr peer6addr weakif
81 json_get_vars ip6addr peer6addr tunlink weakif
83 [ -z "$peer6addr" ] && {
84 proto_notify_error
"$cfg" "MISSING_ADDRESS"
85 proto_block_restart
"$cfg"
89 ( proto_add_host_dependency
"$cfg" "$peer6addr" "$tunlink" )
91 [ -z "$ip6addr" ] && {
92 local wanif
="$tunlink"
93 if [ -z $wanif ] && ! network_find_wan6 wanif
; then
94 proto_notify_error
"$cfg" "NO_WAN_LINK"
98 if ! network_get_ipaddr6 ip6addr
"$wanif"; then
99 [ -z "$weakif" ] && weakif
="lan"
100 if ! network_get_ipaddr6 ip6addr
"$weakif"; then
101 proto_notify_error
"$cfg" "NO_WAN_LINK"
107 vti_generic_setup
$cfg $mode $ip6addr $peer6addr "vti6-$cfg"
113 vti6_setup
$cfg "vtiip6"
116 proto_vti_teardown
() {
120 proto_vti6_teardown
() {
124 vti_generic_init_config
() {
128 proto_config_add_int
"mtu"
129 proto_config_add_string
"tunlink"
130 proto_config_add_string
"zone"
131 proto_config_add_int
"ikey"
132 proto_config_add_int
"okey"
135 proto_vti_init_config
() {
136 vti_generic_init_config
137 proto_config_add_string
"ipaddr"
138 proto_config_add_string
"peeraddr"
141 proto_vti6_init_config
() {
142 vti_generic_init_config
143 proto_config_add_string
"ip6addr"
144 proto_config_add_string
"peer6addr"
145 proto_config_add_string
"weakif"
148 [ -n "$INCLUDE_ONLY" ] ||
{
149 [ -f /lib
/modules
/$
(uname
-r)/ip_vti.ko
] && add_protocol vti
150 [ -f /lib
/modules
/$
(uname
-r)/ip6_vti.ko
] && add_protocol vti6