Commit Graph

412 Commits

Author SHA1 Message Date
arehbein 56ef474988 bankd: Use gsmtap_inst_fd2()
- Use gsmtap_inst_fd2() because gsmtap_inst_fd() is deprecated
 - Add TODO-RELEASE file

Related: OS#6213
Change-Id: I2a7736d6fba795b2c479b2a0bc371b90f838ed61
2023-10-30 12:13:10 +01:00
Harald Welte bfcca52af3 bankd: Don't use as default IP address for the server
If remsim-bankd connects via or any other loopback-routed
IP address to the remsim-server, then the getpername() of remsim-server
for the bankd will also render, and subsequently that IP
address will be provided to remsim-client as address to connect to.

In almost all setups, remsim-client will be running on a remote node and
hence not able to reach remsim-bankd at

Let's turn the server-IP into a mandatory command line argument of
remsim-bankd and not use a problematic default value.

Change-Id: I3deb05e31cdf35232cf9a118d5a5fcdb5d0ab601
2023-07-21 11:10:15 +00:00
Harald Welte 7703150eaf user_simtrace2: Fix uninitialized ifm->path
Let's memset the entire ifm before calling

Fixes: CID#307510: Uninitialized scalar variable (UNINIT)
Change-Id: I2bd0dac76b6d028d10f12f3f58a2aee123ca8562
2023-07-18 20:00:48 +02:00
Harald Welte 958ae50de1 user_shell: Fix unchecked return value of osmo_fd_register()
Fixes: CID#307519: Unchecked return value (CHECKED_RETURN)
Change-Id: I68ed44464573b9a6fecd07cf13fd2d6f4a1013bb
2023-07-18 13:38:07 +02:00
Harald Welte 58eebe13c7 user_ifdhandler: Fix missing check of osmo_fd_register return val
Fixes: CID#307514: Unchecked return value (CHECKED_RETURN)
Change-Id: I99d7254b6cc3bf5ead800dafabc77a965857911c
2023-07-18 13:36:05 +02:00
Harald Welte 189515f199 rspro_client_fsm: Fix integer overflow calculating re-establishment delay
Fixes: CID#307493: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
Change-Id: Ib1cca5ac0d27807936a52e0c013f0442350ecc00
2023-07-18 13:34:14 +02:00
Oliver Smith 852eeb6f31 checkpatch.conf: ignore rspro generated files
Change-Id: I6e5d57f6669f7d1aff00898f1375843b53cd9b9f
2023-07-17 11:52:58 +02:00
Oliver Smith c7287ce580 src/rspro: regenerate to fix misleading indents
After upgrading our CI environment to use Debian 12 with
GCC 12, it complains about the following misleading indentations.
Regenerate the rspro code with asn1c
I2260df8f8ab8eaf5c2aac3c330f87dba4691c01e to be able to compile with
--enable-werror again.

The asn_internal.h file is left unchanged to preserve changes from

Related: OS#6057
Change-Id: Icc2e8da7232a93b04ac8f23800380ca9317bd60f
2023-07-17 11:52:47 +02:00
Stephan Skrodzki 239458e6b7 another csv example for our usb CCID reader
Change-Id: Iec17af23ee9c752facb88b4a497b42678af6065d
2023-06-11 19:32:00 +00:00
Daniel Willmann e78bc32791 remsim_client: Fix custom ATR '-a' option
So far the option only parsed the hexstring into the atr buffer, but
failed to update the length (from the default value of 2). Also set
atr.len so sending custom ATRs works.

Change-Id: I5deb0a432c05ab0bab5081a2812f6718d4a2ac33
2023-05-31 18:34:54 +02:00
Oliver Smith cb283e3b8f systemd: depend on
Related: SYS#6400
Change-Id: Ifbac18a38e086e42c67499b7818cdf08629d0000
2023-05-26 14:10:48 +02:00
Oliver Smith f69498ef83 debian: set compat level to 10
Related: OS#5958
Change-Id: Ib45ad7c44cdefa4c5acab2da09f24796253a133d
2023-04-25 16:48:32 +02:00
Harald Welte a4f1914501 bankd_main: Avoid uninitialized variable
There's not really any ResultCode for the kind of error we encounter,
but sending some uninitialized memory clearly is not the right way

>>>     CID 307528:  Uninitialized variables  (UNINIT)
>>>     Using uninitialized value "res".

Closes: CID#307528
Change-Id: I29f911cb2c8ad67cf1ce4486e1583612fb0b98a6
2023-02-06 13:16:49 +01:00
Harald Welte 5426124dc7 rspro_server: Handle ipa_server_link_open() error case
>>>     CID 307530:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "ipa_server_link_open" without checking return value (as is done elsewhere 4 out of 5

while at it, also add a missing pthread_rwlock_destroy() call which was
missing in the existing ipa_server_link_create() error path.

Closes: CID#307530
Change-Id: Ic32d53a236b80711651fb4ee196ac3b95148e61f
2023-02-06 13:16:02 +01:00
Harald Welte ae0d9d2e60 remsim_server: handle osmo_fd_register() failure case
>>>     CID 307531:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "osmo_fd_register" without checking return value (as is done elsewhere 83 out of 97 times).

Closes: CID#307531
Change-Id: I7c2448303fba7caa27df65ac5f4d91ddf232ceb6
2023-02-06 13:14:02 +01:00
Harald Welte 2d5d4c3bee rest_api: strtoul canot return negative
>>>     CID 307538:  Control flow issues  (NO_EFFECT)
>>>     This less-than-zero comparison of an unsigned value is never true. "map_id < 0UL".

Closes: CID#307538
Change-Id: Ic5019e216dd7b26be0bd988df218a2cb5775e411
2023-02-06 13:13:53 +01:00
Harald Welte 99ea365ce7 Fix various 'uninitialized variable' bugs reported by coverity
The asn1c-generated struct definitions have an automatic _asn_ctx
member, and we never initialize that so far.  Let's do an explicit

Closes: CID#307545, CID#307543, CID#307541, CID#307536, CID#307536
Closes: CID#307534
Change-Id: I217ebbc92935aefaf55d19a14c93a24e5b8fce64
2023-02-03 20:19:44 +01:00
Oliver Smith c69d5c8da7 packaging: osmo-remsim-apitool needs py3-requests
Related: OS#5817
Change-Id: I3b8f86b03aee145e0b0faf0394ab641666710bea
2022-12-08 16:33:39 +01:00
James Tavares b890018456 rspro_client: implement re-establish delay
- add new SRVC_ST_REESTABLISH_DELAY state with delay stipulated by table
k_reestablish_delay_s[], that implements a simple exponential-like back-off
with an upper bound.
- new function srvc_do_reestablish() is used to initiate a reestablish, and
apply the appropriate delay, if any.
- takes external delays (such as TCP connect() delay) into account, and does
not double-penalize.
- delay is reset to shortest possible if there has been no reestablish
initiated in a long time (2x greater than our longest delay). Allows for
fast reconnects even if a delay was used to connect.
- addresses issues and

Change-Id: I86cdc3ba37482e6577b429194d273a2399f32208
2022-11-19 09:21:04 +00:00
James Tavares e206e6a2e2 bankd, client, server: add -L option to disable log coloring
When the stderr of these services is sent to syslog, for example by
using systemd's StandardError=syslog, syslog's escaping of ANSI color
ESC sequences in log messages really clutter the log files. This
option allows log coloring to be disabled on the command line.

Change-Id: I6955b0af1ceb11a4029383e32bb298ee8da7503f
2022-11-19 09:18:16 +00:00
James Tavares 31e8bd786b bankd: Add GSMTAP functionality for SIM traffic
If a --gsmtap-host (-g) address is specified on the command line, trace
SIM ATRs and APDUs to the given IP. If --gsmtap-slot (-G) is provided,
limit tracing to the specified bank slot number. This feature may be
useful when diagnosing issues with the remote SIM framework.

Added new log category: DGSMTAP

Also, cleaned up alignment in bankd --help output and removed unused -o option.

Change-Id: I05b599858d8758633aa56c3f12f258c27cf42d08
2022-11-19 09:18:16 +00:00
Harald Welte 7da85411e3 remsim-client-st2: Proper error if not all endpoints can be found
Let's avoid a segfault and rather print a proper error message in case
we cannot find all the required USB endpoints when opening the
user-specified interface/config/device.

This can happen if the device is currently in DFU mode, or a completely
wrong device/interface was specified.

Before this patch:
Assert failed rc == 0 user_simtrace2.c:305

After this patch:
DMAIN ERROR user_simtrace2.c:448 specified USB dev/config/interface doesn't have at least one IN, OUT and IRQ_IN endpoint

Closes: OS#5416
Change-Id: Icfcc482fff106a232c5125ed8ab463ecc13824ae
2022-11-15 00:59:40 +01:00
James Tavares 11d84c761c client: set the local/remote mode before inserting card
- avoids a race with the modem

Change-Id: I7b0640b929e174e8dfdcc86947fa409e4acf338f
2022-11-14 10:47:35 +00:00
James Tavares f74d1dab7a bankd: edge detect RESET and VCC indications
- perform edge detection on RESET and VCC client indications to filter
out duplicate resets
- prior to this change, unrelated changes in the client slot status
indication (such as CLK change) could trigger duplicate resets
- these resets could happen in rapid succession and lead to reader
libusb communication errors that lock-up the PC/SC daemon
- a drop in VCC will always induce a cold reset, even if a warm
reset is already in progress.
- overall, this change better matches what the hardware would do

Change-Id: I36d30d176c0a03d97554112ca712d658d986c752
2022-11-14 10:46:43 +00:00
James Tavares f75843d9d2 ignore libtool artifacts from cross-compile environments
Change-Id: I549ee65e72fed2d1599b3e2dfc7a37f02a8f80e6
2022-11-14 10:45:01 +00:00
James Tavares 2c0a51205d bankd: add missing -p short form option
Change-Id: I44969c70612a25184fc51b695c7dbf97865fb116
2022-11-13 23:22:22 -05:00
Harald Welte f4be5e16f2 bankd: Don't log an "Error" if slotmap is removed
removing a slotmap and the related client disconnect are perfectly
normal operation. Don't print the word Error in the log in such cases,
it just confuses the user.

Closes: OS#5629
Change-Id: Ie39d35fd348fdf3dd53c860dc830aac794a3ead5
2022-07-24 13:38:16 +02:00
Harald Welte c8c77e08ee client: Option to ignore any ATR sent by bankd
This introduces an --atr-ignore-rspro command line argument, which
will make the remsim-client ignore any RSPRO setAtrReq it receives
from the remote bankd.

The purpose of this is to modify the capabilities advertised by the card
towards the UE (modem/phone).  For example, by modifying the ATR
one can disable/constrain the UE from using higher bit rate support, or
disable the use of logical channels.

Change-Id: I930293f7b637dba60d9dd6d2254f4524f831b491
2022-07-24 13:01:07 +02:00
Harald Welte 445d284dfa client: Fix '-a' command-line argument for ATR
The argument existed (as a long option), and was documented in the
user manual - but it wasn't printed in the help message, nor was it
present in the getopt_long() string.

Let's fix that.

Change-Id: Icfb74597dd813cee8b48b8dcf520fdd1c954338a
2022-07-24 13:00:38 +02:00
Harald Welte 628672bc72 bankd: Open PC/SC by default in EXCLUSIVE mode
Let's open the cards in EXCLUSIVE mode, we don't want other applications
tinkering with the card state while we have a bankd worker running on
it.  This change also means that no two bankd workers can trip on
each other accidentially anymore.

Related: OS#5527
Change-Id: I43a1c8c7bd1c0124ee5f605e2e5b04ed8f7836ab
2022-07-15 08:22:29 +02:00
Harald Welte 1f51279887 client: Log TPDU/ATR/PTS/slotStatus at INFO or NOTICE level
Closes: OS#5615
Change-Id: I9b54a53ef2809c9bfd110636a9ccb0c0d8c90cda
2022-07-15 08:22:29 +02:00
Harald Welte 6cfce3ba7f fix rpm spec file for packacing of apitool
[   62s] RPM build errors:
[   62s]     line 222: multiple %files for package 'osmo-remsim-server'

This fixes a bug introduced in I11d779f66833b5294ffeb422ce6b2a705719a899

Related: OS#5612
Change-Id: If8460b41f0e9fa988215acdf3bda829540c8d599
2022-07-15 08:22:29 +02:00
Harald Welte e25cfa8580 debian/control: Don't use misc:Package
dpkg-gencontrol: warning: package osmo-remsim-doc: substitution variable ${misc:Package} used, but is not defined
dpkg-gencontrol: warning: package osmo-remsim-doc: substitution variable ${misc:Package} used, but is not defined

and indeed, the variable seems to substitute to an empty string,
resulting in

$ apt-cache search osmo-remsim-doc
osmo-remsim-doc/unknown 1.0.0 all
  PDF documentation

Change-Id: I58d267ea61dd9d71e7b9e630e71fd2f64f274569
2022-07-13 07:21:37 +00:00
Harald Welte 4e0e5b8d17 Install + package remsim-apitool as separate sub-package
As the script depends on python3, let's put it into a new
osmo-remsim-apitool package.

As we're installing the tool system-wide, rename it from to osmo-remsim-apitool.

Closes: OS#5612
Change-Id: I11d779f66833b5294ffeb422ce6b2a705719a899
2022-07-13 07:21:37 +00:00
Harald Welte 001884c5c1 bankd: Log not just ModemToCard but also CardToModem
This way we'll get a full trace of commands and repsonses.

Right now the log only shows one direction which is a bit odd.

Related: OS#5615
Change-Id: Ia2de0b850ce78074a411cf0edebfb3ad19253d34
2022-07-11 23:58:03 +02:00
Harald Welte e5ed100fd2 main_fsm: Log bankd config (ip/port/bank_id/slot_nr) + disconnect
Closes: OS#6513
Change-Id: I30a814ba95eb9c545220a1513805f41ccb5acb42
2022-07-11 22:54:43 +02:00
Harald Welte bc2e6e3385 bankd: log BankID:SlotNr in every log line
It's relatively inconvenient having to mentally map the slot-number to a
thread-id on every (re)connect to correlate the logs.

The logs should contain the Bank/Slot number they relate to.

Closes: OS#5611
Change-Id: I84879609781a301338dacde7ff495632e3af08b9
2022-07-11 22:14:17 +02:00
Harald Welte a5637b0f31 update git URLs (git -> https; gitea)
Change-Id: I780bfbcd4afefdc9122bfe696006dec2fdccd3f4
2022-06-18 12:33:43 +02:00
Harald Welte f5f5805f0c rspro_client_fsm: Log clientConnectResult != ok
This should aid debugging.

Related: SYS#5950
Change-Id: I8f584640758be0cceab61dcb333c81374da3288b
2022-05-05 19:19:33 +02:00
Harald Welte 7f8bce4f06 bankd: Log more clearly if we fail to open a PC/SC reader
Related: SYS#5950
Change-Id: I424f585a8a37f21806898e59e350201119645a21
2022-05-05 19:08:13 +02:00
Harald Welte a04ff860c1 server: Fix various error paths if startup fails
Don't segfault or use heap after free if osmo-remsim-server cannot
fully initialize, e.g. due to ports already in use.

Change-Id: I558e6a0ea089a779f916aa5576341d1c55da1271
2022-05-03 18:09:14 +02:00
Harald Welte a9bb9a9348 cosmetic: various typo/spelling fixes
Change-Id: Idc4db138d83be0c7c0b0ff6dfbb9f094b21d6fa9
2022-05-03 18:09:14 +02:00
Harald Welte eea631bff0 encode actual hostname in RSPRO
The RSPRO ComponentIdentity includes a 'name' for each remsim component.

So far we always used "fixme-name" instead of something meaningful.
Let's use the hostname of the system instead.

Change-Id: I14925f16ae242dae89fa853a2fe31c5c1b32981d
2022-05-03 18:09:14 +02:00
Harald Welte e9e505c7c5 bankd: Better error messages during start-up
If something goes wrong during startup (missing CSV file, ...)
let's print a more human-readable error message than just asserting.

Change-Id: I95222d44eefc60ad3857fa70ccebbacce60820df
2022-05-03 18:09:14 +02:00
Harald Welte 65006583c1 server: Detect duplicate client/bankd connection; drop new ones
we're dropping the current (new) connection as we don't really know which
is the "right" one. Dropping the new gives the old connection time to
timeout, or to continue to operate.  If we were to drop the old
connection, this could interrupt a perfectly working connection and opens
some kind of DoS.

Related: OS#5527
Change-Id: I00387dbc19d689415470e2f08df08a47a78b81c0
2022-05-03 18:09:14 +02:00
Harald Welte 900ee725b5 server: Fix segfault in error path (client component ID != client)
When we terminate the FSM instance, we must immediately return.

Change-Id: I8dff45daa6584ed111a8469e7b3bf90e7c939612
2022-05-03 16:28:52 +02:00
Harald Welte 079c068467 bankd: Differentiate log levels, not everything is DEBUG
Change-Id: If3699642fee2d5d92fb164f7f9c41ccff02007cc
2022-04-27 09:26:52 +02:00
Harald Welte 15e8b7f79c server: Differentiate log levels, not everything is DEBUG
Change-Id: Iee1e2f66e8675146883a6f5e355460608fe6d547
2022-04-27 09:24:21 +02:00
Harald Welte e1590df408 server: Log keep-alive timeout and TCP disconnects
Change-Id: I9912fee7fb892c724a0277d1fa52d056c11c9b73
2022-04-27 09:19:48 +02:00
Harald Welte fb48de8968 server: Log connection establishment from bankd/client; warn on localhost
If a bankd connects to the server from, then clients will
not be able to reach it unless they also run on localhost.  Warn the

Change-Id: I5446752961b039dad54aec981c1df4814779f765
2022-04-27 09:15:43 +02:00