summaryrefslogtreecommitdiff
path: root/accel-pptpd
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2010-10-15 22:12:28 +0400
committerDmitry Kozlov <xeb@mail.ru>2010-10-17 19:19:45 +0400
commitab92d89ca62f3a9e63ae4f8731efcdbd1d0a7202 (patch)
treed0071d27489056e4beea5e289e28d1d57dc516f1 /accel-pptpd
parentd32cf13525153b9bb961a72cded215e9866e78bd (diff)
downloadaccel-ppp-ab92d89ca62f3a9e63ae4f8731efcdbd1d0a7202.tar.gz
accel-ppp-ab92d89ca62f3a9e63ae4f8731efcdbd1d0a7202.zip
added cpack interface to generate deb packages
Diffstat (limited to 'accel-pptpd')
-rw-r--r--accel-pptpd/CMakeLists.txt4
-rw-r--r--accel-pptpd/ctrl/l2tp/CMakeLists.txt8
-rw-r--r--accel-pptpd/ctrl/l2tp/l2tp.c56
-rw-r--r--accel-pptpd/extra/CMakeLists.txt2
-rw-r--r--accel-pptpd/ppp/ppp.c1
5 files changed, 48 insertions, 23 deletions
diff --git a/accel-pptpd/CMakeLists.txt b/accel-pptpd/CMakeLists.txt
index fb88d1b..adc1ab4 100644
--- a/accel-pptpd/CMakeLists.txt
+++ b/accel-pptpd/CMakeLists.txt
@@ -11,7 +11,7 @@ IF (NOT HAVE_SSL)
MESSAGE(FATAL_ERROR "openssl headers not found")
ENDIF (NOT HAVE_SSL)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fvisibility=hidden -D_GNU_SOURCE -DGCC_SPINLOCK -DMEMDEBUG")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fvisibility=hidden -D_GNU_SOURCE -DGCC_SPINLOCK -DMEMDEBUG -fPIC")
INCLUDE_DIRECTORIES(include)
@@ -59,7 +59,7 @@ INSTALL(TARGETS accel-pptpd
RUNTIME DESTINATION usr/sbin
)
-INSTALL(FILES accel-pptp.conf DESTINATION /etc)
+INSTALL(FILES accel-pptp.conf DESTINATION etc)
INSTALL(FILES accel-pptp.conf.5 DESTINATION usr/share/man/man5)
INSTALL(CODE "EXECUTE_PROCESS(COMMAND mkdir -p /var/log/accel-pptp)")
diff --git a/accel-pptpd/ctrl/l2tp/CMakeLists.txt b/accel-pptpd/ctrl/l2tp/CMakeLists.txt
index c9b483d..4931007 100644
--- a/accel-pptpd/ctrl/l2tp/CMakeLists.txt
+++ b/accel-pptpd/ctrl/l2tp/CMakeLists.txt
@@ -6,8 +6,12 @@ ADD_LIBRARY(l2tp SHARED
l2tp.c
dict.c
packet.c
- netlink.c
+ # netlink.c
)
-TARGET_LINK_LIBRARIES(l2tp nl-genl)
+#TARGET_LINK_LIBRARIES(l2tp nl nl-genl)
INSTALL(TARGETS l2tp LIBRARY DESTINATION usr/lib/accel-pptp)
+
+FILE(GLOB dict "${CMAKE_CURRENT_SOURCE_DIR}/dict/*")
+INSTALL(FILES ${dict} DESTINATION usr/share/accel-pptp/l2tp)
+
diff --git a/accel-pptpd/ctrl/l2tp/l2tp.c b/accel-pptpd/ctrl/l2tp/l2tp.c
index 2a7687e..b565e33 100644
--- a/accel-pptpd/ctrl/l2tp/l2tp.c
+++ b/accel-pptpd/ctrl/l2tp/l2tp.c
@@ -10,6 +10,7 @@
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
+#include <linux/socket.h>
#include <linux/if.h>
#include <linux/if_ether.h>
#include <linux/if_pppox.h>
@@ -27,6 +28,10 @@
#include "l2tp.h"
#include "attr_defs.h"
+#ifndef SOL_PPPOL2TP
+#define SOL_PPPOL2TP 273
+#endif
+
#define STATE_WAIT_SCCCN 1
#define STATE_WAIT_ICRQ 2
#define STATE_WAIT_ICCN 3
@@ -59,6 +64,8 @@ struct l2tp_conn_t
struct triton_timer_t rtimeout_timer;
struct triton_timer_t hello_timer;
+ int tunnel_fd;
+
struct sockaddr_in addr;
uint16_t tid;
uint16_t sid;
@@ -95,9 +102,6 @@ static void l2tp_disconnect(struct l2tp_conn_t *conn)
{
struct l2tp_packet_t *pack;
- if (conn->tid)
- l2tp_nl_delete_tunnel(conn->tid);
-
triton_md_unregister_handler(&conn->hnd);
close(conn->hnd.fd);
@@ -119,6 +123,12 @@ static void l2tp_disconnect(struct l2tp_conn_t *conn)
l2tp_conn[conn->tid] = NULL;
pthread_mutex_unlock(&l2tp_lock);
+ if (conn->ppp.fd != -1)
+ close(conn->ppp.fd);
+
+ if (conn->tunnel_fd != -1)
+ close(conn->tunnel_fd);
+
triton_event_fire(EV_CTRL_FINISHED, &conn->ppp);
if (conf_verbose)
@@ -298,6 +308,8 @@ static int l2tp_tunnel_alloc(struct l2tp_serv_t *serv, struct l2tp_packet_t *pac
ppp_init(&conn->ppp);
conn->ppp.ctrl = &conn->ctrl;
+ conn->ppp.fd = -1;
+ conn->tunnel_fd = -1;
triton_context_register(&conn->ctx, &conn->ppp);
triton_md_register_handler(&conn->ctx, &conn->hnd);
@@ -323,46 +335,54 @@ out_err:
static int l2tp_connect(struct l2tp_conn_t *conn)
{
struct sockaddr_pppol2tp pppox_addr;
-
+ int arg = 1;
+
+ memset(&pppox_addr, 0, sizeof(pppox_addr));
pppox_addr.sa_family = AF_PPPOX;
pppox_addr.sa_protocol = PX_PROTO_OL2TP;
pppox_addr.pppol2tp.fd = conn->hnd.fd;
memcpy(&pppox_addr.pppol2tp.addr, &conn->addr, sizeof(conn->addr));
pppox_addr.pppol2tp.s_tunnel = conn->tid;
- pppox_addr.pppol2tp.s_session = conn->sid;
pppox_addr.pppol2tp.d_tunnel = conn->peer_tid;
- pppox_addr.pppol2tp.d_session = conn->peer_sid;
- l2tp_nl_delete_tunnel(conn->tid);
- l2tp_nl_create_tunnel(conn->hnd.fd, conn->tid, conn->peer_tid);
- l2tp_nl_create_session(conn->tid, conn->sid, conn->peer_sid);
+ conn->tunnel_fd = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OL2TP);
+ if (!conn->ppp.fd) {
+ log_ppp_error("l2tp: socket(AF_PPPOX): %s\n", strerror(errno));
+ return -1;
+ }
conn->ppp.fd = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OL2TP);
if (!conn->ppp.fd) {
+ close(conn->tunnel_fd);
+ conn->tunnel_fd = -1;
log_ppp_error("l2tp: socket(AF_PPPOX): %s\n", strerror(errno));
return -1;
}
- if (connect(conn->ppp.fd, (struct sockaddr *)&pppox_addr, sizeof(pppox_addr))) {
- log_ppp_error("l2tp: connect: %s\n", strerror(errno));
- close(conn->ppp.fd);
+ if (connect(conn->tunnel_fd, (struct sockaddr *)&pppox_addr, sizeof(pppox_addr)) < 0) {
+ log_ppp_error("l2tp: connect(tunnel): %s\n", strerror(errno));
+ return -1;
+ }
+
+ pppox_addr.pppol2tp.s_session = conn->sid;
+ pppox_addr.pppol2tp.d_session = conn->peer_sid;
+
+ if (connect(conn->ppp.fd, (struct sockaddr *)&pppox_addr, sizeof(pppox_addr)) < 0) {
+ log_ppp_error("l2tp: connect(session): %s\n", strerror(errno));
return -1;
}
- /*if (setsockopt(conn->ppp.fd, SOL_SOCKET, PPPOL2TP_SO_LNSMODE, &conn->ppp.fd, sizeof(conn->ppp.fd))) {
+ if (setsockopt(conn->ppp.fd, SOL_PPPOL2TP, PPPOL2TP_SO_LNSMODE, &arg, sizeof(arg))) {
log_ppp_error("l2tp: setsockopt: %s\n", strerror(errno));
- close(conn->ppp.fd);
return -1;
- }*/
+ }
conn->ppp.chan_name = _strdup(inet_ntoa(conn->addr.sin_addr));
triton_event_fire(EV_CTRL_STARTED, &conn->ppp);
- if (establish_ppp(&conn->ppp)) {
- close(conn->ppp.fd);
+ if (establish_ppp(&conn->ppp))
return -1;
- }
conn->state = STATE_PPP;
diff --git a/accel-pptpd/extra/CMakeLists.txt b/accel-pptpd/extra/CMakeLists.txt
index 9d58b8e..c354c04 100644
--- a/accel-pptpd/extra/CMakeLists.txt
+++ b/accel-pptpd/extra/CMakeLists.txt
@@ -8,7 +8,7 @@ INSTALL(TARGETS pppd_compat ippool sigchld
IF (SHAPER)
ADD_LIBRARY(shaper_tbf SHARED shaper_tbf.c)
- TARGET_LINK_LIBRARIES(shaper_tbf nl-route)
+ TARGET_LINK_LIBRARIES(shaper_tbf nl nl-route m)
INSTALL(TARGETS shaper_tbf LIBRARY DESTINATION usr/lib/accel-pptp)
ENDIF (SHAPER)
diff --git a/accel-pptpd/ppp/ppp.c b/accel-pptpd/ppp/ppp.c
index 4fdcb01..bf3635e 100644
--- a/accel-pptpd/ppp/ppp.c
+++ b/accel-pptpd/ppp/ppp.c
@@ -177,6 +177,7 @@ static void destablish_ppp(struct ppp_t *ppp)
ppp->unit_fd = -1;
ppp->chan_fd = -1;
+ ppp->fd = -1;
_free(ppp->unit_buf);
_free(ppp->chan_buf);