if (type)
{
snprintf(method, sizeof(method), "/%M",
- eap_type_get_names, vendor, type);
+ eap_type_get_names, &vendor, type);
}
written = snprintf(pos, len, "/%N%s", eap_code_short_names,
eap->get_code(eap), method);
if (!method)
{
DBG1(DBG_IKE, "loading EAP-%M method failed",
- eap_type_get_names, vendor, type);
+ eap_type_get_names, &vendor, type);
}
return method;
}
NULL, entry) != SUCCESS)
{
DBG2(DBG_IKE, "proposed EAP-%M method not supported "
- "by %s, skipped", eap_type_get_names, entry->vendor,
+ "by %s, skipped", eap_type_get_names, &entry->vendor,
entry->type, who);
free(entry);
continue;
if (this->method)
{
DBG1(DBG_IKE, "EAP-%M method selected",
- eap_type_get_names, entry->vendor, entry->type);
+ eap_type_get_names, &entry->vendor, entry->type);
free(entry);
break;
}
received_type = in->get_type(in, &received_vendor);
DBG1(DBG_IKE, "received tunneled EAP-PEAP AVP [ EAP/%N/%M ]",
eap_code_short_names, code,
- eap_type_get_names, received_vendor, received_type);
+ eap_type_get_names, &received_vendor, received_type);
/* yet another phase2 authentication? */
if (this->ph2)
if (this->ph2 == NULL)
{
DBG1(DBG_IKE, "server requested EAP method %M (id 0x%02X)",
- eap_type_get_names, received_vendor, received_type,
+ eap_type_get_names, &received_vendor, received_type,
in->get_identifier(in));
this->ph2 = charon->eap->create_instance(charon->eap,
received_type, received_vendor,
return NEED_MORE;
case FAILED:
default:
- DBG1(DBG_IKE, "EAP-%M failed", eap_type_get_names, vendor, type);
+ DBG1(DBG_IKE, "EAP-%M failed", eap_type_get_names, &vendor, type);
return FAILED;
}
}
}
DBG1(DBG_IKE, "received tunneled EAP-PEAP AVP [ EAP/%N/%M ]",
eap_code_short_names, code,
- eap_type_get_names, vendor, type);
+ eap_type_get_names, &vendor, type);
if (vendor == PEN_MICROSOFT && type == EAP_MS_CAPABILITES)
{
return process_capabilities(this, reader);
type = this->out->get_type(this->out, &vendor);
DBG1(DBG_IKE, "sending tunneled EAP-PEAP AVP [ EAP/%N/%M ]",
eap_code_short_names, code,
- eap_type_get_names, vendor, type);
+ eap_type_get_names, &vendor, type);
data = this->out->get_data(this->out);
DBG1(DBG_IKE, "unrecognized phase2 method \"%s\"", eap_type_str);
return FAILED;
}
- DBG1(DBG_IKE, "phase2 method %M selected", eap_type_get_names, vendor, type);
+ DBG1(DBG_IKE, "phase2 method %M selected", eap_type_get_names, &vendor, type);
this->ph2_method = charon->eap->create_instance(charon->eap, type,
vendor, EAP_SERVER, this->server, this->peer);
if (this->ph2_method == NULL)
{
DBG1(DBG_IKE, "%M method not available",
- eap_type_get_names, vendor, type);
+ eap_type_get_names, &vendor, type);
return FAILED;
}
}
else
{
- DBG1(DBG_IKE, "%M method failed", eap_type_get_names, vendor, type);
+ DBG1(DBG_IKE, "%M method failed", eap_type_get_names, &vendor, type);
return FAILED;
}
}
DBG1(DBG_IKE, "unrecognized phase2 method \"%s\"", eap_type_str);
return FAILED;
}
- DBG1(DBG_IKE, "phase2 method %M selected", eap_type_get_names, vendor, type);
+ 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, "%M method not available",
- eap_type_get_names, vendor, type);
+ eap_type_get_names, &vendor, type);
return FAILED;
}
if (this->method->initiate(this->method, &this->out) == NEED_MORE)
}
else
{
- DBG1(DBG_IKE, "%M method failed", eap_type_get_names, vendor, type);
+ DBG1(DBG_IKE, "%M method failed", eap_type_get_names, &vendor, type);
return FAILED;
}
}
}
else
{
+ 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,
- (uintptr_t)auth->get(auth, AUTH_RULE_EAP_VENDOR),
- (uintptr_t)auth->get(auth, AUTH_RULE_EAP_TYPE));
+ eap_type_get_names, &vendor, type);
}
id = auth->get(auth, AUTH_RULE_EAP_IDENTITY);
if (id)
{
data = eap->get_data(eap);
DBG3(DBG_CFG, "%M payload %B",
- eap_type_get_names, this->vendor, this->type, &data);
+ eap_type_get_names, &this->vendor, this->type, &data);
/* fragment data suitable for RADIUS */
while (data.len > MAX_RADIUS_ATTRIBUTE_SIZE)
eap_type = in->get_type(in, &eap_vendor);
DBG3(DBG_CFG, "EAP-%M payload %B",
- eap_type_get_names, eap_vendor, eap_type, &message);
+ eap_type_get_names, &eap_vendor, eap_type, &message);
if (eap_type == EAP_IDENTITY)
{
return NULL;
}
DBG1(DBG_IKE, "eap method %M selected",
- eap_type_get_names, this->vendor, this->type);
+ 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,
{
type = this->method->get_type(this->method, &vendor);
DBG1(DBG_IKE, "%s EAP-%M method (id 0x%02X)", action,
- eap_type_get_names, vendor, type, out->get_identifier(out));
+ 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);
}
DBG1(DBG_IKE, "%s EAP-%M method failed", action,
- eap_type_get_names, vendor, type);
+ eap_type_get_names, &vendor, type);
return eap_payload_create_code(EAP_FAILURE, 0);
}
this->msk = chunk_clone(this->msk);
}
DBG1(DBG_IKE, "EAP method %M succeeded, %sMSK established",
- eap_type_get_names, vendor, type, this->msk.ptr ? "" : "no ");
+ 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;
default:
/* type might have changed for virtual methods */
DBG1(DBG_IKE, "EAP method %M failed for peer %Y",
- eap_type_get_names, vendor, type,
+ 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));
}
if (this->method == NULL)
{
DBG1(DBG_IKE, "server requested %M authentication (id 0x%02X)",
- eap_type_get_names, vendor, type, in->get_identifier(in));
+ 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_type != type || conf_vendor != vendor))
{
DBG1(DBG_IKE, "requesting EAP-%M authentication, sending EAP_NAK",
- eap_type_get_names, conf_vendor, conf_type);
+ 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));
}
return out;
}
- DBG1(DBG_IKE, "EAP-%M method failed", eap_type_get_names, vendor, type);
+ DBG1(DBG_IKE, "EAP-%M method failed", eap_type_get_names, &vendor, type);
return NULL;
}
type = this->method->get_type(this->method, &vendor);
DBG1(DBG_IKE, "EAP-only authentication requires a mutual and "
"MSK deriving EAP method, but %M is not",
- eap_type_get_names, vendor, type);
+ eap_type_get_names, &vendor, type);
return FAILED;
}
return SUCCESS;
}
type = this->method->get_type(this->method, &vendor);
DBG1(DBG_IKE, "EAP method %M succeeded, %sMSK established",
- eap_type_get_names, vendor, type,
+ 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);
/**
* Forward declaration of enum name fallback callback.
*/
-static int eap_type_names_cb(printf_hook_data_t *data, int vendor,
- enum_name_t *e, int type);
+static int eap_type_names_cb(printf_hook_data_t *data, enum_name_t *e, int type,
+ void *vendor);
ENUM(eap_code_names, EAP_REQUEST, EAP_FAILURE,
"EAP_REQUEST",
/**
* Callback function if mapping EAP type to enum name failed
*/
-static int eap_type_names_cb(printf_hook_data_t *data, int vendor,
- enum_name_t *e, int type)
+static int eap_type_names_cb(printf_hook_data_t *data, enum_name_t *e, int type,
+ void *vendor)
{
- if (e == eap_type_short_names)
+ if (e == eap_type_short_names || !vendor)
{
return print_in_hook(data, "%d", type);
}
{
return print_in_hook(data, "MS-%d", type);
}
- return print_in_hook(data, "%d-%d", type, vendor);
+ return print_in_hook(data, "%d-%d", type, *(u_int32_t*)vendor);
}
/*
* See header
*/
-enum_name_t* eap_type_get_names(pen_t vendor)
+enum_name_t* eap_type_get_names(u_int32_t *vendor)
{
- switch (vendor)
+ switch (*vendor)
{
case PEN_IETF:
return eap_type_short_names;
/* check IETF and vendor specific names */
for (i = 0; i < countof(vendors); i++)
{
- enum_name = eap_type_get_names(vendors[i]);
+ enum_name = eap_type_get_names(&vendors[i]);
if (enum_name != eap_vendor_names_unknown)
{
type = enum_from_name(enum_name, name);
};
/**
- * Get the enum names for a specific vendor
+ * Get the enum names for a specific vendor, implementing enum_name_get_t.
+ *
+ * @param vendor pointer to vendor ID
+ * @return enum name for given vendor
*/
-enum_name_t* eap_type_get_names(pen_t vendor);
+enum_name_t* eap_type_get_names(u_int32_t *vendor);
/**
* EAP packet format
{
if (e->cb)
{
- return e->cb(data, 0, e, val);
+ return e->cb(data, e, val, NULL);
}
return print_in_hook(data, "(%d)", val);
}
{
enum_name_t *e;
enum_name_get_t e_get;
- int val, id = 0;
+ int val;
char *name = NULL;
+ void *user;
e_get = *((enum_name_get_t*)(args[0]));
- id = *((int*)(args[1]));
+ user = *((void**)(args[1]));
val = *((int*)(args[2]));
- e = e_get(id);
+ e = e_get(user);
if (e)
{
name = enum_to_name(e, val);
{
if (e && e->cb)
{
- return e->cb(data, id, e, val);
+ return e->cb(data, e, val, user);
}
return print_in_hook(data, "(%d)", val);
}
typedef struct enum_name_elem_t enum_name_elem_t;
/**
- * Callback function to get an enum name using an index variable.
+ * Callback function to get an enum name.
*
- * @param index variable to select enum_name_t
+ * @param user function specific pointer value to select enum name
* @return enum name
*/
-typedef enum_name_t* (*enum_name_get_t)(int id);
+typedef enum_name_t* (*enum_name_get_t)(void *user);
/**
* Fallback callback to call if enum could not be mapped to a string.
* with the supplied data to write to the output stream.
*
* @param data printf hook data to pass to print_in_hook()
- * @param id index variable, as passed to enum_name_get function, or 0
* @param e enum name for which callback is invoked
* @param val enum value to map
+ * @param user function specific pointer, as passed to enum_name_get_t
* @return number of characters written
*/
-typedef int (*enum_name_cb_t)(printf_hook_data_t *data, int id, enum_name_t *e,
- int val);
+typedef int (*enum_name_cb_t)(printf_hook_data_t *data, enum_name_t *e,
+ int val, void *user);
/**
* Struct to store names for enums.
*
* To select an enum name dynamically, the %M printf format specifier can be
* used. Instead of an enum_name_t, the printf hook expects a enum_name_get_t
- * followed by an index, followed by the enum value. The enum_name_t is looked
- * up using the function and the index argument.
+ * followed by a pointer, followed by the enum value. The enum_name_t is looked
+ * up using the function and the function specific pointer argument.
*/
struct enum_name_t {
/** first enum_name_elem_t in chain */
PRINTF_HOOK_ARGTYPE_POINTER, PRINTF_HOOK_ARGTYPE_INT,
PRINTF_HOOK_ARGTYPE_END);
pfh->add_handler(pfh, 'M', enum_dynamic_printf_hook,
- PRINTF_HOOK_ARGTYPE_POINTER, PRINTF_HOOK_ARGTYPE_INT,
+ PRINTF_HOOK_ARGTYPE_POINTER, PRINTF_HOOK_ARGTYPE_POINTER,
PRINTF_HOOK_ARGTYPE_INT, PRINTF_HOOK_ARGTYPE_END);
pfh->add_handler(pfh, 'T', time_printf_hook,
PRINTF_HOOK_ARGTYPE_POINTER, PRINTF_HOOK_ARGTYPE_INT,