Initial commit
Some checks failed
Build Kernel / Build all affected Kernels (push) Has been cancelled
Build all core packages / Build all core packages for selected target (push) Has been cancelled
Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
Build Toolchains / Build Toolchains for each target (push) Has been cancelled
Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
Coverity scan build / Coverity x86/64 build (push) Has been cancelled
Some checks failed
Build Kernel / Build all affected Kernels (push) Has been cancelled
Build all core packages / Build all core packages for selected target (push) Has been cancelled
Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
Build Toolchains / Build Toolchains for each target (push) Has been cancelled
Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
Coverity scan build / Coverity x86/64 build (push) Has been cancelled
This commit is contained in:
44
package/network/config/vti/Makefile
Normal file
44
package/network/config/vti/Makefile
Normal file
@@ -0,0 +1,44 @@
|
||||
#
|
||||
# Copyright (C) 2014 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=vti
|
||||
PKG_RELEASE:=5
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/vti/Default
|
||||
endef
|
||||
|
||||
define Package/vti
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
MAINTAINER:=Andre Valentin <avalentin@marcant.net>
|
||||
TITLE:=Virtual IPsec Tunnel Interface config support
|
||||
DEPENDS:=+kmod-ip-vti +IPV6:kmod-ip6-vti
|
||||
PROVIDES:=vtiv4 vtiv6
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/vti/description
|
||||
Virtual IPsec Tunnel Interface config support (IPv4 and IPv6) in /etc/config/network.
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Package/vti/install
|
||||
$(INSTALL_DIR) $(1)/lib/netifd/proto
|
||||
$(INSTALL_BIN) ./files/vti.sh $(1)/lib/netifd/proto/vti.sh
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,vti))
|
||||
154
package/network/config/vti/files/vti.sh
Executable file
154
package/network/config/vti/files/vti.sh
Executable file
@@ -0,0 +1,154 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ -n "$INCLUDE_ONLY" ] || {
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/network.sh
|
||||
. ../netifd-proto.sh
|
||||
init_proto "$@"
|
||||
}
|
||||
|
||||
vti_generic_setup() {
|
||||
local cfg="$1"
|
||||
local mode="$2"
|
||||
local local="$3"
|
||||
local remote="$4"
|
||||
local link="$5"
|
||||
local mtu zone ikey
|
||||
json_get_vars mtu zone ikey okey
|
||||
|
||||
proto_init_update "$link" 1
|
||||
|
||||
proto_add_tunnel
|
||||
json_add_string mode "$mode"
|
||||
json_add_int mtu "${mtu:-1280}"
|
||||
json_add_string local "$local"
|
||||
json_add_string remote "$remote"
|
||||
[ -n "$tunlink" ] && json_add_string link "$tunlink"
|
||||
|
||||
json_add_object 'data'
|
||||
[ -n "$ikey" ] && json_add_int ikey "$ikey"
|
||||
[ -n "$okey" ] && json_add_int okey "$okey"
|
||||
json_close_object
|
||||
|
||||
proto_close_tunnel
|
||||
|
||||
proto_add_data
|
||||
[ -n "$zone" ] && json_add_string zone "$zone"
|
||||
proto_close_data
|
||||
|
||||
proto_send_update "$cfg"
|
||||
}
|
||||
|
||||
vti_setup() {
|
||||
local cfg="$1"
|
||||
local mode="$2"
|
||||
|
||||
local ipaddr peeraddr
|
||||
json_get_vars df ipaddr peeraddr tunlink
|
||||
|
||||
[ -z "$peeraddr" ] && {
|
||||
proto_notify_error "$cfg" "MISSING_ADDRESS"
|
||||
proto_block_restart "$cfg"
|
||||
exit
|
||||
}
|
||||
|
||||
( proto_add_host_dependency "$cfg" "$peeraddr" "$tunlink" )
|
||||
|
||||
[ -z "$ipaddr" ] && {
|
||||
local wanif="$tunlink"
|
||||
if [ -z $wanif ] && ! network_find_wan wanif; then
|
||||
proto_notify_error "$cfg" "NO_WAN_LINK"
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! network_get_ipaddr ipaddr "$wanif"; then
|
||||
proto_notify_error "$cfg" "NO_WAN_LINK"
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
vti_generic_setup $cfg $mode $ipaddr $peeraddr "vti-$cfg"
|
||||
}
|
||||
|
||||
proto_vti_setup() {
|
||||
local cfg="$1"
|
||||
|
||||
vti_setup $cfg "vtiip"
|
||||
}
|
||||
|
||||
vti6_setup() {
|
||||
local cfg="$1"
|
||||
local mode="$2"
|
||||
|
||||
local ip6addr peer6addr weakif
|
||||
json_get_vars ip6addr peer6addr tunlink weakif
|
||||
|
||||
[ -z "$peer6addr" ] && {
|
||||
proto_notify_error "$cfg" "MISSING_ADDRESS"
|
||||
proto_block_restart "$cfg"
|
||||
exit
|
||||
}
|
||||
|
||||
( proto_add_host_dependency "$cfg" "$peer6addr" "$tunlink" )
|
||||
|
||||
[ -z "$ip6addr" ] && {
|
||||
local wanif="$tunlink"
|
||||
if [ -z $wanif ] && ! network_find_wan6 wanif; then
|
||||
proto_notify_error "$cfg" "NO_WAN_LINK"
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! network_get_ipaddr6 ip6addr "$wanif"; then
|
||||
[ -z "$weakif" ] && weakif="lan"
|
||||
if ! network_get_ipaddr6 ip6addr "$weakif"; then
|
||||
proto_notify_error "$cfg" "NO_WAN_LINK"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
vti_generic_setup $cfg $mode $ip6addr $peer6addr "vti6-$cfg"
|
||||
}
|
||||
|
||||
proto_vti6_setup() {
|
||||
local cfg="$1"
|
||||
|
||||
vti6_setup $cfg "vtiip6"
|
||||
}
|
||||
|
||||
proto_vti_teardown() {
|
||||
local cfg="$1"
|
||||
}
|
||||
|
||||
proto_vti6_teardown() {
|
||||
local cfg="$1"
|
||||
}
|
||||
|
||||
vti_generic_init_config() {
|
||||
no_device=1
|
||||
available=1
|
||||
|
||||
proto_config_add_int "mtu"
|
||||
proto_config_add_string "tunlink"
|
||||
proto_config_add_string "zone"
|
||||
proto_config_add_int "ikey"
|
||||
proto_config_add_int "okey"
|
||||
}
|
||||
|
||||
proto_vti_init_config() {
|
||||
vti_generic_init_config
|
||||
proto_config_add_string "ipaddr"
|
||||
proto_config_add_string "peeraddr"
|
||||
}
|
||||
|
||||
proto_vti6_init_config() {
|
||||
vti_generic_init_config
|
||||
proto_config_add_string "ip6addr"
|
||||
proto_config_add_string "peer6addr"
|
||||
proto_config_add_string "weakif"
|
||||
}
|
||||
|
||||
[ -n "$INCLUDE_ONLY" ] || {
|
||||
[ -d /sys/module/ip_vti ] && add_protocol vti
|
||||
[ -d /sys/module/ip6_vti ] && add_protocol vti6
|
||||
}
|
||||
Reference in New Issue
Block a user