view gen/ota-set-msisdn.c @ 10:2c022e0334c4

convert to new ThemWi configure and build system
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 21 May 2024 01:03:40 +0000
parents a33d4d8079d2
children
line wrap: on
line source

/*
 * 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);
}