return "eap-sim-file";
}
+/**
+ * Load triplet file
+ */
+static bool load_triplets(private_eap_sim_file_t *this,
+ plugin_feature_t *feature, bool reg, void *data)
+{
+ if (reg)
+ {
+ this->triplets = eap_sim_file_triplets_create(TRIPLET_FILE);
+ if (!this->triplets)
+ {
+ return FALSE;
+ }
+ this->provider = eap_sim_file_provider_create(this->triplets);
+ this->card = eap_sim_file_card_create(this->triplets);
+ return TRUE;
+ }
+ this->card->destroy(this->card);
+ this->provider->destroy(this->provider);
+ this->triplets->destroy(this->triplets);
+ this->card = NULL;
+ this->provider = NULL;
+ this->triplets = NULL;
+ return TRUE;
+}
+
/**
* Callback providing our card to register
*/
private_eap_sim_file_t *this, plugin_feature_t *features[])
{
static plugin_feature_t f[] = {
+ PLUGIN_CALLBACK((void*)load_triplets, NULL),
+ PLUGIN_PROVIDE(CUSTOM, "eap-sim-file-triplets"),
PLUGIN_CALLBACK(simaka_manager_register, get_card),
PLUGIN_PROVIDE(CUSTOM, "sim-card"),
PLUGIN_DEPENDS(CUSTOM, "sim-manager"),
+ PLUGIN_DEPENDS(CUSTOM, "eap-sim-file-triplets"),
PLUGIN_CALLBACK(simaka_manager_register, get_provider),
PLUGIN_PROVIDE(CUSTOM, "sim-provider"),
PLUGIN_DEPENDS(CUSTOM, "sim-manager"),
+ PLUGIN_DEPENDS(CUSTOM, "eap-sim-file-triplets"),
};
*features = f;
return countof(f);
METHOD(plugin_t, destroy, void,
private_eap_sim_file_t *this)
{
- this->card->destroy(this->card);
- this->provider->destroy(this->provider);
- this->triplets->destroy(this->triplets);
free(this);
}
.destroy = _destroy,
},
},
- .triplets = eap_sim_file_triplets_create(TRIPLET_FILE),
);
- this->provider = eap_sim_file_provider_create(this->triplets);
- this->card = eap_sim_file_card_create(this->triplets);
return &this->public.plugin;
}
/**
* Read the triplets from the file
*/
-static void read_triplets(private_eap_sim_file_triplets_t *this, char *path)
+static bool read_triplets(private_eap_sim_file_triplets_t *this, char *path)
{
char line[512];
FILE *file;
{
DBG1(DBG_CFG, "opening triplet file %s failed: %s",
path, strerror(errno));
- return;
+ return FALSE;
}
/* read line by line */
DBG1(DBG_CFG, "read %d triplets from %s",
this->triplets->get_count(this->triplets), path);
+ return TRUE;
}
METHOD(eap_sim_file_triplets_t, destroy, void,
.triplets = linked_list_create(),
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
);
- read_triplets(this, file);
+ if (!read_triplets(this, file))
+ {
+ destroy(this);
+ return NULL;
+ }
return &this->public;
}