configure: Fix typo when enabling CPAN modules as dependency
[strongswan.git] / src / libpttls / pt_tls_dispatcher.c
index fab4459..5c30637 100644 (file)
@@ -42,14 +42,24 @@ struct private_pt_tls_dispatcher_t {
        int fd;
 
        /**
+        * Client authentication requirements
+        */
+       pt_tls_auth_t auth;
+
+       /**
         * Server identity
         */
        identification_t *server;
 
        /**
+        * Peer identity
+        */
+       identification_t *peer;
+
+       /**
         * TNCCS protocol handler constructor
         */
-       tnccs_t*(*create)();
+       pt_tls_tnccs_constructor_t *create;
 };
 
 /**
@@ -111,7 +121,8 @@ static void cleanup(pt_tls_server_t *connection)
 }
 
 METHOD(pt_tls_dispatcher_t, dispatch, void,
-       private_pt_tls_dispatcher_t *this, tnccs_t*(*create)())
+       private_pt_tls_dispatcher_t *this,
+       pt_tls_tnccs_constructor_t *create)
 {
        while (TRUE)
        {
@@ -129,13 +140,13 @@ METHOD(pt_tls_dispatcher_t, dispatch, void,
                        continue;
                }
 
-               tnccs = create();
+               tnccs = create(this->server, this->peer);
                if (!tnccs)
                {
                        close(fd);
                        continue;
                }
-               connection = pt_tls_server_create(this->server, fd, tnccs);
+               connection = pt_tls_server_create(this->server, fd, this->auth, tnccs);
                if (!connection)
                {
                        close(fd);
@@ -157,6 +168,7 @@ METHOD(pt_tls_dispatcher_t, destroy, void,
                close(this->fd);
        }
        this->server->destroy(this->server);
+       this->peer->destroy(this->peer);
        free(this);
 }
 
@@ -164,7 +176,7 @@ METHOD(pt_tls_dispatcher_t, destroy, void,
  * See header
  */
 pt_tls_dispatcher_t *pt_tls_dispatcher_create(host_t *address,
-                                                                                         identification_t *id)
+                                                                       identification_t *id, pt_tls_auth_t auth)
 {
        private_pt_tls_dispatcher_t *this;
 
@@ -173,17 +185,18 @@ pt_tls_dispatcher_t *pt_tls_dispatcher_create(host_t *address,
                        .dispatch = _dispatch,
                        .destroy = _destroy,
                },
-               .server = id,
+               .server = id->clone(id),
+               /* we currently don't authenticate the peer, use %any identity */
+               .peer = identification_create_from_encoding(ID_ANY, chunk_empty),
                .fd = -1,
+               .auth = auth,
        );
 
        if (!open_socket(this, address))
        {
-               address->destroy(address);
                destroy(this);
                return NULL;
        }
-       address->destroy(address);
 
        return &this->public;
 }