Browse Source

Merge pull request #50 from oskar456/aiccu

aiccu: import from oldpackages, integrate with netifd
sbyx 10 years ago
parent
commit
eb435b2e55

+ 53
- 0
ipv6/aiccu/Makefile View File

@@ -0,0 +1,53 @@
1
+#
2
+# Copyright (C) 2006-2012 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=aiccu
11
+PKG_VERSION:=20070115
12
+PKG_RELEASE:=11
13
+
14
+PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.gz
15
+PKG_SOURCE_URL:=http://www.sixxs.net/archive/sixxs/aiccu/unix
16
+PKG_MD5SUM:=c9bcc83644ed788e22a7c3f3d4021350
17
+
18
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
19
+
20
+include $(INCLUDE_DIR)/package.mk
21
+
22
+define Package/aiccu
23
+  SECTION:=net
24
+  CATEGORY:=Network
25
+  DEPENDS:=+libpthread +ip +kmod-sit +kmod-tun
26
+  TITLE:=SixXS Automatic IPv6 Connectivity Client Utility
27
+  URL:=http://www.sixxs.net/tools/aiccu/
28
+  MAINTAINER:=Ondrej Caletka <ondrej@caletka.cz>
29
+endef
30
+
31
+define Build/Configure
32
+	$(SED) "s,strip,/bin/true," $(PKG_BUILD_DIR)/unix-console/Makefile
33
+endef
34
+
35
+define Build/Compile
36
+	$(MAKE) -C $(PKG_BUILD_DIR) \
37
+		CC="$(TARGET_CC)" OS_NAME="Linux" OS_VERSION="$(LINUX_VERSION)" \
38
+		EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
39
+		EXTRA_LDFLAGS="$(TARGET_LDFLAGS) -pthread" \
40
+		DEBUG=0
41
+endef
42
+
43
+define Package/aiccu/conffiles
44
+/etc/config/aiccu
45
+endef
46
+
47
+define Package/aiccu/install
48
+	$(INSTALL_DIR) $(1)/usr/sbin $(1)/lib/netifd/proto
49
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/unix-console/$(PKG_NAME) $(1)/usr/sbin/
50
+	$(INSTALL_BIN) ./files/aiccu.sh $(1)/lib/netifd/proto/aiccu.sh
51
+endef
52
+
53
+$(eval $(call BuildPackage,aiccu))

+ 105
- 0
ipv6/aiccu/files/aiccu.sh View File

@@ -0,0 +1,105 @@
1
+#!/bin/sh
2
+# aiccu.sh - AICCU proto
3
+# Copyright (c) 2014 OpenWrt.org
4
+
5
+[ -n "$INCLUDE_ONLY" ] || {
6
+	. /lib/functions.sh
7
+	. /lib/functions/network.sh
8
+	. ../netifd-proto.sh
9
+	init_proto "$@"
10
+}
11
+
12
+proto_aiccu_setup() {
13
+	local cfg="$1"
14
+	local iface="$2"
15
+	local link="aiccu-$cfg"
16
+
17
+	local username password protocol server ip6prefix tunnelid requiretls defaultroute nat heartbeat verbose sourcerouting ip6addr
18
+	json_get_vars username password protocol server ip6prefix tunnelid requiretls defaultroute nat heartbeat verbose sourcerouting ip6addr
19
+
20
+	[ -z "$username" -o -z "$password" ] && {
21
+		proto_notify_error "$cfg" "MISSING_USERNAME_OR_PASSWORD"
22
+		proto_block_restart "$cfg"
23
+		return
24
+	}
25
+
26
+	( proto_add_host_dependency "$cfg" 0.0.0.0 )
27
+
28
+	CFGFILE="/var/etc/${link}.conf"
29
+	PIDFILE="/var/run/${link}.pid"
30
+	mkdir -p /var/run /var/etc
31
+
32
+	echo "username $username" > "$CFGFILE"
33
+	echo "password $password" >> "$CFGFILE"
34
+	echo "ipv6_interface $link"   >> "$CFGFILE"
35
+	[ -n "$server" ] && echo "server $server" >> "$CFGFILE"
36
+	[ -n "$protocol" ] && echo "protocol $protocol" >> "$CFGFILE"
37
+	[ -n "$tunnel_id" ] && echo "tunnel_id $tunnel_id"	  >> "$CFGFILE"
38
+	[ -n "$requiretls" ] && echo "requiretls $requiretls"	   >> "$CFGFILE"
39
+	[ "$nat" == 1 ] && echo "behindnat true"     >> "$CFGFILE"
40
+	[ "$heartbeat"	== 1 ] && echo "makebeats true" >> "$CFGFILE"
41
+	[ "$verbose" == 1 ] && echo "verbose true" >> "$CFGFILE"
42
+	echo "defaultroute false" >> "$CFGFILE"
43
+	echo "daemonize true"	  >> "$CFGFILE"
44
+	echo "pidfile $PIDFILE"   >> "$CFGFILE"
45
+
46
+	aiccu start "$CFGFILE"
47
+
48
+	[ "$?" -ne 0 ] && {
49
+		proto_notify_error "$cfg" "AICCU_FAILED_SEE_LOG"
50
+		proto_block_restart "$cfg"
51
+		return
52
+	}
53
+
54
+	proto_init_update "$link" 1
55
+
56
+	local source=""
57
+	[ "$sourcerouting" != "0" ] && source="::/128"
58
+	[ "$defaultroute" != "0" ] && proto_add_ipv6_route "::" 0 "" "" "" "$source"
59
+
60
+	[ -n "$ip6addr" ] && {
61
+		local local6="${ip6addr%%/*}"
62
+		local mask6="${ip6addr##*/}"
63
+		[[ "$local6" = "$mask6" ]] && mask6=
64
+		proto_add_ipv6_address "$local6" "$mask6"
65
+		[ "$defaultroute" != "0" -a "$sourcerouting" != "0" ] && proto_add_ipv6_route "::" 0 "" "" "" "$local6/$mask6"
66
+	}
67
+
68
+	[ -n "$ip6prefix" ] && {
69
+		proto_add_ipv6_prefix "$ip6prefix"
70
+		[ "$defaultroute" != "0" -a "$sourcerouting" != "0" ] && proto_add_ipv6_route "::" 0 "" "" "" "$ip6prefix"
71
+	}
72
+
73
+	proto_send_update "$cfg"
74
+
75
+}
76
+
77
+proto_aiccu_teardown() {
78
+	local cfg="$1"
79
+	local link="aiccu-$cfg"
80
+	CFGFILE="/var/etc/${link}.conf"
81
+
82
+	aiccu stop "$CFGFILE"
83
+}
84
+
85
+proto_aiccu_init_config() {
86
+	no_device=1
87
+	available=1
88
+	proto_config_add_string "username"
89
+	proto_config_add_string "password"
90
+	proto_config_add_string "protocol"
91
+	proto_config_add_string "server"
92
+	proto_config_add_string "ip6addr:ip6addr"
93
+	proto_config_add_string "ip6prefix:ip6addr"
94
+	proto_config_add_string "tunnelid"
95
+	proto_config_add_boolean "requiretls"
96
+	proto_config_add_boolean "defaultroute"
97
+	proto_config_add_boolean "sourcerouting"
98
+	proto_config_add_boolean "nat"
99
+	proto_config_add_boolean "heartbeat"
100
+	proto_config_add_boolean "verbose"
101
+}
102
+
103
+[ -n "$INCLUDE_ONLY" ] || {
104
+	add_protocol aiccu
105
+}

+ 101
- 0
ipv6/aiccu/patches/100-cross_compile.patch View File

@@ -0,0 +1,101 @@
1
+--- aiccu/unix-console/Makefile.orig	2007-09-02 23:19:39.000000000 +0200
2
++++ aiccu/unix-console/Makefile	2007-09-02 23:20:11.000000000 +0200
3
+@@ -25,7 +25,8 @@
4
+ # CWARNS += -Wpacked
5
+ 
6
+ #CFLAGS	+= $(CWARNS) -D_GNU_SOURCE -D_DEBUG -g3 -O0
7
+-CFLAGS	+= $(CWARNS) -D_GNU_SOURCE
8
++CFLAGS	+= $(CWARNS) $(EXTRA_CFLAGS) -D_GNU_SOURCE
9
++LDFLAGS += $(EXTRA_LDFLAGS)
10
+ CC      = @gcc
11
+ RM      = rm
12
+ 
13
+@@ -40,25 +41,25 @@
14
+ # GnuTLS Support ?
15
+ # Used by TIC to secure that communication
16
+ # Currently defaultly builds only on Linux, but other platforms might easily also support it
17
+-ifeq ($(shell uname | grep -c "Linux"),1)
18
++ifneq ($(HAVE_GNUTLS),)
19
+ CFLAGS	+= -D AICCU_GNUTLS
20
+ LDFLAGS += -lgnutls
21
+ endif
22
+ 
23
+ # Linux
24
+-ifeq ($(shell uname | grep -c "Linux"),1)
25
++ifeq ($(OS_NAME),Linux)
26
+ CFLAGS  += -D_LINUX -D HAS_IFHEAD -D AICCU_TYPE="\"linux\""
27
+ SRCS	+= ../common/aiccu_linux.c
28
+ OBJS	+= ../common/aiccu_linux.o
29
+-LDFLAGS	+= -lpthread -lresolv
30
++LDFLAGS	+= -pthread -lresolv
31
+ endif
32
+ 
33
+ # FreeBSD
34
+-ifeq ($(shell uname | grep -c "FreeBSD"),1)
35
++ifeq ($(OS_NAME),FreeBSD)
36
+ CFLAGS	+= -D_FREEBSD
37
+ 
38
+ # FreeBSD 4.x
39
+-ifeq ($(shell uname -r | cut -c 1),4)
40
++ifeq ($(shell echo $(OS_VERSION) | cut -c 1),4)
41
+ CFLAGS	+= -D AICCU_TYPE="\"freebsd4\""
42
+ SRCS	+= ../common/aiccu_freebsd4.c
43
+ OBJS	+= ../common/aiccu_freebsd4.o
44
+@@ -71,7 +72,7 @@
45
+ endif
46
+ 
47
+ # DragonFlyBSD
48
+-ifeq ($(shell uname | grep -c "DragonFly"),1)
49
++ifeq ($(OS_NAME),DragonFly)
50
+ CFLAGS	+= -D_DFBSD -D NEED_IFHEAD -D AICCU_TYPE="\"dragonfly\""
51
+ SRCS	+= ../common/aiccu_freebsd4.c
52
+ OBJS	+= ../common/aiccu_freebsd4.o
53
+@@ -79,7 +80,7 @@
54
+ endif
55
+ 
56
+ # NetBSD
57
+-ifeq ($(shell uname | grep -c "NetBSD"),1)
58
++ifeq ($(OS_NAME),NetBSD)
59
+ CFLAGS	+= -D_NETBSD -D AICCU_TYPE="\"kame\""
60
+ 
61
+ # Check if net/if_tun.h has TUNSIFHEAD and enable support for it
62
+@@ -97,10 +98,10 @@
63
+ endif
64
+ 
65
+ # OpenBSD
66
+-ifeq ($(shell uname | grep -c "OpenBSD"),1)
67
++ifeq ($(OS_NAME),OpenBSD)
68
+ CFLAGS	+= -D_OPENBSD -D HAS_IFHEAD
69
+ # 2.7-2.9
70
+-ifeq ($(shell uname -r | cut -c 1),2)
71
++ifeq ($(shell echo $(OS_VERSION) | cut -c 1),2)
72
+ CFLAGS	+= -D AICCU_TYPE="\"openbsd2\""
73
+ SRCS	+= ../common/aiccu_openbsd2.c
74
+ OBJS	+= ../common/aiccu_openbsd2.o
75
+@@ -114,7 +115,7 @@
76
+ endif
77
+ 
78
+ # Darwin
79
+-ifeq ($(shell uname | grep -c "Darwin"),1)
80
++ifeq ($(OS_NAME),Darwin)
81
+ CFLAGS	+= -D_DARWIN -D NEED_IFHEAD -D AICCU_TYPE="\"darwin\""
82
+ SRCS	+= ../common/aiccu_darwin.c
83
+ OBJS	+= ../common/aiccu_darwin.o
84
+@@ -122,7 +123,7 @@
85
+ endif
86
+ 
87
+ # SunOS / Solaris
88
+-ifeq ($(shell uname | grep -c "SunOS"),1)
89
++ifeq ($(OS_NAME),SunOS)
90
+ CFLAGS	+= -D_SUNOS -D AICCU_TYPE="\"sunos\""
91
+ SRCS	+= ../common/aiccu_sunos.c
92
+ OBJS	+= ../common/aiccu_sunos.o
93
+@@ -130,7 +131,7 @@
94
+ endif
95
+ 
96
+ # AIX
97
+-ifeq ($(shell uname | grep -c "AIX"),1)
98
++ifeq ($(OS_NAME),AIX)
99
+ CC	= @/usr/vac/bin/xlc_r
100
+ CFLAGS	= -qthreaded -q64 -qlanglvl=stdc99 -bmaxdata:0xD0000000 -D_64BIT -g -qdbxextra -qfullpath -qheapdebug -qformat=all -qcheck=all
101
+ CFLAGS	+= -D AICCU_CONSOLE

+ 70
- 0
ipv6/aiccu/patches/200-add_dn_skipname.patch View File

@@ -0,0 +1,70 @@
1
+diff -Nru aiccu.old/common/dn_skipname.c aiccu/common/dn_skipname.c
2
+--- aiccu.old/common/dn_skipname.c	1970-01-01 02:00:00.000000000 +0200
3
++++ aiccu/common/dn_skipname.c	2006-11-04 00:50:23.000000000 +0200
4
+@@ -0,0 +1,51 @@
5
++#include <errno.h>
6
++#include <resolv.h>
7
++
8
++/* Ripped from glibc 2.4 sources. */
9
++
10
++/*
11
++ * ns_name_skip(ptrptr, eom)
12
++ *      Advance *ptrptr to skip over the compressed name it points at.
13
++ * return:
14
++ *      0 on success, -1 (with errno set) on failure.
15
++ */
16
++int ns_name_skip(const u_char **ptrptr, const u_char *eom)
17
++{
18
++	const u_char *cp;
19
++	u_int n;
20
++
21
++	cp = *ptrptr;
22
++	while (cp < eom && (n = *cp++) != 0)
23
++	{
24
++		/* Check for indirection. */
25
++		switch (n & NS_CMPRSFLGS) {
26
++		case 0:                 /* normal case, n == len */
27
++			cp += n;
28
++			continue;
29
++		case NS_CMPRSFLGS:      /* indirection */
30
++			cp++;
31
++			break;
32
++		default:                /* illegal type */
33
++			errno = EMSGSIZE;
34
++			return (-1);
35
++		}
36
++		break;
37
++	}
38
++	if (cp > eom)
39
++	{
40
++		errno = EMSGSIZE;
41
++		return (-1);
42
++	}
43
++	*ptrptr = cp;
44
++	return (0);
45
++}
46
++
47
++int dn_skipname(const u_char *ptr, const u_char *eom)
48
++{
49
++	const u_char *saveptr = ptr;
50
++
51
++	if(ns_name_skip(&ptr, eom) == -1)
52
++		return (-1);
53
++	return (ptr - saveptr);
54
++}
55
++
56
+diff -Nru aiccu.old/unix-console/Makefile aiccu/unix-console/Makefile
57
+--- aiccu.old/unix-console/Makefile	2006-11-04 00:51:20.000000000 +0200
58
++++ aiccu/unix-console/Makefile	2006-11-04 00:48:51.000000000 +0200
59
+@@ -10,9 +10,9 @@
60
+ #  $Date: 2006-07-25 09:20:48 $
61
+ # **********************************************************/
62
+ 
63
+-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
64
++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
65
+ 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
66
+-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
67
++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
68
+ 
69
+ # New features not fully implemented and thus disabled for now
70
+ #CFLAGS	+= -D NEWSTUFF_TSP -D NEWSTUFF_TEEPEE

+ 29
- 0
ipv6/aiccu/patches/300-resolver-uclibc.patch View File

@@ -0,0 +1,29 @@
1
+--- aiccu/common/resolver.c.orig	2007-09-02 23:10:58.000000000 +0200
2
++++ aiccu/common/resolver.c	2007-09-02 23:11:01.000000000 +0200
3
+@@ -26,7 +26,7 @@
4
+ 
5
+ int getrrs(const char *label, int rrtype, void gotrec(unsigned int num, int type, const char *record))
6
+ {
7
+-#ifdef _LINUX
8
++#if defined(_LINUX) && !defined(__UCLIBC__)
9
+ 	struct __res_state	res;
10
+ #endif
11
+ 	unsigned char		answer[8192];
12
+@@ -38,7 +38,7 @@
13
+ 	uint16_t		type = 0, class = 0;
14
+ 	uint32_t		ttl = 0;
15
+ 
16
+-#ifdef _LINUX
17
++#if defined(_LINUX) && !defined(__UCLIBC__)
18
+ 	memset(&res, 0, sizeof(res));
19
+ 	res.options = RES_DEBUG;
20
+ 	res_ninit(&res);
21
+@@ -47,7 +47,7 @@
22
+ #endif
23
+ 
24
+ 	memset(answer, 0, sizeof(answer));
25
+-#ifdef _LINUX
26
++#if defined(_LINUX) && !defined(__UCLIBC__)
27
+ 	ret = res_nquery(&res, label, C_IN, rrtype, answer, sizeof(answer));
28
+ #else
29
+ 	ret = res_query(label, C_IN, rrtype, answer, sizeof(answer));