Merge pull request #50 from oskar456/aiccu

aiccu: import from oldpackages, integrate with netifd
This commit is contained in:
sbyx 2014-06-23 18:52:49 +02:00
commit eb435b2e55
5 changed files with 358 additions and 0 deletions

53
ipv6/aiccu/Makefile Normal file
View File

@ -0,0 +1,53 @@
#
# 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:=11
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/
MAINTAINER:=Ondrej Caletka <ondrej@caletka.cz>
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 $(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))

105
ipv6/aiccu/files/aiccu.sh Executable file
View File

@ -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
}

View File

@ -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

View File

@ -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 <errno.h>
+#include <resolv.h>
+
+/* 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

View File

@ -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));