view simtool/pbcommon.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 common functions for all phonebook commands.
 */

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

static struct map {
	char	*user_name;
	char	*canon_name;
	int	dir_id;
	int	file_id;
} phonebook_map[] = {
	{"adn",		"EF_ADN",	DF_TELECOM,	EF_ADN},
	{"ADN",		"EF_ADN",	DF_TELECOM,	EF_ADN},
	{"EF_ADN",	"EF_ADN",	DF_TELECOM,	EF_ADN},
	{"fdn",		"EF_FDN",	DF_TELECOM,	EF_FDN},
	{"FDN",		"EF_FDN",	DF_TELECOM,	EF_FDN},
	{"EF_FDN",	"EF_FDN",	DF_TELECOM,	EF_FDN},
	{"sdn",		"EF_SDN",	DF_TELECOM,	EF_SDN},
	{"SDN",		"EF_SDN",	DF_TELECOM,	EF_SDN},
	{"EF_SDN",	"EF_SDN",	DF_TELECOM,	EF_SDN},
	{"msisdn",	"EF_MSISDN",	DF_TELECOM,	EF_MSISDN},
	{"MSISDN",	"EF_MSISDN",	DF_TELECOM,	EF_MSISDN},
	{"EF_MSISDN",	"EF_MSISDN",	DF_TELECOM,	EF_MSISDN},
	{"mbdn",	"EF_MBDN",	DF_GSM,		EF_MBDN},
	{"MBDN",	"EF_MBDN",	DF_GSM,		EF_MBDN},
	{"EF_MBDN",	"EF_MBDN",	DF_GSM,		EF_MBDN},
	/* table search terminator */
	{0,		0,		-1,		-1}
};

phonebook_op_common(reqname)
	char *reqname;
{
	struct map *tp;
	int rc;

	for (tp = phonebook_map; tp->user_name; tp++)
		if (!strcmp(tp->user_name, reqname))
			break;
	if (!tp->canon_name) {
		fprintf(stderr, "error: phone book name \"%s\" not known\n",
			reqname);
		return(-1);
	}
	rc = select_op(tp->dir_id);
	if (rc < 0)
		return(rc);
	rc = select_op(tp->file_id);
	if (rc < 0)
		return(rc);
	rc = parse_ef_select_response();
	if (rc < 0)
		return(rc);
	if (curfile_structure != 0x01) {
		fprintf(stderr, "error: %s is not linear fixed\n",
			tp->canon_name);
		return(-1);
	}
	if (curfile_record_len < 14) {
		fprintf(stderr,
	"error: %s has record length of %u bytes, less than minimum 14\n",
			tp->canon_name, curfile_record_len);
		return(-1);
	}
	return(0);
}

select_ef_lnd()
{
	int rc;

	rc = select_op(DF_TELECOM);
	if (rc < 0)
		return(rc);
	rc = select_op(EF_LND);
	if (rc < 0)
		return(rc);
	rc = parse_ef_select_response();
	if (rc < 0)
		return(rc);
	if (curfile_structure != 0x03) {
		fprintf(stderr, "error: EF_LND is not cyclic\n");
		return(-1);
	}
	if (curfile_record_len < 14) {
		fprintf(stderr,
	"error: EF_LND has record length of %u bytes, less than minimum 14\n",
			curfile_record_len);
		return(-1);
	}
	return(0);
}