diff simtool/hlread.c @ 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 90eff13a72fd
line wrap: on
line diff
--- 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);
+}