FreeCalypso > hg > themwi-ota-tools
changeset 7:a33d4d8079d2
ota-set-msisdn utility written, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 22 Feb 2021 01:00:39 +0000 |
parents | 86b4f288862d |
children | 08e6c475e559 |
files | .hgignore Makefile gen/Makefile gen/ota-set-msisdn.c |
diffstat | 4 files changed, 71 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Mon Feb 22 00:41:12 2021 +0000 +++ b/.hgignore Mon Feb 22 01:00:39 2021 +0000 @@ -2,6 +2,8 @@ \.[oa]$ +^gen/ota-set-msisdn$ + ^smswrap/ota-smswrap-sjs1$ ^test/ota-smspp-envelope$
--- a/Makefile Mon Feb 22 00:41:12 2021 +0000 +++ b/Makefile Mon Feb 22 01:00:39 2021 +0000 @@ -1,9 +1,10 @@ -PROGDIR=smswrap test +PROGDIR=gen smswrap test LIBDIR= libutil SUBDIR= ${PROGDIR} ${LIBDIR} all: ${SUBDIR} +gen: libutil smswrap: libutil test: libutil
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gen/Makefile Mon Feb 22 01:00:39 2021 +0000 @@ -0,0 +1,17 @@ +CC= gcc +CFLAGS= -O2 +PROGS= ota-set-msisdn +LIBS= ../libutil/libutil.a +INSTBIN=/opt/freecalypso/bin + +all: ${PROGS} + +ota-set-msisdn: ota-set-msisdn.o ${LIBS} + ${CC} ${CFLAGS} -o $@ $@.o ${LIBS} + +install: + mkdir -p ${INSTBIN} + install -c ${PROGS} ${INSTBIN} + +clean: + rm -f ${PROGS} *.o
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gen/ota-set-msisdn.c Mon Feb 22 01:00:39 2021 +0000 @@ -0,0 +1,50 @@ +/* + * This program generates the OTA RFM payload (to be fed to ota-smswrap-* + * tools) for programming the MSISDN record. + */ + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> + +main(argc, argv) + char **argv; +{ + int rc; + u_char record[80], *fixp; + unsigned record_len, n; + + if (argc < 3 || argc > 4) { + fprintf(stderr, + "usage: %s record-len phone-number [alpha-tag]\n", + argv[0]); + exit(1); + } + record_len = strtoul(argv[1], 0, 0); + if (record_len < 14 || record_len > 80) { + fprintf(stderr, + "error: specified MSISDN record length is out of range\n"); + exit(1); + } + memset(record, 0xFF, record_len); + fixp = record + record_len - 14; + rc = encode_phone_number_arg(argv[2], fixp, 0); + if (rc < 0) + exit(1); /* error msg already printed */ + if (argv[3]) { + rc = qstring_arg_to_gsm7(argv[3], record, record_len - 14); + if (rc < 0) + exit(1); /* error msg already printed */ + } + /* emit output */ + printf("A0A40000023F00\n"); /* SELECT MF */ + printf("A0A40000027F10\n"); /* SELECT DF_TELECOM */ + printf("A0A40000026F40\n"); /* SELECT EF_MSISDN */ + printf("A0DC0104%02X\n", record_len); /* UPDATE RECORD */ + for (n = 0; n < record_len; n++) + printf("%02X", record[n]); + putchar('\n'); + exit(0); +}