commit | d2192e27ce77b1d60cd4e848b9892c892eaedda5 | [log] [tgz] |
---|---|---|
author | Harald Welte <laforge@osmocom.org> | Thu Nov 07 18:10:57 2019 +0100 |
committer | Harald Welte <laforge@osmocom.org> | Thu Dec 05 08:56:27 2019 +0100 |
tree | 3127168d11aedce3365311c9c41d90d430c6100b | |
parent | 4b75f0dc3ccb879a6344fc2c2fef26e6f948af37 [diff] |
rspro_client_fsm: Disable automatic connect on FSM allocation So far, the rspor_client_fsm immediately attempted to establish a TCP connection to the RSPRO server when calling server_conn_fsm_alloc(). Let's make this implicit auto-connect an explicit request to connect using the newly-introduced SRVC_E_ESTABLISH. Let's also change all three existing users of server_conn_fsm_alloc() to send SRVC_E_ESTABLISH after calling it. The rationale of this change is to use the same rspro_client_fsm also for the client->bankd RSPRO connection, where we don't want to automatically connect at startup, but connect only at a later point, after the server a has told us to do so. Change-Id: Icd882405f2ef54e10a66054829c089e4985f1d1f
This software suite is a work in progress.
The client interfaces with GSM phones / modems via dedicated "Card Emulation" devices such as the Osmocom SIMtrace2 or sysmocom sysmoQMOD board + firmware. This hardware implements the ISO7816-3 electrical interface and protocol handling and passes any TPDU headers received from the phone/modem to osmo-remsim-client for further processing of the TPDUs associated to the given APDU transfer.
osmo-remsim-client connects via a RSPRO control connection to osmo-remsim-server at startup and registers itself. It will receive configuration data such as the osmo-remsim-bankd IP+Port and the ClientId from osmo-remsim-server.
After receiving the configuration, osmo-remsim-client will establish a RSPRO data connection to the osmo-remsim-bankd IP:Port.
As the USB interface for remote SIM in simtrace2.git uses one interface per slot, we can implement the client in blocking mode, i.e. use blocking I/O on the TCP/RSPRO side. This simplifies the code compared to a more complex async implementation.
The osmo-remsim-bankd (SIM Bank Daemon) manages one given SIM bank. The initial implementation supports a PC/SC driver to expose any PC/SC compatible card readers as SIM bank.
osmo-remsim-bankd initially connects via a RSPRO control connection to osmo-remsim-server at startup, and will in turn receive a set of initial [client,slot]:[bankd,slot] mappings. These mappings determine which slot on the client (corresponding to a modem) is mapped to which slot on the SIM bank. Mappings can be updated by osmo-remsim-server at any given point in time.
osmo-remsim-bankd implements a RSPRO server, where it listens to connections from osmo-remsim-clients.
As PC/SC only offers a blocking API, there is one thread per PC/SC slot. This thread will perform blocking I/O on the socket towards the client, and blocking API calls on PC/SC.
In terms of thread handling, we do:
The worker threads initially don't have any mapping to a specific reader, and that mapping is only established at a later point after the client has identified itself. The advantage is that the entire bankd can live without any non-blocking I/O.
The main thread handles the connection to osmo-remsim-server, where it can also use non-blocking I/O. However, re-connection would be required, to avoid stalling all banks/cards in the event of a connection loss to the server.
worker threads have the following states:
Once the client disconnects, or any other error occurs (such as card I/O errors), the worker thread either returns to INIT state (closing client socket and reader), or it terminates. Termination would mean that the main thread would have to do non-blocking join to detect client termination and then re-spawn clients, so the "return to INIT state" approach seems to make more sense.
Open topics: