PT-TLS dispatcher TNCCS constructor takes peer identities to pass to factory

This commit is contained in:
Martin Willi
2013-02-14 17:09:28 +01:00
parent 8b56943222
commit a9df87bf89
2 changed files with 23 additions and 4 deletions
+12 -3
View File
@@ -46,10 +46,15 @@ struct private_pt_tls_dispatcher_t {
*/ */
identification_t *server; identification_t *server;
/**
* Peer identity
*/
identification_t *peer;
/** /**
* TNCCS protocol handler constructor * TNCCS protocol handler constructor
*/ */
tnccs_t*(*create)(); pt_tls_tnccs_constructor_t *create;
}; };
/** /**
@@ -111,7 +116,8 @@ static void cleanup(pt_tls_server_t *connection)
} }
METHOD(pt_tls_dispatcher_t, dispatch, void, 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) while (TRUE)
{ {
@@ -129,7 +135,7 @@ METHOD(pt_tls_dispatcher_t, dispatch, void,
continue; continue;
} }
tnccs = create(); tnccs = create(this->server, this->peer);
if (!tnccs) if (!tnccs)
{ {
close(fd); close(fd);
@@ -157,6 +163,7 @@ METHOD(pt_tls_dispatcher_t, destroy, void,
close(this->fd); close(this->fd);
} }
this->server->destroy(this->server); this->server->destroy(this->server);
this->peer->destroy(this->peer);
free(this); free(this);
} }
@@ -174,6 +181,8 @@ pt_tls_dispatcher_t *pt_tls_dispatcher_create(host_t *address,
.destroy = _destroy, .destroy = _destroy,
}, },
.server = id, .server = id,
/* we currently don't authenticate the peer, use %any identity */
.peer = identification_create_from_encoding(ID_ANY, chunk_empty),
.fd = -1, .fd = -1,
); );
+11 -1
View File
@@ -28,6 +28,15 @@
typedef struct pt_tls_dispatcher_t pt_tls_dispatcher_t; typedef struct pt_tls_dispatcher_t pt_tls_dispatcher_t;
/**
* Constructor callback to create TNCCS to use within PT-TLS.
*
* @param server server identity
* @param peer peer identity
*/
typedef tnccs_t* (pt_tls_tnccs_constructor_t)(identification_t *server,
identification_t *peer);
/** /**
* PT-TLS dispatcher service, handles PT-TLS connections as a server. * PT-TLS dispatcher service, handles PT-TLS connections as a server.
*/ */
@@ -41,7 +50,8 @@ struct pt_tls_dispatcher_t {
* *
* @param create TNCCS constructor function to use * @param create TNCCS constructor function to use
*/ */
void (*dispatch)(pt_tls_dispatcher_t *this, tnccs_t*(*create)()); void (*dispatch)(pt_tls_dispatcher_t *this,
pt_tls_tnccs_constructor_t *create);
/** /**
* Destroy a pt_tls_dispatcher_t. * Destroy a pt_tls_dispatcher_t.