FreeCalypso > hg > freecalypso-hwlab
changeset 97:597c4e87a1f4
fc-simtool: imsi high-level read command implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 24 Jan 2021 22:16:33 +0000 |
parents | a5dfab380a90 |
children | 66c0cb0e9876 |
files | simtool/dispatch.c simtool/hlread.c |
diffstat | 2 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/simtool/dispatch.c Sun Jan 24 22:11:34 2021 +0000 +++ b/simtool/dispatch.c Sun Jan 24 22:16:33 2021 +0000 @@ -13,6 +13,7 @@ #include "globals.h" extern int cmd_iccid(); +extern int cmd_imsi(); extern int cmd_readbin(); extern int cmd_readef(); extern int cmd_readrec(); @@ -35,6 +36,7 @@ } cmdtab[] = { {"exit", 0, 0, cmd_exit}, {"iccid", 0, 0, cmd_iccid}, + {"imsi", 0, 0, cmd_imsi}, {"quit", 0, 0, cmd_exit}, {"readbin", 2, 2, cmd_readbin}, {"readef", 1, 1, cmd_readef},
--- a/simtool/hlread.c Sun Jan 24 22:11:34 2021 +0000 +++ b/simtool/hlread.c Sun Jan 24 22:16:33 2021 +0000 @@ -65,3 +65,30 @@ printf("%s\n", buf); return(0); } + +cmd_imsi() +{ + int rc; + char buf[17]; + + rc = select_op(DF_GSM); + if (rc < 0) + return(rc); + rc = select_op(EF_IMSI); + if (rc < 0) + return(rc); + rc = parse_ef_select_response(); + if (rc < 0) + return(rc); + if (curfile_structure != 0x00 || curfile_total_size != 9) { + fprintf(stderr, "error: expected transparent EF of 9 bytes\n"); + return(-1); + } + rc = readbin_op(0, 9); + if (rc < 0) + return(rc); + decode_reversed_nibbles(sim_resp_data + 1, 8, buf); + buf[16] = '\0'; + printf("%s parity=%c len=%u\n", buf + 1, buf[0], sim_resp_data[0]); + return(0); +}