From 7bf4be7da8ed53e26643e9f3cb72e0c4de8cf3e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Caletka?= Date: Mon, 23 Jun 2014 15:49:35 +0200 Subject: [PATCH 1/3] aiccu: import from oldpackages Signed-off-by: Ondrej Caletka --- ipv6/aiccu/Makefile | 51 ++++++++++ ipv6/aiccu/patches/100-cross_compile.patch | 101 +++++++++++++++++++ ipv6/aiccu/patches/200-add_dn_skipname.patch | 70 +++++++++++++ ipv6/aiccu/patches/300-resolver-uclibc.patch | 29 ++++++ 4 files changed, 251 insertions(+) create mode 100644 ipv6/aiccu/Makefile create mode 100644 ipv6/aiccu/patches/100-cross_compile.patch create mode 100644 ipv6/aiccu/patches/200-add_dn_skipname.patch create mode 100644 ipv6/aiccu/patches/300-resolver-uclibc.patch diff --git a/ipv6/aiccu/Makefile b/ipv6/aiccu/Makefile new file mode 100644 index 0000000000..0590ad0d8c --- /dev/null +++ b/ipv6/aiccu/Makefile @@ -0,0 +1,51 @@ +# +# Copyright (C) 2006-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:=aiccu +PKG_VERSION:=20070115 +PKG_RELEASE:=10 + +PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.sixxs.net/archive/sixxs/aiccu/unix +PKG_MD5SUM:=c9bcc83644ed788e22a7c3f3d4021350 + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) + +include $(INCLUDE_DIR)/package.mk + +define Package/aiccu + SECTION:=net + CATEGORY:=Network + DEPENDS:=+libpthread +ip +kmod-sit +kmod-tun + TITLE:=SixXS Automatic IPv6 Connectivity Client Utility + URL:=http://www.sixxs.net/tools/aiccu/ +endef + +define Build/Configure + $(SED) "s,strip,/bin/true," $(PKG_BUILD_DIR)/unix-console/Makefile +endef + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" OS_NAME="Linux" OS_VERSION="$(LINUX_VERSION)" \ + EXTRA_CFLAGS="$(TARGET_CFLAGS)" \ + EXTRA_LDFLAGS="$(TARGET_LDFLAGS) -pthread" \ + DEBUG=0 +endef + +define Package/aiccu/conffiles +/etc/config/aiccu +endef + +define Package/aiccu/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/unix-console/$(PKG_NAME) $(1)/usr/sbin/ +endef + +$(eval $(call BuildPackage,aiccu)) diff --git a/ipv6/aiccu/patches/100-cross_compile.patch b/ipv6/aiccu/patches/100-cross_compile.patch new file mode 100644 index 0000000000..dbdc50aaa6 --- /dev/null +++ b/ipv6/aiccu/patches/100-cross_compile.patch @@ -0,0 +1,101 @@ +--- aiccu/unix-console/Makefile.orig 2007-09-02 23:19:39.000000000 +0200 ++++ aiccu/unix-console/Makefile 2007-09-02 23:20:11.000000000 +0200 +@@ -25,7 +25,8 @@ + # CWARNS += -Wpacked + + #CFLAGS += $(CWARNS) -D_GNU_SOURCE -D_DEBUG -g3 -O0 +-CFLAGS += $(CWARNS) -D_GNU_SOURCE ++CFLAGS += $(CWARNS) $(EXTRA_CFLAGS) -D_GNU_SOURCE ++LDFLAGS += $(EXTRA_LDFLAGS) + CC = @gcc + RM = rm + +@@ -40,25 +41,25 @@ + # GnuTLS Support ? + # Used by TIC to secure that communication + # Currently defaultly builds only on Linux, but other platforms might easily also support it +-ifeq ($(shell uname | grep -c "Linux"),1) ++ifneq ($(HAVE_GNUTLS),) + CFLAGS += -D AICCU_GNUTLS + LDFLAGS += -lgnutls + endif + + # Linux +-ifeq ($(shell uname | grep -c "Linux"),1) ++ifeq ($(OS_NAME),Linux) + CFLAGS += -D_LINUX -D HAS_IFHEAD -D AICCU_TYPE="\"linux\"" + SRCS += ../common/aiccu_linux.c + OBJS += ../common/aiccu_linux.o +-LDFLAGS += -lpthread -lresolv ++LDFLAGS += -pthread -lresolv + endif + + # FreeBSD +-ifeq ($(shell uname | grep -c "FreeBSD"),1) ++ifeq ($(OS_NAME),FreeBSD) + CFLAGS += -D_FREEBSD + + # FreeBSD 4.x +-ifeq ($(shell uname -r | cut -c 1),4) ++ifeq ($(shell echo $(OS_VERSION) | cut -c 1),4) + CFLAGS += -D AICCU_TYPE="\"freebsd4\"" + SRCS += ../common/aiccu_freebsd4.c + OBJS += ../common/aiccu_freebsd4.o +@@ -71,7 +72,7 @@ + endif + + # DragonFlyBSD +-ifeq ($(shell uname | grep -c "DragonFly"),1) ++ifeq ($(OS_NAME),DragonFly) + CFLAGS += -D_DFBSD -D NEED_IFHEAD -D AICCU_TYPE="\"dragonfly\"" + SRCS += ../common/aiccu_freebsd4.c + OBJS += ../common/aiccu_freebsd4.o +@@ -79,7 +80,7 @@ + endif + + # NetBSD +-ifeq ($(shell uname | grep -c "NetBSD"),1) ++ifeq ($(OS_NAME),NetBSD) + CFLAGS += -D_NETBSD -D AICCU_TYPE="\"kame\"" + + # Check if net/if_tun.h has TUNSIFHEAD and enable support for it +@@ -97,10 +98,10 @@ + endif + + # OpenBSD +-ifeq ($(shell uname | grep -c "OpenBSD"),1) ++ifeq ($(OS_NAME),OpenBSD) + CFLAGS += -D_OPENBSD -D HAS_IFHEAD + # 2.7-2.9 +-ifeq ($(shell uname -r | cut -c 1),2) ++ifeq ($(shell echo $(OS_VERSION) | cut -c 1),2) + CFLAGS += -D AICCU_TYPE="\"openbsd2\"" + SRCS += ../common/aiccu_openbsd2.c + OBJS += ../common/aiccu_openbsd2.o +@@ -114,7 +115,7 @@ + endif + + # Darwin +-ifeq ($(shell uname | grep -c "Darwin"),1) ++ifeq ($(OS_NAME),Darwin) + CFLAGS += -D_DARWIN -D NEED_IFHEAD -D AICCU_TYPE="\"darwin\"" + SRCS += ../common/aiccu_darwin.c + OBJS += ../common/aiccu_darwin.o +@@ -122,7 +123,7 @@ + endif + + # SunOS / Solaris +-ifeq ($(shell uname | grep -c "SunOS"),1) ++ifeq ($(OS_NAME),SunOS) + CFLAGS += -D_SUNOS -D AICCU_TYPE="\"sunos\"" + SRCS += ../common/aiccu_sunos.c + OBJS += ../common/aiccu_sunos.o +@@ -130,7 +131,7 @@ + endif + + # AIX +-ifeq ($(shell uname | grep -c "AIX"),1) ++ifeq ($(OS_NAME),AIX) + CC = @/usr/vac/bin/xlc_r + CFLAGS = -qthreaded -q64 -qlanglvl=stdc99 -bmaxdata:0xD0000000 -D_64BIT -g -qdbxextra -qfullpath -qheapdebug -qformat=all -qcheck=all + CFLAGS += -D AICCU_CONSOLE diff --git a/ipv6/aiccu/patches/200-add_dn_skipname.patch b/ipv6/aiccu/patches/200-add_dn_skipname.patch new file mode 100644 index 0000000000..ca6afcea1e --- /dev/null +++ b/ipv6/aiccu/patches/200-add_dn_skipname.patch @@ -0,0 +1,70 @@ +diff -Nru aiccu.old/common/dn_skipname.c aiccu/common/dn_skipname.c +--- aiccu.old/common/dn_skipname.c 1970-01-01 02:00:00.000000000 +0200 ++++ aiccu/common/dn_skipname.c 2006-11-04 00:50:23.000000000 +0200 +@@ -0,0 +1,51 @@ ++#include ++#include ++ ++/* Ripped from glibc 2.4 sources. */ ++ ++/* ++ * ns_name_skip(ptrptr, eom) ++ * Advance *ptrptr to skip over the compressed name it points at. ++ * return: ++ * 0 on success, -1 (with errno set) on failure. ++ */ ++int ns_name_skip(const u_char **ptrptr, const u_char *eom) ++{ ++ const u_char *cp; ++ u_int n; ++ ++ cp = *ptrptr; ++ while (cp < eom && (n = *cp++) != 0) ++ { ++ /* Check for indirection. */ ++ switch (n & NS_CMPRSFLGS) { ++ case 0: /* normal case, n == len */ ++ cp += n; ++ continue; ++ case NS_CMPRSFLGS: /* indirection */ ++ cp++; ++ break; ++ default: /* illegal type */ ++ errno = EMSGSIZE; ++ return (-1); ++ } ++ break; ++ } ++ if (cp > eom) ++ { ++ errno = EMSGSIZE; ++ return (-1); ++ } ++ *ptrptr = cp; ++ return (0); ++} ++ ++int dn_skipname(const u_char *ptr, const u_char *eom) ++{ ++ const u_char *saveptr = ptr; ++ ++ if(ns_name_skip(&ptr, eom) == -1) ++ return (-1); ++ return (ptr - saveptr); ++} ++ +diff -Nru aiccu.old/unix-console/Makefile aiccu/unix-console/Makefile +--- aiccu.old/unix-console/Makefile 2006-11-04 00:51:20.000000000 +0200 ++++ aiccu/unix-console/Makefile 2006-11-04 00:48:51.000000000 +0200 +@@ -10,9 +10,9 @@ + # $Date: 2006-07-25 09:20:48 $ + # **********************************************************/ + +-SRCS = main.c ../common/tun.c ../common/aiccu.c ../common/hash_md5.c ../common/hash_sha1.c ../common/common.c ../common/heartbeat.c ../common/tic.c ../common/ayiya.c ../common/aiccu_test.c ../common/resolver.c ++SRCS = main.c ../common/tun.c ../common/aiccu.c ../common/hash_md5.c ../common/hash_sha1.c ../common/common.c ../common/heartbeat.c ../common/tic.c ../common/ayiya.c ../common/aiccu_test.c ../common/resolver.c ../common/dn_skipname.c + INCS = ../common/tun.h ../common/aiccu.h ../common/hash_md5.h ../common/hash_sha1.h ../common/common.h ../common/heartbeat.h ../common/tic.h ../common/ayiya.h ../common/resolver.h +-OBJS = main.o ../common/tun.o ../common/aiccu.o ../common/hash_md5.o ../common/hash_sha1.o ../common/common.o ../common/heartbeat.o ../common/tic.o ../common/ayiya.o ../common/aiccu_test.o ../common/resolver.o ++OBJS = main.o ../common/tun.o ../common/aiccu.o ../common/hash_md5.o ../common/hash_sha1.o ../common/common.o ../common/heartbeat.o ../common/tic.o ../common/ayiya.o ../common/aiccu_test.o ../common/resolver.o ../common/dn_skipname.o + + # New features not fully implemented and thus disabled for now + #CFLAGS += -D NEWSTUFF_TSP -D NEWSTUFF_TEEPEE diff --git a/ipv6/aiccu/patches/300-resolver-uclibc.patch b/ipv6/aiccu/patches/300-resolver-uclibc.patch new file mode 100644 index 0000000000..fbd6a5093e --- /dev/null +++ b/ipv6/aiccu/patches/300-resolver-uclibc.patch @@ -0,0 +1,29 @@ +--- aiccu/common/resolver.c.orig 2007-09-02 23:10:58.000000000 +0200 ++++ aiccu/common/resolver.c 2007-09-02 23:11:01.000000000 +0200 +@@ -26,7 +26,7 @@ + + int getrrs(const char *label, int rrtype, void gotrec(unsigned int num, int type, const char *record)) + { +-#ifdef _LINUX ++#if defined(_LINUX) && !defined(__UCLIBC__) + struct __res_state res; + #endif + unsigned char answer[8192]; +@@ -38,7 +38,7 @@ + uint16_t type = 0, class = 0; + uint32_t ttl = 0; + +-#ifdef _LINUX ++#if defined(_LINUX) && !defined(__UCLIBC__) + memset(&res, 0, sizeof(res)); + res.options = RES_DEBUG; + res_ninit(&res); +@@ -47,7 +47,7 @@ + #endif + + memset(answer, 0, sizeof(answer)); +-#ifdef _LINUX ++#if defined(_LINUX) && !defined(__UCLIBC__) + ret = res_nquery(&res, label, C_IN, rrtype, answer, sizeof(answer)); + #else + ret = res_query(label, C_IN, rrtype, answer, sizeof(answer)); From baed04bed06019001fbb1ea7d1e73bb1964c432f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Caletka?= Date: Mon, 23 Jun 2014 15:51:07 +0200 Subject: [PATCH 2/3] aiccu: add myself as maintainer Signed-off-by: Ondrej Caletka --- ipv6/aiccu/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/ipv6/aiccu/Makefile b/ipv6/aiccu/Makefile index 0590ad0d8c..d0ead03173 100644 --- a/ipv6/aiccu/Makefile +++ b/ipv6/aiccu/Makefile @@ -25,6 +25,7 @@ define Package/aiccu DEPENDS:=+libpthread +ip +kmod-sit +kmod-tun TITLE:=SixXS Automatic IPv6 Connectivity Client Utility URL:=http://www.sixxs.net/tools/aiccu/ + MAINTAINER:=Ondrej Caletka endef define Build/Configure From 449ad56fb5a46aeddbb0dcff7c82e7285cee17e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Caletka?= Date: Mon, 23 Jun 2014 11:05:01 +0200 Subject: [PATCH 3/3] aiccu: integrate with netifd This patch integrates AICCU with netifd. Care was taken not to restart aiccu without a reason as it triggers alert on SixXS infrastructure. Example usage: config interface 'wan6' option 'proto' 'aiccu' option 'username' 'HANDLE-SIXXS/TID' option 'password' 'Password' option 'ip6prefix' '2001:db8:aabb::/48' #Delegated subnet option 'ip6addr' '2001:db8:aaaa:aaa::2/64' #Optional option 'verbose' 'true' Tested with current trunk on TL-WR703N. Signed-off-by: Ondrej Caletka --- ipv6/aiccu/Makefile | 5 +- ipv6/aiccu/files/aiccu.sh | 105 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 2 deletions(-) create mode 100755 ipv6/aiccu/files/aiccu.sh diff --git a/ipv6/aiccu/Makefile b/ipv6/aiccu/Makefile index d0ead03173..fe1f162ddb 100644 --- a/ipv6/aiccu/Makefile +++ b/ipv6/aiccu/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=aiccu PKG_VERSION:=20070115 -PKG_RELEASE:=10 +PKG_RELEASE:=11 PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://www.sixxs.net/archive/sixxs/aiccu/unix @@ -45,8 +45,9 @@ define Package/aiccu/conffiles endef define Package/aiccu/install - $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_DIR) $(1)/usr/sbin $(1)/lib/netifd/proto $(INSTALL_BIN) $(PKG_BUILD_DIR)/unix-console/$(PKG_NAME) $(1)/usr/sbin/ + $(INSTALL_BIN) ./files/aiccu.sh $(1)/lib/netifd/proto/aiccu.sh endef $(eval $(call BuildPackage,aiccu)) diff --git a/ipv6/aiccu/files/aiccu.sh b/ipv6/aiccu/files/aiccu.sh new file mode 100755 index 0000000000..4340b2f4e6 --- /dev/null +++ b/ipv6/aiccu/files/aiccu.sh @@ -0,0 +1,105 @@ +#!/bin/sh +# aiccu.sh - AICCU proto +# Copyright (c) 2014 OpenWrt.org + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . /lib/functions/network.sh + . ../netifd-proto.sh + init_proto "$@" +} + +proto_aiccu_setup() { + local cfg="$1" + local iface="$2" + local link="aiccu-$cfg" + + local username password protocol server ip6prefix tunnelid requiretls defaultroute nat heartbeat verbose sourcerouting ip6addr + json_get_vars username password protocol server ip6prefix tunnelid requiretls defaultroute nat heartbeat verbose sourcerouting ip6addr + + [ -z "$username" -o -z "$password" ] && { + proto_notify_error "$cfg" "MISSING_USERNAME_OR_PASSWORD" + proto_block_restart "$cfg" + return + } + + ( proto_add_host_dependency "$cfg" 0.0.0.0 ) + + CFGFILE="/var/etc/${link}.conf" + PIDFILE="/var/run/${link}.pid" + mkdir -p /var/run /var/etc + + echo "username $username" > "$CFGFILE" + echo "password $password" >> "$CFGFILE" + echo "ipv6_interface $link" >> "$CFGFILE" + [ -n "$server" ] && echo "server $server" >> "$CFGFILE" + [ -n "$protocol" ] && echo "protocol $protocol" >> "$CFGFILE" + [ -n "$tunnel_id" ] && echo "tunnel_id $tunnel_id" >> "$CFGFILE" + [ -n "$requiretls" ] && echo "requiretls $requiretls" >> "$CFGFILE" + [ "$nat" == 1 ] && echo "behindnat true" >> "$CFGFILE" + [ "$heartbeat" == 1 ] && echo "makebeats true" >> "$CFGFILE" + [ "$verbose" == 1 ] && echo "verbose true" >> "$CFGFILE" + echo "defaultroute false" >> "$CFGFILE" + echo "daemonize true" >> "$CFGFILE" + echo "pidfile $PIDFILE" >> "$CFGFILE" + + aiccu start "$CFGFILE" + + [ "$?" -ne 0 ] && { + proto_notify_error "$cfg" "AICCU_FAILED_SEE_LOG" + proto_block_restart "$cfg" + return + } + + proto_init_update "$link" 1 + + local source="" + [ "$sourcerouting" != "0" ] && source="::/128" + [ "$defaultroute" != "0" ] && proto_add_ipv6_route "::" 0 "" "" "" "$source" + + [ -n "$ip6addr" ] && { + local local6="${ip6addr%%/*}" + local mask6="${ip6addr##*/}" + [[ "$local6" = "$mask6" ]] && mask6= + proto_add_ipv6_address "$local6" "$mask6" + [ "$defaultroute" != "0" -a "$sourcerouting" != "0" ] && proto_add_ipv6_route "::" 0 "" "" "" "$local6/$mask6" + } + + [ -n "$ip6prefix" ] && { + proto_add_ipv6_prefix "$ip6prefix" + [ "$defaultroute" != "0" -a "$sourcerouting" != "0" ] && proto_add_ipv6_route "::" 0 "" "" "" "$ip6prefix" + } + + proto_send_update "$cfg" + +} + +proto_aiccu_teardown() { + local cfg="$1" + local link="aiccu-$cfg" + CFGFILE="/var/etc/${link}.conf" + + aiccu stop "$CFGFILE" +} + +proto_aiccu_init_config() { + no_device=1 + available=1 + proto_config_add_string "username" + proto_config_add_string "password" + proto_config_add_string "protocol" + proto_config_add_string "server" + proto_config_add_string "ip6addr:ip6addr" + proto_config_add_string "ip6prefix:ip6addr" + proto_config_add_string "tunnelid" + proto_config_add_boolean "requiretls" + proto_config_add_boolean "defaultroute" + proto_config_add_boolean "sourcerouting" + proto_config_add_boolean "nat" + proto_config_add_boolean "heartbeat" + proto_config_add_boolean "verbose" +} + +[ -n "$INCLUDE_ONLY" ] || { + add_protocol aiccu +}