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
diff --git a/src/client/client.h b/src/client/client.h
index 9cfdc5d..8fcbcb3 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -73,6 +73,9 @@
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;
diff --git a/src/client/main_fsm.c b/src/client/main_fsm.c
index b79d061..1da0106 100644
--- a/src/client/main_fsm.c
+++ b/src/client/main_fsm.c
@@ -280,9 +280,13 @@
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);
diff --git a/src/client/remsim_client.c b/src/client/remsim_client.c
index 247ae42..a5dc6c9 100644
--- a/src/client/remsim_client.c
+++ b/src/client/remsim_client.c
@@ -57,6 +57,7 @@
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;
};
diff --git a/src/client/remsim_client_main.c b/src/client/remsim_client_main.c
index 4238864..5a23d82 100644
--- a/src/client/remsim_client_main.c
+++ b/src/client/remsim_client_main.c
@@ -33,6 +33,7 @@
" -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 @@
{ "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 @@
{ 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 @@
exit(2);
}
break;
+ case 'r':
+ cfg->atr_ignore_rspro = true;
+ break;
case 'e':
osmo_talloc_replace_string(cfg, &cfg->event_script, optarg);
break;