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:
42
package/network/ipv6/6to4/Makefile
Normal file
42
package/network/ipv6/6to4/Makefile
Normal file
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# Copyright (C) 2010-2012 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:=6to4
|
||||
PKG_RELEASE:=13
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/6to4
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=@IPV6 +kmod-sit
|
||||
TITLE:=IPv6-to-IPv4 configuration support
|
||||
MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/6to4/description
|
||||
Provides support for 6to4 tunnels in /etc/config/network.
|
||||
Refer to https://openwrt.org/docs/guide-user/base-system/basic-networking
|
||||
configuration details.
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Package/6to4/install
|
||||
$(INSTALL_DIR) $(1)/lib/netifd/proto
|
||||
$(INSTALL_BIN) ./files/6to4.sh $(1)/lib/netifd/proto/6to4.sh
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,6to4))
|
||||
98
package/network/ipv6/6to4/files/6to4.sh
Executable file
98
package/network/ipv6/6to4/files/6to4.sh
Executable file
@@ -0,0 +1,98 @@
|
||||
#!/bin/sh
|
||||
# 6to4.sh - IPv6-in-IPv4 tunnel backend
|
||||
# Copyright (c) 2010-2012 OpenWrt.org
|
||||
|
||||
[ -n "$INCLUDE_ONLY" ] || {
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/network.sh
|
||||
. ../netifd-proto.sh
|
||||
init_proto "$@"
|
||||
}
|
||||
|
||||
find_6to4_prefix() {
|
||||
local ip4="$1"
|
||||
local oIFS="$IFS"; IFS="."; set -- $ip4; IFS="$oIFS"
|
||||
|
||||
printf "2002:%02x%02x:%02x%02x\n" $1 $2 $3 $4
|
||||
}
|
||||
|
||||
test_6to4_rfc1918()
|
||||
{
|
||||
local oIFS="$IFS"; IFS="."; set -- $1; IFS="$oIFS"
|
||||
[ $1 -eq 10 ] && return 0
|
||||
[ $1 -eq 192 ] && [ $2 -eq 168 ] && return 0
|
||||
[ $1 -eq 172 ] && [ $2 -ge 16 ] && [ $2 -le 31 ] && return 0
|
||||
|
||||
# RFC 6598
|
||||
[ $1 -eq 100 ] && [ $2 -ge 64 ] && [ $2 -le 127 ] && return 0
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
proto_6to4_setup() {
|
||||
local cfg="$1"
|
||||
local iface="$2"
|
||||
local link="6to4-$cfg"
|
||||
|
||||
local mtu ttl tos ipaddr
|
||||
json_get_vars mtu ttl tos ipaddr
|
||||
|
||||
( proto_add_host_dependency "$cfg" 0.0.0.0 )
|
||||
|
||||
local wanif
|
||||
if ! network_find_wan wanif; then
|
||||
proto_notify_error "$cfg" "NO_WAN_LINK"
|
||||
return
|
||||
fi
|
||||
|
||||
[ -z "$ipaddr" ] && {
|
||||
if ! network_get_ipaddr ipaddr "$wanif"; then
|
||||
proto_notify_error "$cfg" "NO_WAN_ADDRESS"
|
||||
return
|
||||
fi
|
||||
}
|
||||
|
||||
test_6to4_rfc1918 "$ipaddr" && {
|
||||
proto_notify_error "$cfg" "INVALID_LOCAL_ADDRESS"
|
||||
return
|
||||
}
|
||||
|
||||
# find our local prefix
|
||||
local prefix6=$(find_6to4_prefix "$ipaddr")
|
||||
local local6="$prefix6::1"
|
||||
|
||||
proto_init_update "$link" 1
|
||||
proto_add_ipv6_address "$local6" 16
|
||||
proto_add_ipv6_prefix "$prefix6::/48"
|
||||
|
||||
proto_add_ipv6_route "::" 0 "::192.88.99.1" "" "" "$local6/16"
|
||||
proto_add_ipv6_route "::" 0 "::192.88.99.1" "" "" "$prefix6::/48"
|
||||
|
||||
proto_add_tunnel
|
||||
json_add_string mode sit
|
||||
json_add_int mtu "${mtu:-1280}"
|
||||
json_add_int ttl "${ttl:-64}"
|
||||
[ -n "$tos" ] && json_add_string tos "$tos"
|
||||
json_add_string local "$ipaddr"
|
||||
proto_close_tunnel
|
||||
|
||||
proto_send_update "$cfg"
|
||||
}
|
||||
|
||||
proto_6to4_teardown() {
|
||||
local cfg="$1"
|
||||
}
|
||||
|
||||
proto_6to4_init_config() {
|
||||
no_device=1
|
||||
available=1
|
||||
|
||||
proto_config_add_string "ipaddr"
|
||||
proto_config_add_int "mtu"
|
||||
proto_config_add_int "ttl"
|
||||
proto_config_add_string "tos"
|
||||
}
|
||||
|
||||
[ -n "$INCLUDE_ONLY" ] || {
|
||||
add_protocol 6to4
|
||||
}
|
||||
Reference in New Issue
Block a user