summaryrefslogtreecommitdiff
path: root/accel-pppd/main.c
diff options
context:
space:
mode:
authorKozlov Dmitry <xeb@mail.ru>2012-08-29 11:40:34 +0400
committerKozlov Dmitry <xeb@mail.ru>2012-08-29 11:40:34 +0400
commit28df233a46f2d136e8169d86ee62861a7c024eff (patch)
treea8d1131645c7f09fa276208895b31a5b3b2467bc /accel-pppd/main.c
parent1872dd97822f406a2d54bd75ed8220092ec5d4fb (diff)
downloadaccel-ppp-28df233a46f2d136e8169d86ee62861a7c024eff.tar.gz
accel-ppp-28df233a46f2d136e8169d86ee62861a7c024eff.zip
add 'ppp' filed to CTRL to identify ppp sessions
Diffstat (limited to 'accel-pppd/main.c')
-rw-r--r--accel-pppd/main.c43
1 files changed, 43 insertions, 0 deletions
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;