From: Andreas Steffen Date: Wed, 9 Oct 2013 20:17:24 +0000 (+0200) Subject: Determine IP address of PDP server X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=63aa9b2e8b8aa59401369e73e8c93a0b5371d524;p=thirdparty%2Fstrongswan.git Determine IP address of PDP server --- diff --git a/src/libcharon/plugins/eap_tnc/Makefile.am b/src/libcharon/plugins/eap_tnc/Makefile.am index 9586bef148..43d062fdfc 100644 --- a/src/libcharon/plugins/eap_tnc/Makefile.am +++ b/src/libcharon/plugins/eap_tnc/Makefile.am @@ -3,6 +3,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/libhydra \ -I$(top_srcdir)/src/libcharon \ -I$(top_srcdir)/src/libtls \ + -I$(top_srcdir)/src/libpttls \ -I$(top_srcdir)/src/libtncif \ -I$(top_srcdir)/src/libtnccs @@ -15,6 +16,7 @@ else plugin_LTLIBRARIES = libstrongswan-eap-tnc.la libstrongswan_eap_tnc_la_LIBADD = \ $(top_builddir)/src/libtls/libtls.la \ + $(top_builddir)/src/libpttls/libpttls.la \ $(top_builddir)/src/libtnccs/libtnccs.la endif diff --git a/src/libcharon/plugins/eap_tnc/eap_tnc.c b/src/libcharon/plugins/eap_tnc/eap_tnc.c index f9ab742588..8ff32f6e9d 100644 --- a/src/libcharon/plugins/eap_tnc/eap_tnc.c +++ b/src/libcharon/plugins/eap_tnc/eap_tnc.c @@ -213,17 +213,23 @@ METHOD(eap_method_t, is_mutual, bool, METHOD(eap_method_t, destroy, void, private_eap_tnc_t *this) { - chunk_t pdp_server; + char *pdp_server; u_int16_t pdp_port; + host_t *host; tls_t *tls; + tls = &this->tnccs->tls; pdp_server = this->tnccs->get_pdp_server(this->tnccs, &pdp_port); - if (pdp_server.len) + if (pdp_server) { - DBG2(DBG_TNC, "TODO: setup PT-TLS connection to %.*s:%u", - pdp_server.len, pdp_server.ptr, pdp_port); + host = host_create_from_dns(pdp_server, AF_UNSPEC, pdp_port); + if (host) + { + DBG2(DBG_TNC, "TODO: setup PT-TLS connection to '%s' at %#H", + pdp_server, host); + host->destroy(host); + } } - tls = &this->tnccs->tls; tls->destroy(tls); this->tls_eap->destroy(this->tls_eap); free(this); diff --git a/src/libtnccs/plugins/tnccs_11/tnccs_11.c b/src/libtnccs/plugins/tnccs_11/tnccs_11.c index 91854b5875..0d187e6dd9 100644 --- a/src/libtnccs/plugins/tnccs_11/tnccs_11.c +++ b/src/libtnccs/plugins/tnccs_11/tnccs_11.c @@ -610,12 +610,12 @@ METHOD(tnccs_t, set_auth_type, void, this->auth_type = auth_type; } -METHOD(tnccs_t, get_pdp_server, chunk_t, +METHOD(tnccs_t, get_pdp_server, char*, private_tnccs_11_t *this, u_int16_t *port) { *port = 0; - return chunk_empty; + return NULL; } METHOD(tnccs_t, get_ref, tnccs_t*, diff --git a/src/libtnccs/plugins/tnccs_20/tnccs_20.c b/src/libtnccs/plugins/tnccs_20/tnccs_20.c index b631ef5794..4621a3ab30 100644 --- a/src/libtnccs/plugins/tnccs_20/tnccs_20.c +++ b/src/libtnccs/plugins/tnccs_20/tnccs_20.c @@ -145,7 +145,7 @@ struct private_tnccs_20_t { /** * PDP server FQDN */ - chunk_t pdp_server; + char *pdp_server; /** * PDP server port @@ -471,6 +471,7 @@ static void handle_tcg_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg) { pb_pdp_referral_msg_t *pdp_msg; pen_type_t pdp_id_type; + chunk_t pdp_server; u_int8_t pdp_protocol; pdp_msg = (pb_pdp_referral_msg_t*)msg; @@ -479,16 +480,17 @@ static void handle_tcg_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg) if (pdp_id_type.vendor_id == PEN_TCG && pdp_id_type.type == PB_PDP_ID_FQDN) { - this->pdp_server = chunk_clone(pdp_msg->get_fqdn(pdp_msg, - &pdp_protocol, &this->pdp_port)); + pdp_server = pdp_msg->get_fqdn(pdp_msg, &pdp_protocol, + &this->pdp_port); if (pdp_protocol != 0) { DBG1(DBG_TNC, "unsupported PDP transport protocol"); break; } - DBG1(DBG_TNC, "PDP server '%.*s' is listening on port %u", - this->pdp_server.len, this->pdp_server.ptr, - this->pdp_port); + this->pdp_server = strndup(pdp_server.ptr, pdp_server.len); + + DBG1(DBG_TNC, "PDP server '%s' is listening on port %u", + this->pdp_server, this->pdp_port); } break; } @@ -980,7 +982,7 @@ METHOD(tls_t, destroy, void, this->mutex->destroy(this->mutex); this->messages->destroy_offset(this->messages, offsetof(pb_tnc_msg_t, destroy)); - free(this->pdp_server.ptr); + free(this->pdp_server); free(this); } } @@ -1009,7 +1011,7 @@ METHOD(tnccs_t, set_auth_type, void, this->auth_type = auth_type; } -METHOD(tnccs_t, get_pdp_server, chunk_t, +METHOD(tnccs_t, get_pdp_server, char*, private_tnccs_20_t *this, u_int16_t *port) { *port = this->pdp_port; diff --git a/src/libtnccs/plugins/tnccs_dynamic/tnccs_dynamic.c b/src/libtnccs/plugins/tnccs_dynamic/tnccs_dynamic.c index e08236eb7b..c7db5b5f2a 100644 --- a/src/libtnccs/plugins/tnccs_dynamic/tnccs_dynamic.c +++ b/src/libtnccs/plugins/tnccs_dynamic/tnccs_dynamic.c @@ -211,7 +211,7 @@ METHOD(tnccs_t, set_auth_type, void, this->auth_type = auth_type; } -METHOD(tnccs_t, get_pdp_server, chunk_t, +METHOD(tnccs_t, get_pdp_server, char*, private_tnccs_dynamic_t *this, u_int16_t *port) { tnccs_t *tnccs = (tnccs_t*)this->tls; diff --git a/src/libtnccs/tnc/tnccs/tnccs.h b/src/libtnccs/tnc/tnccs/tnccs.h index eefd5565db..7301d59aab 100644 --- a/src/libtnccs/tnc/tnccs/tnccs.h +++ b/src/libtnccs/tnc/tnccs/tnccs.h @@ -120,7 +120,7 @@ struct tnccs_t { * @param port PDP port number * @return PDP server name */ - chunk_t (*get_pdp_server)(tnccs_t *this, u_int16_t *port); + char* (*get_pdp_server)(tnccs_t *this, u_int16_t *port); /** * Get a new reference to the TNCCS object.