]> git.ipfire.org Git - people/ms/strongswan.git/blobdiff - src/libtnccs/plugins/tnccs_11/tnccs_11.c
Make access requestor IP address available to TNC server
[people/ms/strongswan.git] / src / libtnccs / plugins / tnccs_11 / tnccs_11.c
index 28c5e52b7b7f13da993f28de08337fa50c668794..0918a2badca4e5b3cd23b6b23a36538badd9c242 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2013 Andreas Steffen
+ * Copyright (C) 2010-2015 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -54,12 +54,22 @@ struct private_tnccs_11_t {
        /**
         * Server identity
         */
-       identification_t *server;
+       identification_t *server_id;
 
        /**
         * Client identity
         */
-       identification_t *peer;
+       identification_t *peer_id;
+
+       /**
+        * Server IP address
+        */
+       host_t *server_ip;
+
+       /**
+        * Client IP address
+        */
+       host_t *peer_ip;
 
        /**
         * Underlying TNC IF-T transport protocol
@@ -527,20 +537,20 @@ METHOD(tls_t, is_server, bool,
 METHOD(tls_t, get_server_id, identification_t*,
        private_tnccs_11_t *this)
 {
-       return this->server;
+       return this->server_id;
 }
 
 METHOD(tls_t, set_peer_id, void,
        private_tnccs_11_t *this, identification_t *id)
 {
-       DESTROY_IF(this->peer);
-       this->peer = id->clone(id);
+       DESTROY_IF(this->peer_id);
+       this->peer_id = id->clone(id);
 }
 
 METHOD(tls_t, get_peer_id, identification_t*,
        private_tnccs_11_t *this)
 {
-       return this->peer;
+       return this->peer_id;
 }
 
 METHOD(tls_t, get_purpose, tls_purpose_t,
@@ -578,14 +588,28 @@ METHOD(tls_t, destroy, void,
        {
                tnc->tnccs->remove_connection(tnc->tnccs, this->connection_id,
                                                                                                  this->is_server);
-               this->server->destroy(this->server);
-               this->peer->destroy(this->peer);
+               this->server_id->destroy(this->server_id);
+               this->peer_id->destroy(this->peer_id);
+               this->server_ip->destroy(this->server_ip);
+               this->peer_ip->destroy(this->peer_ip);
                this->mutex->destroy(this->mutex);
                DESTROY_IF(this->batch);
                free(this);
        }
 }
 
+METHOD(tnccs_t, get_server_ip, host_t*,
+       private_tnccs_11_t *this)
+{
+       return this->server_ip;
+}
+
+METHOD(tnccs_t, get_peer_ip, host_t*,
+       private_tnccs_11_t *this)
+{
+       return this->peer_ip;
+}
+
 METHOD(tnccs_t, get_transport, tnc_ift_type_t,
        private_tnccs_11_t *this)
 {
@@ -628,9 +652,10 @@ METHOD(tnccs_t, get_ref, tnccs_t*,
 /**
  * See header
  */
-tnccs_t* tnccs_11_create(bool is_server,
-                                                identification_t *server, identification_t *peer,
-                                                tnc_ift_type_t transport, tnccs_cb_t cb)
+tnccs_t* tnccs_11_create(bool is_server, identification_t *server_id,
+                                                identification_t *peer_id, host_t *server_ip,
+                                                host_t *peer_ip, tnc_ift_type_t transport,
+                                                tnccs_cb_t cb)
 {
        private_tnccs_11_t *this;
 
@@ -648,6 +673,8 @@ tnccs_t* tnccs_11_create(bool is_server,
                                .get_eap_msk = _get_eap_msk,
                                .destroy = _destroy,
                        },
+                       .get_server_ip = _get_server_ip,
+                       .get_peer_ip = _get_peer_ip,
                        .get_transport = _get_transport,
                        .set_transport = _set_transport,
                        .get_auth_type = _get_auth_type,
@@ -656,8 +683,10 @@ tnccs_t* tnccs_11_create(bool is_server,
                        .get_ref = _get_ref,
                },
                .is_server = is_server,
-               .server = server->clone(server),
-               .peer = peer->clone(peer),
+               .server_id = server_id->clone(server_id),
+               .peer_id = peer_id->clone(peer_id),
+               .server_ip = server_ip->clone(server_ip),
+               .peer_ip = peer_ip->clone(peer_ip),
                .transport = transport,
                .callback = cb,
                .mutex = mutex_create(MUTEX_TYPE_DEFAULT),