mirror of
https://github.com/estkme-group/lpac
synced 2024-08-16 06:40:52 +02:00
Add debug env
This commit is contained in:
parent
9abef2c9dc
commit
743969ab06
|
@ -38,12 +38,31 @@ int euicc_apdu_le(struct euicc_ctx *ctx, struct apdu_request **apdu, uint8_t cla
|
||||||
return le(*apdu, cla, ins, p1, p2, requestlen);
|
return le(*apdu, cla, ins, p1, p2, requestlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void euicc_apdu_request_print(const struct apdu_request *req, uint32_t request_len)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "[DEBUG] [REQ] CLA: %02X, INS: %02X, P1: %02X, P2: %02X, Lc: %02X, Data: ", req->cla, req->ins, req->p1, req->p2, req->length);
|
||||||
|
for (int i = 0; i < (request_len - sizeof(struct apdu_request)); i++)
|
||||||
|
fprintf(stderr, "%02X ", req->data[i]);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void euicc_apdu_response_print(const struct apdu_response *resp)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "[DEBUG] [RES] SW1: %02X, SW2: %02X, Data: ", resp->sw1, resp->sw2);
|
||||||
|
for (int i = 0; i < resp->length; i++)
|
||||||
|
fprintf(stderr, "%02X ", resp->data[i]);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
int euicc_apdu_transmit(struct euicc_ctx *ctx, struct apdu_response *response, const struct apdu_request *request, uint32_t request_len)
|
int euicc_apdu_transmit(struct euicc_ctx *ctx, struct apdu_response *response, const struct apdu_request *request, uint32_t request_len)
|
||||||
{
|
{
|
||||||
struct euicc_apdu_interface *in = ctx->interface.apdu;
|
struct euicc_apdu_interface *in = ctx->interface.apdu;
|
||||||
|
|
||||||
memset(response, 0x00, sizeof(*response));
|
memset(response, 0x00, sizeof(*response));
|
||||||
|
|
||||||
|
if (getenv("LIBEUICC_DEBUG_APDU"))
|
||||||
|
euicc_apdu_request_print(request, request_len);
|
||||||
|
|
||||||
if (in->transmit(ctx, &response->data, &response->length, (uint8_t *)request, request_len) < 0)
|
if (in->transmit(ctx, &response->data, &response->length, (uint8_t *)request, request_len) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -54,6 +73,9 @@ int euicc_apdu_transmit(struct euicc_ctx *ctx, struct apdu_response *response, c
|
||||||
response->sw2 = response->data[response->length - 1];
|
response->sw2 = response->data[response->length - 1];
|
||||||
response->length -= 2;
|
response->length -= 2;
|
||||||
|
|
||||||
|
if (getenv("LIBEUICC_DEBUG_APDU"))
|
||||||
|
euicc_apdu_response_print(response);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,19 +85,3 @@ void euicc_apdu_response_free(struct apdu_response *resp)
|
||||||
resp->data = NULL;
|
resp->data = NULL;
|
||||||
resp->length = 0;
|
resp->length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void euicc_apdu_request_print(struct apdu_request *req)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "CLA: %02X, INS: %02X, P1: %02X, P2: %02X, Lc: %02X, Data: ", req->cla, req->ins, req->p1, req->p2, req->length);
|
|
||||||
for (int i = 0; i < req->length; i++)
|
|
||||||
fprintf(stderr, "%02X ", req->data[i]);
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void euicc_apdu_response_print(struct apdu_response *resp)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "SW1: %02X, SW2: %02X, Data: ", resp->sw1, resp->sw2);
|
|
||||||
for (int i = 0; i < resp->length; i++)
|
|
||||||
fprintf(stderr, "%02X ", resp->data[i]);
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
}
|
|
||||||
|
|
|
@ -32,5 +32,3 @@ int euicc_apdu_lc(struct euicc_ctx *ctx, struct apdu_request **apdu, uint8_t cla
|
||||||
int euicc_apdu_le(struct euicc_ctx *ctx, struct apdu_request **apdu, uint8_t cla, uint8_t ins, uint8_t p1, uint8_t p2, uint8_t requestlen);
|
int euicc_apdu_le(struct euicc_ctx *ctx, struct apdu_request **apdu, uint8_t cla, uint8_t ins, uint8_t p1, uint8_t p2, uint8_t requestlen);
|
||||||
int euicc_apdu_transmit(struct euicc_ctx *ctx, struct apdu_response *response, const struct apdu_request *req, uint32_t req_len);
|
int euicc_apdu_transmit(struct euicc_ctx *ctx, struct apdu_response *response, const struct apdu_request *req, uint32_t req_len);
|
||||||
void euicc_apdu_response_free(struct apdu_response *resp);
|
void euicc_apdu_response_free(struct apdu_response *resp);
|
||||||
void euicc_apdu_request_print(struct apdu_request *req);
|
|
||||||
void euicc_apdu_response_print(struct apdu_response *resp);
|
|
||||||
|
|
Loading…
Reference in a new issue