changeset 94:3d9c50880ae7

fc-simtool fetch command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 21 Apr 2021 05:50:45 +0000
parents 6041c601304d
children c06c0e2da24c
files simtool/cmdtab.c simtool/stktest.c
diffstat 2 files changed, 34 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/cmdtab.c	Wed Apr 21 05:38:39 2021 +0000
+++ b/simtool/cmdtab.c	Wed Apr 21 05:50:45 2021 +0000
@@ -21,6 +21,7 @@
 extern int cmd_erase_file();
 extern int cmd_exec();
 extern int cmd_exit();
+extern int cmd_fetch();
 extern int cmd_fix_sysmo_msisdn();
 extern int cmd_fplmn_dump();
 extern int cmd_fplmn_erase();
@@ -150,6 +151,7 @@
 	{"erase-file", 1, 2, 0, cmd_erase_file},
 	{"exec", 1, 1, 0, cmd_exec},
 	{"exit", 0, 1, 0, cmd_exit},
+	{"fetch", 1, 1, 1, cmd_fetch},
 	{"fix-sysmo-msisdn", 0, 0, 0, cmd_fix_sysmo_msisdn},
 	{"fplmn-dump", 0, 0, 1, cmd_fplmn_dump},
 	{"fplmn-erase", 1, 2, 0, cmd_fplmn_erase},
--- a/simtool/stktest.c	Wed Apr 21 05:38:39 2021 +0000
+++ b/simtool/stktest.c	Wed Apr 21 05:50:45 2021 +0000
@@ -1,6 +1,7 @@
 /*
  * This module implements some commands for testing SIM Toolkit functionality,
- * just enough to be able to simulate SMS-PP SIM data download operations.
+ * initially just enough to be able to simulate SMS-PP SIM data download
+ * operations, but now also extending into basic exploration of proactive SIMs.
  */
 
 #include <sys/types.h>
@@ -79,3 +80,33 @@
 	printf("%04X\n", sim_resp_sw);
 	return(0);
 }
+
+cmd_fetch(argc, argv, outf)
+	char **argv;
+	FILE *outf;
+{
+	u_char cmd[5];
+	int rc;
+	unsigned len;
+
+	len = strtoul(argv[1], 0, 0);
+	if (len < 1 || len > 256) {
+		fprintf(stderr, "error: length argument is out of range\n");
+		return(-1);
+	}
+	/* FETCH command APDU */
+	cmd[0] = 0xA0;
+	cmd[1] = 0x12;
+	cmd[2] = 0;
+	cmd[3] = 0;
+	cmd[4] = len;
+	rc = apdu_exchange(cmd, 5);
+	if (rc < 0)
+		return(rc);
+	if (sim_resp_sw != 0x9000) {
+		fprintf(stderr, "bad SW resp: %04X\n", sim_resp_sw);
+		return(-1);
+	}
+	display_sim_resp_in_hex(outf);
+	return(0);
+}