jolly has uploaded this change for review.
Add option to forbid polling given eIM(s)
An eUICC may have eIM configuration data of one or more eIMs that cannot
be removed. Prevent polling theses eIMs by adding an option that blocks
one or multiple eIM IDs.
Related: SYS#8101
Change-Id: Ic6489207e54cdfff57cd214482ac4a071e154c94
---
M include/onomondo/ipa/ipad.h
M src/ipa/libipa/ipad.c
M src/ipa/main.c
3 files changed, 37 insertions(+), 9 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/onomondo-ipa refs/changes/05/43705/1
diff --git a/include/onomondo/ipa/ipad.h b/include/onomondo/ipa/ipad.h
index af8de91..4aecb65 100644
--- a/include/onomondo/ipa/ipad.h
+++ b/include/onomondo/ipa/ipad.h
@@ -12,6 +12,7 @@
#define IPA_LEN_TAC 4
#define IPA_LEN_ALLOWED_CA 20
#define IPE_LEN_EIM_ID 256
+#define IPA_MAX_FORBIDDEN_IDS 5
struct ipa_context;
struct ipa_buf;
@@ -45,6 +46,8 @@
* used.) */
char *preferred_eim_id;
+ char *forbidden_eim_ids[IPA_MAX_FORBIDDEN_IDS];
+
/*! force the IPAd to process only one eUICC package (debug, use with caution) */
bool one_euicc_pkg_only;
diff --git a/src/ipa/libipa/ipad.c b/src/ipa/libipa/ipad.c
index fa91961..00ac9b3 100644
--- a/src/ipa/libipa/ipad.c
+++ b/src/ipa/libipa/ipad.c
@@ -354,7 +354,7 @@
return -EINVAL;
}
-static int eim_init(struct ipa_context *ctx, int index)
+static int eim_init(struct ipa_context *ctx, int *index)
{
struct ipa_es10b_eim_cfg_data *eim_cfg_data = NULL;
struct EimConfigurationData *eim_cfg_data_item = NULL;
@@ -366,12 +366,27 @@
goto error;
}
- /* In case no preferred_eim_id is set, the eIM configuration item of the given index will be pulled from the list */
- rc = ipa_es10b_get_eim_cfg_data_filter(&eim_cfg_data_item, eim_cfg_data, ctx->cfg->preferred_eim_id, index);
- if (rc) {
- if (rc != -ENOENT)
- IPA_LOGP(SIPA, LERROR, "no suitable EimConfigurationData item present.\n");
- goto error;
+ while (1) {
+ /* In case no preferred_eim_id is set, the eIM configuration item of the given index will be pulled from the list */
+ rc = ipa_es10b_get_eim_cfg_data_filter(&eim_cfg_data_item, eim_cfg_data, ctx->cfg->preferred_eim_id, (*index));
+ if (rc) {
+ if (rc != -ENOENT)
+ IPA_LOGP(SIPA, LERROR, "no suitable EimConfigurationData item present.\n");
+ goto error;
+ }
+ /* Skip blocked eIM IDs. Increment index in this case. */
+ if (!ctx->cfg->preferred_eim_id || ctx->cfg->preferred_eim_id[0] == '\0') {
+ int i;
+ const char *eim_id;
+
+ for (i = 0; (eim_id = ctx->cfg->forbidden_eim_ids[i]) && i < IPA_MAX_FORBIDDEN_IDS; i++) {
+ if (IPA_ASN_STR_CMP_BUF(&eim_cfg_data_item->eimId, eim_id, strlen(eim_id))) {
+ (*index)++;
+ continue;
+ }
+ }
+ }
+ break;
}
IPA_FREE(ctx->eim_id);
@@ -506,7 +521,7 @@
/* Loop through all eIM, if no preferred eIM ID is specified. */
for (index = 0; ; index++) {
IPA_LOGP(SIPA, LINFO, "-----------------------------8<-----------------------------\n");
- rc = eim_init(ctx, index);
+ rc = eim_init(ctx, &index);
if (rc < 0) {
if (rc == -ENOENT) {
IPA_LOGP(SIPA, LINFO, "all eIMs polled!\n");
diff --git a/src/ipa/main.c b/src/ipa/main.c
index 183a584..e36b529 100644
--- a/src/ipa/main.c
+++ b/src/ipa/main.c
@@ -45,6 +45,7 @@
printf(" -h .......................... print this text.\n");
printf(" -t TAC ...................... set TAC (default: %s)\n", DEFAULT_TAC);
printf(" -e eimId .................... set preferred eIM (in case the eUICC has multiple)\n");
+ printf(" -f eimId .................... set forbidden eIMs (may call this option multiple times)\n");
printf(" -r N ........................ set reader number (default: %d)\n", DEFAULT_READER_NUMBER);
printf(" -c N ........................ set logical channel number (default: %d)\n", DEFAULT_CHANNEL_NUMBER);
printf(" -R .......................... Make eUICC send a CAT refresh after switching profile\n");
@@ -152,6 +153,7 @@
char *getopt_nvstate_path = DEFAULT_NVSTATE_PATH;
struct ipa_buf *nvstate_load = NULL;
struct ipa_buf *nvstate_save = NULL;
+ int forbidden_eim_index = 0;
signal(SIGUSR1, sig_usr1);
@@ -165,7 +167,7 @@
/* Overwrite configuration values with user defined parameters */
while (1) {
- opt = getopt(argc, argv, "ht:e:r:c:Rn:C:SIEy:a1D:");
+ opt = getopt(argc, argv, "ht:e:f:r:c:Rn:C:SIEy:a1D:");
if (opt == -1)
break;
@@ -180,6 +182,14 @@
case 'e':
cfg.preferred_eim_id = optarg;
break;
+ case 'f':
+ if (forbidden_eim_index == IPA_MAX_FORBIDDEN_IDS) {
+ printf("Too many forbidden eIM IDs given!\n");
+ opt = -1;
+ break;
+ }
+ cfg.forbidden_eim_ids[forbidden_eim_index++] = optarg;
+ break;
case 'r':
cfg.reader_num = atoi(optarg);
break;
To view, visit change 43705. To unsubscribe, or for help writing mail filters, visit settings.