mirror of
https://github.com/estkme-group/lpac
synced 2024-05-13 20:19:53 +02:00
update
This commit is contained in:
parent
c90607b225
commit
c33781300b
|
@ -313,7 +313,10 @@ int euicc_derutil_convert_long2bin(uint8_t *buffer, uint32_t *buffer_len, long v
|
|||
{
|
||||
if (value > 0)
|
||||
{
|
||||
required_len++;
|
||||
if ((value >> ((i - 1) * 8)) & 0x80)
|
||||
{
|
||||
required_len++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
182
euicc/es10b.c
182
euicc/es10b.c
|
@ -1255,7 +1255,7 @@ int es10b_get_rat(struct euicc_ctx *ctx, struct es10b_rat **ratList)
|
|||
n_profile.self.length = 0;
|
||||
|
||||
// ProfilePolicyAuthorisationRule
|
||||
while (euicc_derutil_unpack_next(&n_profile, &n_profile, tmpnode.value,tmpnode.length) == 0)
|
||||
while (euicc_derutil_unpack_next(&n_profile, &n_profile, tmpnode.value, tmpnode.length) == 0)
|
||||
{
|
||||
tmpchildnode.self.ptr = n_profile.value;
|
||||
tmpchildnode.self.length = 0;
|
||||
|
@ -1268,83 +1268,86 @@ int es10b_get_rat(struct euicc_ctx *ctx, struct es10b_rat **ratList)
|
|||
|
||||
memset(rat, 0, sizeof(*rat));
|
||||
|
||||
while (euicc_derutil_unpack_next(&tmpchildnode, &tmpchildnode, n_profile.value,n_profile.length) == 0)
|
||||
while (euicc_derutil_unpack_next(&tmpchildnode, &tmpchildnode, n_profile.value, n_profile.length) == 0)
|
||||
{
|
||||
switch (tmpchildnode.tag) {
|
||||
case 0x80: // ppr ids
|
||||
{
|
||||
static const char *desc[] = {"pprUpdateControl", "ppr1", "ppr2", "ppr3"};
|
||||
switch (tmpchildnode.tag)
|
||||
{
|
||||
case 0x80: // ppr ids
|
||||
{
|
||||
static const char *desc[] = {"pprUpdateControl", "ppr1", "ppr2", "ppr3", NULL};
|
||||
|
||||
if (euicc_derutil_convert_bin2bits_str(&rat->pprIds, tmpchildnode.value, tmpchildnode.length, desc))
|
||||
if (euicc_derutil_convert_bin2bits_str(&rat->pprIds, tmpchildnode.value, tmpchildnode.length, desc))
|
||||
{
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0xA1: // allowed operators
|
||||
{
|
||||
struct euicc_derutil_node n_allowed_operator, n_operator;
|
||||
struct es10b_operation_id *operations_wptr;
|
||||
struct es10b_operation_id *p;
|
||||
|
||||
n_allowed_operator.self.ptr = tmpchildnode.value;
|
||||
n_allowed_operator.self.length = 0;
|
||||
|
||||
while (euicc_derutil_unpack_next(&n_allowed_operator, &n_allowed_operator, tmpchildnode.value, tmpchildnode.length) == 0)
|
||||
{
|
||||
p = malloc(sizeof(struct es10b_operation_id));
|
||||
if (!p)
|
||||
{
|
||||
goto err;
|
||||
}
|
||||
memset(p, 0, sizeof(*p));
|
||||
|
||||
n_operator.self.ptr = n_allowed_operator.value;
|
||||
n_operator.self.length = 0;
|
||||
|
||||
while (euicc_derutil_unpack_next(&n_operator, &n_operator, n_allowed_operator.value, n_allowed_operator.length) == 0)
|
||||
{
|
||||
if (n_operator.length == 0)
|
||||
{
|
||||
goto err;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0xA1: // allowed operators
|
||||
{
|
||||
struct euicc_derutil_node n_allowed_operator, n_operator;
|
||||
struct es10b_operation_id *operations_wptr;
|
||||
struct es10b_operation_id *p;
|
||||
|
||||
n_allowed_operator.self.ptr = tmpchildnode.value;
|
||||
n_allowed_operator.self.length = 0;
|
||||
|
||||
while (euicc_derutil_unpack_next(&n_allowed_operator, &n_allowed_operator, tmpchildnode.value,tmpchildnode.length) == 0) {
|
||||
p = malloc(sizeof(struct es10b_operation_id));
|
||||
if (!p) {
|
||||
goto err;
|
||||
}
|
||||
memset(p, 0, sizeof(*p));
|
||||
|
||||
n_operator.self.ptr = n_allowed_operator.value;
|
||||
n_operator.self.length = 0;
|
||||
|
||||
while (euicc_derutil_unpack_next(&n_operator, &n_operator, n_allowed_operator.value, n_allowed_operator.length) == 0)
|
||||
{
|
||||
if (n_operator.length == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
switch (n_operator.tag)
|
||||
{
|
||||
case 0x80: // mcc_mnc
|
||||
p->plmn = malloc((n_operator.length * 2) + 1);
|
||||
euicc_hexutil_bin2hex(p->plmn, sizeof(p->plmn), n_operator.value, n_operator.length);
|
||||
break;
|
||||
case 0x81: // gid1
|
||||
p->gid1 = malloc((n_operator.length * 2) + 1);
|
||||
euicc_hexutil_bin2hex(p->gid1, sizeof(p->gid1), n_operator.value, n_operator.length);
|
||||
break;
|
||||
case 0x82: // gid2
|
||||
p->gid2 = malloc((n_operator.length * 2) + 1);
|
||||
euicc_hexutil_bin2hex(p->gid2, sizeof(p->gid2), n_operator.value, n_operator.length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (operations_wptr == NULL)
|
||||
{
|
||||
operations_wptr = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
operations_wptr->next = p;
|
||||
}
|
||||
}
|
||||
|
||||
rat->allowedOperators = operations_wptr;
|
||||
}
|
||||
break;
|
||||
case 0x82: // ppr flags
|
||||
{
|
||||
static const char *desc[] = {"consentRequired"};
|
||||
|
||||
if (euicc_derutil_convert_bin2bits_str(&rat->pprFlags, tmpchildnode.value, tmpchildnode.length, desc))
|
||||
switch (n_operator.tag)
|
||||
{
|
||||
goto err;
|
||||
case 0x80: // mcc_mnc
|
||||
p->plmn = malloc((n_operator.length * 2) + 1);
|
||||
euicc_hexutil_bin2hex(p->plmn, sizeof(p->plmn), n_operator.value, n_operator.length);
|
||||
break;
|
||||
case 0x81: // gid1
|
||||
p->gid1 = malloc((n_operator.length * 2) + 1);
|
||||
euicc_hexutil_bin2hex(p->gid1, sizeof(p->gid1), n_operator.value, n_operator.length);
|
||||
break;
|
||||
case 0x82: // gid2
|
||||
p->gid2 = malloc((n_operator.length * 2) + 1);
|
||||
euicc_hexutil_bin2hex(p->gid2, sizeof(p->gid2), n_operator.value, n_operator.length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (operations_wptr == NULL)
|
||||
{
|
||||
operations_wptr = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
operations_wptr->next = p;
|
||||
}
|
||||
}
|
||||
|
||||
rat->allowedOperators = operations_wptr;
|
||||
}
|
||||
break;
|
||||
case 0x82: // ppr flags
|
||||
{
|
||||
static const char *desc[] = {"consentRequired", NULL};
|
||||
|
||||
if (euicc_derutil_convert_bin2bits_str(&rat->pprFlags, tmpchildnode.value, tmpchildnode.length, desc))
|
||||
{
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1358,39 +1361,38 @@ int es10b_get_rat(struct euicc_ctx *ctx, struct es10b_rat **ratList)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
fret = 0;
|
||||
goto exit;
|
||||
err:
|
||||
fret = -1;
|
||||
es10b_get_rat_list_free_all(*ratList);
|
||||
es10b_rat_list_free_all(*ratList);
|
||||
*ratList = NULL;
|
||||
exit:
|
||||
free(respbuf);
|
||||
respbuf = NULL;
|
||||
return fret;
|
||||
}
|
||||
|
||||
void es10b_get_rat_list_free_all(struct es10b_rat *ratList) {
|
||||
struct es10b_rat *next;
|
||||
void es10b_rat_list_free_all(struct es10b_rat *ratList)
|
||||
{
|
||||
struct es10b_rat *next_rat;
|
||||
struct es10b_operation_id *next_operation_id;
|
||||
|
||||
while (ratList)
|
||||
{
|
||||
next = ratList->next;
|
||||
next_rat = ratList->next;
|
||||
free(ratList->pprIds);
|
||||
es10b_operation_id_free_all(ratList->allowedOperators);
|
||||
while (ratList->allowedOperators)
|
||||
{
|
||||
next_operation_id = ratList->allowedOperators->next;
|
||||
free(ratList->allowedOperators->plmn);
|
||||
free(ratList->allowedOperators->gid1);
|
||||
free(ratList->allowedOperators->gid2);
|
||||
free(ratList->allowedOperators);
|
||||
ratList->allowedOperators = next_operation_id;
|
||||
}
|
||||
free(ratList->pprFlags);
|
||||
free(ratList);
|
||||
ratList = next;
|
||||
ratList = next_rat;
|
||||
}
|
||||
}
|
||||
|
||||
void es10b_operation_id_free_all(const struct es10b_operation_id *operations) {
|
||||
struct es10b_operation_id *next;
|
||||
while (operations)
|
||||
{
|
||||
next = operations->next;
|
||||
free(operations->plmn);
|
||||
free(operations->gid1);
|
||||
free(operations->gid2);
|
||||
operations = next;
|
||||
}
|
||||
}
|
|
@ -112,18 +112,18 @@ struct es10b_cancel_session_param
|
|||
|
||||
struct es10b_rat
|
||||
{
|
||||
const char** pprIds;
|
||||
const struct es10b_operation_id* allowedOperators;
|
||||
const char** pprFlags;
|
||||
const char **pprIds;
|
||||
struct es10b_operation_id *allowedOperators;
|
||||
const char **pprFlags;
|
||||
|
||||
struct es10b_rat *next;
|
||||
};
|
||||
|
||||
struct es10b_operation_id
|
||||
{
|
||||
char* plmn;
|
||||
char* gid1;
|
||||
char* gid2;
|
||||
char *plmn;
|
||||
char *gid1;
|
||||
char *gid2;
|
||||
|
||||
struct es10b_operation_id *next;
|
||||
};
|
||||
|
@ -152,5 +152,4 @@ void es10b_notification_metadata_list_free_all(struct es10b_notification_metadat
|
|||
void es10b_pending_notification_free(struct es10b_pending_notification *PendingNotification);
|
||||
|
||||
int es10b_get_rat(struct euicc_ctx *ctx, struct es10b_rat **ratList);
|
||||
void es10b_get_rat_list_free_all(struct es10b_rat *ratList);
|
||||
void es10b_operation_id_free_all(const struct es10b_operation_id *operations);
|
||||
void es10b_rat_list_free_all(struct es10b_rat *ratList);
|
||||
|
|
|
@ -84,7 +84,7 @@ int es10c_ex_get_euiccinfo2(struct euicc_ctx *ctx, struct es10c_ex_euiccinfo2 *e
|
|||
break;
|
||||
case 0x85: // uiccCapability
|
||||
{
|
||||
static const char *desc[] = {"contactlessSupport", "usimSupport", "isimSupport", "csimSupport", "akaMilenage", "akaCave", "akaTuak128", "akaTuak256", "rfu1", "rfu2", "gbaAuthenUsim", "gbaAuthenISim", "mbmsAuthenUsim", "eapClient", "javacard", "multos", "multipleUsimSupport", "multipleIsimSupport", "multipleCsimSupport"};
|
||||
static const char *desc[] = {"contactlessSupport", "usimSupport", "isimSupport", "csimSupport", "akaMilenage", "akaCave", "akaTuak128", "akaTuak256", "rfu1", "rfu2", "gbaAuthenUsim", "gbaAuthenISim", "mbmsAuthenUsim", "eapClient", "javacard", "multos", "multipleUsimSupport", "multipleIsimSupport", "multipleCsimSupport", NULL};
|
||||
|
||||
if (euicc_derutil_convert_bin2bits_str(&euiccinfo2->uiccCapability, tmpnode.value, tmpnode.length, desc))
|
||||
{
|
||||
|
@ -100,7 +100,7 @@ int es10c_ex_get_euiccinfo2(struct euicc_ctx *ctx, struct es10c_ex_euiccinfo2 *e
|
|||
break;
|
||||
case 0x88: // rspCapability
|
||||
{
|
||||
static const char *desc[] = {"additionalProfile", "crlSupport", "rpmSupport", "testProfileSupport"};
|
||||
static const char *desc[] = {"additionalProfile", "crlSupport", "rpmSupport", "testProfileSupport", NULL};
|
||||
|
||||
if (euicc_derutil_convert_bin2bits_str(&euiccinfo2->rspCapability, tmpnode.value, tmpnode.length, desc))
|
||||
{
|
||||
|
@ -202,7 +202,7 @@ int es10c_ex_get_euiccinfo2(struct euicc_ctx *ctx, struct es10c_ex_euiccinfo2 *e
|
|||
break;
|
||||
case 0x99: // forbiddenProfilePolicyRules
|
||||
{
|
||||
static const char *desc[] = {"pprUpdateControl", "ppr1", "ppr2", "ppr3"};
|
||||
static const char *desc[] = {"pprUpdateControl", "ppr1", "ppr2", "ppr3", NULL};
|
||||
|
||||
if (euicc_derutil_convert_bin2bits_str(&euiccinfo2->forbiddenProfilePolicyRules, tmpnode.value, tmpnode.length, desc))
|
||||
{
|
||||
|
|
|
@ -51,49 +51,6 @@ static int applet_main(int argc, char **argv)
|
|||
cJSON_AddItemToObject(jdata, "EuiccConfiguredAddresses", jaddresses);
|
||||
es10a_euicc_configured_addresses_free(&addresses);
|
||||
|
||||
if (jratList)
|
||||
{
|
||||
while (ratList) {
|
||||
struct cJSON *jrat = cJSON_CreateObject();
|
||||
if (ratList->pprIds)
|
||||
{
|
||||
cJSON *jPPR = cJSON_CreateArray();
|
||||
for (int i = 0; ratList->pprIds[i] != NULL; i++)
|
||||
{
|
||||
cJSON_AddItemToArray(jPPR, cJSON_CreateString(ratList->pprIds[i]));
|
||||
}
|
||||
cJSON_AddItemToObject(jrat, "pprIds", jPPR);
|
||||
}
|
||||
if (ratList->allowedOperators)
|
||||
{
|
||||
cJSON *jAllowedOperators = cJSON_CreateArray();
|
||||
const struct es10b_operation_id *rptr = ratList->allowedOperators;
|
||||
while (rptr)
|
||||
{
|
||||
cJSON *joperator = cJSON_CreateObject();
|
||||
cJSON_AddStringOrNullToObject(joperator, "plmn", rptr->plmn);
|
||||
cJSON_AddStringOrNullToObject(joperator, "gid1", rptr->gid1);
|
||||
cJSON_AddStringOrNullToObject(joperator, "gid2", rptr->gid2);
|
||||
cJSON_AddItemToArray(jAllowedOperators, joperator);
|
||||
rptr = rptr->next;
|
||||
}
|
||||
cJSON_AddItemToObject(jrat, "allowedOperators", jAllowedOperators);
|
||||
}
|
||||
if (ratList->pprFlags)
|
||||
{
|
||||
cJSON *jFlags = cJSON_CreateArray();
|
||||
for (int i = 0; ratList->pprFlags[i] != NULL; i++)
|
||||
{
|
||||
cJSON_AddItemToArray(jFlags, cJSON_CreateString(ratList->pprFlags[i]));
|
||||
}
|
||||
cJSON_AddItemToObject(jrat, "pprFlags", jFlags);
|
||||
}
|
||||
cJSON_AddItemToArray(jratList, jrat);
|
||||
ratList = ratList->next;
|
||||
}
|
||||
cJSON_AddItemToObject(jdata, "rulesAuthorisationTable", jratList);
|
||||
}
|
||||
|
||||
if (jeuiccinfo2)
|
||||
{
|
||||
cJSON_AddStringOrNullToObject(jeuiccinfo2, "profileVersion", euiccinfo2.profileVersion);
|
||||
|
@ -170,6 +127,50 @@ static int applet_main(int argc, char **argv)
|
|||
}
|
||||
cJSON_AddItemToObject(jdata, "EUICCInfo2", jeuiccinfo2);
|
||||
|
||||
if (jratList)
|
||||
{
|
||||
while (ratList) {
|
||||
struct cJSON *jrat = cJSON_CreateObject();
|
||||
if (ratList->pprIds)
|
||||
{
|
||||
cJSON *jPPR = cJSON_CreateArray();
|
||||
for (int i = 0; ratList->pprIds[i] != NULL; i++)
|
||||
{
|
||||
cJSON_AddItemToArray(jPPR, cJSON_CreateString(ratList->pprIds[i]));
|
||||
}
|
||||
cJSON_AddItemToObject(jrat, "pprIds", jPPR);
|
||||
}
|
||||
if (ratList->allowedOperators)
|
||||
{
|
||||
cJSON *jAllowedOperators = cJSON_CreateArray();
|
||||
const struct es10b_operation_id *rptr = ratList->allowedOperators;
|
||||
while (rptr)
|
||||
{
|
||||
cJSON *joperator = cJSON_CreateObject();
|
||||
cJSON_AddStringOrNullToObject(joperator, "plmn", rptr->plmn);
|
||||
cJSON_AddStringOrNullToObject(joperator, "gid1", rptr->gid1);
|
||||
cJSON_AddStringOrNullToObject(joperator, "gid2", rptr->gid2);
|
||||
cJSON_AddItemToArray(jAllowedOperators, joperator);
|
||||
rptr = rptr->next;
|
||||
}
|
||||
cJSON_AddItemToObject(jrat, "allowedOperators", jAllowedOperators);
|
||||
}
|
||||
if (ratList->pprFlags)
|
||||
{
|
||||
cJSON *jFlags = cJSON_CreateArray();
|
||||
for (int i = 0; ratList->pprFlags[i] != NULL; i++)
|
||||
{
|
||||
cJSON_AddItemToArray(jFlags, cJSON_CreateString(ratList->pprFlags[i]));
|
||||
}
|
||||
cJSON_AddItemToObject(jrat, "pprFlags", jFlags);
|
||||
}
|
||||
cJSON_AddItemToArray(jratList, jrat);
|
||||
ratList = ratList->next;
|
||||
}
|
||||
cJSON_AddItemToObject(jdata, "rulesAuthorisationTable", jratList);
|
||||
es10b_rat_list_free_all(ratList);
|
||||
}
|
||||
|
||||
jprint_success(jdata);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue