view sw/sniff-dec/hl_decode.c @ 56:966a54303d68

simsniff-dec: factor out high-level decoding
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 04 Oct 2023 01:18:50 +0000
parents
children eb4274e7f4da
line wrap: on
line source

/*
 * Here we implement higher-level decoding of INS codes and SELECT file IDs.
 */

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

static struct ins_code_tab {
	u_char	ins_code;
	char	*cmdname;
} ins_code_table[] = {
	{0xA4, "SELECT"},
	{0xF2, "STATUS"},
	{0xB0, "READ BINARY"},
	{0xD6, "UPDATE BINARY"},
	{0xB2, "READ RECORD"},
	{0xDC, "UPDATE RECORD"},
	{0xA2, "SEEK"},
	{0x32, "INCREASE"},
	{0x20, "VERIFY PIN"},
	{0x24, "CHANGE PIN"},
	{0x26, "DISABLE PIN"},
	{0x28, "ENABLE PIN"},
	{0x2C, "UNBLOCK PIN"},
	{0x04, "INVALIDATE"},
	{0x44, "REHABILITATE"},
	{0x88, "RUN GSM ALGO"},
	{0xFA, "SLEEP"},
	{0xC0, "GET RESPONSE"},
	{0x10, "TERMINAL PROFILE"},
	{0xC2, "ENVELOPE"},
	{0x12, "FETCH"},
	{0x14, "TERMINAL RESPONSE"},
	/* table search terminator */
	{0,    0}
};

void
decode_cmd_opcode(ins)
	u_char ins;
{
	struct ins_code_tab *tp;

	for (tp = ins_code_table; tp->cmdname; tp++)
		if (tp->ins_code == ins)
			break;
	if (tp->cmdname)
		printf(" Command: %s\n", tp->cmdname);
}