]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
determine underlying IF-T transport protocol
authorAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 12 Feb 2013 11:25:39 +0000 (12:25 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 12 Feb 2013 11:25:39 +0000 (12:25 +0100)
13 files changed:
src/libcharon/plugins/eap_tnc/eap_tnc.c
src/libcharon/plugins/tnc_imc/Makefile.am
src/libcharon/plugins/tnc_imv/Makefile.am
src/libcharon/plugins/tnc_tnccs/tnc_tnccs_manager.c
src/libcharon/plugins/tnccs_11/tnccs_11.c
src/libcharon/plugins/tnccs_11/tnccs_11.h
src/libcharon/plugins/tnccs_20/tnccs_20.c
src/libcharon/plugins/tnccs_20/tnccs_20.h
src/libcharon/plugins/tnccs_dynamic/tnccs_dynamic.c
src/libcharon/plugins/tnccs_dynamic/tnccs_dynamic.h
src/libtnccs/Makefile.am
src/libtnccs/tnc/tnccs/tnccs.h
src/libtnccs/tnc/tnccs/tnccs_manager.h

index 6d76710f5bdf20675ccf5a4a33f9ead48abdc128..a6c7d30730cd8d49c8c5f8e857460587a1d87a1f 100644 (file)
@@ -173,10 +173,10 @@ static eap_tnc_t *eap_tnc_create(identification_t *server,
                return NULL;
        }
        tnccs = tnc->tnccs->create_instance(tnc->tnccs, type, is_server,
-                                                                               server, peer);
-       this->tls_eap = tls_eap_create(EAP_TNC, (tls_t*)tnccs,
-                                                                                        EAP_TNC_MAX_MESSAGE_LEN,
-                                                                                        max_msg_count, FALSE);
+                                                                               server, peer, TNC_IFT_EAP_1_1);
+       this->tls_eap = tls_eap_create(EAP_TNC, &tnccs->tls,
+                                                                  EAP_TNC_MAX_MESSAGE_LEN,
+                                                                  max_msg_count, FALSE);
        if (!this->tls_eap)
        {
                free(this);
index 5e2c30df95322a16e5165bc024941b12049ff537..eba280690fa1c2ba3e987810340853c87cf42e1c 100644 (file)
@@ -4,7 +4,8 @@ INCLUDES = \
        -I$(top_srcdir)/src/libhydra \
        -I$(top_srcdir)/src/libcharon \
        -I$(top_srcdir)/src/libtncif \
-       -I$(top_srcdir)/src/libtnccs
+       -I$(top_srcdir)/src/libtnccs \
+       -I$(top_srcdir)/src/libtls
 
 AM_CFLAGS = -rdynamic
 
index eca3b377b3ae48d5c7d8949a95fe2ab369633598..90b3507ce34b7ae339fea84e68f2d53982848c3c 100644 (file)
@@ -4,7 +4,8 @@ INCLUDES = \
        -I$(top_srcdir)/src/libhydra \
        -I$(top_srcdir)/src/libcharon \
        -I$(top_srcdir)/src/libtncif \
-       -I$(top_srcdir)/src/libtnccs
+       -I$(top_srcdir)/src/libtnccs \
+       -I$(top_srcdir)/src/libtls
 
 AM_CFLAGS = -rdynamic
 
index 8d3c8a9e1c94ce50d334ee0ad3e108d3dfb26c99..482cc2abf87210bf3d69c6b5d09ce2173de9b24f 100644 (file)
@@ -165,7 +165,8 @@ METHOD(tnccs_manager_t, remove_method, void,
 
 METHOD(tnccs_manager_t, create_instance, tnccs_t*,
        private_tnc_tnccs_manager_t *this, tnccs_type_t type, bool is_server,
-       identification_t *server, identification_t *peer)
+       identification_t *server, identification_t *peer,
+       tnc_ift_type_t transport)
 {
        enumerator_t *enumerator;
        tnccs_entry_t *entry;
@@ -177,7 +178,7 @@ METHOD(tnccs_manager_t, create_instance, tnccs_t*,
        {
                if (type == entry->type)
                {
-                       protocol = entry->constructor(is_server, server, peer);
+                       protocol = entry->constructor(is_server, server, peer, transport);
                        if (protocol)
                        {
                                break;
@@ -662,15 +663,52 @@ METHOD(tnccs_manager_t, get_attribute, TNC_Result,
                                        version = "1.0";
                                        break;
                                default:
-                               return TNC_RESULT_INVALID_PARAMETER;
+                                       return TNC_RESULT_INVALID_PARAMETER;
                        }
                        return str_attribute(buffer_len, buffer, value_len, version);
                }
                case TNC_ATTRIBUTEID_IFT_PROTOCOL:
-                       return str_attribute(buffer_len, buffer, value_len,
-                                                                                "IF-T for Tunneled EAP");
+               {
+                       char *protocol;
+
+                       switch (entry->tnccs->get_transport(entry->tnccs))
+                       {
+                               case TNC_IFT_EAP_1_0:
+                               case TNC_IFT_EAP_1_1:
+                               case TNC_IFT_EAP_2_0:
+                                       protocol = "IF-T for Tunneled EAP";
+                                       break;
+                               case TNC_IFT_TLS_1_0:
+                               case TNC_IFT_TLS_2_0:
+                                       protocol = "IF-T for TLS";
+                                       break;
+                               default:
+                                       return TNC_RESULT_INVALID_PARAMETER;
+                       }
+                       return str_attribute(buffer_len, buffer, value_len, protocol);
+               }
                case TNC_ATTRIBUTEID_IFT_VERSION:
-                       return str_attribute(buffer_len, buffer, value_len, "1.1");
+               {
+                       char *version;
+
+                       switch (entry->tnccs->get_transport(entry->tnccs))
+                       {
+                               case TNC_IFT_EAP_1_0:
+                               case TNC_IFT_TLS_1_0:
+                                       version = "1.0";
+                                       break;
+                               case TNC_IFT_EAP_1_1:
+                                       version = "1.1";
+                                       break;
+                               case TNC_IFT_EAP_2_0:
+                               case TNC_IFT_TLS_2_0:
+                                       version = "2.0";
+                                       break;
+                               default:
+                                       return TNC_RESULT_INVALID_PARAMETER;
+                       }
+                       return str_attribute(buffer_len, buffer, value_len, version);
+               }
                case TNC_ATTRIBUTEID_AR_IDENTITIES:
                {
                        linked_list_t *list;
@@ -681,7 +719,7 @@ METHOD(tnccs_manager_t, get_attribute, TNC_Result,
                        TNC_Result result;
 
                        list = linked_list_create();
-                       tnccs = (tls_t*)entry->tnccs;
+                       tnccs = &entry->tnccs->tls;
                        peer = tnccs->get_peer_id(tnccs);
                        if (peer)
                        {
index 4720f797a20471e4de06676bbd64bbafa31e5318..4a61bdef785dd330eaa9b975f50d8a13b358741f 100644 (file)
@@ -43,9 +43,9 @@ typedef struct private_tnccs_11_t private_tnccs_11_t;
 struct private_tnccs_11_t {
 
        /**
-        * Public tls_t interface.
+        * Public tnccs_t interface.
         */
-       tls_t public;
+       tnccs_t public;
 
        /**
         * TNCC if TRUE, TNCS if FALSE
@@ -62,6 +62,11 @@ struct private_tnccs_11_t {
         */
        identification_t *peer;
 
+       /**
+        * Underlying TNC IF-T transport protocol
+        */
+       tnc_ift_type_t transport;
+
        /**
         * Connection ID assigned to this TNCCS connection
         */
@@ -557,29 +562,48 @@ METHOD(tls_t, destroy, void,
        free(this);
 }
 
+METHOD(tnccs_t, get_transport, tnc_ift_type_t,
+       private_tnccs_11_t *this)
+{
+       return this->transport;
+}
+
+METHOD(tnccs_t, set_transport, void,
+       private_tnccs_11_t *this, tnc_ift_type_t transport)
+{
+       this->transport = transport;
+}
+
 /**
  * See header
  */
-tls_t *tnccs_11_create(bool is_server, identification_t *server,
-                                          identification_t *peer)
+tnccs_t* tnccs_11_create(bool is_server,
+                                                identification_t *server,
+                                                identification_t *peer,
+                                                tnc_ift_type_t transport)
 {
        private_tnccs_11_t *this;
 
        INIT(this,
                .public = {
-                       .process = _process,
-                       .build = _build,
-                       .is_server = _is_server,
-                       .get_server_id = _get_server_id,
-                       .get_peer_id = _get_peer_id,
-                       .get_purpose = _get_purpose,
-                       .is_complete = _is_complete,
-                       .get_eap_msk = _get_eap_msk,
-                       .destroy = _destroy,
+                       .tls = {
+                               .process = _process,
+                               .build = _build,
+                               .is_server = _is_server,
+                               .get_server_id = _get_server_id,
+                               .get_peer_id = _get_peer_id,
+                               .get_purpose = _get_purpose,
+                               .is_complete = _is_complete,
+                               .get_eap_msk = _get_eap_msk,
+                               .destroy = _destroy,
+                       },
+                       .get_transport = _get_transport,
+                       .set_transport = _set_transport,
                },
                .is_server = is_server,
                .server = server->clone(server),
                .peer = peer->clone(peer),
+               .transport = transport,
                .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
                .max_msg_len = lib->settings->get_int(lib->settings,
                                                                "%s.plugins.tnccs-11.max_message_size", 45000,
index 79fccf9c79c8a476bd0c8438b92ab472d2ae6e27..531ebb611011c14f6704fd47dd6dea5758d6090a 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <library.h>
 
-#include <tls.h>
+#include <tnc/tnccs/tnccs.h>
 
 /**
  * Create an instance of the TNC IF-TNCCS 1.1 protocol handler.
  * @param is_server            TRUE to act as TNC Server, FALSE for TNC Client
  * @param server               Server identity
  * @param peer                 Client identity
+ * @param transport            Underlying IF-T transport protocol
  * @return                             TNC_IF_TNCCS 1.1 protocol stack
  */
-tls_t *tnccs_11_create(bool is_server, identification_t *server,
-                                          identification_t *peer);
+tnccs_t* tnccs_11_create(bool is_server,
+                                                identification_t *server,
+                                                identification_t *peer,
+                                                tnc_ift_type_t transport);
 
 #endif /** TNCCS_11_H_ @}*/
index fbbbebee6d4d6f8f8b8bb4b834db45987ed74e1e..4447ba2fd7aae73ecb462de198159ebaab3e492d 100644 (file)
@@ -48,9 +48,9 @@ typedef struct private_tnccs_20_t private_tnccs_20_t;
 struct private_tnccs_20_t {
 
        /**
-        * Public tls_t interface.
+        * Public tnccs_t interface.
         */
-       tls_t public;
+       tnccs_t public;
 
        /**
         * TNCC if TRUE, TNCS if FALSE
@@ -67,6 +67,11 @@ struct private_tnccs_20_t {
         */
        identification_t *peer;
 
+       /**
+        * Underlying TNC IF-T transport protocol
+        */
+       tnc_ift_type_t transport;
+
        /**
         * PB-TNC State Machine
         */
@@ -823,29 +828,48 @@ METHOD(tls_t, destroy, void,
        free(this);
 }
 
+METHOD(tnccs_t, get_transport, tnc_ift_type_t,
+       private_tnccs_20_t *this)
+{
+       return this->transport;
+}
+
+METHOD(tnccs_t, set_transport, void,
+       private_tnccs_20_t *this, tnc_ift_type_t transport)
+{
+       this->transport = transport;
+}
+
 /**
  * See header
  */
-tls_t *tnccs_20_create(bool is_server, identification_t *server,
-                                          identification_t *peer)
+tnccs_t* tnccs_20_create(bool is_server,
+                                                identification_t *server,
+                                                identification_t *peer,
+                                                tnc_ift_type_t transport)
 {
        private_tnccs_20_t *this;
 
        INIT(this,
                .public = {
-                       .process = _process,
-                       .build = _build,
-                       .is_server = _is_server,
-                       .get_server_id = _get_server_id,
-                       .get_peer_id = _get_peer_id,
-                       .get_purpose = _get_purpose,
-                       .is_complete = _is_complete,
-                       .get_eap_msk = _get_eap_msk,
-                       .destroy = _destroy,
+                       .tls = {
+                               .process = _process,
+                               .build = _build,
+                               .is_server = _is_server,
+                               .get_server_id = _get_server_id,
+                               .get_peer_id = _get_peer_id,
+                               .get_purpose = _get_purpose,
+                               .is_complete = _is_complete,
+                               .get_eap_msk = _get_eap_msk,
+                               .destroy = _destroy,
+                       },
+                       .get_transport = _get_transport,
+                       .set_transport = _set_transport,
                },
                .is_server = is_server,
                .server = server->clone(server),
                .peer = peer->clone(peer),
+               .transport = transport,
                .state_machine = pb_tnc_state_machine_create(is_server),
                .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
                .messages = linked_list_create(),
index d42ebf218abb302768765a3b3142303a878b72d1..314935069128b7c99dee2a6e8db4c770fd4cb8cc 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <library.h>
 
-#include <tls.h>
+#include <tnc/tnccs/tnccs.h>
 
 /**
  * Create an instance of the TNC IF-TNCCS 2.0 protocol handler.
  * @param is_server            TRUE to act as TNC Server, FALSE for TNC Client
  * @param server               Server identity
  * @param peer                 Client identity
+ * @param transport            Underlying IF-T transport protocol
  * @return                             TNC_IF_TNCCS 2.0 protocol stack
  */
-tls_t *tnccs_20_create(bool is_server, identification_t *server,
-                                          identification_t *peer);
+tnccs_t* tnccs_20_create(bool is_server,
+                                                identification_t *server,
+                                                identification_t *peer,
+                                                tnc_ift_type_t transport);
 
 #endif /** TNCCS_20_H_ @}*/
index 4b04d692016fcc0f5ad494a39905d51d39f0207f..49f421e9b25b206b65f49c8019a98855fd5c8eba 100644 (file)
@@ -27,9 +27,9 @@ typedef struct private_tnccs_dynamic_t private_tnccs_dynamic_t;
 struct private_tnccs_dynamic_t {
 
        /**
-        * Public tls_t interface.
+        * Public tnccs_t interface.
         */
-       tls_t public;
+       tnccs_t public;
 
        /**
         * Server identity
@@ -45,6 +45,12 @@ struct private_tnccs_dynamic_t {
         * Detected TNC IF-TNCCS stack
         */
        tls_t *tls;
+
+       /**
+        * Underlying TNC IF-T transport protocol
+        */
+       tnc_ift_type_t transport;
+
 };
 
 /**
@@ -87,7 +93,7 @@ METHOD(tls_t, process, status_t,
                DBG1(DBG_TNC, "%N protocol detected dynamically",
                                           tnccs_type_names, type);
                this->tls = (tls_t*)tnc->tnccs->create_instance(tnc->tnccs, type, TRUE,
-                                                                                                       this->server, this->peer);
+                                                                       this->server, this->peer, this->transport);
                if (!this->tls)
                {
                        DBG1(DBG_TNC, "N% protocol not supported", tnccs_type_names, type);
@@ -148,28 +154,47 @@ METHOD(tls_t, destroy, void,
        free(this);
 }
 
+METHOD(tnccs_t, get_transport, tnc_ift_type_t,
+       private_tnccs_dynamic_t *this)
+{
+       return this->transport;
+}
+
+METHOD(tnccs_t, set_transport, void,
+       private_tnccs_dynamic_t *this, tnc_ift_type_t transport)
+{
+       this->transport = transport;
+}
+
 /**
  * See header
  */
-tls_t *tnccs_dynamic_create(bool is_server, identification_t *server,
-                                                       identification_t *peer)
+tnccs_t* tnccs_dynamic_create(bool is_server,
+                                                         identification_t *server,
+                                                         identification_t *peer,
+                                                         tnc_ift_type_t transport)
 {
        private_tnccs_dynamic_t *this;
 
        INIT(this,
                .public = {
-                       .process = _process,
-                       .build = _build,
-                       .is_server = _is_server,
-                       .get_server_id = _get_server_id,
-                       .get_peer_id = _get_peer_id,
-                       .get_purpose = _get_purpose,
-                       .is_complete = _is_complete,
-                       .get_eap_msk = _get_eap_msk,
-                       .destroy = _destroy,
+                       .tls = {
+                               .process = _process,
+                               .build = _build,
+                               .is_server = _is_server,
+                               .get_server_id = _get_server_id,
+                               .get_peer_id = _get_peer_id,
+                               .get_purpose = _get_purpose,
+                               .is_complete = _is_complete,
+                               .get_eap_msk = _get_eap_msk,
+                               .destroy = _destroy,
+                       },
+                       .get_transport = _get_transport,
+                       .set_transport = _set_transport,
                },
                .server = server->clone(server),
                .peer = peer->clone(peer),
+               .transport = transport,
        );
 
        return &this->public;
index 383ebfcfa7ef2dee8799d67457c4244e1c1dd627..e4cff74b84f96430a16b6dcbeb1f3df03e345d7e 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <library.h>
 
-#include <tls.h>
+#include <tnc/tnccs/tnccs.h>
 
 /**
  * Create an instance of a dynamic TNC IF-TNCCS protocol handler.
  * @param is_server            TRUE to act as TNC Server, FALSE for TNC Client
  * @param server               Server identity
  * @param peer                 Client identity
+ * @param transport            Underlying IF-T transport protocol
  * @return                             dynamic TNC IF-TNCCS protocol stack
  */
-tls_t *tnccs_dynamic_create(bool is_server, identification_t *server,
-                                                       identification_t *peer);
+tnccs_t* tnccs_dynamic_create(bool is_server,
+                                                         identification_t *server,
+                                                         identification_t *peer,
+                                                         tnc_ift_type_t transport);
 
 #endif /** TNCCS_DYNAMIC_H_ @}*/
index 449d32d922f6a1dbbf748bf1900511609efbe77c..c6492d8d33e4d5542fe8a2d0ec0de03e89d48ab5 100644 (file)
@@ -1,5 +1,8 @@
 
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libtncif
+INCLUDES = \
+       -I$(top_srcdir)/src/libstrongswan \
+       -I$(top_srcdir)/src/libtncif \
+       -I$(top_srcdir)/src/libtls
 
 ipseclib_LTLIBRARIES = libtnccs.la
 
index 530562e7f46844d85c40ad03e43f1ce248a47393..3c7249fb06b82f4fd6e9e0f2110e892e524307e5 100644 (file)
@@ -26,6 +26,7 @@
 
 typedef struct tnccs_t tnccs_t;
 typedef enum tnccs_type_t tnccs_type_t;
+typedef enum tnc_ift_type_t tnc_ift_type_t;
 
 #include <tncif.h>
 #include <tncifimc.h>
@@ -34,6 +35,8 @@ typedef enum tnccs_type_t tnccs_type_t;
 #include <library.h>
 #include <plugins/plugin.h>
 
+#include <tls.h>
+
 /**
  * Type of TNC Client/Server protocol
  */
@@ -45,22 +48,58 @@ enum tnccs_type_t {
        TNCCS_DYNAMIC
 };
 
+/**
+ * Type of TNC Transport protocol
+ */
+enum tnc_ift_type_t {
+       TNC_IFT_UNKNOWN,
+       TNC_IFT_EAP_1_0,
+       TNC_IFT_EAP_1_1,
+       TNC_IFT_EAP_2_0,
+       TNC_IFT_TLS_1_0,
+       TNC_IFT_TLS_2_0
+};
+
 /**
  * enum names for tnccs_type_t.
  */
 extern enum_name_t *tnccs_type_names;
 
+/**
+ * TNCCS public interface
+ */
+struct tnccs_t {
+
+       /**
+        * Implements tls_t
+        */
+       tls_t tls;
+
+       /**
+        * Get underlying TNC IF-T transport protocol
+        */
+       tnc_ift_type_t (*get_transport)(tnccs_t *this);
+
+       /**
+        * Set underlying TNC IF-T transport protocol
+        */
+       void (*set_transport)(tnccs_t *this, tnc_ift_type_t transport);
+
+};
+
 /**
  * Constructor definition for a pluggable TNCCS protocol implementation.
  *
  * @param is_server            TRUE if TNC Server, FALSE if TNC Client
  * @param server               Server identity
  * @param peer                 Client identity
+ * @param transport            Underlying TNC IF-T transport protocol used
  * @return                             implementation of the tnccs_t interface
  */
 typedef tnccs_t *(*tnccs_constructor_t)(bool is_server,
                                                                                identification_t *server,
-                                                                               identification_t *peer);
+                                                                               identification_t *peer,
+                                                                               tnc_ift_type_t transport);
 
 /**
  * Callback function adding a message to a TNCCS batch
index 812f40a29333d5d820eabb8d9700e7304c357b32..4ab9d7e18867df0557f06154ea0793582b65b3fe 100644 (file)
@@ -58,11 +58,13 @@ struct tnccs_manager_t {
         * @param is_server       TRUE if TNC Server, FALSE if TNC Client
         * @param server          Server identity
         * @param peer            Client identity
+        * @param transport       Underlying TNC IF-T transport protocol used
         * @return                        TNCCS protocol instance, NULL if no constructor found
         */
        tnccs_t* (*create_instance)(tnccs_manager_t *this, tnccs_type_t type,
                                                                bool is_server, identification_t *server,
-                                                               identification_t *peer);
+                                                               identification_t *peer,
+                                                               tnc_ift_type_t transport);
 
        /**
         * Create a TNCCS connection and assign a unique connection ID as well a