Skip to content

Commit

Permalink
update debug env
Browse files Browse the repository at this point in the history
  • Loading branch information
estkme committed Dec 7, 2023
1 parent 743969a commit 4d811eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 9 additions & 4 deletions euicc/es9p.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@ static int es9p_trans_ex(struct euicc_ctx *ctx, const char *url, const char *url
strcat(full_url, url_prefix);
strcat(full_url, url);
strcat(full_url, url_postfix);
// printf("url: %s\n", full_url);
// printf("tx: %s\n", str_tx);

if (getenv("LIBEUICC_DEBUG_HTTP"))
{
fprintf(stderr, "[DEBUG] [HTTP] [TX] url: %s, data: %s\n", full_url, str_tx);
}
if (ctx->interface.http->transmit(ctx, full_url, &rcode_mearged, &rbuf, &rlen, str_tx, strlen(str_tx), lpa_header) < 0)
{
goto err;
}
// printf("rcode: %d\n", rcode_mearged);
// printf("rx: %s\n", rbuf);
if (getenv("LIBEUICC_DEBUG_HTTP"))
{
fprintf(stderr, "[DEBUG] [HTTP] [RX] rcode: %d, data: %s\n", rcode_mearged, rbuf);
}

free(full_url);
full_url = NULL;
Expand Down
8 changes: 6 additions & 2 deletions euicc/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ int euicc_apdu_le(struct euicc_ctx *ctx, struct apdu_request **apdu, uint8_t cla

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);
fprintf(stderr, "[DEBUG] [APDU] [TX] 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);
fprintf(stderr, "[DEBUG] [APDU] [RX] 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");
Expand All @@ -61,7 +61,9 @@ int euicc_apdu_transmit(struct euicc_ctx *ctx, struct apdu_response *response, c
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)
return -1;
Expand All @@ -74,7 +76,9 @@ int euicc_apdu_transmit(struct euicc_ctx *ctx, struct apdu_response *response, c
response->length -= 2;

if (getenv("LIBEUICC_DEBUG_APDU"))
{
euicc_apdu_response_print(response);
}

return 0;
}
Expand Down

0 comments on commit 4d811eb

Please sign in to comment.