client: Option to ignore any ATR sent by bankd

This introduces an --atr-ignore-rspro command line argument, which
will make the remsim-client ignore any RSPRO setAtrReq it receives
from the remote bankd.

The purpose of this is to modify the capabilities advertised by the card
towards the UE (modem/phone).  For example, by modifying the ATR
one can disable/constrain the UE from using higher bit rate support, or
disable the use of logical channels.

Change-Id: I930293f7b637dba60d9dd6d2254f4524f831b491
This commit is contained in:
Harald Welte 2022-07-24 12:54:24 +02:00
parent 445d284dfa
commit c8c77e08ee
5 changed files with 24 additions and 5 deletions

View File

@ -93,7 +93,13 @@ osmo-remsim-client-st2 currently has the following command-line options:
*-a, --atr HEXSTRING*::
Specify the initial ATR to be communicated to the modem/phone. Can
and will later be overridden by the ATR as specified by
`osmo-remsim-bankd` once a card has been mapped to this client.
`osmo-remsim-bankd` once a card has been mapped to this client, unless
the `--atr-ignore-rspro` option is also specified.
*-r, --atr-ignore-rspro*::
Ignore any incoming RSPRO setAtrReq and always only use the locally-specified
ATR when communicating with the UE/modem/phone. This can be used to constrain
the capabilities advertised. This way, for example, the baud rate can be constrained,
or the use of logical channels prevented.
*-e, --event-script COMMAND*::
Specify the shell command to be execute when the client wants to call its
helper script

View File

@ -73,6 +73,9 @@ struct client_config {
uint8_t data[ATR_SIZE_MAX];
uint8_t len;
} atr;
/* ignore any ATR received via RSPRO; only use the hard-coded default or
* optionally the ATR given at the command line */
bool atr_ignore_rspro;
struct {
int vendor_id;

View File

@ -280,9 +280,13 @@ static void main_st_operational(struct osmo_fsm_inst *fi, uint32_t event, void *
LOGPFSML(fi, LOGL_NOTICE, "Rx setAtrReq(%s)\n",
osmo_hexdump_nospc(pdu_rx->msg.choice.setAtrReq.atr.buf,
pdu_rx->msg.choice.setAtrReq.atr.size));
/* forward to modem/cardem (via API) */
frontend_handle_set_atr(bc, pdu_rx->msg.choice.setAtrReq.atr.buf,
pdu_rx->msg.choice.setAtrReq.atr.size);
if (bc->cfg->atr_ignore_rspro) {
LOGPFSML(fi, LOGL_NOTICE, "Ignoring RSPRO setAtrReq\n");
} else {
/* forward to modem/cardem (via API) */
frontend_handle_set_atr(bc, pdu_rx->msg.choice.setAtrReq.atr.buf,
pdu_rx->msg.choice.setAtrReq.atr.size);
}
/* send response to bankd */
resp = rspro_gen_SetAtrRes(ResultCode_ok);
server_conn_send_rspro(&bc->bankd_conn, resp);

View File

@ -57,6 +57,7 @@ struct client_config *client_config_init(void *ctx)
cfg->atr.data[0] = 0x3B;
cfg->atr.data[1] = 0x00; // the shortest simplest ATR possible
cfg->atr.len = 2;
cfg->atr_ignore_rspro = false;
return cfg;
};

View File

@ -33,6 +33,7 @@ static void printf_help()
" -c --client-id <0-1023> RSPRO ClientId of this client\n"
" -n --client-slot <0-1023> RSPRO SlotNr of this client\n"
" -a --atr HEXSTRING default ATR to simulate (until bankd overrides it)\n"
" -r --atr-ignore-rspro Ignore any ATR from bankd; use only ATR given by -a)\n"
" -e --event-script <path> event script to be called by client\n"
#ifdef USB_SUPPORT
" -V --usb-vendor VENDOR_ID\n"
@ -61,6 +62,7 @@ static void handle_options(struct client_config *cfg, int argc, char **argv)
{ "client-id", 1, 0, 'c' },
{ "client-slot", 1, 0, 'n' },
{ "atr", 1, 0, 'a' },
{ "atr-ignore-rspro", 0, 0, 'r' },
{ "event-script", 1, 0, 'e' },
#ifdef USB_SUPPORT
{ "usb-vendor", 1, 0, 'V' },
@ -74,7 +76,7 @@ static void handle_options(struct client_config *cfg, int argc, char **argv)
{ 0, 0, 0, 0 }
};
c = getopt_long(argc, argv, "hvd:i:p:c:n:a:e:"
c = getopt_long(argc, argv, "hvd:i:p:c:n:a:re:"
#ifdef USB_SUPPORT
"V:P:C:I:S:A:H:"
#endif
@ -114,6 +116,9 @@ static void handle_options(struct client_config *cfg, int argc, char **argv)
exit(2);
}
break;
case 'r':
cfg->atr_ignore_rspro = true;
break;
case 'e':
osmo_talloc_replace_string(cfg, &cfg->event_script, optarg);
break;