Avoid proxy for bypass_socket, enable_udp_decap
[strongswan.git] / src / charon-tkm / src / charon-tkm.c
index c9c27ba..0782bda 100644 (file)
 #include <library.h>
 #include <utils/backtrace.h>
 #include <threading/thread.h>
+#include <sa/keymat.h>
 
 #include "tkm.h"
 #include "tkm_nonceg.h"
+#include "tkm_diffie_hellman.h"
+#include "tkm_keymat.h"
+#include "tkm_listener.h"
+#include "tkm_kernel_ipsec.h"
+
+/**
+ * TKM bus listener for IKE authorize events.
+ */
+static tkm_listener_t *listener;
 
 /**
  * PID file, in which charon-tkm stores its process id
@@ -271,11 +281,19 @@ int main(int argc, char *argv[])
        /* register TKM specific plugins */
        static plugin_feature_t features[] = {
                PLUGIN_REGISTER(NONCE_GEN, tkm_nonceg_create),
-               PLUGIN_PROVIDE(NONCE_GEN)
+                       PLUGIN_PROVIDE(NONCE_GEN),
+               PLUGIN_REGISTER(DH, tkm_diffie_hellman_create),
+                       PLUGIN_PROVIDE(DH, MODP_3072_BIT),
+                       PLUGIN_PROVIDE(DH, MODP_4096_BIT),
+               PLUGIN_CALLBACK(kernel_ipsec_register, tkm_kernel_ipsec_create),
+                       PLUGIN_PROVIDE(CUSTOM, "kernel-ipsec"),
        };
        lib->plugins->add_static_features(lib->plugins, "tkm-backend", features,
                        countof(features), TRUE);
 
+       /* register TKM keymat variant */
+       keymat_register_constructor(IKEV2, (keymat_constructor_t)tkm_keymat_create);
+
        /* initialize daemon */
        if (!charon->initialize(charon, PLUGINS))
        {
@@ -310,6 +328,10 @@ int main(int argc, char *argv[])
                goto deinit;
        }
 
+       /* register TKM authorization hook */
+       listener = tkm_listener_create();
+       charon->bus->add_listener(charon->bus, &listener->listener);
+
        /* add handler for SEGV and ILL,
         * INT and TERM are handled by sigwait() in run() */
        action.sa_handler = segv_handler;
@@ -333,6 +355,8 @@ int main(int argc, char *argv[])
 
        unlink_pidfile();
        status = 0;
+       charon->bus->remove_listener(charon->bus, &listener->listener);
+       listener->destroy(listener);
 
 deinit:
        libcharon_deinit();