]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Use eap_type_get_names() to printf EAP types eap-vendor-names
authorMartin Willi <martin@revosec.ch>
Wed, 12 Sep 2012 11:16:21 +0000 (13:16 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 12 Sep 2012 15:10:41 +0000 (17:10 +0200)
src/libcharon/encoding/message.c
src/libcharon/plugins/eap_dynamic/eap_dynamic.c
src/libcharon/plugins/eap_ttls/eap_ttls_server.c
src/libcharon/plugins/stroke/stroke_list.c
src/libcharon/plugins/tnc_pdp/tnc_pdp.c
src/libcharon/sa/ikev2/authenticators/eap_authenticator.c

index d3b72ea956a3d487dc12d553e67d7c9b94ab4069..6531971e088aa46cb869049e2c0bddd6bd228c22 100644 (file)
@@ -1229,15 +1229,8 @@ static char* get_string(private_message_t *this, char *buf, int len)
                        type = eap->get_type(eap, &vendor);
                        if (type)
                        {
-                               if (vendor)
-                               {
-                                       snprintf(method, sizeof(method), "/%d-%d", type, vendor);
-                               }
-                               else
-                               {
-                                       snprintf(method, sizeof(method), "/%N",
-                                                        eap_type_short_names, type);
-                               }
+                               snprintf(method, sizeof(method), "/%M",
+                                                eap_type_get_names, &vendor, type);
                        }
                        written = snprintf(pos, len, "/%N%s", eap_code_short_names,
                                                           eap->get_code(eap), method);
index 004151a2f9b36f26fd7966b07b6942f2c20fcb88..9c167a68c6246e9b29d8d7012ca7db25d9e631d5 100644 (file)
@@ -91,15 +91,8 @@ static eap_method_t *load_method(private_eap_dynamic_t *this,
                                                                                  this->server, this->peer);
        if (!method)
        {
-               if (vendor)
-               {
-                       DBG1(DBG_IKE, "loading vendor specific EAP method %d-%d failed",
-                                type, vendor);
-               }
-               else
-               {
-                       DBG1(DBG_IKE, "loading %N method failed", eap_type_names, type);
-               }
+               DBG1(DBG_IKE, "loading EAP-%M method failed",
+                        eap_type_get_names, &vendor, type);
        }
        return method;
 }
@@ -127,17 +120,9 @@ static void select_method(private_eap_dynamic_t *this)
                        if (inner->find_first(inner, (void*)entry_matches,
                                                                  NULL, entry) != SUCCESS)
                        {
-                               if (entry->vendor)
-                               {
-                                       DBG2(DBG_IKE, "proposed vendor specific EAP method %d-%d "
-                                                "not supported by %s, skipped", entry->type,
-                                                 entry->vendor, who);
-                               }
-                               else
-                               {
-                                       DBG2(DBG_IKE, "proposed %N method not supported by %s, "
-                                                "skipped", eap_type_names, entry->type, who);
-                               }
+                               DBG2(DBG_IKE, "proposed EAP-%M method not supported "
+                                        "by %s, skipped", eap_type_get_names, &entry->vendor,
+                                        entry->type, who);
                                free(entry);
                                continue;
                        }
@@ -145,16 +130,8 @@ static void select_method(private_eap_dynamic_t *this)
                this->method = load_method(this, entry->type, entry->vendor);
                if (this->method)
                {
-                       if (entry->vendor)
-                       {
-                               DBG1(DBG_IKE, "vendor specific EAP method %d-%d selected",
-                                        entry->type, entry->vendor);
-                       }
-                       else
-                       {
-                               DBG1(DBG_IKE, "%N method selected", eap_type_names,
-                                        entry->type);
-                       }
+                       DBG1(DBG_IKE, "EAP-%M method selected",
+                                eap_type_get_names, &entry->vendor, entry->type);
                        free(entry);
                        break;
                }
index 0a31d17c998a15af22acae8b1d772e29b96b880c..41c12c3ce40e970faa389e46719457d925a1f5a3 100644 (file)
@@ -87,12 +87,13 @@ static status_t start_phase2_auth(private_eap_ttls_server_t *this)
                DBG1(DBG_IKE, "unrecognized phase2 method \"%s\"", eap_type_str);
                return FAILED;
        }
-       DBG1(DBG_IKE, "phase2 method %N selected", eap_type_names, type);
-               this->method = charon->eap->create_instance(charon->eap, type, 0,
-                                                               EAP_SERVER, this->server, this->peer);
+       DBG1(DBG_IKE, "phase2 method %M selected", eap_type_get_names, &vendor, type);
+       this->method = charon->eap->create_instance(charon->eap, type, vendor,
+                                                                               EAP_SERVER, this->server, this->peer);
        if (this->method == NULL)
        {
-               DBG1(DBG_IKE, "%N method not available", eap_type_names, type);
+               DBG1(DBG_IKE, "%M method not available",
+                        eap_type_get_names, &vendor, type);
                return FAILED;
        }
        if (this->method->initiate(this->method, &this->out) == NEED_MORE)
@@ -101,8 +102,8 @@ static status_t start_phase2_auth(private_eap_ttls_server_t *this)
        }
        else
        {
-               DBG1(DBG_IKE, "%N method failed", eap_type_names, type);
-                       return FAILED;
+               DBG1(DBG_IKE, "%M method failed", eap_type_get_names, &vendor, type);
+               return FAILED;
        }
 }
 
index 1381e5842be171f8debf784d90f94d2bf8e028e7..a99483a18dce96fa02df0f26313ceceddfbb3c06 100644 (file)
@@ -355,17 +355,14 @@ static void log_auth_cfgs(FILE *out, peer_cfg_t *peer_cfg, bool local)
                        }
                        else
                        {
-                               if ((uintptr_t)auth->get(auth, AUTH_RULE_EAP_VENDOR))
-                               {
-                                       fprintf(out, "EAP_%" PRIuPTR "-%" PRIuPTR " authentication",
-                                               (uintptr_t)auth->get(auth, AUTH_RULE_EAP_TYPE),
-                                               (uintptr_t)auth->get(auth, AUTH_RULE_EAP_VENDOR));
-                               }
-                               else
-                               {
-                                       fprintf(out, "%N authentication", eap_type_names,
-                                               (uintptr_t)auth->get(auth, AUTH_RULE_EAP_TYPE));
-                               }
+                               u_int32_t vendor;
+                               eap_type_t type;
+
+                               vendor = (uintptr_t)auth->get(auth, AUTH_RULE_EAP_VENDOR);
+                               type = (uintptr_t)auth->get(auth, AUTH_RULE_EAP_TYPE);
+
+                               fprintf(out, "EAP-%M authentication",
+                                               eap_type_get_names, &vendor, type);
                        }
                        id = auth->get(auth, AUTH_RULE_EAP_IDENTITY);
                        if (id)
index 3e02f26c6a3b4a2bba6d2a65d50fc4e29a7af778..d13b764a21af4c9f723d39ae49eddc84b5de658c 100644 (file)
@@ -225,7 +225,7 @@ static chunk_t encrypt_mppe_key(private_tnc_pdp_t *this, u_int8_t type,
                {
                        free(data.ptr);
                        return chunk_empty;
-               }       
+               }
                *a.ptr |= 0x80;
        }
        while (mppe_key->salt == *salt);
@@ -274,7 +274,8 @@ static void send_response(private_tnc_pdp_t *this, radius_message_t *request,
        if (eap)
        {
                data = eap->get_data(eap);
-               DBG3(DBG_CFG, "%N payload %B", eap_type_names, this->type, &data);
+               DBG3(DBG_CFG, "%M payload %B",
+                        eap_type_get_names, &this->vendor, this->type, &data);
 
                /* fragment data suitable for RADIUS */
                while (data.len > MAX_RADIUS_ATTRIBUTE_SIZE)
@@ -363,7 +364,8 @@ static void process_eap(private_tnc_pdp_t *this, radius_message_t *request,
                /* apply EAP method selected by RADIUS server */
                eap_type = in->get_type(in, &eap_vendor);
 
-               DBG3(DBG_CFG, "%N payload %B", eap_type_names, eap_type, &message);
+               DBG3(DBG_CFG, "EAP-%M payload %B",
+                        eap_type_get_names, &eap_vendor, eap_type, &message);
 
                if (eap_type == EAP_IDENTITY)
                {
@@ -648,7 +650,8 @@ tnc_pdp_t *tnc_pdp_create(u_int16_t port)
                destroy(this);
                return NULL;
        }
-       DBG1(DBG_IKE, "eap method %N selected", eap_type_names, this->type);
+       DBG1(DBG_IKE, "eap method %M selected",
+                eap_type_get_names, &this->vendor, this->type);
 
        lib->processor->queue_job(lib->processor,
                (job_t*)callback_job_create_with_prio((callback_job_cb_t)receive, this,
@@ -656,4 +659,3 @@ tnc_pdp_t *tnc_pdp_create(u_int16_t port)
 
        return &this->public;
 }
-
index aa064403336ae078454a30f3da381288e58717bb..408785e3d3bde30d32d091f422b148253754f7f7 100644 (file)
@@ -190,30 +190,15 @@ static eap_payload_t* server_initiate_eap(private_eap_authenticator_t *this,
                if (this->method->initiate(this->method, &out) == NEED_MORE)
                {
                        type = this->method->get_type(this->method, &vendor);
-                       if (vendor)
-                       {
-                               DBG1(DBG_IKE, "initiating EAP vendor type %d-%d method (id 0x%02X)",
-                                        type, vendor, out->get_identifier(out));
-                       }
-                       else
-                       {
-                               DBG1(DBG_IKE, "initiating %N method (id 0x%02X)", eap_type_names,
-                                        type, out->get_identifier(out));
-                       }
+                       DBG1(DBG_IKE, "%s EAP-%M method (id 0x%02X)", action,
+                                eap_type_get_names, &vendor, type, out->get_identifier(out));
                        return out;
                }
                /* type might have changed for virtual methods */
                type = this->method->get_type(this->method, &vendor);
        }
-       if (vendor)
-       {
-               DBG1(DBG_IKE, "%s EAP vendor type %d-%d method failed",
-                                         action, type, vendor);
-       }
-       else
-       {
-               DBG1(DBG_IKE, "%s %N method failed", action, eap_type_names, type);
-       }
+       DBG1(DBG_IKE, "%s EAP-%M method failed", action,
+                eap_type_get_names, &vendor, type);
        return eap_payload_create_code(EAP_FAILURE, 0);
 }
 
@@ -299,17 +284,8 @@ static eap_payload_t* server_process_eap(private_eap_authenticator_t *this,
                        {
                                this->msk = chunk_clone(this->msk);
                        }
-                       if (vendor)
-                       {
-                               DBG1(DBG_IKE, "EAP vendor specific method %d-%d succeeded, "
-                                        "%sMSK established", type, vendor,
-                                        this->msk.ptr ? "" : "no ");
-                       }
-                       else
-                       {
-                               DBG1(DBG_IKE, "EAP method %N succeeded, %sMSK established",
-                                        eap_type_names, type, this->msk.ptr ? "" : "no ");
-                       }
+                       DBG1(DBG_IKE, "EAP method %M succeeded, %sMSK established",
+                                eap_type_get_names, &vendor, type, this->msk.ptr ? "" : "no ");
                        this->ike_sa->set_condition(this->ike_sa, COND_EAP_AUTHENTICATED,
                                                                                TRUE);
                        this->eap_complete = TRUE;
@@ -317,19 +293,9 @@ static eap_payload_t* server_process_eap(private_eap_authenticator_t *this,
                case FAILED:
                default:
                        /* type might have changed for virtual methods */
-                       type = this->method->get_type(this->method, &vendor);
-                       if (vendor)
-                       {
-                               DBG1(DBG_IKE, "EAP vendor specific method %d-%d failed for "
-                                        "peer %Y", type, vendor,
-                                        this->ike_sa->get_other_id(this->ike_sa));
-                       }
-                       else
-                       {
-                               DBG1(DBG_IKE, "EAP method %N failed for peer %Y",
-                                        eap_type_names, type,
-                                        this->ike_sa->get_other_id(this->ike_sa));
-                       }
+                       DBG1(DBG_IKE, "EAP method %M failed for peer %Y",
+                                eap_type_get_names, &vendor, type,
+                                this->ike_sa->get_other_id(this->ike_sa));
                        return eap_payload_create_code(EAP_FAILURE, in->get_identifier(in));
        }
 }
@@ -381,32 +347,17 @@ static eap_payload_t* client_process_eap(private_eap_authenticator_t *this,
        }
        if (this->method == NULL)
        {
-               if (vendor)
-               {
-                       DBG1(DBG_IKE, "server requested vendor specific EAP method %d-%d ",
-                                                 "(id 0x%02X)", type, vendor, in->get_identifier(in));
-               }
-               else
-               {
-                       DBG1(DBG_IKE, "server requested %N authentication (id 0x%02X)",
-                                eap_type_names, type, in->get_identifier(in));
-               }
+               DBG1(DBG_IKE, "server requested %M authentication (id 0x%02X)",
+                        eap_type_get_names, &vendor, type, in->get_identifier(in));
+
                auth = this->ike_sa->get_auth_cfg(this->ike_sa, TRUE);
                conf_type = (uintptr_t)auth->get(auth, AUTH_RULE_EAP_TYPE);
                conf_vendor = (uintptr_t)auth->get(auth, AUTH_RULE_EAP_VENDOR);
                if (conf_type != EAP_NAK &&
                   (conf_type != type || conf_vendor != vendor))
                {
-                       if (conf_vendor)
-                       {
-                               DBG1(DBG_IKE, "requesting EAP method %d-%d, sending EAP_NAK",
-                                        conf_type, conf_vendor);
-                       }
-                       else
-                       {
-                               DBG1(DBG_IKE, "requesting %N authentication, sending EAP_NAK",
-                                        eap_type_names, conf_type);
-                       }
+                       DBG1(DBG_IKE, "requesting EAP-%M authentication, sending EAP_NAK",
+                                eap_type_get_names, &conf_vendor, conf_type);
                        return eap_payload_create_nak(in->get_identifier(in), conf_type,
                                                                                  conf_vendor, in->is_expanded(in));
                }
@@ -426,14 +377,7 @@ static eap_payload_t* client_process_eap(private_eap_authenticator_t *this,
                return out;
        }
 
-       if (vendor)
-       {
-               DBG1(DBG_IKE, "vendor specific EAP method %d-%d failed", type, vendor);
-       }
-       else
-       {
-               DBG1(DBG_IKE, "%N method failed", eap_type_names, type);
-       }
+       DBG1(DBG_IKE, "EAP-%M method failed", eap_type_get_names, &vendor, type);
        return NULL;
 }
 
@@ -579,11 +523,12 @@ METHOD(authenticator_t, process_client, status_t,
                }
                if (this->require_mutual && !this->method->is_mutual(this->method))
                {       /* we require mutual authentication due to EAP-only */
-                       u_int32_t vendor;
+                       u_int32_t vendor, type;
 
+                       type = this->method->get_type(this->method, &vendor);
                        DBG1(DBG_IKE, "EAP-only authentication requires a mutual and "
-                                "MSK deriving EAP method, but %N is not",
-                                eap_type_names, this->method->get_type(this->method, &vendor));
+                                "MSK deriving EAP method, but %M is not",
+                                eap_type_get_names, &vendor, type);
                        return FAILED;
                }
                return SUCCESS;
@@ -615,17 +560,9 @@ METHOD(authenticator_t, process_client, status_t,
                                        this->msk = chunk_clone(this->msk);
                                }
                                type = this->method->get_type(this->method, &vendor);
-                               if (vendor)
-                               {
-                                       DBG1(DBG_IKE, "EAP vendor specific method %d-%d succeeded, "
-                                                "%sMSK established", type, vendor,
-                                                this->msk.ptr ? "" : "no ");
-                               }
-                               else
-                               {
-                                       DBG1(DBG_IKE, "EAP method %N succeeded, %sMSK established",
-                                                eap_type_names, type, this->msk.ptr ? "" : "no ");
-                               }
+                               DBG1(DBG_IKE, "EAP method %M succeeded, %sMSK established",
+                                        eap_type_get_names, &vendor, type,
+                                        this->msk.ptr ? "" : "no ");
                                cfg = this->ike_sa->get_auth_cfg(this->ike_sa, TRUE);
                                cfg->add(cfg, AUTH_RULE_EAP_TYPE, type);
                                if (vendor)