Commit Graph

44 Commits

Author SHA1 Message Date
Harald Welte d2192e27ce 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
2019-12-05 08:56:27 +01:00
Harald Welte cd7fcd717c Add "--version" to all executables to print compile-time version info
Change-Id: I9ae504ff95beeefb9e90e02a576861351ea9e143
2019-12-04 21:13:24 +00:00
Kevin Redon da1854c2d7 client: fix help strings
for the osmo-remsim-client-st2 client,
the command line arguments bankd-port and slot-nr have been renamed
to server-port and client-slot in the opts options, but not in the
help output.
this is now fixed.

Change-Id: Ie23fdc443f2f90f4baf36f8aca237c9994cce8ad
2019-09-17 14:17:14 +02:00
Harald Welte 573a5b9ed9 rspro_dec_msg: Simplify msgb ownership handling
Initially it seemed like a good idea that rspro_dec_msg() takes care
of freeing the input msgb when generating a new decoded output
structure.  However, in reality this made the implementation of
every caller more complicated, as it had to treat messages going into
rspro_dec_msg() differently than messages going elsewhere.

Adding to that, not every caller got it right, and the comments were
disagreeing about what happens to msgb ownership in erroneous cases.

Change-Id: I55d5d61922053fd94e2b5a8cdf0d799b29feec98
2019-09-12 20:27:58 +02:00
Harald Welte 9392e08011 rspro_client_fsm/remsim_client: Fix double-free
respro_dec_msg() takes ownership of the input msgb in both
successful and unsuccessful cases, so we must not call talloc_free
on the resulting msgb.

Change-Id: Id54d1b73395da1329a998d213c190da49eb90a93
2019-07-23 18:16:40 +02:00
Harald Welte 80df20e055 remsim_client: Fix memory leak receiving RSPRO messages
Change-Id: Ic3b5b7b03d557557a245fcd5c31bd687e11c7477
Closes: OS#4119
2019-07-18 19:02:31 +02:00
Harald Welte f7442b5125 remsim_client: Enable talloc tracking of msgb allocations
Change-Id: I45f90f1a841b5b1f29bdb41671085eeebf934a6f
2019-07-18 19:02:31 +02:00
Harald Welte b6b7bd1dff remsim_client: Reduce simtrace timeout from 100s to 1s
As we're waiting in blocking mode (and hence block things like the
IPA keepalive FSM), we cannot afford to block for 100s in one shot.

Change-Id: If316018d89367d54167fde021649fb3cfe218744
2019-04-01 10:52:17 +02:00
Harald Welte b54a51eec2 improve talloc memory leak debugging
* switch to talloc_report_full() on SIGUSR1
* include asn1-internal allocations in talloc report

Change-Id: I14fff863449971024002e0d5465fb7a964d67095
2019-03-31 15:57:59 +02:00
Harald Welte 3f09f634e0 fixup warnings
Change-Id: I73262ebf04640782859c5fa43b9172de3c788e3d
2019-03-31 15:51:13 +02:00
Harald Welte 72cde1052b client: Allow specification of clientId / slotNr as command line arguments
Change-Id: I0a96a49af8bceb5f14db056f11619a12ef42f4f1
2019-03-30 12:01:51 +01:00
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 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 8d8d4f162b remsim_client: Use osmocom logging instead of printf
Change-Id: I7e695335b4c4652a534cefa073dcea9f424d6744
2019-03-27 22:53:47 +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 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 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 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 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 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
Harald Welte 7fc64bc5b2 move osmo_fsm_register() into constructor function
This way each application doesn't have to explicitly call it.

Change-Id: I20753d7f7f485e7e495b64fa74b24858cd22ffa9
2019-03-02 12:55:59 +01:00
Kevin Redon 6f074b787a minor: show USB error message instead of number
Change-Id: I272ac1be82b7432934969ea4d204dd20067d9428
2018-11-12 22:53:48 +01:00
Kevin Redon 206c3d7d0a add ATR as command line argument
we could add a function checking the ATR validity
also before updating the (conditional) checksum we should check if
it is actually present in the ATR

Change-Id: Id1084abdf2318e96c22f8e69cc1ef161b12ef5ea
2018-11-12 22:51:42 +01:00
Kevin Redon f120b64b90 remsim: fix TPDU response size transmission
the TDPU response data size can be up to 256.
this length cannot be stored in a uint8_t, which would cause the
length to become 0, no data being send, and the reader reset the
card because of misbehaviour of the card (i.e. no/malformed
response leading to the timeout of the waiting time).

Change-Id: Id38f9e597ffff242e89ea3dd9fbdf0c9f444cc03
2018-10-15 20:02:52 +02:00
Harald Welte 7f0e82f9d4 move ipa_client_conn_send_rspro() into remsim_client_fsm.c
Change-Id: I805e7dee0e3dd5a591d215ad340da356b19d03dd
2018-10-15 00:27:20 +00:00
Kevin Redon 3428e415b3 add sim switch and modem reset for OWHW
Change-Id: I9d395c2c7e10a0e7e5f7c84bc7d951431bfc68ba
2018-10-12 14:58:20 +02:00
Kevin Redon fbca97a87e add client id and slot number as command line argument
Change-Id: I832ea69b303bf52561e4245991bb25af62558ea0
2018-10-12 14:58:20 +02:00
Kevin Redon 3ec265bca1 move main print output closer to main (minor)
Change-Id: Ib866f8b8b879a3a23bdc31eafe8735c7420bb353
2018-10-12 14:58:20 +02:00
Kevin Redon 19c97ed22a set client name (minor)
Change-Id: Iebb486ede19bd44e49a975c1b5e6c5a26378ba09
2018-10-12 14:58:20 +02:00
Kevin Redon efbf249e08 remove duplicate print output (minor)
the URB content is also shown in process_usb_msg

Change-Id: I3985449daf71d6a450b3339e9feaa26528b86535
2018-10-12 14:58:20 +02:00
Kevin Redon 21e31de068 indicate more clearly SIMtrace traffic in output log
Change-Id: Ie18c8aaace7c7f7cfef9119a01140b8f500de213
2018-10-12 14:58:20 +02:00
Kevin Redon 193a8c19c3 remove unused remote UDP variable
Change-Id: I3256ead1d6c4b8d64468fe1635b10a47e37e4df8
2018-10-12 14:58:20 +02:00
Kevin Redon 39eb9dce71 add command line arguments to set bankd host and port
these replace the remove UDP port not used in this SIMtrace2 host
application.

Change-Id: I16fef1a13da23e5395985320b59647d29680fc9d
2018-10-12 14:58:20 +02:00
Kevin Redon 9b69a3f4b9 send response APDU from bankd (card) to SIMtrace (modem)
Change-Id: I50270dbba8eb93133d1a48ba62a7f8a7dfc555d0
2018-10-12 14:58:20 +02:00
Kevin Redon bc08db5cee send correct APDU to bankd
Change-Id: I777f739793dfeec85823519f9d3d43b22090f209
2018-10-12 14:58:20 +02:00
Kevin Redon e0b837cfcb adapt remsim-client to use simtrace2 cardem
simtrace2-remsim_client.c combines simtrace2-remsim and
remsim_client.c.
it compiles but is short of sending the modem APDU from simtrace2
cardem to bankd.
2018-10-12 14:58:20 +02:00