summaryrefslogtreecommitdiff
path: root/net-dialup/xl2tpd
diff options
context:
space:
mode:
Diffstat (limited to 'net-dialup/xl2tpd')
-rw-r--r--net-dialup/xl2tpd/Manifest22
-rw-r--r--net-dialup/xl2tpd/files/xl2tpd-1.3.0-LDFLAGS.patch15
-rw-r--r--net-dialup/xl2tpd/files/xl2tpd-1.3.1-CFLAGS.patch19
-rw-r--r--net-dialup/xl2tpd/files/xl2tpd-1.3.1-kernelmode.patch361
-rw-r--r--net-dialup/xl2tpd/files/xl2tpd-1.3.1-no-type-punning-b119c0da.patch23
-rw-r--r--net-dialup/xl2tpd/files/xl2tpd-dnsretry.patch42
-rw-r--r--net-dialup/xl2tpd/files/xl2tpd-init31
-rw-r--r--net-dialup/xl2tpd/files/xl2tpd-init-r111
-rw-r--r--net-dialup/xl2tpd/files/xl2tpd.conf1
-rw-r--r--net-dialup/xl2tpd/files/xl2tpd.service12
-rw-r--r--net-dialup/xl2tpd/metadata.xml20
-rw-r--r--net-dialup/xl2tpd/xl2tpd-1.3.1-r2.ebuild52
-rw-r--r--net-dialup/xl2tpd/xl2tpd-1.3.1-r3.ebuild52
-rw-r--r--net-dialup/xl2tpd/xl2tpd-1.3.1-r4.ebuild52
-rw-r--r--net-dialup/xl2tpd/xl2tpd-1.3.10.ebuild55
-rw-r--r--net-dialup/xl2tpd/xl2tpd-1.3.6.ebuild45
-rw-r--r--net-dialup/xl2tpd/xl2tpd-1.3.9.ebuild55
17 files changed, 868 insertions, 0 deletions
diff --git a/net-dialup/xl2tpd/Manifest b/net-dialup/xl2tpd/Manifest
new file mode 100644
index 000000000000..62d1511f0bf9
--- /dev/null
+++ b/net-dialup/xl2tpd/Manifest
@@ -0,0 +1,22 @@
+AUX xl2tpd-1.3.0-LDFLAGS.patch 387 SHA256 c240a4e47775f8037c840a8b2ccaefb29ecca610f4c5d65e4effebec9694cd5d SHA512 e388638b623cae4464bd6946b81682ef8a41c50dd3b93d64a9888e94ff34a7e97db1b34b2c950b3e73a783024e5542ce4d18e63c2465787cc25c0a4e8f28f39e WHIRLPOOL 216d7824dac75fc2946ca2ee1c481a33a6932770f54f7adf906fb368c58a5b5289ee6d78bf13ed60d4dfd9b375072edf560cfcaa0269135d891887ee8ac4822c
+AUX xl2tpd-1.3.1-CFLAGS.patch 522 SHA256 c3afc76cd539d8b450ebbd2bf29ca5600599e842baa6a1046bde56c13744ffd3 SHA512 f8b9b684f92104d1d3f1db1784d2961b537ef204ba426ff7d277a23b564137a5ab42a3db2f9b9259f45cfadbe528bfb0588fb69cbde2e0193be508d6e1786451 WHIRLPOOL 19bfa625869699e3c631d146bf2900cf11c1bd12df7b87e3e4018ae471354088a4ad573f050d767064c202c558dadb51af3ea1bc3a620a1470638f74536ede94
+AUX xl2tpd-1.3.1-kernelmode.patch 12375 SHA256 5c776962eb66e11f98a96f61a9bc01070b0dc060b92098f5f6ac97f5d7ee7c69 SHA512 05ba1380a96dfc3e9ed90fff2ef3746e5b3f835f77220723a702a7581e2b6638e58d0dde3833c2f4f91043322a14a05f8fb5b412ba13d7f879af9452f3e94696 WHIRLPOOL 3a8487978a6a604dd0cadb60a95604659979aa26adb5558ff021af4e05fea205c07dbaf621a56f8e1f618fcfa97e0f61bb4bc4235d7f264578631514980eb1ee
+AUX xl2tpd-1.3.1-no-type-punning-b119c0da.patch 849 SHA256 20d446b8ad52b18212bbaed3386dc9f1a530252a84d0d5519490307e0d88f8d0 SHA512 3d1229f47bb0b5ea0817f1cacc6870221179d43f1602ca71af6bdbf74d3b36d4267482d0767344c0bde51f0d967ed3b2045adde6e4dc02d4baf11f7977d41b8f WHIRLPOOL a62c1b03d256a00d9bcc56ca9cf9da6074dc902b274cbe2073917dd86f34f80fc955e64eea91e3c7b531fe80c3a5a28bb7a7cb899520b43a9886bdb777d93d67
+AUX xl2tpd-dnsretry.patch 1509 SHA256 ac398be2d5fb67cc7c5e5b7247572d89cde85b2dc988e4e99c470afddfc5860c SHA512 7999c8e990f7bcd620042295e5fc6e12cf4b1e4faf7cd560bdd4ade4103b171e76a06cb11caea0046b8141a4fa9592bd8851f933072c5e7f71d8b1f4b6fb2bbd WHIRLPOOL e584d4b46dc6249d41b8228246f856ca263c9c3b6713bbb953b17d3265653ee4e45a582f1e2c80f3ad33a0369ed59ddfab50e4c1b5bab9e3be22814c3d034880
+AUX xl2tpd-init 617 SHA256 2d1bc2be1860674812ce81a3571e67c988f423a6bfd52ff2bfc5be680f2d4871 SHA512 c1a66ae80ee87e31bb1a1f81ee353d32a454092af4a11948de52a871f79e43b60169b250c3fa79ee8e93d8d3b93a7dd680fc4b9989470e707e9b4fd9534250de WHIRLPOOL 5c9a33eca5c34d26569cba38650416153bd7ca602b71079496368bfc48c55c5aa8c9f76da137ff8c235aa7f627ec66073c69ec49107e1a7cf92434f7460abfa9
+AUX xl2tpd-init-r1 272 SHA256 60309d44bd9256a695d180cba1a88a752c955d2d8c973b77d3fbf1cb03ad0ef5 SHA512 80235d4084963f9285fc11f30ca648ebe4a23e3f74e41fddb81d6fdc08808b1772163192f61f56c677c3003f10809f7d014ddeaa427eabfad490106ac7e14f67 WHIRLPOOL 790bdfffb6bb237f7fe1364411fccd528456e95191555ea6bf72f194dbd8dba1a5593e76ee7576f2dc6f310c93641a6ae3b7538c37665a01ca52a154d083939e
+AUX xl2tpd.conf 18 SHA256 9e6280cf9dbd14036dccc3c40a3f9acc65efe279f6c46d7edc1f786adf6f6e6d SHA512 0b3c6d4784b997d12734fe1e5165dc066269db24608638566c0fc317c1927331ed806fdb7a4f816bd16d1f22046b52badd99c2f0977c157b2b3f3ed42071ae42 WHIRLPOOL baedb7e8e2568dad9953894085d2290ce96b5a7c3393b4b4f69cc439a0e2cfe15bda0c505a83c5d0672fa07c4e83eac72ed80e858a28c371409914e3546904e5
+AUX xl2tpd.service 232 SHA256 fa82928fbd632a1c3f2897f371b178b055cee4dd1e46248fd64887e65c1b8e15 SHA512 184b4f63492c5a09fa61ebf0913a4a47e1cd3b321b80b122f2177ff8f5c9eccdc4a73831dfffc3c2e39325f5cb0b30c4e3f99c1f0fed1f21935be5da38a83579 WHIRLPOOL b5fa9a92fc399fb2126109694f5f9539f5985c082ec32f13b8a0959bd5c9146761fefd8ff2e2ecbbd084c6609d3d7579dc47da0a29852d1936be8d6ad27efd43
+DIST xl2tpd-1.3.1.tar.gz 551923 SHA256 147ea96a957628bc31bba6fd5f5ef5522366691f936ce4c0a0988d9876e3ba14 SHA512 2265a19eda1521fd4314ad1b28cc1bb781d2f0edb06ad619afbb364f5896e23db7e444ac10709c1ae9b9ac648e4354aea7af57bb5bc20b706b00e2a131fc29d6 WHIRLPOOL b5465605ae5c3bbf73227f11958a43c66191bb557447ce224de044358e738331cf8e64e783bb5527517683cbcc59d57df9cc17c990f652fe7aed1ab2cfd7f9b2
+DIST xl2tpd-1.3.10.tar.gz 510777 SHA256 48bbc86b448a51bf167f1e04d10e2b97f9e928da42eb0dd455b419ef0522d1c3 SHA512 304b8cd098608a866d32c65c55ba98a01e10abb473d8bff488c723fd1f6d4a66cf98c6d3044f7986a334739693767608c48999f873e95a51f0fa6c23cb61ecd4 WHIRLPOOL a1912740ebf1aeae3e2133443b92bbe28db91937701796ee8136009522ca1e7416d6a406182a820fee0c68904fb6f07556e618749613f96c7e8b2ae240a1d669
+DIST xl2tpd-1.3.6.tar.gz 553981 SHA256 49b069aa8d873e1d8f615ccc4212351e427bf681ba453fdd211256a8345bb7fb SHA512 868c65660e6a45fb8dc22b95542e9d6ca0dc8e5033cc9df04171a651ef273bc5d711a85f61d4a971d714089f7a10ee67460d8ab9f3c007fcffe0e11e81ae0bfd WHIRLPOOL 92bf661e0ae95bcf80cb8b8c5c9c8648d3aa5375a9dc598f0f4fa3be3bce2bc9a36a60eabf44da3dad24fb3f2b03e30b960d73e6a16c51c8ea25397639766328
+DIST xl2tpd-1.3.9.tar.gz 510538 SHA256 62f683ab4cda2941261e37828f2939b5a2e85b437e9a3cd86bbd660c26e04a1e SHA512 858e342e3f5b9c460c8fd041cb2873c79dbb9fbef1e5caf8c367a6c74ca175c2a020a4b152757892c24950eebf701324c0ba682eafd23cd370d36da7118cb3d9 WHIRLPOOL 186ed1f8729eacbf6aa35ac0af97fdf1124ff85cebd119ba0d7f6d303fbfa3292fb7c247c3308743fd2785de0ebaa8fd7adf7801b6f4db8102abf9211f84732a
+EBUILD xl2tpd-1.3.1-r2.ebuild 1585 SHA256 88c112b2ee71092dfb26cc18e3ef51e45aa8f4092e615e4006fad87516c65015 SHA512 4c98a2b83d51a08045d8921c0f2390b3f79dbcc48b67601e51a13c3a1e047a6fd07db880df53428b7a17dcb4375ca1748f1467b9119ded5954c9f7ddff22df64 WHIRLPOOL 8e863ef51faa4887c535cc1f7de774d6cd3c6ab030300f40a580b5b80248eab2fd63f2858b4e383b1f835ab86afd8ca07c4d979c49b4778546a2051cab4e71d4
+EBUILD xl2tpd-1.3.1-r3.ebuild 1641 SHA256 f99aa027978f0f7ee40e19eae8e381be5e1ae3a133db85a9736f51ae970f724b SHA512 cd6af025e51af02060f5408ee7550bd9af5be0db2d4bcc8c5e37342572a2416e7754f91c6df9c1beea7ba3b077d9aadf2ec4ebb5e64a922d575d46c7bf4db78d WHIRLPOOL 282565842b7035caaba93644f80e1a6eba3458b17422008172734ebc542aafd43e50f1c79c8a85c0558d43b1fe3b0dac2cc74f03b412e5109dcb2acf521312fd
+EBUILD xl2tpd-1.3.1-r4.ebuild 1646 SHA256 92134978feb7f85f8e28fb376d780479c75ea49107df854b76847834fb9fa669 SHA512 10a1cf9ca036b556ae0468846105eb18c197e18b8524cb525e1023d830b398398e9d7c0b88155379c0f4d042a8469f11f336b71f8c48885e3db109baba817273 WHIRLPOOL edb0fffbd355e6c56f9047147668972418f63e373fd9ca7718040979f7fcb6b8e9b0d834ebe7de69ac1206059747a12c6baf33583885a904bb42477643621e50
+EBUILD xl2tpd-1.3.10.ebuild 1428 SHA256 6078f0e68ef0fcbcb61da854b2acffd81e37628a3676507955c74bb6c97f0efb SHA512 468fc0a9222904f2db0f3ea985d146508af6a6e13183703be733317895fe9db0889408743b204d0754f95835c906e9c4451a23c84a172afc720e53ea55420c95 WHIRLPOOL 5f724f33017b320260f4ba343bb16796d29740daa3ead4ea0a8cc075616ccd3b681ba0c4b4507409fbb6e48e0a01bbc37fd399e401507c55135fde0804fe66e1
+EBUILD xl2tpd-1.3.6.ebuild 1344 SHA256 5631346059fcfdf73b43ffb3981b03ca907b4ef9e0b02967b1bc2acd94784a81 SHA512 7f12712ad899f57b32b8533340c0e57cfcb8907f5031715e548c9286b1ae4b77c0486c547355f0beadba267aa945169f9149b078373cbd8f5a82d0547ca1f58b WHIRLPOOL 3055e392467896cb4e3b3e6080c38bff5f3526b3defa61c732cf3f5931c359b41a0dcac1295f5a7f0132610ab9cc93621d7837e4d01274bf3330aee0143ba59c
+EBUILD xl2tpd-1.3.9.ebuild 1429 SHA256 258b5f7afb0ab17f8ff9b20273096e7ff574ec4ac017a23dc0c83ddd37a9cbba SHA512 2e54802e5bd813dbb4e27bb7a474667fef31f6239659780d7eadca93cc331305ddce0df7814f6f7504ee93a1b2cb9d2d0046dd676c72937299c23d121ab0ab90 WHIRLPOOL 61acc26b38ac66f0035b9e0e3e1f444213fba0251538c26a1c8f4e24900b6dd84b60983b0918fb67bbfeb86816f9798be8b5e0822a267c559a1c6612f0a0d477
+MISC ChangeLog 3033 SHA256 7f4d2d32b3494039425dc65483703afcca760d66ec6238cc2d9b9b1277953d07 SHA512 35c61c2a7ecd16762acd245168906b551f817b838a34cd16fe5fc9f88a99f8a8891b560ae2037306d65065075cdb06d214509b54b5dd9261bbc4e04414568e9a WHIRLPOOL 570bff028d7fd04fc5988de2f360e1ff37d2e027364c51202277c270cfe84c05576fc8f0938cb89bb035c0bb3a4cd9c57b0cef4bc6ab54c79672d9d1a0a896c2
+MISC ChangeLog-2015 7995 SHA256 1afc60e0e6060cf9b32bb9ed8c8fd1af5214185937c16efe777d31f05841eb7e SHA512 b263ce817e4b2abc82345b0547623f00f988af611f5853a8b5c23a4a06ba673c3470e6b8513d637bc27c48a3667a5bdcfde809c92e841e0cf670254d610989b9 WHIRLPOOL 32bee86c8cc11ba86d3a941ce10af30329b76b4dc7cb3d688a73c208beef7fcfc570a253c8d6920c47610aeab026ba4bbfe8339d63473971bde8b9172bf1671f
+MISC metadata.xml 956 SHA256 ef85f34123c3666f5377942563a185e14618620553715798ad589e058eba55af SHA512 22a1d2541c0bd7e46a54a75d4199233d216b2678bc7c60b0c0c29d2cfc1c9f6320afb22611e1f4fd1b1801fb2084d565a79cb3eeaa5092d9e836a8fdf3dcc9cb WHIRLPOOL d183aada3327b13bd2b4e8b4bc7ecc6695c0375234d28145776f14c30c3b08e2d23ba16fca1e9dc2b4b8517230099a267560bf06b38692e7a882fac11a22a82a
diff --git a/net-dialup/xl2tpd/files/xl2tpd-1.3.0-LDFLAGS.patch b/net-dialup/xl2tpd/files/xl2tpd-1.3.0-LDFLAGS.patch
new file mode 100644
index 000000000000..8203e51ebc1f
--- /dev/null
+++ b/net-dialup/xl2tpd/files/xl2tpd-1.3.0-LDFLAGS.patch
@@ -0,0 +1,15 @@
+"Submitted" upstream: https://github.com/xelerance/xl2tpd/pull/4
+
+=== modified file 'Makefile'
+--- Makefile 2011-09-20 04:44:23 +0000
++++ Makefile 2011-09-20 04:44:35 +0000
+@@ -114,7 +114,7 @@
+ $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
+
+ $(CONTROL_EXEC): $(CONTROL_SRCS)
+- $(CC) $(CONTROL_SRCS) -o $@
++ $(CC) $(LDFLAGS) $(CONTROL_SRCS) -o $@
+
+ pfc:
+ $(CC) $(CFLAGS) -c contrib/pfc.c
+
diff --git a/net-dialup/xl2tpd/files/xl2tpd-1.3.1-CFLAGS.patch b/net-dialup/xl2tpd/files/xl2tpd-1.3.1-CFLAGS.patch
new file mode 100644
index 000000000000..b069a9a4822d
--- /dev/null
+++ b/net-dialup/xl2tpd/files/xl2tpd-1.3.1-CFLAGS.patch
@@ -0,0 +1,19 @@
+commit 898e8541804d0f5a6475b27f8ca5e57cf282208f
+Author: Mike Gilbert <floppym@gentoo.org>
+Date: Tue Dec 25 16:05:33 2012 -0500
+
+ Respect CFLAGS for xl2tpd-control.
+
+diff --git a/Makefile b/Makefile
+index 2a0f341..d694246 100644
+--- a/Makefile
++++ b/Makefile
+@@ -115,7 +115,7 @@ $(EXEC): $(OBJS) $(HDRS)
+ $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
+
+ $(CONTROL_EXEC): $(CONTROL_SRCS)
+- $(CC) $(LDFLAGS) $(CONTROL_SRCS) -o $@
++ $(CC) $(CFLAGS) $(LDFLAGS) $(CONTROL_SRCS) -o $@
+
+ pfc:
+ $(CC) $(CFLAGS) -c contrib/pfc.c
diff --git a/net-dialup/xl2tpd/files/xl2tpd-1.3.1-kernelmode.patch b/net-dialup/xl2tpd/files/xl2tpd-1.3.1-kernelmode.patch
new file mode 100644
index 000000000000..5ce9b1244c76
--- /dev/null
+++ b/net-dialup/xl2tpd/files/xl2tpd-1.3.1-kernelmode.patch
@@ -0,0 +1,361 @@
+https://bugs.gentoo.org/show_bug.cgi?id=441828
+
+Based on Fedora patch
+http://pkgs.fedoraproject.org/cgit/xl2tpd.git/plain/xl2tpd-1.3.1-kernelmode.patch
+
+Which is based on a patch by Sergey Fionov (sigwall)
+https://github.com/sigwall/overlay/blob/master/net-dialup/xl2tpd/files/xl2tpd-1.3.0-kernel.patch
+
+diff --git a/call.c b/call.c
+index d1b1858..b672f91 100644
+--- a/call.c
++++ b/call.c
+@@ -680,6 +680,8 @@ struct call *get_call (int tunnel, int call, struct in_addr addr, int port,
+ st->peer.sin_port = port;
+ st->refme = refme;
+ st->refhim = refhim;
++ st->udp_fd = -1;
++ st->pppox_fd = -1;
+ bcopy (&addr, &st->peer.sin_addr, sizeof (addr));
+ st->next = tunnels.head;
+ tunnels.head = st;
+diff --git a/control.c b/control.c
+index 6a41143..8937f2e 100644
+--- a/control.c
++++ b/control.c
+@@ -596,6 +596,9 @@ int control_finish (struct tunnel *t, struct call *c)
+ if (gconfig.debug_state)
+ l2tp_log (LOG_DEBUG, "%s: sending SCCCN\n", __FUNCTION__);
+ control_xmit (buf);
++
++ connect_pppol2tp(t);
++
+ /* Schedule a HELLO */
+ tv.tv_sec = HELLO_DELAY;
+ tv.tv_usec = 0;
+@@ -608,6 +611,7 @@ int control_finish (struct tunnel *t, struct call *c)
+ "Connection established to %s, %d. Local: %d, Remote: %d (ref=%u/%u).\n",
+ IPADDY (t->peer.sin_addr),
+ ntohs (t->peer.sin_port), t->ourtid, t->tid, t->refme, t->refhim);
++
+ if (t->lac)
+ {
+ /* This is part of a LAC, so we want to go ahead
+@@ -635,6 +639,9 @@ int control_finish (struct tunnel *t, struct call *c)
+ IPADDY (t->peer.sin_addr),
+ ntohs (t->peer.sin_port), t->ourtid, t->tid, t->refme, t->refhim,
+ t->lns->entname);
++
++ connect_pppol2tp(t);
++
+ /* Schedule a HELLO */
+ tv.tv_sec = HELLO_DELAY;
+ tv.tv_usec = 0;
+diff --git a/l2tp.h b/l2tp.h
+index ac22f3f..0062095 100644
+--- a/l2tp.h
++++ b/l2tp.h
+@@ -167,6 +167,8 @@ struct tunnel
+ int ourrws; /* Receive Window Size */
+ int rxspeed; /* Receive bps */
+ int txspeed; /* Transmit bps */
++ int udp_fd; /* UDP fd */
++ int pppox_fd; /* PPPOX tunnel fd */
+ struct call *self;
+ struct lns *lns; /* LNS that owns us */
+ struct lac *lac; /* LAC that owns us */
+@@ -220,6 +222,7 @@ extern void control_xmit (void *);
+ extern int ppd;
+ extern int switch_io; /* jz */
+ extern int control_fd;
++extern int connect_pppol2tp(struct tunnel *t);
+ extern int start_pppd (struct call *c, struct ppp_opts *);
+ extern void magic_lac_dial (void *);
+ extern int get_entropy (unsigned char *, int);
+diff --git a/network.c b/network.c
+index 82aedd7..8a3fec2 100644
+--- a/network.c
++++ b/network.c
+@@ -22,6 +22,7 @@
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <sys/ioctl.h>
++#include <sys/wait.h>
+ #ifndef LINUX
+ # include <sys/uio.h>
+ #endif
+@@ -36,7 +37,6 @@ int server_socket; /* Server socket */
+ int kernel_support; /* Kernel Support there or not? */
+ #endif
+
+-
+ int init_network (void)
+ {
+ long arg;
+@@ -45,6 +45,7 @@ int init_network (void)
+ server.sin_family = AF_INET;
+ server.sin_addr.s_addr = gconfig.listenaddr;
+ server.sin_port = htons (gconfig.port);
++ int flags;
+ if ((server_socket = socket (PF_INET, SOCK_DGRAM, 0)) < 0)
+ {
+ l2tp_log (LOG_CRIT, "%s: Unable to allocate socket. Terminating.\n",
+@@ -52,6 +53,10 @@ int init_network (void)
+ return -EINVAL;
+ };
+
++ flags = 1;
++ setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, &flags, sizeof(flags));
++ setsockopt(server_socket, SOL_SOCKET, SO_NO_CHECK, &flags, sizeof(flags));
++
+ if (bind (server_socket, (struct sockaddr *) &server, sizeof (server)))
+ {
+ close (server_socket);
+@@ -94,7 +99,7 @@ int init_network (void)
+ int kernel_fd = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OL2TP);
+ if (kernel_fd < 0)
+ {
+- l2tp_log (LOG_INFO, "L2TP kernel support not detected.\n");
++ l2tp_log (LOG_INFO, "L2TP kernel support not detected (try modprobing l2tp_ppp and pppol2tp)\n");
+ kernel_support = 0;
+ }
+ else
+@@ -321,6 +326,11 @@ int build_fdset (fd_set *readfds)
+
+ while (tun)
+ {
++ if (tun->udp_fd > -1) {
++ if (tun->udp_fd > max)
++ max = tun->udp_fd;
++ FD_SET (tun->udp_fd, readfds);
++ }
+ call = tun->call_head;
+ while (call)
+ {
+@@ -390,6 +400,8 @@ void network_thread ()
+ struct iovec iov;
+ char cbuf[256];
+ unsigned int refme, refhim;
++ int * currentfd;
++ int server_socket_processed;
+
+ /* This one buffer can be recycled for everything except control packets */
+ buf = new_buf (MAX_RECV_SIZE);
+@@ -428,7 +440,21 @@ void network_thread ()
+ {
+ do_control ();
+ }
+- if (FD_ISSET (server_socket, &readfds))
++ server_socket_processed = 0;
++ currentfd = NULL;
++ st = tunnels.head;
++ while (st || !server_socket_processed) {
++ if (st && (st->udp_fd == -1)) {
++ st=st->next;
++ continue;
++ }
++ if (st) {
++ currentfd = &st->udp_fd;
++ } else {
++ currentfd = &server_socket;
++ server_socket_processed = 1;
++ }
++ if (FD_ISSET (*currentfd, &readfds))
+ {
+ /*
+ * Okay, now we're ready for reading and processing new data.
+@@ -456,12 +482,19 @@ void network_thread ()
+ msgh.msg_flags = 0;
+
+ /* Receive one packet. */
+- recvsize = recvmsg(server_socket, &msgh, 0);
++ recvsize = recvmsg(*currentfd, &msgh, 0);
+
+ if (recvsize < MIN_PAYLOAD_HDR_LEN)
+ {
+ if (recvsize < 0)
+ {
++ if (errno == ECONNREFUSED) {
++ close(*currentfd);
++ }
++ if ((errno == ECONNREFUSED) ||
++ (errno == EBADF)) {
++ *currentfd = -1;
++ }
+ if (errno != EAGAIN)
+ l2tp_log (LOG_WARNING,
+ "%s: recvfrom returned error %d (%s)\n",
+@@ -566,6 +599,8 @@ void network_thread ()
+ }
+ };
+ }
++ if (st) st=st->next;
++ }
+
+ /*
+ * finished obvious sources, look for data from PPP connections.
+@@ -638,3 +673,82 @@ void network_thread ()
+ }
+
+ }
++
++int connect_pppol2tp(struct tunnel *t) {
++#ifdef USE_KERNEL
++ if (kernel_support) {
++ int ufd = -1, fd2 = -1;
++ int flags;
++ struct sockaddr_pppol2tp sax;
++
++ struct sockaddr_in server;
++ server.sin_family = AF_INET;
++ server.sin_addr.s_addr = gconfig.listenaddr;
++ server.sin_port = htons (gconfig.port);
++ if ((ufd = socket (PF_INET, SOCK_DGRAM, 0)) < 0)
++ {
++ l2tp_log (LOG_CRIT, "%s: Unable to allocate UDP socket. Terminating.\n",
++ __FUNCTION__);
++ return -EINVAL;
++ };
++
++ flags=1;
++ setsockopt(ufd, SOL_SOCKET, SO_REUSEADDR, &flags, sizeof(flags));
++ setsockopt(ufd, SOL_SOCKET, SO_NO_CHECK, &flags, sizeof(flags));
++
++ if (bind (ufd, (struct sockaddr *) &server, sizeof (server)))
++ {
++ close (ufd);
++ l2tp_log (LOG_CRIT, "%s: Unable to bind UDP socket: %s. Terminating.\n",
++ __FUNCTION__, strerror(errno), errno);
++ return -EINVAL;
++ };
++ server = t->peer;
++ flags = fcntl(ufd, F_GETFL);
++ if (flags == -1 || fcntl(ufd, F_SETFL, flags | O_NONBLOCK) == -1) {
++ l2tp_log (LOG_WARNING, "%s: Unable to set UDP socket nonblock.\n",
++ __FUNCTION__);
++ return -EINVAL;
++ }
++ if (connect (ufd, (struct sockaddr *) &server, sizeof(server)) < 0) {
++ l2tp_log (LOG_CRIT, "%s: Unable to connect UDP peer. Terminating.\n",
++ __FUNCTION__);
++ return -EINVAL;
++ }
++
++ t->udp_fd=ufd;
++
++ fd2 = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OL2TP);
++ if (fd2 < 0) {
++ l2tp_log (LOG_WARNING, "%s: Unable to allocate PPPoL2TP socket.\n",
++ __FUNCTION__);
++ return -EINVAL;
++ }
++ flags = fcntl(fd2, F_GETFL);
++ if (flags == -1 || fcntl(fd2, F_SETFL, flags | O_NONBLOCK) == -1) {
++ l2tp_log (LOG_WARNING, "%s: Unable to set PPPoL2TP socket nonblock.\n",
++ __FUNCTION__);
++ return -EINVAL;
++ }
++ sax.sa_family = AF_PPPOX;
++ sax.sa_protocol = PX_PROTO_OL2TP;
++ sax.pppol2tp.pid = 0;
++ sax.pppol2tp.fd = t->udp_fd;
++ sax.pppol2tp.addr.sin_addr.s_addr = t->peer.sin_addr.s_addr;
++ sax.pppol2tp.addr.sin_port = t->peer.sin_port;
++ sax.pppol2tp.addr.sin_family = AF_INET;
++ sax.pppol2tp.s_tunnel = t->ourtid;
++ sax.pppol2tp.s_session = 0;
++ sax.pppol2tp.d_tunnel = t->tid;
++ sax.pppol2tp.d_session = 0;
++ if ((connect(fd2, (struct sockaddr *)&sax, sizeof(sax))) < 0) {
++ l2tp_log (LOG_WARNING, "%s: Unable to connect PPPoL2TP socket. %d %s\n",
++ __FUNCTION__, errno, strerror(errno));
++ close(fd2);
++ return -EINVAL;
++ }
++ t->pppox_fd = fd2;
++ }
++#endif
++ return 0;
++}
+diff --git a/xl2tpd.c b/xl2tpd.c
+index e98c948..8d7d117 100644
+--- a/xl2tpd.c
++++ b/xl2tpd.c
+@@ -278,7 +278,11 @@ void death_handler (int signal)
+ struct tunnel *st, *st2;
+ int sec;
+ l2tp_log (LOG_CRIT, "%s: Fatal signal %d received\n", __FUNCTION__, signal);
++#ifdef USE_KERNEL
++ if (kernel_support || signal != SIGTERM) {
++#else
+ if (signal != SIGTERM) {
++#endif
+ st = tunnels.head;
+ while (st)
+ {
+@@ -349,7 +353,7 @@ int start_pppd (struct call *c, struct ppp_opts *opts)
+ int flags;
+ #endif
+ int pos = 1;
+- int fd2;
++ int fd2 = -1;
+ #ifdef DEBUG_PPPD
+ int x;
+ #endif
+@@ -397,7 +401,7 @@ int start_pppd (struct call *c, struct ppp_opts *opts)
+ sax.sa_family = AF_PPPOX;
+ sax.sa_protocol = PX_PROTO_OL2TP;
+ sax.pppol2tp.pid = 0;
+- sax.pppol2tp.fd = server_socket;
++ sax.pppol2tp.fd = c->container->udp_fd;
+ sax.pppol2tp.addr.sin_addr.s_addr = c->container->peer.sin_addr.s_addr;
+ sax.pppol2tp.addr.sin_port = c->container->peer.sin_port;
+ sax.pppol2tp.addr.sin_family = AF_INET;
+@@ -408,6 +412,7 @@ int start_pppd (struct call *c, struct ppp_opts *opts)
+ if (connect(fd2, (struct sockaddr *)&sax, sizeof(sax)) < 0) {
+ l2tp_log (LOG_WARNING, "%s: Unable to connect PPPoL2TP socket.\n",
+ __FUNCTION__);
++ close(fd2);
+ return -EINVAL;
+ }
+ stropt[pos++] = strdup ("plugin");
+@@ -484,7 +489,7 @@ int start_pppd (struct call *c, struct ppp_opts *opts)
+ dup2 (fd2, 0);
+ dup2 (fd2, 1);
+ close(fd2);
+-
++ }
+ /* close all the calls pty fds */
+ st = tunnels.head;
+ while (st)
+@@ -492,12 +497,17 @@ int start_pppd (struct call *c, struct ppp_opts *opts)
+ sc = st->call_head;
+ while (sc)
+ {
+- close (sc->fd);
++#ifdef USE_KERNEL
++ if (kernel_support) {
++ close(st->udp_fd); /* tunnel UDP fd */
++ close(st->pppox_fd); /* tunnel PPPoX fd */
++ } else
++#endif
++ close (sc->fd); /* call pty fd */
+ sc = sc->next;
+ }
+ st = st->next;
+ }
+- }
+
+ /* close the UDP socket fd */
+ close (server_socket);
+@@ -615,6 +625,10 @@ void destroy_tunnel (struct tunnel *t)
+ the memory pointed to by t->chal_us.vector at some other place */
+ if (t->chal_them.vector)
+ free (t->chal_them.vector);
++ if (t->pppox_fd > -1 )
++ close (t->pppox_fd);
++ if (t->udp_fd > -1 )
++ close (t->udp_fd);
+ free (t);
+ free (me);
+ }
diff --git a/net-dialup/xl2tpd/files/xl2tpd-1.3.1-no-type-punning-b119c0da.patch b/net-dialup/xl2tpd/files/xl2tpd-1.3.1-no-type-punning-b119c0da.patch
new file mode 100644
index 000000000000..681d9a6f94c4
--- /dev/null
+++ b/net-dialup/xl2tpd/files/xl2tpd-1.3.1-no-type-punning-b119c0da.patch
@@ -0,0 +1,23 @@
+commit b119c0daf006dcf9d960e5a98902d619cdfdf485
+Author: Ted Phelps <phelps@gnusto.com>
+Date: Thu Dec 20 17:53:54 2012 +1100
+
+ Avoid type punning: it makes gcc grumpy.
+
+ Compilers don't like it when we write to memory as one type and read from it
+ as another. Use memcpy instead of typecast games to avoid doing that.
+
+diff --git a/md5.c b/md5.c
+index 175edcc..cb056da 100644
+--- a/md5.c
++++ b/md5.c
+@@ -161,8 +161,7 @@ void MD5Final (unsigned char digest[16], struct MD5Context *ctx)
+ byteReverse (ctx->in, 14);
+
+ /* Append length in bits and transform */
+- ((uint32 *) ctx->in)[14] = ctx->bits[0];
+- ((uint32 *) ctx->in)[15] = ctx->bits[1];
++ memcpy(ctx->in + 14 * sizeof(uint32), ctx->bits, sizeof(ctx->bits));
+
+ MD5Transform (ctx->buf, (uint32 *) ctx->in);
+ byteReverse ((unsigned char *) ctx->buf, 4);
diff --git a/net-dialup/xl2tpd/files/xl2tpd-dnsretry.patch b/net-dialup/xl2tpd/files/xl2tpd-dnsretry.patch
new file mode 100644
index 000000000000..b27703fe435e
--- /dev/null
+++ b/net-dialup/xl2tpd/files/xl2tpd-dnsretry.patch
@@ -0,0 +1,42 @@
+https://bugs.gentoo.org/show_bug.cgi?id=307489
+http://homenet.beeline.ru/index.php?showtopic=192551&st=0&p=1063626345&#entry1063626345
+
+--- xl2tpd.c 2010-05-10 22:35:43.000000000 +0200
++++ xl2tpd.c 2010-08-15 22:02:14.000000000 +0200
+@@ -587,9 +587,33 @@
+ hp = gethostbyname (host);
+ if (!hp)
+ {
+- l2tp_log (LOG_WARNING, "Host name lookup failed for %s.\n",
+- host);
+- return NULL;
++ if ( lac->redial )
++ {
++ int imax=lac->rmax;
++ if ( lac->rmax == 0 )
++ imax = 1;
++ while ( imax > 0 )
++ {
++ hp = gethostbyname ( host );
++ if ( hp )
++ break;
++ l2tp_log ( LOG_WARNING, "Y: Host name lookup failed for %s. Trying to look again in %d seconds.\n", host, lac->rtimeout );
++ if ( lac->rtimeout > 0 )
++ sleep ( lac->rtimeout );
++ if ( lac->rmax > 0 )
++ imax--;
++ }
++ if ( ( imax == 0 ) && ( lac->rmax > 0 ) )
++ {
++ l2tp_log ( LOG_WARNING, "Y: Host name lookup failed for %s after %d tries. Lookup stops now.\n", host, lac->rmax );
++ return NULL;
++ }
++ }
++ else
++ {
++ l2tp_log (LOG_WARNING, "Host name lookup failed for %s.\n", host);
++ return NULL;
++ }
+ }
+ bcopy (hp->h_addr, &addr, hp->h_length);
+ /* Force creation of a new tunnel
diff --git a/net-dialup/xl2tpd/files/xl2tpd-init b/net-dialup/xl2tpd/files/xl2tpd-init
new file mode 100644
index 000000000000..7323af64087f
--- /dev/null
+++ b/net-dialup/xl2tpd/files/xl2tpd-init
@@ -0,0 +1,31 @@
+#!/sbin/openrc-run
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need net
+}
+
+checkconfig() {
+ if [ ! -f /etc/xl2tpd/xl2tpd.conf ] ; then
+ eerror "Missing /etc/xl2tpd/xl2tpd.conf configuration file!"
+ eerror "Example configuration file could be found in doc directory."
+ return 1
+ fi
+
+ return 0
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting xl2tpd"
+ start-stop-daemon --start --quiet --exec /usr/sbin/xl2tpd
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping xl2tpd"
+ start-stop-daemon --stop --quiet --pidfile /var/run/xl2tpd.pid
+ eend $?
+}
diff --git a/net-dialup/xl2tpd/files/xl2tpd-init-r1 b/net-dialup/xl2tpd/files/xl2tpd-init-r1
new file mode 100644
index 000000000000..4e9956a4d13d
--- /dev/null
+++ b/net-dialup/xl2tpd/files/xl2tpd-init-r1
@@ -0,0 +1,11 @@
+#!/sbin/openrc-run
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+command="/usr/sbin/xl2tpd"
+pidfile="/var/run/xl2tpd.pid"
+required_files="/etc/xl2tpd/xl2tpd.conf"
+
+start_pre() {
+ checkpath -d /var/run/xl2tpd
+}
diff --git a/net-dialup/xl2tpd/files/xl2tpd.conf b/net-dialup/xl2tpd/files/xl2tpd.conf
new file mode 100644
index 000000000000..67162b26df06
--- /dev/null
+++ b/net-dialup/xl2tpd/files/xl2tpd.conf
@@ -0,0 +1 @@
+d /var/run/xl2tpd
diff --git a/net-dialup/xl2tpd/files/xl2tpd.service b/net-dialup/xl2tpd/files/xl2tpd.service
new file mode 100644
index 000000000000..37d46cc63493
--- /dev/null
+++ b/net-dialup/xl2tpd/files/xl2tpd.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Layer 2 Tunneling Protocol Daemon (L2TP)
+After=syslog.target network.target
+After=ipsec.service
+
+[Service]
+ExecStart=/usr/sbin/xl2tpd -D
+KillSignal=SIGINT
+SuccessExitStatus=1
+
+[Install]
+WantedBy=multi-user.target
diff --git a/net-dialup/xl2tpd/metadata.xml b/net-dialup/xl2tpd/metadata.xml
new file mode 100644
index 000000000000..8066f7a44b9e
--- /dev/null
+++ b/net-dialup/xl2tpd/metadata.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <email>tee@itc-gmbh.de</email>
+ <name>Torsten Alex</name>
+ </maintainer>
+ <maintainer type="project">
+ <email>proxy-maint@gentoo.org</email>
+ <name>Gentoo Proxy Maintainers Project</name>
+ </maintainer>
+ <longdescription>xl2tpd is a fork of l2tpd Layer 2 Tunneling Protocol (L2TP) daemon that can be used to transfer frames of OSI layer 2 protocols through an IP tunnel. While it provides authentication via CHAP or PAP it does not provide encryption itself and should therefore be externally secured (via IPSEC).</longdescription>
+ <use>
+ <flag name="dnsretry">Patch for host lookup retries, activated by redial feature</flag>
+ <flag name="kernel">Enable kernel interface for PPPoL2TP</flag>
+ </use>
+ <upstream>
+ <remote-id type="github">xelerance/xl2tpd</remote-id>
+ </upstream>
+</pkgmetadata>
diff --git a/net-dialup/xl2tpd/xl2tpd-1.3.1-r2.ebuild b/net-dialup/xl2tpd/xl2tpd-1.3.1-r2.ebuild
new file mode 100644
index 000000000000..d192d17f4459
--- /dev/null
+++ b/net-dialup/xl2tpd/xl2tpd-1.3.1-r2.ebuild
@@ -0,0 +1,52 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="4"
+
+inherit eutils toolchain-funcs vcs-snapshot
+
+DESCRIPTION="A modern version of the Layer 2 Tunneling Protocol (L2TP) daemon"
+HOMEPAGE="http://www.xelerance.com/services/software/xl2tpd/"
+SRC_URI="https://github.com/xelerance/${PN}/tarball/v${PV} -> ${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="amd64 ~ppc x86"
+IUSE="dnsretry +kernel"
+
+DEPEND="net-libs/libpcap"
+RDEPEND="${DEPEND}
+ net-dialup/ppp"
+DEPEND+=" kernel? ( >=sys-kernel/linux-headers-2.6.23 )"
+
+src_prepare() {
+ epatch "${FILESDIR}/${PN}-1.3.0-LDFLAGS.patch"
+ epatch "${FILESDIR}/${PN}-1.3.1-CFLAGS.patch"
+ epatch "${FILESDIR}/${PN}-1.3.1-no-type-punning-b119c0da.patch"
+ epatch "${FILESDIR}/${PN}-1.3.1-kernelmode.patch"
+ sed -i Makefile -e 's| -O2||g' || die "sed Makefile"
+ # The below patch is questionable. Why wasn't it submitted upstream? If it
+ # ever breaks, it will just be removed. -darkside 20120914
+ use dnsretry && epatch "${FILESDIR}/${PN}-dnsretry.patch"
+ # Remove bundled headers
+ rm -r linux || die
+}
+
+src_compile() {
+ tc-export CC
+ export OSFLAGS="-DLINUX"
+ use kernel && OSFLAGS+=" -DUSE_KERNEL"
+ emake
+}
+
+src_install() {
+ emake PREFIX=/usr DESTDIR="${D}" install
+
+ dodoc CREDITS README.xl2tpd BUGS CHANGES TODO doc/README.patents doc/rfc2661.txt
+
+ dodir /etc/xl2tpd
+ cp doc/l2tp-secrets.sample "${ED}/etc/xl2tpd/l2tp-secrets" || die
+ cp doc/l2tpd.conf.sample "${ED}/etc/xl2tpd/xl2tpd.conf" || die
+ fperms 0600 /etc/xl2tpd/l2tp-secrets
+ newinitd "${FILESDIR}"/xl2tpd-init-r1 xl2tpd
+}
diff --git a/net-dialup/xl2tpd/xl2tpd-1.3.1-r3.ebuild b/net-dialup/xl2tpd/xl2tpd-1.3.1-r3.ebuild
new file mode 100644
index 000000000000..2988e43fc915
--- /dev/null
+++ b/net-dialup/xl2tpd/xl2tpd-1.3.1-r3.ebuild
@@ -0,0 +1,52 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit eutils systemd toolchain-funcs vcs-snapshot
+
+DESCRIPTION="A modern version of the Layer 2 Tunneling Protocol (L2TP) daemon"
+HOMEPAGE="http://www.xelerance.com/services/software/xl2tpd/"
+SRC_URI="https://github.com/xelerance/${PN}/tarball/v${PV} -> ${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="amd64 ~ppc x86"
+IUSE="dnsretry +kernel"
+
+DEPEND="net-libs/libpcap"
+RDEPEND="${DEPEND}
+ net-dialup/ppp"
+DEPEND+=" kernel? ( >=sys-kernel/linux-headers-2.6.23 )"
+
+src_prepare() {
+ epatch "${FILESDIR}/${PN}-1.3.0-LDFLAGS.patch"
+ epatch "${FILESDIR}/${PN}-1.3.1-CFLAGS.patch"
+ epatch "${FILESDIR}/${PN}-1.3.1-no-type-punning-b119c0da.patch"
+ epatch "${FILESDIR}/${PN}-1.3.1-kernelmode.patch"
+ sed -i Makefile -e 's| -O2||g' || die "sed Makefile"
+ # The below patch is questionable. Why wasn't it submitted upstream? If it
+ # ever breaks, it will just be removed. -darkside 20120914
+ use dnsretry && epatch "${FILESDIR}/${PN}-dnsretry.patch"
+ # Remove bundled headers
+ rm -r linux || die
+}
+
+src_compile() {
+ tc-export CC
+ export OSFLAGS="-DLINUX"
+ use kernel && OSFLAGS+=" -DUSE_KERNEL"
+ emake
+}
+
+src_install() {
+ emake PREFIX=/usr DESTDIR="${D}" install
+ dodoc CREDITS README.xl2tpd BUGS CHANGES TODO doc/README.patents doc/rfc2661.txt
+ insinto /etc/xl2tpd
+ newins doc/l2tpd.conf.sample xl2tpd.conf
+ newins doc/l2tp-secrets.sample l2tp-secrets
+ fperms 0600 /etc/xl2tpd/l2tp-secrets
+ newinitd "${FILESDIR}"/xl2tpd-init-r1 xl2tpd
+ systemd_dounit "${FILESDIR}"/xl2tpd.service
+ systemd_dotmpfilesd "${FILESDIR}"/xl2tpd.conf
+}
diff --git a/net-dialup/xl2tpd/xl2tpd-1.3.1-r4.ebuild b/net-dialup/xl2tpd/xl2tpd-1.3.1-r4.ebuild
new file mode 100644
index 000000000000..48cb8655eb27
--- /dev/null
+++ b/net-dialup/xl2tpd/xl2tpd-1.3.1-r4.ebuild
@@ -0,0 +1,52 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit eutils systemd toolchain-funcs vcs-snapshot
+
+DESCRIPTION="A modern version of the Layer 2 Tunneling Protocol (L2TP) daemon"
+HOMEPAGE="http://www.xelerance.com/services/software/xl2tpd/"
+SRC_URI="https://github.com/xelerance/${PN}/tarball/v${PV} -> ${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="amd64 ~arm ~ppc x86"
+IUSE="dnsretry +kernel"
+
+DEPEND="net-libs/libpcap"
+RDEPEND="${DEPEND}
+ net-dialup/ppp"
+DEPEND+=" kernel? ( >=sys-kernel/linux-headers-2.6.23 )"
+
+src_prepare() {
+ epatch "${FILESDIR}/${PN}-1.3.0-LDFLAGS.patch"
+ epatch "${FILESDIR}/${PN}-1.3.1-CFLAGS.patch"
+ epatch "${FILESDIR}/${PN}-1.3.1-no-type-punning-b119c0da.patch"
+ epatch "${FILESDIR}/${PN}-1.3.1-kernelmode.patch"
+ sed -i Makefile -e 's| -O2||g' || die "sed Makefile"
+ # The below patch is questionable. Why wasn't it submitted upstream? If it
+ # ever breaks, it will just be removed. -darkside 20120914
+ use dnsretry && epatch "${FILESDIR}/${PN}-dnsretry.patch"
+ # Remove bundled headers
+ rm -r linux || die
+}
+
+src_compile() {
+ tc-export CC
+ export OSFLAGS="-DLINUX"
+ use kernel && OSFLAGS+=" -DUSE_KERNEL"
+ emake
+}
+
+src_install() {
+ emake PREFIX=/usr DESTDIR="${D}" install
+ dodoc CREDITS README.xl2tpd BUGS CHANGES TODO doc/README.patents doc/rfc2661.txt
+ insinto /etc/xl2tpd
+ newins doc/l2tpd.conf.sample xl2tpd.conf
+ newins doc/l2tp-secrets.sample l2tp-secrets
+ fperms 0600 /etc/xl2tpd/l2tp-secrets
+ newinitd "${FILESDIR}"/xl2tpd-init-r1 xl2tpd
+ systemd_dounit "${FILESDIR}"/xl2tpd.service
+ systemd_dotmpfilesd "${FILESDIR}"/xl2tpd.conf
+}
diff --git a/net-dialup/xl2tpd/xl2tpd-1.3.10.ebuild b/net-dialup/xl2tpd/xl2tpd-1.3.10.ebuild
new file mode 100644
index 000000000000..32fb054177dc
--- /dev/null
+++ b/net-dialup/xl2tpd/xl2tpd-1.3.10.ebuild
@@ -0,0 +1,55 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit systemd toolchain-funcs
+
+DESCRIPTION="A modern version of the Layer 2 Tunneling Protocol (L2TP) daemon"
+HOMEPAGE="http://www.xelerance.com/services/software/xl2tpd/"
+SRC_URI="https://github.com/xelerance/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~mips ~ppc ~ppc64 ~x86"
+IUSE="dnsretry"
+
+DEPEND="
+ net-libs/libpcap
+ >sys-kernel/linux-headers-2.6"
+
+RDEPEND="
+ ${DEPEND}
+ net-dialup/ppp"
+
+DOCS=(CREDITS README.xl2tpd BUGS CHANGES TODO doc/README.patents)
+
+src_prepare() {
+ default
+ # The below patch is questionable. Why wasn't it submitted upstream? If it
+ # ever breaks, it will just be removed. -darkside 20120914
+ # Patch has been discussed with upstream and is marked as feature by now:
+ # https://github.com/xelerance/xl2tpd/issues/134 // -- tenX 2017-08-06
+ use dnsretry && eapply -p0 "${FILESDIR}/${PN}-dnsretry.patch"
+}
+
+src_compile() {
+ tc-export CC
+ emake OSFLAGS="-DLINUX"
+}
+
+src_install() {
+ emake PREFIX=/usr DESTDIR="${D}" install
+
+ insinto /etc/xl2tpd
+ newins doc/l2tpd.conf.sample xl2tpd.conf
+ newins doc/l2tp-secrets.sample l2tp-secrets
+ fperms 0600 /etc/xl2tpd/l2tp-secrets
+
+ newinitd "${FILESDIR}"/xl2tpd-init-r1 xl2tpd
+
+ systemd_dounit "${FILESDIR}"/xl2tpd.service
+ systemd_dotmpfilesd "${FILESDIR}"/xl2tpd.conf
+
+ einstalldocs
+}
diff --git a/net-dialup/xl2tpd/xl2tpd-1.3.6.ebuild b/net-dialup/xl2tpd/xl2tpd-1.3.6.ebuild
new file mode 100644
index 000000000000..d341d3479b51
--- /dev/null
+++ b/net-dialup/xl2tpd/xl2tpd-1.3.6.ebuild
@@ -0,0 +1,45 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit eutils systemd toolchain-funcs
+
+DESCRIPTION="A modern version of the Layer 2 Tunneling Protocol (L2TP) daemon"
+HOMEPAGE="http://www.xelerance.com/services/software/xl2tpd/"
+SRC_URI="https://github.com/xelerance/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~mips ~ppc ppc64 ~x86"
+IUSE="dnsretry"
+
+DEPEND="net-libs/libpcap"
+RDEPEND="${DEPEND}
+ net-dialup/ppp"
+DEPEND+=" >=sys-kernel/linux-headers-2.6.23"
+
+src_prepare() {
+ sed -i Makefile -e 's| -O2||g' || die "sed Makefile"
+ # The below patch is questionable. Why wasn't it submitted upstream? If it
+ # ever breaks, it will just be removed. -darkside 20120914
+ use dnsretry && epatch "${FILESDIR}/${PN}-dnsretry.patch"
+}
+
+src_compile() {
+ tc-export CC
+ export OSFLAGS="-DLINUX"
+ emake
+}
+
+src_install() {
+ emake PREFIX=/usr DESTDIR="${D}" install
+ dodoc CREDITS README.xl2tpd BUGS CHANGES TODO doc/README.patents doc/rfc2661.txt
+ insinto /etc/xl2tpd
+ newins doc/l2tpd.conf.sample xl2tpd.conf
+ newins doc/l2tp-secrets.sample l2tp-secrets
+ fperms 0600 /etc/xl2tpd/l2tp-secrets
+ newinitd "${FILESDIR}"/xl2tpd-init-r1 xl2tpd
+ systemd_dounit "${FILESDIR}"/xl2tpd.service
+ systemd_dotmpfilesd "${FILESDIR}"/xl2tpd.conf
+}
diff --git a/net-dialup/xl2tpd/xl2tpd-1.3.9.ebuild b/net-dialup/xl2tpd/xl2tpd-1.3.9.ebuild
new file mode 100644
index 000000000000..e5b9615f9ca9
--- /dev/null
+++ b/net-dialup/xl2tpd/xl2tpd-1.3.9.ebuild
@@ -0,0 +1,55 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit systemd toolchain-funcs
+
+DESCRIPTION="A modern version of the Layer 2 Tunneling Protocol (L2TP) daemon"
+HOMEPAGE="http://www.xelerance.com/services/software/xl2tpd/"
+SRC_URI="https://github.com/xelerance/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~mips ~ppc ~ppc64 ~x86"
+IUSE="dnsretry"
+
+DEPEND="
+ net-libs/libpcap
+ >sys-kernel/linux-headers-2.6"
+
+RDEPEND="
+ ${DEPEND}
+ net-dialup/ppp"
+
+DOCS=( CREDITS README.xl2tpd BUGS CHANGES TODO doc/README.patents)
+
+src_prepare() {
+ default
+ # The below patch is questionable. Why wasn't it submitted upstream? If it
+ # ever breaks, it will just be removed. -darkside 20120914
+ # Patch has been discussed with upstream and is marked as feature by now:
+ # https://github.com/xelerance/xl2tpd/issues/134 // -- tenX 2017-08-06
+ use dnsretry && eapply -p0 "${FILESDIR}/${PN}-dnsretry.patch"
+}
+
+src_compile() {
+ tc-export CC
+ emake OSFLAGS="-DLINUX"
+}
+
+src_install() {
+ emake PREFIX=/usr DESTDIR="${D}" install
+
+ insinto /etc/xl2tpd
+ newins doc/l2tpd.conf.sample xl2tpd.conf
+ newins doc/l2tp-secrets.sample l2tp-secrets
+ fperms 0600 /etc/xl2tpd/l2tp-secrets
+
+ newinitd "${FILESDIR}"/xl2tpd-init-r1 xl2tpd
+
+ systemd_dounit "${FILESDIR}"/xl2tpd.service
+ systemd_dotmpfilesd "${FILESDIR}"/xl2tpd.conf
+
+ einstalldocs
+}