changeset 48:9a21f4353158

fc-simtool sst-dump implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 13 Feb 2021 03:09:44 +0000
parents ae3342497fea
children bbc2821288aa
files simtool/Makefile simtool/dispatch.c simtool/sstdump.c
diffstat 3 files changed, 59 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/Makefile	Sat Feb 13 00:57:57 2021 +0000
+++ b/simtool/Makefile	Sat Feb 13 03:09:44 2021 +0000
@@ -5,7 +5,8 @@
 	hlread.o main.o pbcommon.o pbdump.o pberase.o pbupd_file.o pbupd_imm.o \
 	pbupd_immhex.o readcmd.o readops.o restorebin.o savebin.o script.o \
 	select.o smserase.o smsp_common.o smsp_dump.o smsp_erase.o \
-	smsp_restore.o smsp_set.o sysmo.o telsum.o writecmd.o writeops.o
+	smsp_restore.o smsp_set.o sstdump.o sysmo.o telsum.o writecmd.o \
+	writeops.o
 LIBS=	../libcommon/libcommon.a
 INSTBIN=/opt/freecalypso/bin
 
--- a/simtool/dispatch.c	Sat Feb 13 00:57:57 2021 +0000
+++ b/simtool/dispatch.c	Sat Feb 13 03:09:44 2021 +0000
@@ -49,6 +49,7 @@
 extern int cmd_smsp_set();
 extern int cmd_smsp_set_tag();
 extern int cmd_spn();
+extern int cmd_sst_dump();
 extern int cmd_telecom_sum();
 extern int cmd_uicc_dir();
 extern int cmd_unblock_chv();
@@ -123,6 +124,7 @@
 	{"smsp-set", 2, 6, cmd_smsp_set},
 	{"smsp-set-tag", 3, 7, cmd_smsp_set_tag},
 	{"spn", 0, 0, cmd_spn},
+	{"sst-dump", 0, 0, cmd_sst_dump},
 	{"telecom-sum", 0, 0, cmd_telecom_sum},
 	{"uicc-dir", 0, 0, cmd_uicc_dir},
 	{"unblock-chv1", 2, 2, cmd_unblock_chv},
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simtool/sstdump.c	Sat Feb 13 03:09:44 2021 +0000
@@ -0,0 +1,55 @@
+/*
+ * This module implements the sst-dump command,
+ * providing a more readable form of the SIM Service Table.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include "simresp.h"
+#include "curfile.h"
+#include "file_id.h"
+
+cmd_sst_dump()
+{
+	int rc;
+	unsigned byte, pos, code, nserv;
+
+	rc = select_op(DF_GSM);
+	if (rc < 0)
+		return(rc);
+	rc = select_op(EF_SST);
+	if (rc < 0)
+		return(rc);
+	rc = parse_ef_select_response();
+	if (rc < 0)
+		return(rc);
+	if (curfile_structure != 0x00) {
+		fprintf(stderr, "error: EF_SST is not transparent\n");
+		return(-1);
+	}
+	if (curfile_total_size < 2) {
+		fprintf(stderr,
+		"error: EF_SST is shorter than spec minimum of 2 bytes\n");
+		return(-1);
+	}
+	if (curfile_total_size > 256) {
+		fprintf(stderr,
+			"error: EF_SST is longer than our 256 byte limit\n");
+		return(-1);
+	}
+	rc = readbin_op(0, curfile_total_size);
+	if (rc < 0)
+		return(rc);
+	nserv = 1;
+	for (byte = 0; byte < curfile_total_size; byte++) {
+		for (pos = 0; pos < 8; pos += 2) {
+			code = (sim_resp_data[byte] >> pos) & 3;
+			if (code == 3)
+				printf("#%u: activated\n", nserv);
+			else if (code == 1)
+				printf("#%u: allocated\n", nserv);
+			nserv++;
+		}
+	}
+	return(0);
+}