changeset 58:1861d9fb7751

fc-simtool dump-lnd command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 13 Feb 2021 21:40:38 +0000
parents 10030acba82f
children c56e63a8725d
files simtool/dispatch.c simtool/pbdump.c
diffstat 2 files changed, 38 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/dispatch.c	Sat Feb 13 20:28:44 2021 +0000
+++ b/simtool/dispatch.c	Sat Feb 13 21:40:38 2021 +0000
@@ -11,6 +11,7 @@
 extern int cmd_a38();
 extern int cmd_change_chv();
 extern int cmd_disable_chv();
+extern int cmd_dump_lnd();
 extern int cmd_enable_chv();
 extern int cmd_exec();
 extern int cmd_fix_sysmo_msisdn();
@@ -81,6 +82,7 @@
 	{"change-pin2", 2, 2, cmd_change_chv},
 	{"disable-chv", 1, 1, cmd_disable_chv},
 	{"disable-pin", 1, 1, cmd_disable_chv},
+	{"dump-lnd", 0, 0, cmd_dump_lnd},
 	{"enable-chv", 1, 1, cmd_enable_chv},
 	{"enable-pin", 1, 1, cmd_enable_chv},
 	{"exec", 1, 1, cmd_exec},
--- a/simtool/pbdump.c	Sat Feb 13 20:28:44 2021 +0000
+++ b/simtool/pbdump.c	Sat Feb 13 21:40:38 2021 +0000
@@ -7,6 +7,7 @@
 #include <stdlib.h>
 #include "simresp.h"
 #include "curfile.h"
+#include "file_id.h"
 
 static
 check_blank_area(dp, endp)
@@ -131,3 +132,38 @@
 	}
 	return(0);
 }
+
+cmd_dump_lnd()
+{
+	int rc;
+	unsigned recno;
+
+	rc = select_op(DF_TELECOM);
+	if (rc < 0)
+		return(rc);
+	rc = select_op(EF_LND);
+	if (rc < 0)
+		return(rc);
+	rc = parse_ef_select_response();
+	if (rc < 0)
+		return(rc);
+	if (curfile_structure != 0x03) {
+		fprintf(stderr, "error: EF_LND is not cyclic\n");
+		return(-1);
+	}
+	if (curfile_record_len < 14) {
+		fprintf(stderr,
+	"error: EF_LND has record length of %u bytes, less than minimum 14\n",
+			curfile_record_len);
+		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, stdout);
+	}
+	return(0);
+}