laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-remsim/+/28772 )
Change subject: client: Option to ignore any ATR sent by bankd
......................................................................
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
---
M doc/manuals/chapters/remsim-client.adoc
M src/client/client.h
M src/client/main_fsm.c
M src/client/remsim_client.c
M src/client/remsim_client_main.c
5 files changed, 24 insertions(+), 5 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/doc/manuals/chapters/remsim-client.adoc b/doc/manuals/chapters/remsim-client.adoc
index d897431..f5d5550 100644
--- a/doc/manuals/chapters/remsim-client.adoc
+++ b/doc/manuals/chapters/remsim-client.adoc
@@ -93,7 +93,13 @@
*-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
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;
--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/28772
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I930293f7b637dba60d9dd6d2254f4524f831b491
Gerrit-Change-Number: 28772
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-remsim/+/28590 )
Change subject: bankd: Open PC/SC by default in EXCLUSIVE mode
......................................................................
bankd: Open PC/SC by default in EXCLUSIVE mode
Let's open the cards in EXCLUSIVE mode, we don't want other applications
tinkering with the card state while we have a bankd worker running on
it. This change also means that no two bankd workers can trip on
each other accidentially anymore.
Related: OS#5527
Change-Id: I43a1c8c7bd1c0124ee5f605e2e5b04ed8f7836ab
---
M doc/manuals/chapters/remsim-bankd.adoc
M src/bankd/bankd.h
M src/bankd/bankd_main.c
M src/bankd/bankd_pcsc.c
4 files changed, 31 insertions(+), 3 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/doc/manuals/chapters/remsim-bankd.adoc b/doc/manuals/chapters/remsim-bankd.adoc
index 7c102de..cb3061c 100644
--- a/doc/manuals/chapters/remsim-bankd.adoc
+++ b/doc/manuals/chapters/remsim-bankd.adoc
@@ -89,6 +89,15 @@
*-P, --bind-port <1-65535>*::
Specify the local TCP port to which the socket for incoming connections
from `osmo-remsim-client`s is bound to.
+*-s, --permit-shared-pcsc*::
+ Specify whether the PC/SC readers should be accessed in SCARD_SHARE_SHARED
+ mode, instead of the default (SCARD_SHARE_EXCLUSIVE). Shared mode would
+ permit multiple application programs to access a single reader/slot/card
+ concurrently. This is potentially dangerous as the two programs operate
+ without knowledge of each other, and either of them might modify the card
+ state (such as the currently selected file, validated PIN, etc.) in a
+ way not expected by the other application.
+
==== Examples
.remsim-server is on 10.2.3.4, cardreader has 5 slots:
diff --git a/src/bankd/bankd.h b/src/bankd/bankd.h
index 9bf9bc9..0f94818 100644
--- a/src/bankd/bankd.h
+++ b/src/bankd/bankd.h
@@ -130,6 +130,10 @@
pthread_mutex_t workers_mutex;
struct llist_head pcsc_slot_names;
+
+ struct {
+ bool permit_shared_pcsc;
+ } cfg;
};
int bankd_pcsc_read_slotnames(struct bankd *bankd, const char *csv_file);
diff --git a/src/bankd/bankd_main.c b/src/bankd/bankd_main.c
index b28eec9..c2d6e69 100644
--- a/src/bankd/bankd_main.c
+++ b/src/bankd/bankd_main.c
@@ -98,6 +98,8 @@
/* FIXME: other members of app_comp_id */
INIT_LLIST_HEAD(&bankd->pcsc_slot_names);
+
+ bankd->cfg.permit_shared_pcsc = false;
}
/* create + start a new bankd_worker thread */
@@ -291,6 +293,7 @@
" connections (default: INADDR_ANY)\n"
" -P --bind-port <1-65535> Local TCP port to bind for incoming client\n"
" connectionss (default: 9999)\n"
+" -s --permit-shared-pcsc Permit SHARED access to PC/SC readers (default: exclusive)\n"
);
}
@@ -312,10 +315,11 @@
{ "component-name", 1, 0, 'N' },
{ "bind-ip", 1, 0, 'I' },
{ "bind-port", 1, 0, 'P' },
+ { "permit-shared-pcsc", 0, 0, 's' },
{ 0, 0, 0, 0 }
};
- c = getopt_long(argc, argv, "hVd:i:o:b:n:N:I:P:", long_options, &option_index);
+ c = getopt_long(argc, argv, "hVd:i:o:b:n:N:I:P:s", long_options, &option_index);
if (c == -1)
break;
@@ -352,6 +356,9 @@
case 'P':
g_bind_port = atoi(optarg);
break;
+ case 's':
+ g_bankd->cfg.permit_shared_pcsc = true;
+ break;
}
}
}
diff --git a/src/bankd/bankd_pcsc.c b/src/bankd/bankd_pcsc.c
index ee01c93..e1477dd 100644
--- a/src/bankd/bankd_pcsc.c
+++ b/src/bankd/bankd_pcsc.c
@@ -184,6 +184,14 @@
LOGW((w), text ": OK\n"); \
}
+static DWORD bankd_share_mode(struct bankd *bankd)
+{
+ if (bankd->cfg.permit_shared_pcsc)
+ return SCARD_SHARE_SHARED;
+ else
+ return SCARD_SHARE_EXCLUSIVE;
+}
+
static int pcsc_get_atr(struct bankd_worker *worker)
{
long rc;
@@ -232,7 +240,7 @@
int r = regexec(&compiled_name, p, 0, NULL, 0);
if (r == 0) {
LOGW(worker, "Attempting to open card/slot '%s'\n", p);
- rc = SCardConnect(worker->reader.pcsc.hContext, p, SCARD_SHARE_SHARED,
+ rc = SCardConnect(worker->reader.pcsc.hContext, p, bankd_share_mode(worker->bankd),
SCARD_PROTOCOL_T0, &worker->reader.pcsc.hCard,
&dwActiveProtocol);
if (rc == SCARD_S_SUCCESS)
@@ -289,7 +297,7 @@
LOGW(worker, "Resetting card in '%s' (%s)\n", worker->reader.name,
cold_reset ? "cold reset" : "warm reset");
- rc = SCardReconnect(worker->reader.pcsc.hCard, SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0,
+ rc = SCardReconnect(worker->reader.pcsc.hCard, bankd_share_mode(worker->bankd), SCARD_PROTOCOL_T0,
cold_reset ? SCARD_UNPOWER_CARD : SCARD_RESET_CARD, &dwActiveProtocol);
PCSC_ERROR(worker, rc, "SCardReconnect");
--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/28590
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I43a1c8c7bd1c0124ee5f605e2e5b04ed8f7836ab
Gerrit-Change-Number: 28590
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-remsim/+/28771 )
Change subject: client: Fix '-a' command-line argument for ATR
......................................................................
client: Fix '-a' command-line argument for ATR
The argument existed (as a long option), and was documented in the
user manual - but it wasn't printed in the help message, nor was it
present in the getopt_long() string.
Let's fix that.
Change-Id: Icfb74597dd813cee8b48b8dcf520fdd1c954338a
---
M src/client/remsim_client_main.c
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, approved
diff --git a/src/client/remsim_client_main.c b/src/client/remsim_client_main.c
index e3d3cf8..4238864 100644
--- a/src/client/remsim_client_main.c
+++ b/src/client/remsim_client_main.c
@@ -32,6 +32,7 @@
" -p --server-port 13245 remsim-server TCP port\n"
" -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"
" -e --event-script <path> event script to be called by client\n"
#ifdef USB_SUPPORT
" -V --usb-vendor VENDOR_ID\n"
@@ -73,7 +74,7 @@
{ 0, 0, 0, 0 }
};
- c = getopt_long(argc, argv, "hvd:i:p:c:n:e:"
+ c = getopt_long(argc, argv, "hvd:i:p:c:n:a:e:"
#ifdef USB_SUPPORT
"V:P:C:I:S:A:H:"
#endif
--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/28771
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: Icfb74597dd813cee8b48b8dcf520fdd1c954338a
Gerrit-Change-Number: 28771
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
Attention is currently required from: laforge, pespin, dexter.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/28678 )
Change subject: trxcon: support handling of multiple L1CTL client connections
......................................................................
Patch Set 6:
(2 comments)
File src/host/trxcon/src/l1ctl_server.c:
https://gerrit.osmocom.org/c/osmocom-bb/+/28678/comment/14c0fe08_6c6b15d3
PS6, Line 55: "L1CTL server has lost connection (id=%u)\n",
> looks like you want to print id inside LOGP_CLI directly, not here.
No, because at this point you don't have struct trxcon_inst associated with struct l1ctl_client. This is done in client->server->cfg->conn_accept_cb().
https://gerrit.osmocom.org/c/osmocom-bb/+/28678/comment/7674b2f7_2c994ede
PS6, Line 167: LOGP(DL1C, LOGL_NOTICE, "L1CTL server got a new connection (id=%u)\n", client->id);
> Use LOGP_CLI
Same here, struct trxcon_inst is allocated and associated in client->server->cfg->conn_accept_cb(). I intentionally print "got a new connection" before calling it because logging chronology looks more logical this way.
--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/28678
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Id92e5b553487e4cf10ea291b487a3ef0c65d72ae
Gerrit-Change-Number: 28678
Gerrit-PatchSet: 6
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 25 Jul 2022 12:06:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: comment