view simtool/pbupd_immhex.c @ 99:97ba63d9361a

scripts/fcsim1-sst: turn off STK & OTA services In the initial unprogrammed state of the cards from Grcard, SST has services 25 through 29 set to allocated and activated. However, these cards appear to not actually support OTA, ENVELOPE commands do nothing (just return SW 9000), and they were never observed issuing any proactive SIM commands, even after a feature-generous TERMINAL PROFILE. Therefore, let's list these STK & OTA services as allocated, but not activated in our FCSIM1 SST.
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 05 May 2021 04:26:07 +0000
parents ddd767f6e15b
children
line wrap: on
line source

/*
 * This module implements the pb-update-imm-hex command.
 */

#include <sys/types.h>
#include <ctype.h>
#include <string.h>
#include <strings.h>
#include <stdio.h>
#include <stdlib.h>
#include "curfile.h"

static
decode_alphatag_arg_hex(arg, record, maxlen)
	char *arg;
	u_char *record;
	unsigned maxlen;
{
	unsigned acclen;

	for (acclen = 0; ; acclen++) {
		while (isspace(*arg))
			arg++;
		if (!*arg)
			break;
		if (!isxdigit(arg[0]) || !isxdigit(arg[1])) {
			fprintf(stderr, "error: invalid hex string input\n");
			return(-1);
		}
		if (acclen >= maxlen) {
			fprintf(stderr,
			"error: alpha tag string is longer than SIM limit\n");
			return(-1);
		}
		record[acclen] = (decode_hex_digit(arg[0]) << 4) |
				 decode_hex_digit(arg[1]);
		arg += 2;
	}
	return(0);
}

cmd_pb_update_imm_hex(argc, argv)
	char **argv;
{
	int rc;
	unsigned recno;
	u_char record[255], *fixp;

	rc = phonebook_op_common(argv[1]);
	if (rc < 0)
		return(rc);
	recno = strtoul(argv[2], 0, 0);
	if (recno < 1 || recno > curfile_record_count) {
		fprintf(stderr, "error: specified record number is invalid\n");
		return(-1);
	}
	memset(record, 0xFF, curfile_record_len);
	fixp = record + curfile_record_len - 14;
	rc = encode_phone_number_arg(argv[3], fixp, 0);
	if (rc < 0)
		return(rc);
	rc = decode_alphatag_arg_hex(argv[4], record, curfile_record_len - 14);
	if (rc < 0)
		return(rc);
	return update_rec_op(recno, 0x04, record, curfile_record_len);
}