Browse Source

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 <ondrej@caletka.cz>
Ondřej Caletka 10 years ago
parent
commit
449ad56fb5
2 changed files with 108 additions and 2 deletions
  1. 3
    2
      ipv6/aiccu/Makefile
  2. 105
    0
      ipv6/aiccu/files/aiccu.sh

+ 3
- 2
ipv6/aiccu/Makefile View File

@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=aiccu
11 11
 PKG_VERSION:=20070115
12
-PKG_RELEASE:=10
12
+PKG_RELEASE:=11
13 13
 
14 14
 PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.gz
15 15
 PKG_SOURCE_URL:=http://www.sixxs.net/archive/sixxs/aiccu/unix
@@ -45,8 +45,9 @@ define Package/aiccu/conffiles
45 45
 endef
46 46
 
47 47
 define Package/aiccu/install
48
-	$(INSTALL_DIR) $(1)/usr/sbin
48
+	$(INSTALL_DIR) $(1)/usr/sbin $(1)/lib/netifd/proto
49 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
50 51
 endef
51 52
 
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
+}