Commit Graph

145 Commits

Author SHA1 Message Date
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
Harald Welte f5a0fa37c4 Initial version of remsim-server
Change-Id: I1caadc528d5e61a4129c32c53283250cd37f3a3c
2019-03-07 21:35:48 +01:00
Harald Welte 648f4e33b4 slotmap: Introduce slotmap_{rd,wr,un}lock() wrappers for lock debugging
Change-Id: I8dde90d62e673e60e026979c74074f7084490467
2019-03-07 21:15:32 +01:00
Harald Welte 4b676bc6f1 slotmap: Log file/line when changing state
Change-Id: Idc7b350b464ddc50076f92dae592a0d5ad4d486a
2019-03-07 21:15:32 +01:00
Harald Welte 294298c4af slotmap: Add _slotmap_del() for callers that already have a lock
Change-Id: Id05872c3676d0afe4c7abe74677fee62b4f03e53
2019-03-07 10:09:26 +01:00
Harald Welte c86568359c slotmap: Add slotmap_get_id() function to get numeric ID of slot map
Change-Id: Ie476244d9ade30eed9215923275aa82a5d10176f
2019-03-07 10:09:26 +01:00
Harald Welte 2bf39e0fe0 slotmap: Add "DELETE_REQ" state
Change-Id: I953e72e304d6403b2e47f7546a36abfdf246e44b
2019-03-07 10:09:26 +01:00
Harald Welte f4e75043de slotmap: Return newly-created map from slotmap_add()
Change-Id: I1bc66fee1f457bcf9693491031d7d4c411fc582e
2019-03-05 15:23:12 +01:00
Harald Welte 91a0a4adda slotmap: Introduce the concept of a slotmap state
... which is required in remsim-server

Change-Id: I56f5ecd6194ef62c87d87d2965ca0315e3d0fc2d
2019-03-05 15:23:12 +01:00
Harald Welte faef8f06ed slotmap: Introduce slotmap-printing function and use it
... avoid code duplication

Change-Id: I6458b9d222ed9f4113c3bb1c538b4b710559c6b2
2019-03-03 21:59:37 +01:00
Harald Welte cbd18960e7 generalize slotmap to make use of it outside of bankd
Change-Id: I0ca7feaa38dfd0468814ef5a1eff997ce854cedf
2019-03-03 19:38:40 +01:00
Harald Welte 61d98e9f3e share debug.[ch] across all executables
This avoids us having to re-define log_info/log_info_cat for each
program.

Change-Id: I22f4f8a51b91ee09c5be26b1ed1bfca41730c577
2019-03-03 15:43:07 +01:00
Harald Welte e56f2b9b46 client: Connect to server before connecting to bankd
So far we skipped the client->server connection and related
configuration transfer from server to client.  Now, the server
instructs the client to which bankd ip/port to connect.

Change-Id: I76c9498089515d1a6190f3e79e143b7df3a531bd
2019-03-02 17:02:13 +01:00