changeset 68:105aa3d1a494

fc-simtool write-iccid command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 15 Feb 2021 00:36:56 +0000
parents 9ff7ee99346f
children d4058ae94749
files simtool/dispatch.c simtool/miscadm.c
diffstat 2 files changed, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/dispatch.c	Mon Feb 15 00:30:08 2021 +0000
+++ b/simtool/dispatch.c	Mon Feb 15 00:36:56 2021 +0000
@@ -64,6 +64,7 @@
 extern int cmd_verify_chv();
 extern int cmd_verify_ext();
 extern int cmd_verify_hex();
+extern int cmd_write_iccid();
 extern int cmd_write_imsi();
 
 extern int display_sim_resp_in_hex();
@@ -155,6 +156,7 @@
 	{"verify-hex", 2, 2, cmd_verify_hex},
 	{"verify-pin1", 1, 1, cmd_verify_chv},
 	{"verify-pin2", 1, 1, cmd_verify_chv},
+	{"write-iccid", 1, 1, cmd_write_iccid},
 	{"write-imsi", 1, 1, cmd_write_imsi},
 	{0, 0, 0, 0}
 };
--- a/simtool/miscadm.c	Mon Feb 15 00:30:08 2021 +0000
+++ b/simtool/miscadm.c	Mon Feb 15 00:36:56 2021 +0000
@@ -9,6 +9,33 @@
 #include "curfile.h"
 #include "file_id.h"
 
+cmd_write_iccid(argc, argv)
+	char **argv;
+{
+	int rc;
+	u_char nibbles[20], binrec[10];
+
+	rc = parse_decimal_string_arg(argv[1], nibbles, 20);
+	if (rc < 0)
+		return(rc);
+	pack_reversed_nibbles(nibbles, binrec, 10);
+	rc = select_op(FILEID_MF);
+	if (rc < 0)
+		return(rc);
+	rc = select_op(EF_ICCID);
+	if (rc < 0)
+		return(rc);
+	rc = parse_ef_select_response();
+	if (rc < 0)
+		return(rc);
+	if (curfile_structure != 0x00 || curfile_total_size != 10) {
+		fprintf(stderr,
+		"error: EF_ICCID is not a transparent EF of 10 bytes\n");
+		return(-1);
+	}
+	return update_bin_op(0, binrec, 10);
+}
+
 cmd_write_imsi(argc, argv)
 	char **argv;
 {