Commit Graph

307 Commits

Author SHA1 Message Date
Harald Welte fd5a62ab47 client: Sort getopt-long like getopt like help message
Change-Id: I150bf89c3b0652c860a90d728dc7a6e1d23f2961
2019-03-30 12:01:51 +01:00
Harald Welte 2f89b965a6 client: transmit RSPRO via bankd_conn_fsm
This fixes a crash where the modem/phone would sent APDUs at a time
when there is no connection to the bankd yet.  If we transmit the
RSPRO PDUs via the FSM, this cannot happen.

Change-Id: I965666ae4622c403e63c060deaa4d80e9249d155
2019-03-30 12:01:51 +01:00
Harald Welte 2eee4507ca bankd/client: Fix memory leak if rspro_enc_msg() fails
Change-Id: Ib72b077d82939be0627b9dd7c905fb2a33db9ca5
2019-03-30 08:50:35 +01:00
Harald Welte 972a1e892e client: Fix initialization order: logging first
otherwise some sub-system might want to log without the logging being
initialized first.

Change-Id: I179d937bd4eae0e82d9ebdb07748a0663a244756
2019-03-30 08:34:30 +01:00
Harald Welte 7817b20e04 client: Default server port is 9998, not 9999
Change-Id: Ifd19cb2aaff7e53c0d142cea07ca75c064a7ee12
2019-03-30 08:34:14 +01:00
Harald Welte 2ea20b92fd client: Use stack instead of heap when possible
Change-Id: If555d7cf2d7ef2152dd9d78e7ed1ba65e83ed59b
2019-03-30 08:33:49 +01:00
Harald Welte 9bfc6b3ba6 remsim_client: Use bankd_conn_send_rspro() where applicable
Change-Id: I63b3b07379ae66208a03d3a27500e7973ddfb9e7
2019-03-28 20:29:53 +01:00
Harald Welte f14dc04627 cosmetic: fix typo in comment
Change-Id: I3a1be1b8adc74a2f2ef51b766ef4e17ac88a7ce9
2019-03-28 20:29:36 +01:00
Harald Welte fa365593cb remsim_client: Process SetAtrReq() and set ATR in SIMtrace2 firmware
Change-Id: Iddcb13c8f4e98aac4e44bda32b8ad4cdeead50e7
2019-03-28 20:28:57 +01:00
Harald Welte 297d72ef47 bankd: Move all PC/SC specific code to bankd_pcsc
Change-Id: I435b42982b54d74447c435dcefa26d1e317d15e0
2019-03-28 18:58:21 +01:00
Harald Welte 1f699b405a bankd_main: Obtain ATR of card via PC/SC API
Change-Id: Ie73806e2190e604cab96b3f632b4bbfffb7d0112
2019-03-28 18:58:21 +01:00
Harald Welte e57334ed9d rspro_client_fsm: Use osmocom logging API instead of direct printf
Change-Id: Iaf004e1839340371052d4e36baed4faee9f3744e
2019-03-27 22:58:10 +01:00
Harald Welte 8d8d4f162b remsim_client: Use osmocom logging instead of printf
Change-Id: I7e695335b4c4652a534cefa073dcea9f424d6744
2019-03-27 22:53:47 +01:00
Harald Welte 94ba99b5d0 bankd_main: Add more logging in error situations
Change-Id: I48e01d4517da1ac2983946d84c7a95ea9797e5b8
2019-03-27 22:42:11 +01:00
Harald Welte eb971b5209 bankd_main: don't use fprintf if we can use osmocom logging API
Change-Id: I0b6ed933ffb3e3d689b344bd215357577e3120aa
2019-03-27 22:41:45 +01:00
Harald Welte e1d3289ed9 bankd: Verify bankd/client slot in tpduModemToCard rx handler
Change-Id: I58fce1392f418b36f5f61f224e03a9dbbe34f01f
2019-03-27 20:47:42 +01:00
Harald Welte 4e7a285427 rspro_client_fsm: Disconnect if Connect{Client,Bank}Res != ok
Change-Id: Id199f9c4cb4c86fd0dba8939334ac69878f4a3f5
2019-03-17 21:01:50 +01:00
Harald Welte ce638d8fd7 client, bankd: Add SIGUSR1 handling for talloc context debugging
Change-Id: I9153f4cc89b3911a4f9ea4f02fe1b108420d2eed
2019-03-17 09:36:04 +01:00
Harald Welte 75f560338c bankd_client_fsm: Fix ESTABLISH signal handling
Change-Id: Ib7a09ff6cad0b0eba17908cba733df35b7ee767d
2019-03-17 09:35:41 +01:00
Harald Welte 7a950888f5 client: Don't ntohs() integer values from asn1 decoder
The ASN1 decoder takes care of endianness for us.

Change-Id: I9c3127b4fb195db5e81702e043e4fe595474b561
2019-03-17 09:35:16 +01:00
Harald Welte 9cf013a343 remsim_client: Store and use BankSlot received in ConfigClientBankReq
Change-Id: I6858b68590789d38741e541b9028d2b9b142e0c0
2019-03-11 22:19:19 +01:00
Harald Welte cf8b89ad84 Move client/bank slot conversion functions to rspro_util.c
Change-Id: I18f1d1cb1fb712b01a0991419743db52338688af
2019-03-11 22:16:22 +01:00
Harald Welte d571a3e2e1 RSPRO: split ConfigClient into ConfigClientId and ConfigClientBank
The point is that the ClientId is only set once at start-up (and
also only optionally), while the Bank IP/port/ID/slot can be changed
any number of times during a RSPRO connection.

Change-Id: Ic76207c7dd7c18fe93bc5133b29c5f9438a9fb0e
2019-03-11 22:09:50 +01:00
Harald Welte 19f881a373 bankd: respond to IPA PING from client with IPA PONG
The bankd worker threads handle the RSPRO connection from the
remsim-clients outside of our usual osmo* infrastructure and hence
they don't inherit the common IPA CCM handling.  This means we need
to explicitly implement the keep-alive PONG support.

What this doesn't add is any outbound keepalive handling towards
the client.

Change-Id: I86f8ca28ece62c33ccbf45c9c65172be8a647407
2019-03-11 18:39:13 +01:00
Harald Welte 653d6a0b38 bankd: Disconnect client if we enter state BW_ST_CONN_CLIENT_UNMAPPED
Change-Id: Ifc1741610fc8a3c0413844e0c37a6fcbb2c55067
2019-03-11 18:38:44 +01:00
Harald Welte 2507597c42 bankd: Implement thread-safe SIGUSR1 talloc context reporting
If the main thread receives SIGUSR1, we dump its talloc report and
then signal all worker threads so each can dump their own talloc
report.

Change-Id: I89e7e22de5557376bd5a9625662d99ac0badf00c
2019-03-11 17:39:29 +01:00
Harald Welte 286a2beaa9 bandk: store the worker name as part of 'struct bankd_worker'
Change-Id: Ife981a4d555f96b63aeaedf27c3ebe513191b0c7
2019-03-11 17:39:29 +01:00
Harald Welte 00a9673ac2 bankd: terminate bankd connection once map is deleted
This implements a signal based mechanism by which the main thread can
inform worker threads that their mapping has just been removed and
they should hence terminate the connection and return themselves to the
pool.

Change-Id: Id932810d59e9e5d8994629d57aaf180bc96f90f5
2019-03-11 17:18:02 +01:00
Harald Welte 458e01b611 bankd: Return ConnectClientRes in error paths of worker_handle_connectClientReq
Change-Id: Ic0d3119c1c5fa412a9d14bb26da5f84ba6f55ae3
2019-03-10 11:14:43 +01:00
Harald Welte 942f1ff162 bankd: Actually send the RemoveMappingRes we prepare
Change-Id: I01d1216ab9461a7e3c51c55a1ab33229bd920da7
2019-03-09 21:49:08 +01:00
Harald Welte a025e7008d rspro_client_fsm: Ensure close + reconnect on missing Connect*Res from server
Change-Id: I7f9bbdf246eb206342bd94be0b13ae45dd40084e
2019-03-09 21:39:09 +01:00
Harald Welte 454f5e2543 bankd: Don't use hard-coded slotmaps but receive them from remsim-server
Change-Id: I642476c2935fbaa96ce5986e3e6708eed0d2ffe2
2019-03-09 21:38:34 +01:00
Harald Welte a0f395043e bankd: Don't create 10 workers, but 'num_slots' workers
Change-Id: Ie86321e3f61ed86bbbe2ca8cfbd9edde6060bb9f
2019-03-09 21:01:31 +01:00
Harald Welte f4b16f1c11 bankd_main: Introduce g_bankd global variable
Change-Id: Ib1a94333f107beb695075b30e41396a6d1f4f29d
2019-03-09 20:58:17 +01:00
Harald Welte b49ac9c6bb rspro_util: Add rspro_msgt_name() to get RSPRO message type name + use it
Change-Id: I4b270addd024f9766923183a75381b71ffe1cfae
2019-03-09 20:36:07 +01:00
Harald Welte 229e6abce1 Add asn1c_helpers.c file to get type/enum/choice names for printing
Change-Id: I478d09776e58c86b84e82251f46f8d778b79a04c
2019-03-09 20:19:28 +01:00
Harald Welte 769ab7d04a RSPRO: Add ErrorInd
Change-Id: I5e5e227d188c5f30ae9be60dd0439ae6f6913b8a
2019-03-09 15:10:36 +01:00
Harald Welte 71752ddd2b RSPRO: Add two more ResoltCodes
Change-Id: I1b665b501106a4aac90e642c11f4123e6a77868d
2019-03-09 15:08:01 +01:00
Harald Welte a844bb07d8 Introduce {server,bankd}_conn_send_rspro()
Change-Id: I8cae6f67567dcbf4b6d62fb5a76f5b7134b16f5d
2019-03-09 13:40:34 +01:00
Harald Welte 3dcdd20343 add missing copyright / license headers everywhere
Change-Id: I5c1fceead0ee799a948995f55c6ebee441cfb79a
2019-03-09 13:11:56 +01:00
Harald Welte 3cded63aa6 naming: Distinguish "rspro client" from "remsim client"
"remsim-client" is the client program running next to a phone/modem
which is attaching to the SIM slot.

"RSPRO client" is a protocl-level client of the RSPRO protocol:
* the remsim-client connects as RSPRO client to the remsim-server
* the remsim-client connects as RSPRO client to the remsim-bankd
* the remsim-bankd connects as RSPRO client to the remsim-server

Let's clarify this in naming.

Change-Id: I10462d4669a0a30c46f3f8d3df67e9c1d4ce8c4b
2019-03-09 13:11:56 +01:00
Harald Welte 707c85a49b Split "RSPRO client FSM" from "BANKD client FSM"
This allows the RSPRO client FSM to be used by both remsim-client
as well as remsim-bankd -- both of which connect as RSPRO client to
remsim-server.

Change-Id: I57b5f8dc9de522b6ae8ceb030e639b5b8001b55a
2019-03-09 13:11:48 +01:00
Harald Welte 228af8a19b remsim-client: Add command-line options for server ip/port and client id/slot
Change-Id: I26d6e0d2ad92e7164e0d8ac710361f9c5f5200df
2019-03-08 22:20:21 +01:00
Harald Welte ec628e964e client: move ClientSlot from bankd_conn to srv_conn
If the client uses a locally-configured (static) ClientId, then
the bankd_client_fsm.c code needs access to this information
at time of the connect to the server, not just when connecting
to the bankd.

Change-Id: I8238b4c56c723f9edcf1042f8a7793208c42f15c
2019-03-08 22:18:31 +01:00
Harald Welte c7995e7112 client: Early call to osmo_init_logging2()
Change-Id: I8f6ee5a95c23821efb02872c41b3121ed532a819
2019-03-08 20:45:46 +01:00
Harald Welte 03b24114b3 client: Add IPA Keepalive handling
Change-Id: I4acf862bc575741e57ef76c1709d3a00e1850566
2019-03-08 20:43:00 +01:00
Harald Welte 1a17104639 client: Restructure {srvc,bankd}_read_cb()
Introduce some switch statements to make code more extensable.

Change-Id: I9d1a6c29cbfc2f01995a2093978fae8577f1771f
2019-03-08 19:18:52 +01:00
Harald Welte 15b75e1e5c remsim-server: Add support for keepalive
This ensures that any RSPRO client (remsim-client or remsim-bankd) is
disconnected if he's no longer responding to IPA PING requests.

Change-Id: I324f0f2a0613d6310e1d191103b136c539b6ec05
Depends: libosmocore Change-Id I2763da49a74de85046ac07d53592c89973314ca6
2019-03-08 17:09:07 +01:00
Harald Welte 7bfcc65227 slotmap: restructure read_cb()
Change-Id: I7fb457f028f9aabc7b4b53bf036e5eac9d785299
2019-03-08 16:55:01 +01:00
Harald Welte e5c7773c7f client slot
Change-Id: I40f0589b2014a1df5ce4de745ec46642c68ad0c5
2019-03-07 23:58:24 +01:00