TAYGA is an out-of-kernel stateless NAT64 implementation for Linux. It uses the TUN driver to exchange packets with the kernel, which is the same driver used by OpenVPN and QEMU/KVM.
Signed-off-by: Alexey I. Froloff <[email protected]> --- ipv6/tayga/Makefile | 44 ++++++++++++++++++ ipv6/tayga/files/tayga.config | 6 +++ ipv6/tayga/files/tayga.iface.hotplug | 7 +++ ipv6/tayga/files/tayga.init | 82 ++++++++++++++++++++++++++++++++++ 4 files changed, 139 insertions(+), 0 deletions(-) create mode 100644 ipv6/tayga/Makefile create mode 100644 ipv6/tayga/files/tayga.config create mode 100644 ipv6/tayga/files/tayga.iface.hotplug create mode 100644 ipv6/tayga/files/tayga.init diff --git a/ipv6/tayga/Makefile b/ipv6/tayga/Makefile new file mode 100644 index 0000000..dacb4d6 --- /dev/null +++ b/ipv6/tayga/Makefile @@ -0,0 +1,44 @@ +# $Id$ + +include $(TOPDIR)/rules.mk + +PKG_NAME:=tayga +PKG_VERSION:=0.9.2 +PKG_RELEASE:=1 + +PKG_SOURCE:=tayga-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:=http://www.litech.org/tayga/ +PKG_MD5SUM:=7a7b24165ce008df772f398d86fa280e +PKG_CAT:=bzcat + +PKG_BUILD_DIR:=$(BUILD_DIR)/tayga-$(PKG_VERSION) + +include $(INCLUDE_DIR)/package.mk + +define Package/tayga + SECTION:=ipv6 + CATEGORY:=IPv6 + DEPENDS:=+kmod-tun + TITLE:=Out-of-kernel stateless NAT64 implementation for Linux + URL:=http://www.litech.org/tayga/ +endef + +define Package/tayga/conffiles +/etc/config/tayga +endef + +define Package/tayga/description + TAYGA is an out-of-kernel stateless NAT64 implementation for + Linux. It uses the TUN driver to exchange packets with the + kernel, which is the same driver used by OpenVPN and QEMU/KVM. +endef + +define Package/tayga/install + $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d $(1)/etc/config $(1)/etc/hotplug.d/iface + $(INSTALL_BIN) $(PKG_BUILD_DIR)/tayga $(1)/usr/sbin/ + $(INSTALL_BIN) ./files/tayga.init $(1)/etc/init.d/tayga + $(INSTALL_CONF) ./files/tayga.config $(1)/etc/config/tayga + $(INSTALL_DATA) ./files/tayga.iface.hotplug $(1)/etc/hotplug.d/iface/50-tayga +endef + +$(eval $(call BuildPackage,tayga)) diff --git a/ipv6/tayga/files/tayga.config b/ipv6/tayga/files/tayga.config new file mode 100644 index 0000000..b3f56c6 --- /dev/null +++ b/ipv6/tayga/files/tayga.config @@ -0,0 +1,6 @@ +config tayga config + option interface lan + option tun_device nat64 + option ipv4_addr 192.0.2.1 + option prefix 2001:db8:dead:beef::ffff:0:0/96 + option dynamic_pool 192.0.2.0/24 diff --git a/ipv6/tayga/files/tayga.iface.hotplug b/ipv6/tayga/files/tayga.iface.hotplug new file mode 100644 index 0000000..946cdf9 --- /dev/null +++ b/ipv6/tayga/files/tayga.iface.hotplug @@ -0,0 +1,7 @@ +#!/bin/sh + +/etc/init.d/tayga enabled && [ -n "`pidof tayga`" ] && { + local iface="$(uci_get tayga config interface)" + [ "$ACTION" = "ifup" ] && [ "$INTERFACE" = "$iface" ] && \ + /etc/init.d/tayga restart +} diff --git a/ipv6/tayga/files/tayga.init b/ipv6/tayga/files/tayga.init new file mode 100644 index 0000000..7120b35 --- /dev/null +++ b/ipv6/tayga/files/tayga.init @@ -0,0 +1,82 @@ +#!/bin/sh /etc/rc.common +START=95 + +conf_rule_add() { + local cfg="$1" + local tmpconf="$2" + local ipv4_addr ipv6_addr + config_get ipv4_addr "$cfg" ipv4_addr "" + config_get ipv6_addr "$cfg" ipv6_addr "" + [ -n "$ipv4_addr" ] && [ -n "$ipv6_addr" ] && + echo "map $ipv4_addr $ipv6_addr" >>$tmpconf +} + +start() { + config_load "tayga" + local interface tun_device ipv4_addr ipv6_addr prefix dynamic_pool + + config_get interface config interface + config_get tun_device config tun_device + config_get ipv4_addr config ipv4_addr + config_get ipv6_addr config ipv6_addr + config_get prefix config prefix + config_get dynamic_pool config dynamic_pool + + local args + + include /lib/network + scan_interfaces + + local tmpconf="/var/etc/tayga.conf" + args="-c $tmpconf" + mkdir -p /var/etc + mkdir -p /var/run/tayga + + local iface + + echo "tun-device $tun_device" >$tmpconf + echo "ipv4-addr $ipv4_addr" >>$tmpconf + [ -n "$ipv6_addr" ] && + echo "ipv6-addr $ipv6_addr" >>$tmpconf + [ -n "$prefix" ] && + echo "prefix $prefix" >>$tmpconf + + config_foreach conf_rule_add map_rule "$tmpconf" + + [ -n "$dynamic_pool" ] && + echo "dynamic-pool $dynamic_pool" >>$tmpconf + echo "data-dir /var/run/tayga" >>$tmpconf + + tayga $args --mktun + ip link set "$tun_device" up + + for iface in ${interface:-lan}; do + local ipaddr ip6addr + config_get ipaddr "$iface" ipaddr + config_get ip6addr "$iface" ip6addr + [ -n "$ipaddr" ] && + ip addr add "${ipaddr%/*}" dev "$tun_device" + [ -n "$ip6addr" ] && + ip addr add "${ip6addr%/*}" dev "$tun_device" + done + [ -n "$dynamic_pool" ] && + ip route add "$dynamic_pool" dev "$tun_device" + [ -n "$prefix" ] && + ip route add "$prefix" dev "$tun_device" + + start-stop-daemon -S -x tayga -- $args -p /var/run/tayga.pid +} + +stop() { + start-stop-daemon -K -q -x tayga -p /var/run/tayga.pid + rm -f /var/run/tayga.pid + + config_load "tayga" + local tun_device + + config_get tun_device config tun_device + + ip link set "$tun_device" down + ip addr flush dev "$tun_device" + ip route flush dev "$tun_device" +} -- 1.7.3.4 _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/mailman/listinfo/openwrt-devel
