Harald Welte | 51cfec0 | 2019-04-03 09:18:44 +0200 | [diff] [blame] | 1 | == osmo-remsim-bankd |
Harald Welte | 5bae20b | 2019-04-01 09:36:42 +0200 | [diff] [blame] | 2 | |
Harald Welte | 51cfec0 | 2019-04-03 09:18:44 +0200 | [diff] [blame] | 3 | The `osmo-remsim-bankd` (SIM Bank Daemon) manages one given SIM bank. |
| 4 | The initial implementation supports a PC/SC driver to expose any PC/SC |
Harald Welte | 35f2b20 | 2019-04-01 11:01:51 +0200 | [diff] [blame] | 5 | compatible card readers as SIM bank. |
| 6 | |
Harald Welte | 51cfec0 | 2019-04-03 09:18:44 +0200 | [diff] [blame] | 7 | `osmo-remsim-bankd` initially connects via a RSPRO control connection to |
| 8 | `osmo-remsim-server` at startup, and will in turn receive a set of |
| 9 | initial [client,slot]:[bankd,slot] mappings. These mappings determine |
| 10 | which slot on the client (corresponding to a modem) is mapped to which |
| 11 | slot on the SIM bank. Mappings can be updated by `osmo-remsim-server` |
| 12 | at any given point in time. |
Harald Welte | 35f2b20 | 2019-04-01 11:01:51 +0200 | [diff] [blame] | 13 | |
Harald Welte | 51cfec0 | 2019-04-03 09:18:44 +0200 | [diff] [blame] | 14 | `osmo-remsim-bankd` implements a RSPRO server, where it listens to |
| 15 | connections from `osmo-remsim-clients`. |
Harald Welte | 35f2b20 | 2019-04-01 11:01:51 +0200 | [diff] [blame] | 16 | |
| 17 | As PC/SC only offers a blocking API, there is one thread per PC/SC slot. |
| 18 | This thread will perform blocking I/O on the socket towards the client, |
| 19 | and blocking API calls on PC/SC. |
| 20 | |
| 21 | In terms of thread handling, we do: |
| 22 | |
| 23 | * accept() handling in [spare] worker threads |
| 24 | ** this means blocking I/O can be used, as each worker thread only has |
| 25 | one TCP connection |
| 26 | ** client identifies itself with client:slot |
| 27 | ** lookup mapping based on client:slot (using mutex for protection) |
| 28 | ** open the reader based on the lookup result |
| 29 | |
| 30 | The worker threads initially don't have any mapping to a specific |
| 31 | reader, and that mapping is only established at a later point after the |
| 32 | client has identified itself. The advantage is that the entire bankd |
| 33 | can live without any non-blocking I/O. |
| 34 | |
Harald Welte | 51cfec0 | 2019-04-03 09:18:44 +0200 | [diff] [blame] | 35 | The main thread handles the connection to `osmo-remsim-server`, where it |
| 36 | can also use non-blocking I/O. However, re-connection would be |
| 37 | required, to avoid stalling all banks/cards in the event of a connection |
| 38 | loss to the server. |
Harald Welte | 35f2b20 | 2019-04-01 11:01:51 +0200 | [diff] [blame] | 39 | |
| 40 | worker threads have the following states: |
| 41 | * INIT (just started) |
| 42 | * ACCEPTING (they're blocking in the accept() call on the server socket fd) |
| 43 | * CONNECTED_WAIT_ID (TCP established, but peer not yet identified itself) |
| 44 | * CONNECTED_CLIENT (TCP established, client has identified itself, no mapping) |
| 45 | * CONNECTED_CLIENT_MAPPED (TCP established, client has identified itself, mapping exists) |
| 46 | * CONNECTED_CLIENT_MAPPED_CARD (TCP established, client identified, mapping exists, card opened) |
| 47 | * CONNECTED_SERVER (TCP established, server has identified itself) |
| 48 | |
| 49 | Once the client disconnects, or any other error occurs (such as card I/O |
| 50 | errors), the worker thread either returns to INIT state (closing client |
| 51 | socket and reader), or it terminates. Termination would mean that the |
| 52 | main thread would have to do non-blocking join to detect client |
| 53 | termination and then re-spawn clients, so the "return to INIT state" |
| 54 | approach seems to make more sense. |
| 55 | |
| 56 | |
Harald Welte | 5bae20b | 2019-04-01 09:36:42 +0200 | [diff] [blame] | 57 | === Running |
| 58 | |
Harald Welte | 51cfec0 | 2019-04-03 09:18:44 +0200 | [diff] [blame] | 59 | `osmo-remsim-bankd` currently has the following command-line options: |
Harald Welte | 5bae20b | 2019-04-01 09:36:42 +0200 | [diff] [blame] | 60 | |
| 61 | ==== SYNOPSIS |
| 62 | |
Harald Welte | 51cfec0 | 2019-04-03 09:18:44 +0200 | [diff] [blame] | 63 | *osmo-remsim-bankd* [-h] [-i A.B.C.D] [-p <1-65535>] [-b <1-65535>] [-n <1-65535>] [-I A.B.C.D] [-P <1-65535> ] |
Harald Welte | 5bae20b | 2019-04-01 09:36:42 +0200 | [diff] [blame] | 64 | |
| 65 | ==== OPTIONS |
| 66 | |
| 67 | *-h, --help*:: |
| 68 | Print a short help message about the supported options |
Harald Welte | 3c4d006 | 2019-03-31 18:55:18 +0200 | [diff] [blame] | 69 | *-i, --server-host A.B.C.D*:: |
Harald Welte | 51cfec0 | 2019-04-03 09:18:44 +0200 | [diff] [blame] | 70 | Specify the remote IP address/hostname of the `osmo-remsim-server` to |
| 71 | which this bankd shall establish its RSPRO control connection |
Harald Welte | 5bae20b | 2019-04-01 09:36:42 +0200 | [diff] [blame] | 72 | *-p, --server-port <1-65535>*:: |
Harald Welte | 51cfec0 | 2019-04-03 09:18:44 +0200 | [diff] [blame] | 73 | Specify the remote TCP port number of the `osmo-remsim-server` to which |
| 74 | this bankd shall establish its RSPRO control connection |
Harald Welte | 5bae20b | 2019-04-01 09:36:42 +0200 | [diff] [blame] | 75 | *-b, --bank-id <1-65535>*:: |
Harald Welte | 51cfec0 | 2019-04-03 09:18:44 +0200 | [diff] [blame] | 76 | Specify the numeric bank identifier of the SIM bank this bankd |
| 77 | instance operates. Must be unique among all banks connecting to the |
| 78 | same `osmo-remsim-server`. |
Harald Welte | 2513d81 | 2019-04-01 21:03:02 +0200 | [diff] [blame] | 79 | *-n, --num-slots <1-65535>*:: |
| 80 | Specify the number of slots that this bankd handles. |
Harald Welte | 5bae20b | 2019-04-01 09:36:42 +0200 | [diff] [blame] | 81 | *-I, --bind-IP A.B.C.D*:: |
| 82 | Specify the local IP address to which the socket for incoming connections |
Harald Welte | 51cfec0 | 2019-04-03 09:18:44 +0200 | [diff] [blame] | 83 | from `osmo-remsim-clients` is bound to. |
Harald Welte | 5bae20b | 2019-04-01 09:36:42 +0200 | [diff] [blame] | 84 | *-P, --bind-port <1-65535>*:: |
| 85 | Specify the local TCP port to whicc the socket for incoming connections |
Harald Welte | 51cfec0 | 2019-04-03 09:18:44 +0200 | [diff] [blame] | 86 | from `osmo-remsim-client`s is bound to. |
Harald Welte | 5bae20b | 2019-04-01 09:36:42 +0200 | [diff] [blame] | 87 | |
Joachim Steiger | 68f9510 | 2019-07-03 19:03:24 +0200 | [diff] [blame] | 88 | ==== Examples |
| 89 | .remsim-server is on 10.2.3.4, cardreader has 5 slots: |
| 90 | ---- |
| 91 | osmo-remsim-bankd -i 10.2.3.4 -n 5 |
| 92 | ---- |
| 93 | .remsim-server is on 10.2.3.4, cardreader has 4 slots, local ip is 10.5.4.3 |
| 94 | ---- |
| 95 | osmo-remsim-bankd -i 10.2.3.4 -n 4 -I 10.5.4.3 |
| 96 | ---- |
| 97 | |
Harald Welte | 5bae20b | 2019-04-01 09:36:42 +0200 | [diff] [blame] | 98 | === Logging |
| 99 | |
Harald Welte | 51cfec0 | 2019-04-03 09:18:44 +0200 | [diff] [blame] | 100 | `osmo-remsim-bankd` currently logs to stdout only, and the logging |
| 101 | verbosity is not yet configurable. However, as the libosmocore logging |
| 102 | framework is used, extending this is an easy modification. |
Harald Welte | 5bae20b | 2019-04-01 09:36:42 +0200 | [diff] [blame] | 103 | |
| 104 | === `bankd_pcsc_slots.csv` CSV file |
| 105 | |
| 106 | bankd expects a CSV file `bankd_pcsc_slots.csv` in the current working directory at startup. |
| 107 | |
| 108 | This CSV file specifies the mapping between the string names of the PCSC |
Harald Welte | 0138bb4 | 2019-04-01 11:04:04 +0200 | [diff] [blame] | 109 | readers and the RSPRO bandk/slot numbers. The format is as follows: |
Harald Welte | 5bae20b | 2019-04-01 09:36:42 +0200 | [diff] [blame] | 110 | |
| 111 | .Example: CSV file mapping bankd slots 0..4 to an ACS ACR33U-A1 reader slots |
| 112 | ---- |
| 113 | "1","0","ACS ACR33 ICC Reader 00 00" |
| 114 | "1","1","ACS ACR33 ICC Reader 00 01" |
| 115 | "1","2","ACS ACR33 ICC Reader 00 02" |
| 116 | "1","3","ACS ACR33 ICC Reader 00 03" |
| 117 | "1","4","ACS ACR33 ICC Reader 00 04" |
| 118 | ---- |
Harald Welte | 33a3e87 | 2019-05-29 20:12:32 +0200 | [diff] [blame] | 119 | |
| 120 | You can obtain the exact string to use as PC/SC reader name from the output of the |
| 121 | `pcsc_scan` utility (part of pcsc-lite package). The tool will produce output like: |
| 122 | |
| 123 | .Example: Output of `pcsc_scan` utility on a system with a single reader installed |
| 124 | ---- |
| 125 | Scanning present readers... |
| 126 | 0: Alcor Micro AU9560 00 00 |
| 127 | ---- |
| 128 | |
| 129 | In this example, there's only a single PC/SC reader available, and it has a string of |
Martin Hauke | 4e87beb | 2019-07-17 22:10:47 +0200 | [diff] [blame] | 130 | "Alcor Micro AU9560 00 00" which needs to be copy-pasted into the CSV file. |