Skip to content

Commit c0f585f

Browse files
authored
feat(euicc): return the ICCID in the result of load_bound_profile_package (#420)
1 parent aac8c81 commit c0f585f

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

euicc/es10b.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,14 @@ static int es10b_load_bound_profile_package_tx(struct euicc_ctx *ctx,
172172
result->seqNumber = 0;
173173
result->bppCommandId = ES10B_BPP_COMMAND_ID_UNDEFINED;
174174
result->errorReason = ES10B_ERROR_REASON_UNDEFINED;
175+
result->iccid = NULL;
175176

176177
if (es10x_command(ctx, &respbuf, &resplen, reqbuf, reqbuf_len) < 0) {
177178
goto err;
178179
}
179180

180181
if (resplen > 0) {
181-
struct euicc_derutil_node tmpnode, n_notificationMetadata, n_sequenceNumber, n_finalResult;
182+
struct euicc_derutil_node tmpnode, n_notificationMetadata, n_sequenceNumber, n_iccid, n_finalResult;
182183

183184
if (euicc_derutil_unpack_find_tag(&tmpnode, 0xBF37, respbuf, resplen) < 0) // ProfileInstallationResult
184185
{
@@ -213,6 +214,18 @@ static int es10b_load_bound_profile_package_tx(struct euicc_ctx *ctx,
213214
result->seqNumber = euicc_derutil_convert_bin2long(n_sequenceNumber.value, n_sequenceNumber.length);
214215
}
215216

217+
if (euicc_derutil_unpack_find_tag(&n_iccid, 0x5A, n_notificationMetadata.value, n_notificationMetadata.length)
218+
== 0) {
219+
result->iccid = malloc((n_iccid.length * 2) + 1);
220+
if (result->iccid) {
221+
if (euicc_hexutil_bin2gsmbcd(result->iccid, (n_iccid.length * 2) + 1, n_iccid.value, n_iccid.length)
222+
< 0) {
223+
free(result->iccid);
224+
result->iccid = NULL;
225+
}
226+
}
227+
}
228+
216229
switch (n_finalResult.tag) {
217230
case 0xA0: // SuccessResult
218231
break;

euicc/es10b.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ enum es10b_cancel_session_reason {
5959

6060
struct es10b_load_bound_profile_package_result {
6161
unsigned long seqNumber;
62+
char *iccid;
6263
enum es10b_bpp_command_id bppCommandId;
6364
enum es10b_error_reason errorReason;
6465
};

src/applet/profile/download.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ static cJSON *build_download_result_json(const struct es10b_load_bound_profile_p
6060
return NULL;
6161
}
6262
cJSON_AddNumberToObject(jdata, "seqNumber", (double)result->seqNumber);
63+
cJSON_AddStringOrNullToObject(jdata, "iccid", result->iccid);
6364
cJSON_AddStringToObject(jdata, "bppCommandId", euicc_bppcommandid2str(result->bppCommandId));
6465
cJSON_AddStringToObject(jdata, "errorReason", euicc_errorreason2str(result->errorReason));
6566
return jdata;

0 commit comments

Comments
 (0)