Commit Graph

263 Commits

Author SHA1 Message Date
Harald Welte a9bc4de83b remsim-client: Fix the -k/ --keep-running option
When introducing asynchronous USB support in Change-Id
Ic18690b3c2cbc5e99de0665c0b68b7555433b3cd, we accidentially
broke the --keep-running behavior, where even a disappearing USB
device will not terminate the remsim-client process.

Change-Id: I19cca9f7953d61058a36856b2fc4c97a3b93e15d
2020-02-16 15:41:56 +01:00
Harald Welte f7598fe417 remsim-client: move from common 'src' directory to 'src/client'
As both the bankd and the server already are in src/bankd and
src/server, respectively: Let's unify this and have the client
also in its own sub-directory.

Change-Id: I67a3a5941434f09f7099c2cdb19c126cea305a73
2020-02-16 15:41:12 +01:00
Harald Welte a86e6b73d8 remsim_client: Move body of main() loop to separate function
I rally don't like the existing spaghetti-style code.

Change-Id: I85c166e8aa95bb3f2e5d60d14f60caa94f3116fb
2020-01-12 19:41:36 +01:00
Harald Welte f918748208 client: Enable talloc NULL context tracking
Change-Id: I41ac5437e9262cf9e5a6e92db9b733902c91755b
2020-01-12 19:41:36 +01:00
Harald Welte 9636d2b090 remsim-client: Introduce 'struct client_config'
Introduce a dedicated structure for the parsed command line options
converted into the configuration for the client.  This reduces the
amount of spaghetti code and paves the way for a later VTY / config
file.

Change-Id: I59980a78f0344602f9fa5b2277c99dfbf0b7815c
2020-01-12 19:41:36 +01:00
Harald Welte b90fc443f3 require minimum version 1.3.0 of libosmocore
Finally, a libosmocore version with per-thread select loop fd sets
has been released, so we can update our version requirement here.

Change-Id: Ic2654b18fd1f00aa4c1ab01892ecaa48ad2ba29f
Closes: OS#4250
2020-01-12 19:41:36 +01:00
Harald Welte 25bcbbe3cc fix the package we depend on: libosmosimtrace2-dev
Change-Id: If7d4f8c5901ea1e34fb6c85bc6e6f1211c7f7bf7
2019-12-18 12:33:47 +00:00
Harald Welte 3e66be5986 debian/control: Add missing Build-Requires libosmo-simtrace2
In Change-Id Idf5a861f4dacbec3c664f4ced6e03d8662c73112 we introduced
the use of libosmo-simtrace2 (from simtrace2.git).  Our configure
script checks for it properly, but the debian/control wasn't updated.

Change-Id: I875f9d6d06d806fb9f9264840a65934fb0e99972
2019-12-17 15:38:48 +01:00
Harald Welte bbd18bd7fe bankd: Implement card reset based on clientSlotStatusInd
If a client is sending us a clientSlotStatusInd indicating that
the modem has switched off VCC or activated RST, bankd will
now issue a respective PC/SC command to perform a cold or warm
reset of the card.

Change-Id: Ifa615d239ec3ad6daebd8e99e4f7d5b99d32c0e1
Closes: OS#4330
2019-12-17 13:31:20 +01:00
Harald Welte 0e0e932ce9 client: generate clientSlotStatusInd to bankd
* enable generation of CEMU_USB_MSGT_DO_STATUS on IRQ endpoint
* translate that to clientSlotStatusInd towards bankd

This will allow bankd to understand when to reset the card as
requested by the modem.

Change-Id: Ibe2266ffa473823e925d4e3afcf168353b11cdd8
Related: OS#4330
2019-12-17 13:31:20 +01:00
Harald Welte a9bf5c24c0 rspro_util: Add functions generating {Bank,Client}SlotStatusInd
Change-Id: Ib07d397d80310f94dd6357b895455a1897e01cf3
2019-12-17 13:31:20 +01:00
Harald Welte 32e2e006b1 remsim_client: Port to async libosmousb select loop
By using the non-blocking / asynchronous libusb via the newly-
introduced libosmousb (integration to libosmocore select loop),
we can not only get a cleaner code-base, but we also get a
considerable speed-up.

In my tests with a Quectel E25 and a sysmoUSIM-SJS1 card,
I am down from 41.4s to 4.7s for the initial reading of the SIM
at start-up.

Change-Id: Ic18690b3c2cbc5e99de0665c0b68b7555433b3cd
Closes: OS#4299
Depends: libosmocore.git I656a1a38cbb5b1f3a9145d2869d3b4d0adefcae3
2019-12-17 13:31:20 +01:00
Harald Welte 8c1ca1bb87 jenkins.sh: don't verify (possibly outdated) deps
When we call a script for verification of our source code, let'sn
not check the (old, previous) code from the ./deps directory, too.

We should either only verify our own code (solution implemented here)
or alternatively verify only after we updated all dependencies to the
latest stage.

Change-Id: I20e6a3b7b4109b99c91a4921285cacb168c5796b
2019-12-17 13:31:20 +01:00
Harald Welte fd5dafc2a2 remsim-client: Port from local copy to libosmousb + libosmo-simtrace2
We originally imported a copy of [most of] the code of
simtrace2.git/host into this repository.  That was a quick hack to get
things going, but now that simtrace2.git is providing a shared library
of simtrace2 utility functions, let's migrate over to it.

At the same time, some functions (libusb_util) have been migrated to
libosmousb (a new library in libosmocore.git), so we must add that
as new dependency, too.

This performs the minimally required changes and is *not* a proper
port to the libosmousb osmocore select loop integration, whcih will
follow in a separate patch.

Change-Id: Idf5a861f4dacbec3c664f4ced6e03d8662c73112
Closes: OS#4298
Related: OS#4299
Depends: libosmocore.git I656a1a38cbb5b1f3a9145d2869d3b4d0adefcae3
2019-12-17 11:56:21 +01:00
Harald Welte 0fd77a5790 bankd: Introduce SIGMAPADD to tell worker about new mapping
So far the wokrer used to sleep 10s and only check in those intervals
if [finally] a mapping had arrived.  Using SIGMAPADD, we can
directly break the worker out of its select() call and hence make
it pick up a new mapping instantaneously.

This also makes RemsimBankd_Tests.TC_removeMapping_connected() pass

Change-Id: If0130ab4b49ffcae6ab7a8b9926a6d9477eb3981
2019-12-15 00:11:43 +01:00
Harald Welte a49678309d bankd: Factor out signal-sending from bankd_srvc_remove_mapping()
This way we can also deliver other signals to workers.

Change-Id: I86744554187d5bcee75592427990d404889f29fe
2019-12-15 00:11:43 +01:00
Harald Welte b8ec65ae8f rspro_client_fsm: Fix handling of IPA keepalive
We cannot rely on the implicit IPA keepalive FSM termination, as that
somehow gets the termination order wrong and we end up accessing free'd
memory.

Let's handle the termination explicitly:  We register a callback with
the IPA keepalive FSM, and once that callback gets hit, we ask the
core to *not* terminate the FSM implicitly.  We are anyway terminating
it explicitly in st_reestablish_onenter().

Change-Id: Ia745ccb44c0d0224d1e7ab6b6da3713474111d41
2019-12-15 00:11:43 +01:00
Harald Welte 9cdd094516 rspro_client_fsm: Fix uninitialized return variable use
rspro_client_fsm.c:180:9: warning: ‘rc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  180 |  return rc;
      |         ^~

Change-Id: I64b275b06b2aa40bd7c6e1dd42afba5ffebd7b00
2019-12-15 00:11:43 +01:00
Harald Welte 071892974a rspro_client_fsm(): Remove outdated/wrong comment from code
Since Change-Id I55d5d61922053fd94e2b5a8cdf0d799b29feec98,
rspro_dec_msg() is no longer taking ownership of the msgb.

Change-Id: Ic1e9f35a2ae82b28dbb4b2ba850c257fa9629cbf
2019-12-15 00:06:09 +01:00
Harald Welte 6d61b166c8 rspro_client_fsm: Mark ipa_client_conn_send_rspro() as static
Change-Id: Icc2f9e984dee4a2f1f604beee6c9081ecf032dd2
2019-12-15 00:06:09 +01:00
Harald Welte 82194454b3 remsim-client: Differentiate the two rspro_client_fsm instances by name
They were both called "server", which can be confusing.  Now the
bankd-facing FSM has the identity of "bankd"

Change-Id: I2626f92202717880c678ce219a14872538713f4e
2019-12-15 00:06:09 +01:00
Harald Welte 3e9860bb77 Replace bankd_client_fsm with rspro_client_fsm
There was a lot of similarity between the bankd_client_fsm (for the
client->bankd RSPRO connection) and the rspro_client_fsm (for the
client->server and the bankd->server RSPRO connections).

With the last few commits introducing the missing features to
rspro_client_fsm, we can completely obsolete bankd_client_fsm and
further simplify the codebase.

Change-Id: Icbe9881a0391fcd0c47e5d930dc764fc0cb1dfbf
2019-12-15 00:06:09 +01:00
Harald Welte a3b14d1890 rspro_client_fsm: Make RSPRO transmit use FSM event
This way we can easily guarantee that RSPRO transmit will only happen
in the fully established state, and that violations of that rule will
generate error logs by means of osmo_fsm core logging code.

Change-Id: I3c403507fa11c068d7503107857fbd5676ce135f
2019-12-05 08:56:27 +01:00
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 4b75f0dc3c add missing debian/libosmo-rspro1.install
In Change-Id I77c86455f9c36c16271bc8e7f8f3f72d682d23fd for some
reason libosmo-rspro0.install was not renamed/moved but deleted,
causing failures to build debian packages

Change-Id: I825d70abbbd067955d7038377692beea87545ce0
2019-12-05 08:56:26 +01:00
Harald Welte a8d945e191 bankd: No need to handle SIGMAPDEL if we're not mapped yet
Change-Id: I187b833a9b7ec3d3763e21b5c88a3fa39ba0c4c7
2019-12-04 22:25:37 +01:00
Harald Welte f34fb79cc1 bankd: Implement new ResetStateReq
Change-Id: Ib794e605162903a2b2c4f4516887ec91fc8d139a
2019-12-04 22:25:37 +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
Harald Welte 3f9663215f RSPRO: Add new ResetState{Req,Res}
These commands are introduced to enable the server to request the
full reset of all state in a client or bankd.  This is particularly
useful in TTCN-3 tests, where we typically want to reset the state
between tests.

Change-Id: I442bab523486bbdf2faa8028f8972cd0af795303
2019-12-04 21:52:58 +01:00
Harald Welte 602b6f7763 bankd: initialize bank_id/slot_nr to 0xffff for unmapped workers
Otherwise the loop for SIGMAPDEL delivery code will match any
unused worker for bank_id=0/slot_nr=0, which is not what we want.

This also makes repeated RemsimBankd_Tests.TC_removeMapping_connected
runs work reliably.

Change-Id: I6976eb96feae6a3b66bacf787e436a2df29f9ce0
2019-12-04 21:52:58 +01:00
Harald Welte d9fb93991b bankd: Reject removeSlotmap when ClientID doesn't match
It's a bit of a matter of taste whether we should simply log + ignore
if the Client of a removeMappingReq doesn't match what the bankd
currently has configured.  I chose to reject it, as a new createMapping
for the same bandk+slot will overwrite any existing mapping anyway,
at least as of I83e319d22896b881c0d882542842f500075aa546

Change-Id: I892282821f4650614d1d08ed4bdf11eaabf947c0
2019-12-04 21:24:10 +01:00
Harald Welte e6fa46acd5 bankd: createMapping should implicitly delete existing mappings
As explained in OS#4278, a remsim-bankd currently doesn't recover after
a remsim-server resetart, since old mappings remain in the bankd, and
the server has no chance of removing them.

To avoid this problem, a createMapping now always implicitly removes
any existing mapping that may exist for the given bankdSlot.

Change-Id: I83e319d22896b881c0d882542842f500075aa546
Closes: OS#4278
2019-12-04 21:24:10 +01:00
Harald Welte 550b2958d3 bankd: Fix log print during removeMapping
We need to dereference 'rreq' nor 'creq' in the remove handling.

Change-Id: I04e9e2447336f7d1aaeb932928a79bb705aa0c5a
2019-12-04 21:24:10 +01:00
Harald Welte c650a4daec bankd_main: Refactor code: bankd_srvc_remove_mapping()
Change-Id: Iceb1d015e0ea760cce2cd99bc22ae0149bdb42f1
2019-12-04 15:08:10 +01:00
Harald Welte b2a00776a0 Bump version: 0.2.1.10-35d9-dirty → 0.2.2
Change-Id: I77c86455f9c36c16271bc8e7f8f3f72d682d23fd
2019-12-03 20:38:18 +01:00
Harald Welte 667d694a38 bankd: send IPA CCM ID_ACK after receiving ID_ACK
It is customary in the IPA protocol that a a server side
responds with an ID_ACK if the client sends an ID_ACK.  Due
to the lack of any protocol specification, it's unclear why
exactly, but we know it does happen.

osmo-remsim-bankd so far failed to implement this, which is
not directly a problem as the only user (osmo-remsim-client)
didn't care.  However, when executing TTCN3 test cases,
the IPA_Emulation expects that ID_ACK and related test fail.

Change-Id: Ie55c9d5c435df786e97ec3900837bb21ab80140a
2019-12-03 16:42:47 +01:00
Harald Welte 0a68497324 cosmetic: more comments; spelling fixes in comments
Change-Id: I4939a386ac48e4e66bce9784d9a1539426c41aae
2019-12-02 23:10:31 +01:00
Harald Welte 4ccd2fca84 Check for osmo_fsm_register() error return value
Change-Id: Idda1a4050cf9d285225ae48a4ba6f48c04f9598b
2019-12-01 13:34:32 +01:00
Harald Welte 13ebf436ac bankd_client_fsm: close IPA client connection before re-establishing it
ipa_client_conn_destroy() really only destroys the object, but not close
the underlying file descriptor.  This leads to old connections
lingering around, which in turn (in case of the remsim client) will
occupy banksim worker threads.

Change-Id: If87f4bbc133e4dc812fa96a75e8495bad65275aa
2019-11-07 13:00:39 +01: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
Kevin Redon 3119c2eb1f remsim-apitool.py: pass IDs as integer
currently the bankId, clientId, and slotNr are passed as strings.
this is not the format expected by the server, which returns 400
"Bad Request".
the issue was that the python tool did not parse the arguments as
integer.

Change-Id: I8baab1b516067f47a7d230213e44d8f85e6d9919
2019-09-17 11:37:39 +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 fc0fff1880 remsim-apitool: Fix slotmap-create (integer needed, not string!)
Change-Id: If3237de7cf08be49645dfac2e3f7173d43a47e53
2019-09-12 19:59:29 +02:00
Joachim Steiger a008e62523 add contrib/remsim-apitool.py to control the REST-interface of osmo-remsim-server
Change-Id: Ia01b0a89e21af18b898becd8f5440c32936772b7
2019-07-30 11:39:15 +02:00
Harald Welte cacbc2b37d rspro_client_fsm: Fix another memory leak
We basically must ensure that all code paths *except* the path leading
to rspro_dec_msg() must call msgb_free(msg).  This was not the case
in two situations, as fixed now.

Change-Id: I29f8413bb43b3ebf827be0bceda1a4db1e6e2b7c
2019-07-24 18:42:02 +02:00
Harald Welte 6478cdac2d Bump version: 0.2.0.4-573d → 0.2.1
Change-Id: I70d67eddd474f7f738ec1a032e438a6211e2daa3
2019-07-23 20:37:00 +02:00
Harald Welte 573ddfdce1 debian: build manuals as osmo-remsim-doc package
Change-Id: If5812983d319a32864f5f34b160978533465d185
2019-07-23 20:27:47 +02:00
Harald Welte 32e204c83d doc/manuals: Use correct path (osmo-remsim-doc)
Change-Id: I16a56af66a450e6bb19a53c652d6f93d35aacb8e
2019-07-23 20:27:46 +02:00
Harald Welte bb9e32ea1a usermanual: disable non-existant architecture chapter
Change-Id: I897fb528990d8cf47bd0796603b79bff5fd94bc0
2019-07-23 20:21: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