changeset 83:07e395fddfe1

lnd-write command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 17 Feb 2021 06:08:28 +0000
parents fe660c7ea97f
children 51f26fd967e2
files simtool/Makefile simtool/dispatch.c simtool/lndwrite.c
diffstat 3 files changed, 38 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/Makefile	Wed Feb 17 05:59:27 2021 +0000
+++ b/simtool/Makefile	Wed Feb 17 06:08:28 2021 +0000
@@ -2,9 +2,9 @@
 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 miscadm.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 \
+	hlread.o lndwrite.o main.o miscadm.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 \
 	sstlist.o sysmo.o telsum.o usersum.o writecmd.o writeops.o
 LIBS=	../libcommon/libcommon.a
--- a/simtool/dispatch.c	Wed Feb 17 05:59:27 2021 +0000
+++ b/simtool/dispatch.c	Wed Feb 17 06:08:28 2021 +0000
@@ -26,6 +26,7 @@
 extern int cmd_iccid();
 extern int cmd_imsi();
 extern int cmd_lnd_dump();
+extern int cmd_lnd_write();
 extern int cmd_opl_dump();
 extern int cmd_pb_dump();
 extern int cmd_pb_dump_rec();
@@ -113,6 +114,7 @@
 	{"iccid", 0, 0, cmd_iccid},
 	{"imsi", 0, 0, cmd_imsi},
 	{"lnd-dump", 0, 1, cmd_lnd_dump},
+	{"lnd-write", 1, 2, cmd_lnd_write},
 	{"opl-dump", 0, 0, cmd_opl_dump},
 	{"pb-dump", 1, 2, cmd_pb_dump},
 	{"pb-dump-rec", 2, 3, cmd_pb_dump_rec},
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simtool/lndwrite.c	Wed Feb 17 06:08:28 2021 +0000
@@ -0,0 +1,33 @@
+/*
+ * This module implements lnd-write and lnd-erase commands.
+ */
+
+#include <sys/types.h>
+#include <string.h>
+#include <strings.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "curfile.h"
+
+cmd_lnd_write(argc, argv)
+	char **argv;
+{
+	int rc;
+	u_char record[255], *fixp;
+
+	rc = select_ef_lnd();
+	if (rc < 0)
+		return(rc);
+	memset(record, 0xFF, curfile_record_len);
+	fixp = record + curfile_record_len - 14;
+	rc = encode_phone_number_arg(argv[1], fixp, 0);
+	if (rc < 0)
+		return(rc);
+	if (argv[2]) {
+		rc = qstring_arg_to_gsm7(argv[2], record,
+					 curfile_record_len - 14);
+		if (rc < 0)
+			return(rc);
+	}
+	return update_rec_op(0, 0x03, record, curfile_record_len);
+}