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"
30 json_add_object
'data'
31 [ -n "$ikey" ] && json_add_int ikey
"$ikey"
32 [ -n "$okey" ] && json_add_int okey
"$okey"
38 [ -n "$zone" ] && json_add_string zone
"$zone"
41 proto_send_update
"$cfg"
49 json_get_vars df ipaddr peeraddr tunlink
51 [ -z "$peeraddr" ] && {
52 proto_notify_error
"$cfg" "MISSING_ADDRESS"
53 proto_block_restart
"$cfg"
57 ( proto_add_host_dependency
"$cfg" "$peeraddr" "$tunlink" )
60 local wanif
="$tunlink"
61 if [ -z $wanif ] && ! network_find_wan wanif
; then
62 proto_notify_error
"$cfg" "NO_WAN_LINK"
66 if ! network_get_ipaddr ipaddr
"$wanif"; then
67 proto_notify_error
"$cfg" "NO_WAN_LINK"
72 vti_generic_setup
$cfg $mode $ipaddr $peeraddr "vti-$cfg"
78 vti_setup
$cfg "vtiip"
85 local ip6addr peer6addr weakif
86 json_get_vars ip6addr peer6addr tunlink weakif
88 [ -z "$peer6addr" ] && {
89 proto_notify_error
"$cfg" "MISSING_ADDRESS"
90 proto_block_restart
"$cfg"
94 ( proto_add_host_dependency
"$cfg" "$peer6addr" "$tunlink" )
96 [ -z "$ip6addr" ] && {
97 local wanif
="$tunlink"
98 if [ -z $wanif ] && ! network_find_wan6 wanif
; then
99 proto_notify_error
"$cfg" "NO_WAN_LINK"
103 if ! network_get_ipaddr6 ip6addr
"$wanif"; then
104 [ -z "$weakif" ] && weakif
="lan"
105 if ! network_get_ipaddr6 ip6addr
"$weakif"; then
106 proto_notify_error
"$cfg" "NO_WAN_LINK"
112 vti_generic_setup
$cfg $mode $ip6addr $peer6addr "vti6-$cfg"
118 vti6_setup
$cfg "vtiip6"
121 proto_vti_teardown
() {
125 proto_vti6_teardown
() {
129 vti_generic_init_config
() {
133 proto_config_add_int
"mtu"
134 proto_config_add_string
"tunlink"
135 proto_config_add_string
"zone"
136 proto_config_add_int
"ikey"
137 proto_config_add_int
"okey"
140 proto_vti_init_config
() {
141 vti_generic_init_config
142 proto_config_add_string
"ipaddr"
143 proto_config_add_string
"peeraddr"
146 proto_vti6_init_config
() {
147 vti_generic_init_config
148 proto_config_add_string
"ip6addr"
149 proto_config_add_string
"peer6addr"
150 proto_config_add_string
"weakif"
153 [ -n "$INCLUDE_ONLY" ] ||
{
154 [ -f /lib
/modules
/$
(uname
-r)/ip_vti.ko
] && add_protocol vti
155 [ -f /lib
/modules
/$
(uname
-r)/ip6_vti.ko
] && add_protocol vti6