view simtool/opldump.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 2d1679c7975b
children 440a4582d2a5
line wrap: on
line source

/*
 * This module implements the opl-dump command,
 * a companion command to pnn-dump.
 */

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

static void
dump_record(recno)
	unsigned recno;
{
	char ascbuf[8];

	decode_plmn_3bytes(sim_resp_data, ascbuf, 0);
	printf("#%u: %s %02X%02X-%02X%02X %u\n", recno, ascbuf,
		sim_resp_data[3], sim_resp_data[4], sim_resp_data[5],
		sim_resp_data[6], sim_resp_data[7]);
}

cmd_opl_dump()
{
	int rc;
	unsigned recno;

	rc = select_op(DF_GSM);
	if (rc < 0)
		return(rc);
	rc = select_op(EF_OPL);
	if (rc < 0)
		return(rc);
	rc = parse_ef_select_response();
	if (rc < 0)
		return(rc);
	if (curfile_structure != 0x01) {
		fprintf(stderr, "error: EF_OPL is not linear fixed\n");
		return(-1);
	}
	if (curfile_record_len < 8) {
		fprintf(stderr,
"error: EF_OPL record length is less than the spec minimum of 8 bytes\n");
		return(-1);
	}
	for (recno = 1; recno <= curfile_record_count; recno++) {
		rc = readrec_op(recno, 0x04, curfile_record_len);
		if (rc < 0)
			return(rc);
		if (check_simresp_all_blank())
			continue;
		dump_record(recno);
	}
	return(0);
}