This is useful if we have external programs interfacing with
stdin/stdout of osmo-remsim-client-shell. We don't want that output
to hang in some buffer indefinitely, but rather have the lines flushed
immediately.
Change-Id: I6879f9f186ce87e0644b3d7868fc5ea031b82c62
If the server sends us ConfigClientBankReq with bankd_port == 0, then
this means that we shall disconnect from the bankd. Translate this to
the SRVC_E_DISCONNECT event towards the RSPRO connection FSM.
Change-Id: Idbfbfa0e84fa14dcb913b4dcbd943bc80ec175ac
Related: OS#4399
This is in preparation of other patches which will actually issue the
SRVC_E_DISCONNET event towards this FSM.
Related: OS#4399
Change-Id: I080f9e85987bbbe7aef84c32ce84b69d949ff561
If a slotmap is deleted via the REST API, don't only remove it from
the bankd, but also remove it from the client.
Change-Id: Ia2fc2a098471add56cb35e74639417d865704989
Closes: OS#4399
We may want to use the entire client code independent of the current
'main' portion, so let's introduce separation via API.
Change-Id: I6456317c3968551cd69ba379c746e4dd9690d02d
We may want to develop programs that include multiple instances of
a remsim_client. Let's remove the global variable 'g_client' and
instead de-reference the bankd_client using container_of() macros
Change-Id: I456fb633561b88912be2f78c3e0264794d921255
This is a remsim-client with an interactive 'shell', where the user
can type in C-APDUs in hex formats, which will be sent to the bankd /
SIM-card. Responses received from SIM Card via bankd will be printed
in return.
Change-Id: I636505fd9741833ccf5cbd1bcac30f7b9aa94425
There were quite a bit of API changes that hadn't yet been applied
to remsim_client.c (which was disabled and hence not compiled for
quite some time).
Change-Id: I0b3733f6851a951ee24ae87aa5db0ee8daa7a841
There are some situations where remsim-client would want to make its
surrounding system aware of, e.g. to take specific action.
This is particularly important on platforms where the simtrace2 firmware
doesn't have direct control over modem reset/poweron or the like.
Change-Id: I61cf4d93c669db137de801f8b147dcffaa6f3abd
Depends: libosmocore.git Ib24ac8a083db32e55402ce496a5eabd8749cc888
Closes: OS#4332
While the user may have specified a USB path at the command line
(or not), let's make sure we obtain the actual path after opening
the respective USB device.
Change-Id: I7e707c74647f4c5db06d495d369b2e69e2fc7c97
Rather, pass it around between functions and attach it to other state.
Also, make it a talloc contxt so other objects can be allocated off it.
Change-Id: I25f592581382238d5640c1f6326dec745f8d1d40
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
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
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
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
* 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
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
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
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
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
rspro_client_fsm.c:180:9: warning: ‘rc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
180 | return rc;
| ^~
Change-Id: I64b275b06b2aa40bd7c6e1dd42afba5ffebd7b00
Since Change-Id I55d5d61922053fd94e2b5a8cdf0d799b29feec98,
rspro_dec_msg() is no longer taking ownership of the msgb.
Change-Id: Ic1e9f35a2ae82b28dbb4b2ba850c257fa9629cbf
They were both called "server", which can be confusing. Now the
bankd-facing FSM has the identity of "bankd"
Change-Id: I2626f92202717880c678ce219a14872538713f4e
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
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
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
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
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
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
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
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
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
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
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
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
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
We need to unconditionally free the msgb that gets handed into
sock_read_cb() by the ipa server.
Closes: OS#4096
Change-Id: I12b4a22854eea79c9e9c3e565dd4803e4dc0ed5a
This allows builds on small/embedded platforms to avoid all the
dependencies required by remsim-bankd, including libpcsc-lite
Change-Id: I29a1a0131fdfea6742ec12d81228879066b1ff7e
This allows builds on small/embedded platforms to avoid all the
dependencies required by remsim-server, including ulfius, yder, etc.
Closes: OS#3896
Change-Id: I2b1ec8a9a88b931ac56a63df88886e37c580a92b
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
Once we know the Client / Bankd Identity, update not only the connection
FSM with that identity, but also the IPA keepalive FSM. This will
provide proper context when logging.
Change-Id: I92bf47b6b0072c8062449ed3bb51ddf0b7aaf9a1
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