Browse Source

Import xl2tpd

Use sources on github and add myself as maintainer.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Daniel Golle 10 years ago
parent
commit
4ce0354910

+ 71
- 0
net/xl2tpd/Makefile View File

@@ -0,0 +1,71 @@
1
+#
2
+# Copyright (C) 2006-2014 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:=xl2tpd
11
+PKG_VERSION:=1.3.6
12
+PKG_RELEASE:=1
13
+PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
14
+
15
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
16
+
17
+PKG_SOURCE_PROTO:=git
18
+PKG_SOURCE_URL:=https://github.com/xelerance/xl2tpd.git
19
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
20
+PKG_SOURCE_VERSION:=5619e1771048e74b729804e8602f409af0f3faea
21
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
22
+
23
+PKG_INSTALL:=1
24
+
25
+include $(INCLUDE_DIR)/package.mk
26
+
27
+define Package/xl2tpd
28
+  SECTION:=net
29
+  CATEGORY:=Network
30
+  TITLE:=An L2TP (Layer 2 Tunneling Protocol) daemon
31
+  URL:=http://www.xelerance.com/software/xl2tpd/
32
+  SUBMENU:=VPN
33
+  DEPENDS:=+ppp-mod-pppol2tp +ip +resolveip
34
+endef
35
+
36
+define Package/xl2tpd/description
37
+l2tpd is the open source implementation of the L2TP tunneling protocol (RFC2661).
38
+It does implement both LAC and LNS role in a L2TP networking architecture. The
39
+main goal of this protocol is to tunnel PPP frame trough an IP network.
40
+endef
41
+
42
+# XXX: CFLAGS are already set by Build/Compile/Default
43
+MAKE_FLAGS+= \
44
+	OFLAGS=""
45
+
46
+define Package/xl2tpd/conffiles
47
+/etc/xl2tpd/xl2tpd.conf
48
+/etc/xl2tpd/xl2tp-secrets
49
+/etc/ppp/options.xl2tpd
50
+endef
51
+
52
+define Package/xl2tpd/install
53
+	$(INSTALL_DIR) $(1)/usr/sbin
54
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/local/sbin/xl2tpd $(1)/usr/sbin/
55
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/local/sbin/xl2tpd-control $(1)/usr/sbin/
56
+
57
+	$(INSTALL_DIR) $(1)/etc/init.d
58
+	$(INSTALL_BIN) ./files/xl2tpd.init $(1)/etc/init.d/xl2tpd
59
+
60
+	$(INSTALL_DIR) $(1)/etc/xl2tpd
61
+	$(INSTALL_DATA) ./files/xl2tpd.conf $(1)/etc/xl2tpd/
62
+	$(INSTALL_CONF) ./files/xl2tp-secrets $(1)/etc/xl2tpd/
63
+
64
+	$(INSTALL_DIR) $(1)/etc/ppp
65
+	$(INSTALL_DATA) ./files/options.xl2tpd $(1)/etc/ppp/
66
+
67
+	$(INSTALL_DIR) $(1)/lib/netifd/proto
68
+	$(INSTALL_BIN) ./files/l2tp.sh $(1)/lib/netifd/proto
69
+endef
70
+
71
+$(eval $(call BuildPackage,xl2tpd))

+ 23
- 0
net/xl2tpd/README View File

@@ -0,0 +1,23 @@
1
+OpenWRT Package for xl2tpd
2
+
3
+xl2tpd is a development from the original l2tpd package originally written by
4
+Mark Spencer, subsequently forked by Scott Balmos and David Stipp, inherited
5
+by Jeff McAdams, modified substantially by Jacco de Leeuw and then forked 
6
+again by Xelerance (after it was abandoned by l2tpd.org).
7
+
8
+Rationale for inclusion in OpenWRT:
9
+
10
+l2tpd has some serious alignment problems on RISC platforms. It also runs 
11
+purely in userspace.
12
+
13
+Some of the features added in this fork include:
14
+
15
+1. IPSec SA reference tracking inconjunction with openswan's IPSec transport
16
+   mode, which adds support for multiple clients behind the same NAT router
17
+	 and multiple clients on the same internal IP behind different NAT routers.
18
+
19
+2. Support for the pppol2tp kernel mode L2TP.
20
+
21
+3. Alignment and endian problems resolved.
22
+
23
+hcg

+ 107
- 0
net/xl2tpd/files/l2tp.sh View File

@@ -0,0 +1,107 @@
1
+#!/bin/sh
2
+
3
+[ -x /usr/sbin/xl2tpd ] || exit 0
4
+
5
+[ -n "$INCLUDE_ONLY" ] || {
6
+	. /lib/functions.sh
7
+	. ../netifd-proto.sh
8
+	init_proto "$@"
9
+}
10
+
11
+proto_l2tp_init_config() {
12
+	proto_config_add_string "username"
13
+	proto_config_add_string "password"
14
+	proto_config_add_string "keepalive"
15
+	proto_config_add_string "pppd_options"
16
+	proto_config_add_boolean "ipv6"
17
+	proto_config_add_int "mtu"
18
+	proto_config_add_string "server"
19
+	available=1
20
+	no_device=1
21
+}
22
+
23
+proto_l2tp_setup() {
24
+	local config="$1"
25
+	local iface="$2"
26
+	local optfile="/tmp/l2tp/options.${config}"
27
+
28
+	local ip serv_addr server
29
+	json_get_var server server && {
30
+		for ip in $(resolveip -t 5 "$server"); do
31
+			( proto_add_host_dependency "$config" "$ip" )
32
+			serv_addr=1
33
+		done
34
+	}
35
+	[ -n "$serv_addr" ] || {
36
+		echo "Could not resolve server address"
37
+		sleep 5
38
+		proto_setup_failed "$config"
39
+		exit 1
40
+	}
41
+
42
+	if [ ! -p /var/run/xl2tpd/l2tp-control ]; then
43
+		/etc/init.d/xl2tpd start
44
+	fi
45
+
46
+	json_get_vars ipv6 demand keepalive username password pppd_options
47
+	[ "$ipv6" = 1 ] || ipv6=""
48
+	if [ "${demand:-0}" -gt 0 ]; then
49
+		demand="precompiled-active-filter /etc/ppp/filter demand idle $demand"
50
+	else
51
+		demand="persist"
52
+	fi
53
+
54
+	[ -n "$mtu" ] || json_get_var mtu mtu
55
+
56
+	local interval="${keepalive##*[, ]}"
57
+	[ "$interval" != "$keepalive" ] || interval=5
58
+
59
+	mkdir -p /tmp/l2tp
60
+
61
+	echo "${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}}" > "${optfile}"
62
+	echo "usepeerdns" >> "${optfile}"
63
+	echo "nodefaultroute" >> "${optfile}"
64
+	echo "${username:+user \"$username\" password \"$password\"}" >> "${optfile}"
65
+	echo "ipparam \"$config\"" >> "${optfile}"
66
+	echo "ifname \"l2tp-$config\"" >> "${optfile}"
67
+	echo "ip-up-script /lib/netifd/ppp-up" >> "${optfile}"
68
+	echo "ipv6-up-script /lib/netifd/ppp-up" >> "${optfile}"
69
+	echo "ip-down-script /lib/netifd/ppp-down" >> "${optfile}"
70
+	echo "ipv6-down-script /lib/netifd/ppp-down" >> "${optfile}"
71
+	# Don't wait for LCP term responses; exit immediately when killed.
72
+	echo "lcp-max-terminate 0" >> "${optfile}"
73
+	echo "${ipv6:++ipv6} ${pppd_options}" >> "${optfile}"
74
+	echo "${mtu:+mtu $mtu mru $mtu}" >> "${optfile}"
75
+
76
+	xl2tpd-control add l2tp-${config} pppoptfile=${optfile} lns=${server} redial=yes redial timeout=20
77
+	xl2tpd-control connect l2tp-${config}
78
+}
79
+
80
+proto_l2tp_teardown() {
81
+	local interface="$1"
82
+	local optfile="/tmp/l2tp/options.${interface}"
83
+
84
+	case "$ERROR" in
85
+		11|19)
86
+			proto_notify_error "$interface" AUTH_FAILED
87
+			proto_block_restart "$interface"
88
+		;;
89
+		2)
90
+			proto_notify_error "$interface" INVALID_OPTIONS
91
+			proto_block_restart "$interface"
92
+		;;
93
+	esac
94
+
95
+	xl2tpd-control disconnect l2tp-${interface}
96
+	# Wait for interface to go down
97
+        while [ -d /sys/class/net/l2tp-${interface} ]; do
98
+		sleep 1
99
+	done
100
+
101
+	xl2tpd-control remove l2tp-${interface}
102
+	rm -f ${optfile}
103
+}
104
+
105
+[ -n "$INCLUDE_ONLY" ] || {
106
+	add_protocol l2tp
107
+}

+ 13
- 0
net/xl2tpd/files/options.xl2tpd View File

@@ -0,0 +1,13 @@
1
+#
2
+
3
+lock
4
+noauth
5
+debug
6
+dump
7
+logfd 2
8
+logfile /var/log/xl2tpd.log
9
+noccp
10
+novj
11
+novjccomp
12
+nopcomp
13
+noaccomp

+ 5
- 0
net/xl2tpd/files/xl2tp-secrets View File

@@ -0,0 +1,5 @@
1
+# Secrets for authenticating l2tp tunnels
2
+# us		them		secret
3
+# *		marko		blah2
4
+# zeus		marko		blah
5
+# *		*		interop

+ 23
- 0
net/xl2tpd/files/xl2tpd.conf View File

@@ -0,0 +1,23 @@
1
+[global]
2
+port = 1701
3
+auth file = /etc/xl2tpd/xl2tp-secrets
4
+access control = no
5
+
6
+;[lns default]
7
+;exclusive = yes
8
+;ip range = 192.168.254.202-192.168.254.210
9
+;lac = 10.0.1.2
10
+;hidden bit = no
11
+;local ip = 192.168.254.200
12
+;length bit = yes
13
+;refuse authentication = yes
14
+;name = VersaLink
15
+;ppp debug = yes
16
+;pppoptfile = /etc/ppp/options.xl2tpd
17
+
18
+;[lac left]
19
+;lns = 10.0.1.2
20
+;refuse authentication = yes
21
+;name = VersaLink
22
+;ppp debug = yes
23
+;pppoptfile = /etc/ppp/options.xl2tpd

+ 73
- 0
net/xl2tpd/files/xl2tpd.conf.sample View File

@@ -0,0 +1,73 @@
1
+;
2
+; Sample l2tpd configuration file
3
+;
4
+; This example file should give you some idea of how the options for l2tpd
5
+; should work.  The best place to look for a list of all options is in
6
+; the source code itself, until I have the time to write better documetation :)
7
+; Specifically, the file "file.c" contains a list of commands at the end.
8
+;
9
+; You most definitely don't have to spell out everything as it is done here
10
+;
11
+; [global]										; Global parameters:
12
+; port = 1701									; * Bind to port 1701
13
+; auth file = /etc/xl2tpd/xl2tp-secrets			; * Where our challenge secrets are
14
+; access control = yes							; * Refuse connections without IP match
15
+; rand source = dev								; Source for entropy for random
16
+; 												; numbers, options are:
17
+; 												; dev - reads of /dev/urandom
18
+; 												; sys - uses rand()
19
+; 												; egd - reads from egd socket
20
+; 												; egd is not yet implemented
21
+;
22
+; [lns default]									; Our fallthrough LNS definition
23
+; exclusive = no								; * Only permit one tunnel per host
24
+; ip range = 192.168.0.1-192.168.0.20			; * Allocate from this IP range
25
+; no ip range = 192.168.0.3-192.168.0.9			; * Except these hosts
26
+; ip range = 192.168.0.5						; * But this one is okay
27
+; ip range = lac1-lac2							; * And anything from lac1 to lac2's IP
28
+; lac = 192.168.1.4 - 192.168.1.8				; * These can connect as LAC's
29
+; no lac = untrusted.marko.net					; * This guy can't connect
30
+; hidden bit = no								; * Use hidden AVP's?
31
+; local ip = 192.168.1.2						; * Our local IP to use
32
+; length bit = yes								; * Use length bit in payload?
33
+; require chap = yes							; * Require CHAP auth. by peer
34
+; refuse pap = yes								; * Refuse PAP authentication
35
+; refuse chap = no								; * Refuse CHAP authentication
36
+; refuse authentication = no					; * Refuse authentication altogether
37
+; require authentication = yes					; * Require peer to authenticate
38
+; unix authentication = no						; * Use /etc/passwd for auth.
39
+; name = myhostname								; * Report this as our hostname
40
+; ppp debug = no								; * Turn on PPP debugging
41
+; pppoptfile = /etc/ppp/options.xl2tpd.lns		; * ppp options file
42
+; call rws = 10									; * RWS for call (-1 is valid)
43
+; tunnel rws = 4								; * RWS for tunnel (must be > 0)
44
+; flow bit = yes								; * Include sequence numbers
45
+; challenge = yes								; * Challenge authenticate peer ;
46
+;
47
+; [lac marko]									; Example VPN LAC definition
48
+; lns = lns.marko.net							; * Who is our LNS?
49
+; lns = lns2.marko.net							; * A backup LNS (not yet used)
50
+; redial = yes									; * Redial if disconnected?
51
+; redial timeout = 15							; * Wait n seconds between redials
52
+; max redials = 5								; * Give up after n consecutive failures
53
+; hidden bit = yes								; * User hidden AVP's?
54
+; local ip = 192.168.1.1						; * Force peer to use this IP for us
55
+; remote ip = 192.168.1.2						; * Force peer to use this as their IP
56
+; length bit = no								; * Use length bit in payload?
57
+; require pap = no								; * Require PAP auth. by peer
58
+; require chap = yes							; * Require CHAP auth. by peer
59
+; refuse pap = yes								; * Refuse PAP authentication
60
+; refuse chap = no								; * Refuse CHAP authentication
61
+; refuse authentication = no					; * Refuse authentication altogether
62
+; require authentication = yes					; * Require peer to authenticate
63
+; name = marko									; * Report this as our hostname
64
+; ppp debug = no								; * Turn on PPP debugging
65
+; pppoptfile = /etc/ppp/options.xl2tpd.marko	; * ppp options file for this lac
66
+; call rws = 10									; * RWS for call (-1 is valid)
67
+; tunnel rws = 4								; * RWS for tunnel (must be > 0)
68
+; flow bit = yes								; * Include sequence numbers
69
+; challenge = yes								; * Challenge authenticate peer
70
+;
71
+; [lac cisco]									; Another quick LAC
72
+; lns = cisco.marko.net							; * Required, but can take from default
73
+; require authentication = yes

+ 18
- 0
net/xl2tpd/files/xl2tpd.init View File

@@ -0,0 +1,18 @@
1
+#!/bin/sh /etc/rc.common
2
+# Copyright (C) 2006-2010 OpenWrt.org
3
+
4
+START=60
5
+BIN=xl2tpd
6
+DEFAULT=/etc/default/$BIN
7
+RUN_D=/var/run
8
+PID_F=$RUN_D/$BIN.pid
9
+
10
+start() {
11
+	mkdir -p $RUN_D/$BIN
12
+	[ -f $DEFAULT ] && . $DEFAULT
13
+	$BIN $OPTIONS
14
+}
15
+
16
+stop() {
17
+	[ -f $PID_F ] && kill $(cat $PID_F)
18
+}

+ 12
- 0
net/xl2tpd/patches/100-makefile_opt_flags.patch View File

@@ -0,0 +1,12 @@
1
+--- a/Makefile
2
++++ b/Makefile
3
+@@ -91,7 +91,8 @@ OSFLAGS+= -DUSE_KERNEL
4
+ 
5
+ IPFLAGS?= -DIP_ALLOCATION
6
+ 
7
+-CFLAGS+= $(DFLAGS) -O2 -fno-builtin -Wall -DSANITY $(OSFLAGS) $(IPFLAGS)
8
++OFLAGS=-O2
9
++CFLAGS+= $(DFLAGS) $(OFLAGS) -fno-builtin -Wall -DSANITY $(OSFLAGS) $(IPFLAGS)
10
+ HDRS=l2tp.h avp.h misc.h control.h call.h scheduler.h file.h aaa.h md5.h
11
+ OBJS=xl2tpd.o pty.o misc.o control.o avp.o call.o network.o avpsend.o scheduler.o file.o aaa.o md5.o
12
+ SRCS=${OBJS:.o=.c} ${HDRS}

+ 43
- 0
net/xl2tpd/patches/110-makefile_dont_build_pfc.patch View File

@@ -0,0 +1,43 @@
1
+--- a/Makefile
2
++++ b/Makefile
3
+@@ -107,10 +107,10 @@ BINDIR?=$(DESTDIR)${PREFIX}/bin
4
+ MANDIR?=$(DESTDIR)${PREFIX}/share/man
5
+ 
6
+ 
7
+-all: $(EXEC) pfc $(CONTROL_EXEC)
8
++all: $(EXEC) $(CONTROL_EXEC)
9
+ 
10
+ clean:
11
+-	rm -f $(OBJS) $(EXEC) pfc.o pfc $(CONTROL_EXEC)
12
++	rm -f $(OBJS) $(EXEC) $(CONTROL_EXEC)
13
+ 
14
+ $(EXEC): $(OBJS) $(HDRS)
15
+ 	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
16
+@@ -118,14 +118,10 @@ $(EXEC): $(OBJS) $(HDRS)
17
+ $(CONTROL_EXEC): $(CONTROL_SRCS)
18
+ 	$(CC) $(CFLAGS) $(LDFLAGS) $(CONTROL_SRCS) -o $@
19
+ 
20
+-pfc:
21
+-	$(CC) $(CFLAGS) -c contrib/pfc.c
22
+-	$(CC) $(LDFLAGS) -o pfc pfc.o -lpcap $(LDLIBS)
23
+-
24
+ romfs:
25
+ 	$(ROMFSINST) /bin/$(EXEC)
26
+ 
27
+-install: ${EXEC} pfc ${CONTROL_EXEC}
28
++install: ${EXEC} ${CONTROL_EXEC}
29
+ 	install -d -m 0755 ${SBINDIR}
30
+ 	install -m 0755 $(EXEC) ${SBINDIR}/$(EXEC)
31
+ 	install -d -m 0755 ${MANDIR}/man5
32
+@@ -133,11 +129,6 @@ install: ${EXEC} pfc ${CONTROL_EXEC}
33
+ 	install -m 0644 doc/xl2tpd.8 ${MANDIR}/man8/
34
+ 	install -m 0644 doc/xl2tpd.conf.5 doc/l2tp-secrets.5 \
35
+ 		 ${MANDIR}/man5/
36
+-	# pfc
37
+-	install -d -m 0755 ${BINDIR}
38
+-	install -m 0755 pfc ${BINDIR}/pfc
39
+-	install -d -m 0755 ${MANDIR}/man1
40
+-	install -m 0644 contrib/pfc.1 ${MANDIR}/man1/
41
+ 	# control exec
42
+ 	install -d -m 0755 ${SBINDIR}
43
+ 	install -m 0755 $(CONTROL_EXEC) ${SBINDIR}/$(CONTROL_EXEC)