Esempio n. 1
0
/* ------------------------------------------------------------------------------------
 ------------------------------------------------------------------------------------ */
static int
EAPAKALoad (void)
{
    EAPClientModuleStatus status;
	
	if (eapRef)
		return EAP_NO_ERROR;
	
	status = EAPClientModuleAddBuiltinModule(eapaka_introspect);
	if (status != kEAPClientModuleStatusOK) {
		plog(ASL_LEVEL_INFO, "EAP-AKA: EAPClientAddBuiltinModule(eapaka) failed %d\n", status);
		return EAP_ERROR_GENERIC;
	}
	
	eapRef = EAPClientModuleLookup(kEAPTypeEAPAKA);
	if (eapRef == NULL) {
		plog(ASL_LEVEL_INFO, "EAP-AKA: EAPClientModuleLookup(eapaka) failed\n");
		return EAP_ERROR_GENERIC;
	}
	
	return EAP_NO_ERROR;
}
Esempio n. 2
0
EAPClientModuleStatus
EAPClientModuleAddBuiltinModule(EAPClientPluginFuncIntrospect * func)
{
    EAPType			eap_type;
    const char *		eap_name;
    EAPClientInfoRef		info = NULL;
    EAPClientPluginFuncEAPName *name_func;
    EAPClientModuleStatus	status = kEAPClientModuleStatusOK;
    EAPClientPluginFuncEAPType *type_func;

    EAPClientModuleInit();
    type_func = (EAPClientPluginFuncEAPType *)
	(*func)(kEAPClientPluginFuncNameEAPType);
    if (type_func == NULL) {
	status = kEAPClientModuleStatusPluginIncomplete;
	goto failed;
    }
    name_func = (EAPClientPluginFuncEAPName *)
	(*func)(kEAPClientPluginFuncNameEAPName);
    if (name_func == NULL) {
	status = kEAPClientModuleStatusPluginIncomplete;
	goto failed;
    }
    eap_type = (*type_func)();
    if (eap_type <= 0 || eap_type > 255) {
	status = kEAPClientModuleStatusInvalidType;
	goto failed;
    }
    eap_name = (*name_func)();
    if (eap_name == NULL) {
	status = kEAPClientModuleStatusPluginIncomplete;
	goto failed;
    }
    if (EAPClientModuleLookup(eap_type)) {
	status = kEAPClientModuleStatusTypeAlreadyLoaded;
	goto failed;
    }
    info = malloc(sizeof(*info));
    if (info == NULL) {
	status = kEAPClientModuleStatusAllocationFailed;
	goto failed;
    }
    bzero(info, sizeof(*info));
    info->eap_type = eap_type;
    info->eap_name = eap_name;
    info->introspect = (EAPClientPluginFuncIntrospect *)
	(*func)(kEAPClientPluginFuncNameIntrospect);
    info->init = (EAPClientPluginFuncInit *)
	(*func)(kEAPClientPluginFuncNameInit);
    info->version = (EAPClientPluginFuncVersion *)
	(*func)(kEAPClientPluginFuncNameVersion);
    info->free = (EAPClientPluginFuncFree *)
	(*func)(kEAPClientPluginFuncNameFree);
    info->process = (EAPClientPluginFuncProcess *)
	(*func)(kEAPClientPluginFuncNameProcess);
    info->free_packet = (EAPClientPluginFuncFreePacket *)
	(*func)(kEAPClientPluginFuncNameFreePacket);
    info->failure_string = (EAPClientPluginFuncFailureString *)
	(*func)(kEAPClientPluginFuncNameFailureString);
    info->session_key = (EAPClientPluginFuncSessionKey *)
	(*func)(kEAPClientPluginFuncNameSessionKey);
    info->server_key = (EAPClientPluginFuncServerKey *)
	(*func)(kEAPClientPluginFuncNameServerKey);
    info->msk_copy_bytes = (EAPClientPluginFuncMasterSessionKeyCopyBytes *)
	(*func)(kEAPClientPluginFuncNameMasterSessionKeyCopyBytes);
    info->require_properties = (EAPClientPluginFuncRequireProperties *)
	(*func)(kEAPClientPluginFuncNameRequireProperties);
    info->publish_properties = (EAPClientPluginFuncPublishProperties *)
	(*func)(kEAPClientPluginFuncNamePublishProperties);
    info->packet_dump = (EAPClientPluginFuncPacketDump *)
	(*func)(kEAPClientPluginFuncNamePacketDump);
    info->user_name = (EAPClientPluginFuncUserName *)
	(*func)(kEAPClientPluginFuncNameUserName);
    info->copy_identity = (EAPClientPluginFuncCopyIdentity *)
	(*func)(kEAPClientPluginFuncNameCopyIdentity);
    info->copy_packet_description = (EAPClientPluginFuncCopyPacketDescription *)
	(*func)(kEAPClientPluginFuncNameCopyPacketDescription);
    status = EAPClientModuleValidatePlugin(info);
    if (status != kEAPClientModuleStatusOK) {
	goto failed;
    }
    status = EAPClientModuleAdd(info);
    if (status != kEAPClientModuleStatusOK) {
	goto failed;
    }
    return (status);

 failed:
    if (info != NULL) {
	free (info);
    }
    return (status);
}