summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--accel-pppd/cli/show_sessions.c2
-rw-r--r--accel-pppd/ctrl/l2tp/l2tp.c1
-rw-r--r--accel-pppd/ctrl/pppoe/pppoe.c1
-rw-r--r--accel-pppd/ctrl/pptp/pptp.c1
-rw-r--r--accel-pppd/ifcfg.c4
-rw-r--r--accel-pppd/include/ap_session.h11
-rw-r--r--accel-pppd/main.c43
-rw-r--r--accel-pppd/ppp/ipcp_opt_dns.c2
-rw-r--r--accel-pppd/radius/auth.c2
-rw-r--r--accel-pppd/radius/radius.c2
-rw-r--r--accel-pppd/radius/req.c2
12 files changed, 61 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8bcaf1af..7a6d8312 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,7 +17,7 @@ if (NOT BUILD_DRIVER_ONLY)
if (CRYPTO STREQUAL OPENSSL)
add_definitions(-DCRYPTO_OPENSSL)
- set(crypto_lib crypto)
+ set(crypto_lib crypto ssl)
elseif (CRYPTO STREQUAL TOMCRYPT)
add_definitions(-DCRYPTO_TOMCRYPT)
set(crypto_lib tomcrypt)
diff --git a/accel-pppd/cli/show_sessions.c b/accel-pppd/cli/show_sessions.c
index 746ce583..fe202980 100644
--- a/accel-pppd/cli/show_sessions.c
+++ b/accel-pppd/cli/show_sessions.c
@@ -456,7 +456,7 @@ static void print_comp(const struct ap_session *ses, char *buf)
*buf = 0;
- if (ses->ctrl->type != CTRL_TYPE_IPOE) {
+ if (ses->ctrl->ppp) {
ppp = container_of(ses, typeof(*ppp), ses);
if (ppp->comp)
snprintf(buf, CELL_SIZE, "%s", ppp->comp);
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c
index 43b210ff..85d79793 100644
--- a/accel-pppd/ctrl/l2tp/l2tp.c
+++ b/accel-pppd/ctrl/l2tp/l2tp.c
@@ -333,6 +333,7 @@ static int l2tp_tunnel_alloc(struct l2tp_serv_t *serv, struct l2tp_packet_t *pac
conn->hello_timer.period = conf_hello_interval * 1000;
conn->ctrl.ctx = &conn->ctx;
conn->ctrl.type = CTRL_TYPE_L2TP;
+ conn->ctrl.ppp = 1;
conn->ctrl.name = "l2tp";
conn->ctrl.started = l2tp_ppp_started;
conn->ctrl.finished = l2tp_ppp_finished;
diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c
index e4b414f5..7db55113 100644
--- a/accel-pppd/ctrl/pppoe/pppoe.c
+++ b/accel-pppd/ctrl/pppoe/pppoe.c
@@ -265,6 +265,7 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui
conn->ctrl.terminate = ppp_terminate;
conn->ctrl.max_mtu = MAX_PPPOE_MTU;
conn->ctrl.type = CTRL_TYPE_PPPOE;
+ conn->ctrl.ppp = 1;
conn->ctrl.name = "pppoe";
conn->ctrl.mppe = conf_mppe;
diff --git a/accel-pppd/ctrl/pptp/pptp.c b/accel-pppd/ctrl/pptp/pptp.c
index dddf5edc..0fef12f4 100644
--- a/accel-pppd/ctrl/pptp/pptp.c
+++ b/accel-pppd/ctrl/pptp/pptp.c
@@ -671,6 +671,7 @@ static int pptp_connect(struct triton_md_handler_t *h)
conn->ctrl.terminate = ppp_terminate;
conn->ctrl.max_mtu = PPTP_MAX_MTU;
conn->ctrl.type = CTRL_TYPE_PPTP;
+ conn->ctrl.ppp = 1;
conn->ctrl.name = "pptp";
conn->ctrl.mppe = conf_mppe;
diff --git a/accel-pppd/ifcfg.c b/accel-pppd/ifcfg.c
index ac88a0d1..296b354b 100644
--- a/accel-pppd/ifcfg.c
+++ b/accel-pppd/ifcfg.c
@@ -119,7 +119,7 @@ void ap_session_ifup(struct ap_session *ses)
memset(&ifr6, 0, sizeof(ifr6));
- if (ses->ctrl->type != CTRL_TYPE_IPOE) {
+ if (ses->ctrl->ppp) {
ifr6.ifr6_addr.s6_addr32[0] = htons(0xfe80);
*(uint64_t *)(ifr6.ifr6_addr.s6_addr + 8) = ses->ipv6->intf_id;
ifr6.ifr6_prefixlen = 64;
@@ -149,7 +149,7 @@ void ap_session_ifup(struct ap_session *ses)
if (ioctl(sock_fd, SIOCSIFFLAGS, &ifr))
log_ppp_error("failed to set interface flags: %s\n", strerror(errno));
- if (ses->ctrl->type != CTRL_TYPE_IPOE) {
+ if (ses->ctrl->ppp) {
ppp = container_of(ses, typeof(*ppp), ses);
if (ses->ipv4) {
np.protocol = PPP_IP;
diff --git a/accel-pppd/include/ap_session.h b/accel-pppd/include/ap_session.h
index cc7153c1..95f0ea21 100644
--- a/accel-pppd/include/ap_session.h
+++ b/accel-pppd/include/ap_session.h
@@ -20,10 +20,12 @@
#define TERM_LOST_CARRIER 9
#define TERM_IDLE_TIMEOUT 10
-#define CTRL_TYPE_PPTP 1
-#define CTRL_TYPE_L2TP 2
-#define CTRL_TYPE_PPPOE 3
-#define CTRL_TYPE_IPOE 4
+#define CTRL_TYPE_PPTP 1
+#define CTRL_TYPE_L2TP 2
+#define CTRL_TYPE_PPPOE 3
+#define CTRL_TYPE_IPOE 4
+#define CTRL_TYPE_OPENVPN 5
+#define CTRL_TYPE_SSTP 6
#define MPPE_UNSET -2
#define MPPE_ALLOW -1
@@ -44,6 +46,7 @@ struct ap_ctrl
char *calling_station_id;
char *called_station_id;
int dont_ifcfg:1;
+ int ppp:1;
void (*started)(struct ap_session*);
void (*finished)(struct ap_session *);
void (*terminate)(struct ap_session *, int hard);
diff --git a/accel-pppd/main.c b/accel-pppd/main.c
index 14180605..491e07db 100644
--- a/accel-pppd/main.c
+++ b/accel-pppd/main.c
@@ -9,10 +9,15 @@
#include <limits.h>
#include <malloc.h>
#include <dirent.h>
+#include <pthread.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/resource.h>
+#ifdef CRYPTO_OPENSSL
+#include <openssl/ssl.h>
+#endif
+
#include "triton/triton.h"
#include "memdebug.h"
@@ -29,6 +34,40 @@ static char *conf_file;
static char *conf_dump;
static sigset_t orig_set;
+#ifdef CRYPTO_OPENSSL
+static pthread_mutex_t *ssl_lock_cs;
+
+static unsigned long ssl_thread_id(void)
+{
+ return (unsigned long)pthread_self();
+}
+
+static void ssl_lock(int mode, int type, const char *file, int line)
+{
+ if (mode & CRYPTO_LOCK)
+ pthread_mutex_lock(&ssl_lock_cs[type]);
+ else
+ pthread_mutex_unlock(&ssl_lock_cs[type]);
+}
+
+static void openssl_init(void)
+{
+ int i;
+
+ SSL_library_init();
+ SSL_load_error_strings();
+ OpenSSL_add_all_algorithms();
+
+ ssl_lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
+
+ for (i = 0; i < CRYPTO_num_locks(); i++)
+ pthread_mutex_init(&ssl_lock_cs[i], NULL);
+
+ CRYPTO_set_id_callback(ssl_thread_id);
+ CRYPTO_set_locking_callback(ssl_lock);
+}
+#endif
+
static void change_limits(void)
{
FILE *f;
@@ -274,6 +313,10 @@ int main(int argc, char **argv)
change_limits();
+#ifdef CRYPTO_OPENSSL
+ openssl_init();
+#endif
+
if (triton_load_modules("modules"))
return EXIT_FAILURE;
diff --git a/accel-pppd/ppp/ipcp_opt_dns.c b/accel-pppd/ppp/ipcp_opt_dns.c
index 1ca8723b..245960c7 100644
--- a/accel-pppd/ppp/ipcp_opt_dns.c
+++ b/accel-pppd/ppp/ipcp_opt_dns.c
@@ -145,7 +145,7 @@ static void ev_dns(struct ev_dns_t *ev)
struct dns_option_t *dns_opt;
struct ppp_t *ppp;
- if (ev->ses->ctrl->type == CTRL_TYPE_IPOE)
+ if (!ev->ses->ctrl->ppp)
return;
ppp = container_of(ev->ses, typeof(*ppp), ses);
diff --git a/accel-pppd/radius/auth.c b/accel-pppd/radius/auth.c
index 6cb4e803..dafc8d63 100644
--- a/accel-pppd/radius/auth.c
+++ b/accel-pppd/radius/auth.c
@@ -342,7 +342,7 @@ static void setup_mppe(struct rad_req_t *req, const uint8_t *challenge)
.ppp = container_of(req->rpd->ses, typeof(struct ppp_t), ses),
};
- if (req->rpd->ses->ctrl->type == CTRL_TYPE_IPOE)
+ if (!req->rpd->ses->ctrl->ppp)
return;
list_for_each_entry(attr, &req->reply->attrs, entry) {
diff --git a/accel-pppd/radius/radius.c b/accel-pppd/radius/radius.c
index 03e9e665..5f5d0ba4 100644
--- a/accel-pppd/radius/radius.c
+++ b/accel-pppd/radius/radius.c
@@ -225,7 +225,7 @@ static void session_timeout(struct triton_timer_t *t)
if (rpd->ses->stop_time)
return;
- if (rpd->termination_action == Termination_Action_RADIUS_Request && rpd->ses->ctrl->type != CTRL_TYPE_IPOE) {
+ if (rpd->termination_action == Termination_Action_RADIUS_Request && rpd->ses->ctrl->ppp) {
if (ppp_auth_restart(container_of(rpd->ses, struct ppp_t, ses)))
ap_session_terminate(rpd->ses, TERM_SESSION_TIMEOUT, 0);
} else
diff --git a/accel-pppd/radius/req.c b/accel-pppd/radius/req.c
index cd9a170b..a93c12e1 100644
--- a/accel-pppd/radius/req.c
+++ b/accel-pppd/radius/req.c
@@ -29,7 +29,7 @@ static struct rad_req_t *__rad_req_alloc(struct radius_pd_t *rpd, int code, cons
return NULL;
}
- if (rpd->ses->ctrl->type != CTRL_TYPE_IPOE)
+ if (rpd->ses->ctrl->ppp)
ppp = container_of(rpd->ses, typeof(*ppp), ses);
memset(req, 0, sizeof(*req));