# HG changeset patch # User Mychaela Falconia # Date 1611459781 0 # Node ID 2a0d1d5b93135bb08c890651268026272f68030d # Parent 54c444eb084b9b6596a8bdecf351ae3203dccf50 fc-simtool: symbolic file names implemented diff -r 54c444eb084b -r 2a0d1d5b9313 simtool/Makefile --- a/simtool/Makefile Sun Jan 24 01:42:15 2021 +0000 +++ b/simtool/Makefile Sun Jan 24 03:43:01 2021 +0000 @@ -1,7 +1,7 @@ CC= gcc CFLAGS= -O2 -I/usr/include/PCSC PROG= fc-simtool -OBJS= apdu.o atr.o cardconnect.o dispatch.o globals.o main.o select.o +OBJS= apdu.o atr.o cardconnect.o dispatch.o globals.o main.o names.o select.o all: ${PROG} diff -r 54c444eb084b -r 2a0d1d5b9313 simtool/file_id.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/simtool/file_id.h Sun Jan 24 03:43:01 2021 +0000 @@ -0,0 +1,48 @@ +/* definitions of a few file IDs we find interesting */ + +#define FILEID_MF 0x3F00 + +#define DF_TELECOM 0x7F10 +#define DF_GSM 0x7F20 +#define DF_DCS1800 0x7F21 + +/* EFs under MF */ +#define EF_ICCID 0x2FE2 + +/* EFs under DF_GSM */ +#define EF_LP 0x6F05 +#define EF_IMSI 0x6F07 +#define EF_Kc 0x6F20 +#define EF_PLMNsel 0x6F30 +#define EF_HPLMN 0x6F31 +#define EF_ACMmax 0x6F37 +#define EF_SST 0x6F38 +#define EF_ACM 0x6F39 +#define EF_GID1 0x6F3E +#define EF_GID2 0x6F3F +#define EF_PUCT 0x6F41 +#define EF_CBMI 0x6F45 +#define EF_SPN 0x6F46 +#define EF_CBMID 0x6F48 +#define EF_CBMIR 0x6F50 +#define EF_BCCH 0x6F74 +#define EF_ACC 0x6F78 +#define EF_FPLMN 0x6F7B +#define EF_LOCI 0x6F7E +#define EF_AD 0x6FAD +#define EF_PHASE 0x6FAE +#define EF_ECC 0x6FB7 + +/* EFs under DF_TELECOM */ +#define EF_ADN 0x6F3A +#define EF_FDN 0x6F3B +#define EF_SMS 0x6F3C +#define EF_CCP 0x6F3D +#define EF_MSISDN 0x6F40 +#define EF_SMSP 0x6F42 +#define EF_SMSS 0x6F43 +#define EF_LND 0x6F44 +#define EF_SDN 0x6F49 +#define EF_EXT1 0x6F4A +#define EF_EXT2 0x6F4B +#define EF_EXT3 0x6F4C diff -r 54c444eb084b -r 2a0d1d5b9313 simtool/names.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/simtool/names.c Sun Jan 24 03:43:01 2021 +0000 @@ -0,0 +1,73 @@ +/* + * This module contains the table of user-friendly file names + * and a function for searching this table. + */ + +#include +#include +#include +#include +#include "file_id.h" + +static struct nametab { + char *name; + int file_id; +} name_table[] = { + {"MF", FILEID_MF}, + {"DF_GSM", DF_GSM}, + {"DF_DCS1800", DF_DCS1800}, + {"DF_TELECOM", DF_TELECOM}, + {"gsm", DF_GSM}, + {"telecom", DF_TELECOM}, + /* EFs under MF */ + {"EF_ICCID", EF_ICCID}, + /* EFs under DF_GSM */ + {"EF_LP", EF_LP}, + {"EF_IMSI", EF_IMSI}, + {"EF_Kc", EF_Kc}, + {"EF_PLMNsel", EF_PLMNsel}, + {"EF_HPLMN", EF_HPLMN}, + {"EF_ACMmax", EF_ACMmax}, + {"EF_SST", EF_SST}, + {"EF_ACM", EF_ACM}, + {"EF_GID1", EF_GID1}, + {"EF_GID2", EF_GID2}, + {"EF_PUCT", EF_PUCT}, + {"EF_CBMI", EF_CBMI}, + {"EF_SPN", EF_SPN}, + {"EF_CBMID", EF_CBMID}, + {"EF_CBMIR", EF_CBMIR}, + {"EF_BCCH", EF_BCCH}, + {"EF_ACC", EF_ACC}, + {"EF_FPLMN", EF_FPLMN}, + {"EF_LOCI", EF_LOCI}, + {"EF_AD", EF_AD}, + {"EF_PHASE", EF_PHASE}, + {"EF_ECC", EF_ECC}, + /* EFs under DF_TELECOM */ + {"EF_ADN", EF_ADN}, + {"EF_FDN", EF_FDN}, + {"EF_SMS", EF_SMS}, + {"EF_CCP", EF_CCP}, + {"EF_MSISDN", EF_MSISDN}, + {"EF_SMSP", EF_SMSP}, + {"EF_SMSS", EF_SMSS}, + {"EF_LND", EF_LND}, + {"EF_SDN", EF_SDN}, + {"EF_EXT1", EF_EXT1}, + {"EF_EXT2", EF_EXT2}, + {"EF_EXT3", EF_EXT3}, + /* table search terminator */ + {0, -1} +}; + +find_symbolic_file_name(soughtname) + char *soughtname; +{ + struct nametab *tp; + + for (tp = name_table; tp->name; tp++) + if (!strcmp(tp->name, soughtname)) + break; + return tp->file_id; +} diff -r 54c444eb084b -r 2a0d1d5b9313 simtool/select.c --- a/simtool/select.c Sun Jan 24 01:42:15 2021 +0000 +++ b/simtool/select.c Sun Jan 24 03:43:01 2021 +0000 @@ -82,15 +82,16 @@ cmd_select(argc, argv) char **argv; { - unsigned file_id; - int rc; + int file_id, rc; if (isxdigit(argv[1][0]) && isxdigit(argv[1][1]) && isxdigit(argv[1][2]) && isxdigit(argv[1][3]) && !argv[1][4]) file_id = strtoul(argv[1], 0, 16); - else { + else + file_id = find_symbolic_file_name(argv[1]); + if (file_id < 0) { fprintf(stderr, - "select: only hex file IDs are currently supported\n"); +"error: file ID argument is not a hex value or a recognized symbolic name\n"); return(-1); } rc = select_op(file_id);