summaryrefslogtreecommitdiff
path: root/accel-pptpd/ctrl
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pptpd/ctrl')
-rw-r--r--accel-pptpd/ctrl/pptp.c19
-rw-r--r--accel-pptpd/ctrl/pptp_prot.h2
2 files changed, 19 insertions, 2 deletions
diff --git a/accel-pptpd/ctrl/pptp.c b/accel-pptpd/ctrl/pptp.c
index 9f76a341..d19420a9 100644
--- a/accel-pptpd/ctrl/pptp.c
+++ b/accel-pptpd/ctrl/pptp.c
@@ -18,7 +18,9 @@
#include "triton.h"
#include "log.h"
#include "ppp.h"
+#include "mempool.h"
#include "iprange.h"
+#include "utils.h"
#include "memdebug.h"
@@ -50,6 +52,8 @@ struct pptp_conn_t
static int conf_timeout = 3;
static int conf_echo_interval = 0;
+static mempool_t conn_pool;
+
static int pptp_read(struct triton_md_handler_t *h);
static int pptp_write(struct triton_md_handler_t *h);
static void pptp_timeout(struct triton_timer_t *);
@@ -81,7 +85,9 @@ static void disconnect(struct pptp_conn_t *conn)
_free(conn->in_buf);
_free(conn->out_buf);
- _free(conn);
+ _free(conn->ctrl.calling_station_id);
+ _free(conn->ctrl.called_station_id);
+ mempool_free(conn);
}
static int post_msg(struct pptp_conn_t *conn, void *buf, int size)
@@ -491,7 +497,7 @@ static int pptp_connect(struct triton_md_handler_t *h)
continue;
}
- conn = _malloc(sizeof(*conn));
+ conn = mempool_alloc(conn_pool);
memset(conn, 0, sizeof(*conn));
conn->hnd.fd = sock;
conn->hnd.read = pptp_read;
@@ -506,6 +512,13 @@ static int pptp_connect(struct triton_md_handler_t *h)
conn->ctrl.ctx = &conn->ctx;
conn->ctrl.started = ppp_started;
conn->ctrl.finished = ppp_finished;
+ conn->ctrl.max_mtu = PPTP_MAX_MTU;
+
+ conn->ctrl.calling_station_id = _malloc(17);
+ conn->ctrl.called_station_id = _malloc(17);
+ u_inet_ntoa(addr.sin_addr.s_addr, conn->ctrl.calling_station_id);
+ getsockname(sock, &addr, &size);
+ u_inet_ntoa(addr.sin_addr.s_addr, conn->ctrl.called_station_id);
ppp_init(&conn->ppp);
conn->ppp.ctrl = &conn->ctrl;
@@ -565,6 +578,8 @@ static void __init pptp_init(void)
return;
}
+ conn_pool = mempool_create(sizeof(struct pptp_conn_t));
+
triton_context_register(&serv.ctx, NULL);
triton_md_register_handler(&serv.ctx, &serv.hnd);
triton_md_enable_handler(&serv.hnd, MD_MODE_READ);
diff --git a/accel-pptpd/ctrl/pptp_prot.h b/accel-pptpd/ctrl/pptp_prot.h
index 7e3ebdd4..ee8cb341 100644
--- a/accel-pptpd/ctrl/pptp_prot.h
+++ b/accel-pptpd/ctrl/pptp_prot.h
@@ -3,6 +3,8 @@
#include <sys/types.h>
+#define PPTP_MAX_MTU 1436
+
#define hton8(x) (x)
#define ntoh8(x) (x)
#define hton16(x) htons(x)