3 [ -n "$INCLUDE_ONLY" ] ||
{
5 .
/lib
/functions
/network.sh
17 json_get_vars mtu zone ikey okey
19 proto_init_update
"$link" 1
22 json_add_string mode
"$mode"
23 json_add_int mtu
"${mtu:-1280}"
24 json_add_string
local "$local"
25 json_add_string remote
"$remote"
26 [ -n "$tunlink" ] && json_add_string link
"$tunlink"
28 json_add_object
'data'
29 [ -n "$ikey" ] && json_add_int ikey
"$ikey"
30 [ -n "$okey" ] && json_add_int okey
"$okey"
36 [ -n "$zone" ] && json_add_string zone
"$zone"
39 proto_send_update
"$cfg"
47 json_get_vars df ipaddr peeraddr tunlink
49 [ -z "$peeraddr" ] && {
50 proto_notify_error
"$cfg" "MISSING_ADDRESS"
51 proto_block_restart
"$cfg"
55 ( proto_add_host_dependency
"$cfg" "$peeraddr" "$tunlink" )
58 local wanif
="$tunlink"
59 if [ -z $wanif ] && ! network_find_wan wanif
; then
60 proto_notify_error
"$cfg" "NO_WAN_LINK"
64 if ! network_get_ipaddr ipaddr
"$wanif"; then
65 proto_notify_error
"$cfg" "NO_WAN_LINK"
70 vti_generic_setup
$cfg $mode $ipaddr $peeraddr "vti-$cfg"
76 vti_setup
$cfg "vtiip"
83 local ip6addr peer6addr weakif
84 json_get_vars ip6addr peer6addr tunlink weakif
86 [ -z "$peer6addr" ] && {
87 proto_notify_error
"$cfg" "MISSING_ADDRESS"
88 proto_block_restart
"$cfg"
92 ( proto_add_host_dependency
"$cfg" "$peer6addr" "$tunlink" )
94 [ -z "$ip6addr" ] && {
95 local wanif
="$tunlink"
96 if [ -z $wanif ] && ! network_find_wan6 wanif
; then
97 proto_notify_error
"$cfg" "NO_WAN_LINK"
101 if ! network_get_ipaddr6 ip6addr
"$wanif"; then
102 [ -z "$weakif" ] && weakif
="lan"
103 if ! network_get_ipaddr6 ip6addr
"$weakif"; then
104 proto_notify_error
"$cfg" "NO_WAN_LINK"
110 vti_generic_setup
$cfg $mode $ip6addr $peer6addr "vti6-$cfg"
116 vti6_setup
$cfg "vtiip6"
119 proto_vti_teardown
() {
123 proto_vti6_teardown
() {
127 vti_generic_init_config
() {
131 proto_config_add_int
"mtu"
132 proto_config_add_string
"tunlink"
133 proto_config_add_string
"zone"
134 proto_config_add_int
"ikey"
135 proto_config_add_int
"okey"
138 proto_vti_init_config
() {
139 vti_generic_init_config
140 proto_config_add_string
"ipaddr"
141 proto_config_add_string
"peeraddr"
144 proto_vti6_init_config
() {
145 vti_generic_init_config
146 proto_config_add_string
"ip6addr"
147 proto_config_add_string
"peer6addr"
148 proto_config_add_string
"weakif"
151 [ -n "$INCLUDE_ONLY" ] ||
{
152 [ -f /lib
/modules
/$
(uname
-r)/ip_vti.ko
] && add_protocol vti
153 [ -f /lib
/modules
/$
(uname
-r)/ip6_vti.ko
] && add_protocol vti6