view simtool/telsum.c @ 74:8562d8508cf2

grcard2-set-{adm,super}-hex commands implemented It appears that GrcardSIM2 cards allow arbitrary 64-bit keys for ADM and SUPER ADM, not necessarily consisting of ASCII digits like the specs require for standard PIN and PUK, and pySim-prog.py in fact sets the ADM key to 4444444444444444 in hex by default, which is not an ASCII digit string. If the cards allow such keys, we need to support them too.
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 16 Feb 2021 04:10:36 +0000
parents 2071b28cd0c7
children
line wrap: on
line source

/*
 * This module implements the telecom-sum (summary info) command.
 */

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include "simresp.h"
#include "curfile.h"
#include "file_id.h"

static
do_phonebook_file(file_id, book_name)
	unsigned file_id;
	char *book_name;
{
	int rc;

	rc = select_op(file_id);
	if (rc < 0) {
		printf("%s not present\n", book_name);
		return(rc);
	}
	rc = parse_ef_select_response();
	if (rc < 0) {
		fprintf(stderr, "error occurred on SELECT of EF_%s\n",
			book_name);
		return(rc);
	}
	if (curfile_structure != 0x01) {
		fprintf(stderr, "error: EF_%s is not linear fixed\n",
			book_name);
		return(-1);
	}
	if (curfile_record_len < 14) {
		fprintf(stderr,
	"error: EF_%s has record length of %u bytes, less than minimum 14\n",
			book_name, curfile_record_len);
		return(-1);
	}
	printf("%s has %u entries, %u bytes of alpha tag\n", book_name,
		curfile_record_count, curfile_record_len - 14);
	return(0);
}

static
do_sms_store()
{
	int rc;

	rc = select_op(EF_SMS);
	if (rc < 0) {
		printf("EF_SMS not present\n");
		return(rc);
	}
	rc = parse_ef_select_response();
	if (rc < 0) {
		fprintf(stderr, "error occurred on SELECT of EF_SMS\n");
		return(rc);
	}
	if (curfile_structure != 0x01 || curfile_record_len != 176) {
		fprintf(stderr,
		"error: EF_SMS is not linear fixed with 176-byte records\n");
		return(-1);
	}
	printf("SMS store has %u entries\n", curfile_record_count);
	return(0);
}

cmd_telecom_sum()
{
	int rc;

	rc = select_op(DF_TELECOM);
	if (rc < 0)
		return(rc);
	do_phonebook_file(EF_ADN, "ADN");
	do_phonebook_file(EF_FDN, "FDN");
	do_phonebook_file(EF_SDN, "SDN");
	do_phonebook_file(EF_MSISDN, "MSISDN");
	do_sms_store();
	return(0);
}