]> git.ipfire.org Git - people/ms/strongswan.git/blobdiff - src/libtnccs/plugins/tnccs_dynamic/tnccs_dynamic.c
Make access requestor IP address available to TNC server
[people/ms/strongswan.git] / src / libtnccs / plugins / tnccs_dynamic / tnccs_dynamic.c
index e08236eb7b87a5909bfb6eec06c4a99f9264b832..44b804fb20297ae868a31ec399f29583200ce66c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2013 Andreas Steffen
+ * Copyright (C) 2011-2015 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -34,12 +34,22 @@ struct private_tnccs_dynamic_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;
 
        /**
         * Detected TNC IF-TNCCS stack
@@ -109,8 +119,8 @@ METHOD(tls_t, process, status_t,
                DBG1(DBG_TNC, "%N protocol detected dynamically",
                                           tnccs_type_names, type);
                tnccs = tnc->tnccs->create_instance(tnc->tnccs, type, TRUE,
-                                                       this->server, this->peer, this->transport,
-                                                       this->callback);
+                                                       this->server_id, this->peer_id, this->server_ip,
+                                                       this->peer_ip, this->transport, this->callback);
                if (!tnccs)
                {
                        DBG1(DBG_TNC, "N% protocol not supported", tnccs_type_names, type);
@@ -137,14 +147,14 @@ METHOD(tls_t, is_server, bool,
 METHOD(tls_t, get_server_id, identification_t*,
        private_tnccs_dynamic_t *this)
 {
-       return this->server;
+       return this->server_id;
 }
 
 METHOD(tls_t, set_peer_id, void,
        private_tnccs_dynamic_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);
        if (this->tls)
        {
                this->tls->set_peer_id(this->tls, id);
@@ -154,7 +164,7 @@ METHOD(tls_t, set_peer_id, void,
 METHOD(tls_t, get_peer_id, identification_t*,
        private_tnccs_dynamic_t *this)
 {
-       return this->peer;
+       return this->peer_id;
 }
 
 METHOD(tls_t, get_purpose, tls_purpose_t,
@@ -181,12 +191,26 @@ METHOD(tls_t, destroy, void,
        if (ref_put(&this->ref))
        {
                DESTROY_IF(this->tls);
-               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);
                free(this);
        }
 }
 
+METHOD(tnccs_t, get_server_ip, host_t*,
+       private_tnccs_dynamic_t *this)
+{
+       return this->server_ip;
+}
+
+METHOD(tnccs_t, get_peer_ip, host_t*,
+       private_tnccs_dynamic_t *this)
+{
+       return this->peer_ip;
+}
+
 METHOD(tnccs_t, get_transport, tnc_ift_type_t,
        private_tnccs_dynamic_t *this)
 {
@@ -229,9 +253,10 @@ METHOD(tnccs_t, get_ref, tnccs_t*,
 /**
  * See header
  */
-tnccs_t* tnccs_dynamic_create(bool is_server,
-                                                         identification_t *server, identification_t *peer,
-                                                         tnc_ift_type_t transport, tnccs_cb_t cb)
+tnccs_t* tnccs_dynamic_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_dynamic_t *this;
 
@@ -249,6 +274,8 @@ tnccs_t* tnccs_dynamic_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,
@@ -256,8 +283,10 @@ tnccs_t* tnccs_dynamic_create(bool is_server,
                        .get_pdp_server = _get_pdp_server,
                        .get_ref = _get_ref,
                },
-               .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,
                .ref = 1,