changeset 211:31cd62f91522

fc-simtool write-spn command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 07 Mar 2021 06:41:40 +0000
parents 9797417ececa
children 43b57865fdb5
files simtool/dispatch.c simtool/miscadm.c
diffstat 2 files changed, 41 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/dispatch.c	Sun Mar 07 06:26:20 2021 +0000
+++ b/simtool/dispatch.c	Sun Mar 07 06:41:40 2021 +0000
@@ -105,6 +105,7 @@
 extern int cmd_write_iccid_sh19();
 extern int cmd_write_imsi();
 extern int cmd_write_imsi_sh();
+extern int cmd_write_spn();
 extern int cmd_write_sst();
 
 extern int current_ef_inval();
@@ -239,6 +240,7 @@
 	{"write-iccid-sh19", 1, 1, 0, cmd_write_iccid_sh19},
 	{"write-imsi", 1, 1, 0, cmd_write_imsi},
 	{"write-imsi-sh", 1, 1, 0, cmd_write_imsi_sh},
+	{"write-spn", 2, 2, 0, cmd_write_spn},
 	{"write-sst", 1, 1, 0, cmd_write_sst},
 	{0, 0, 0, 0, 0}
 };
--- a/simtool/miscadm.c	Sun Mar 07 06:26:20 2021 +0000
+++ b/simtool/miscadm.c	Sun Mar 07 06:41:40 2021 +0000
@@ -7,6 +7,8 @@
 #include <sys/types.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+#include <strings.h>
 #include "curfile.h"
 #include "file_id.h"
 
@@ -175,3 +177,40 @@
 	binrec[1] = acc;
 	return write_acc_bin(binrec);
 }
+
+static
+write_spn_bin(binrec)
+	u_char *binrec;
+{
+	int rc;
+
+	rc = select_op(DF_GSM);
+	if (rc < 0)
+		return(rc);
+	rc = select_op(EF_SPN);
+	if (rc < 0)
+		return(rc);
+	rc = parse_ef_select_response();
+	if (rc < 0)
+		return(rc);
+	if (curfile_structure != 0x00 || curfile_total_size != 17) {
+		fprintf(stderr,
+			"error: EF_SPN is not a transparent EF of 17 bytes\n");
+		return(-1);
+	}
+	return update_bin_op(0, binrec, 17);
+}
+
+cmd_write_spn(argc, argv)
+	char **argv;
+{
+	u_char binrec[17];
+	int rc;
+
+	binrec[0] = strtoul(argv[1], 0, 16);
+	memset(binrec + 1, 0xFF, 16);
+	rc = qstring_arg_to_gsm7(argv[2], binrec + 1, 16);
+	if (rc < 0)
+		return(rc);
+	return write_spn_bin(binrec);
+}