changeset 54:2d1679c7975b

fc-simtool opl-dump implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 13 Feb 2021 06:44:34 +0000
parents 4eb447be01c0
children 4c570522de5d
files simtool/Makefile simtool/dispatch.c simtool/opldump.c
diffstat 3 files changed, 63 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/Makefile	Sat Feb 13 06:26:52 2021 +0000
+++ b/simtool/Makefile	Sat Feb 13 06:44:34 2021 +0000
@@ -2,11 +2,11 @@
 CFLAGS=	-O2 -I/usr/include/PCSC -I../libcommon
 PROG=	fc-simtool
 OBJS=	a38.o chv.o chvext.o curfile.o dispatch.o dumpdir.o grcard1.o grcard2.o\
-	hlread.o main.o pbcommon.o pbdump.o pberase.o pbupd_file.o pbupd_imm.o \
-	pbupd_immhex.o plmnsel.o pnndump.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 sstdump.o sysmo.o telsum.o \
-	writecmd.o writeops.o
+	hlread.o main.o opldump.o pbcommon.o pbdump.o pberase.o pbupd_file.o \
+	pbupd_imm.o pbupd_immhex.o plmnsel.o pnndump.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 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 06:26:52 2021 +0000
+++ b/simtool/dispatch.c	Sat Feb 13 06:44:34 2021 +0000
@@ -23,6 +23,7 @@
 extern int cmd_grcard2_set_super();
 extern int cmd_iccid();
 extern int cmd_imsi();
+extern int cmd_opl_dump();
 extern int cmd_pb_dump();
 extern int cmd_pb_dump_rec();
 extern int cmd_pb_erase();
@@ -98,6 +99,7 @@
 	{"grcard2-set-super", 1, 1, cmd_grcard2_set_super},
 	{"iccid", 0, 0, cmd_iccid},
 	{"imsi", 0, 0, cmd_imsi},
+	{"opl-dump", 0, 0, cmd_opl_dump},
 	{"pb-dump", 1, 2, cmd_pb_dump},
 	{"pb-dump-rec", 2, 3, cmd_pb_dump_rec},
 	{"pb-erase", 1, 1, cmd_pb_erase},
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simtool/opldump.c	Sat Feb 13 06:44:34 2021 +0000
@@ -0,0 +1,56 @@
+/*
+ * This module implements the opl-dump command,
+ * a companion command to pnn-dump.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include "simresp.h"
+#include "curfile.h"
+#include "file_id.h"
+
+static void
+dump_record(recno)
+	unsigned recno;
+{
+	char ascbuf[8];
+
+	decode_plmn_3bytes(sim_resp_data, ascbuf, 0);
+	printf("#%u: %s %02X%02X-%02X%02X %u\n", recno, ascbuf,
+		sim_resp_data[3], sim_resp_data[4], sim_resp_data[5],
+		sim_resp_data[6], sim_resp_data[7]);
+}
+
+cmd_opl_dump()
+{
+	int rc;
+	unsigned recno;
+
+	rc = select_op(DF_GSM);
+	if (rc < 0)
+		return(rc);
+	rc = select_op(EF_OPL);
+	if (rc < 0)
+		return(rc);
+	rc = parse_ef_select_response();
+	if (rc < 0)
+		return(rc);
+	if (curfile_structure != 0x01) {
+		fprintf(stderr, "error: EF_OPL is not linear fixed\n");
+		return(-1);
+	}
+	if (curfile_record_len < 8) {
+		fprintf(stderr,
+"error: EF_OPL record length is less than the spec minimum of 8 bytes\n");
+		return(-1);
+	}
+	for (recno = 1; recno <= curfile_record_count; recno++) {
+		rc = readrec_op(recno, 0x04, curfile_record_len);
+		if (rc < 0)
+			return(rc);
+		if (check_simresp_all_blank())
+			continue;
+		dump_record(recno);
+	}
+	return(0);
+}