Commit Graph

307 Commits

Author SHA1 Message Date
Harald Welte 7cd8b76577 bankd: Avoid useless dependency to libosmosim
Change-Id: I015b1a49dbdd19d030acd929b5a935021b77cefa
dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/osmo-remsim-bankd/usr/bin/osmo-remsim-bankd was not linked against (it uses none of the library's symbols)
2020-03-04 19:15:32 +01:00
Harald Welte f14f337d06 libosmo-rspro: Avoid useless dependency to libosmo-abis
Change-Id: I124003dafb7b90664e6614965990243771be62a9
dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/libosmo-rspro1/usr/lib/x86_64-linux-gnu/ was not linked against (it uses none of the library's symbols)
2020-03-04 19:15:32 +01:00
Harald Welte 73b6d703ad Avoid useless dependency on libcsv
We don't want to link everything against libvsv.  Only bankd needs it.

Change-Id: I288c27611b042fef76101e247b41c7a2f6c7483b
dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/libosmo-rspro1/usr/lib/x86_64-linux-gnu/ was not linked against (it uses none of the library's symbols)
dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/osmo-remsim-server/usr/bin/osmo-remsim-server was not linked against (it uses none of the library's symbols)
dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/osmo-remsim-client/usr/bin/osmo-remsim-client-shell debian/osmo-remsim-client/usr/bin/osmo-remsim-client-st2 were not linked against (they use none of the library's symbols)
dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/libifd-osmo-remsim-client0/usr/lib/pcsc/drivers/libifd-osmo-remsim-client.bundle/Contents/Linux/ was not linked against (it uses none of the library's symbols)
2020-03-04 19:15:32 +01:00
Harald Welte 2a5f44750d libosmo-rspro: Avoid useless dependency to libosmogsm
dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/libosmo-rspro1/usr/lib/x86_64-linux-gnu/ was not linked against (it uses none of the library's symbols)

Change-Id: I6ed59e4b1a23625653be2647f271a5d993535800
2020-03-04 19:15:32 +01:00
Harald Welte d9dfb72662 debian: split osmo-remsim-client into osmo-remsim-client-{shell,st2}
The -shell client has no dependency to libosmo-simtrace2, so it makes
sense to package it separately.

Change-Id: I6c634572af5036fd7f9ce1fee6d1474e06bdaa5a
2020-03-04 19:15:32 +01:00
Harald Welte 753d2b585a contrib/ Harmonize with what we do in other projects
most importantly:
* conditional build of manuals
* enforce build of manuals if enabled
* publish manuals, if requested

Change-Id: I4ed51fd5aa9d861ea4795e33b6201c15b2281b53
2020-03-04 19:15:32 +01:00
Harald Welte e10022df38 Install config files to /etc/default/
Related: OS#4326
Change-Id: Ibff534c2f247557bb4eb0f72b8babe85ad0b315b
2020-03-04 18:18:14 +01:00
Harald Welte 75b8eb3bcc + debian: Add systemd service file support
Closes: OS#4326
Change-Id: I0d7b6562c1127f005ddbd47298c03942ac3d241d
2020-03-04 18:18:14 +01:00
Harald Welte de80eb3988 configure/Makefile: Include contrib in "make dist"
Change-Id: I2d6a2e06f075391e8e51d1342a1afe955cc127b0
2020-03-04 18:18:14 +01:00
Harald Welte 9629ba3fb9 client: Fix TODO: add CLK status information to event-script environment
Change-Id: Iecc6002a8effaae7d8c3cab2aa4c6109f83f35b2
2020-03-04 18:02:21 +01:00
Harald Welte 0e968cce38 client: major restructuring around new main_fsm
The remsim_client code already used FSMs for the connections
to both remsim-server and remsim-bankd.  However the 'main' part of the
program was not yet implemented as a FSM, making it somewhat difficult
to perform the right actions in every possible situation.

This commit re-structures the code around a central main_fsm, which
gets notified from the per-connection FSMs and which handles the common
processing.  It also handles the execution of external script commands,
and hence further unifies the code base between the different backends
(simtrace2, ifd_handler, shell)

Closes: #4414

Change-Id: I44a430bc5674dea00ed72a0b28729ac8bcb4e022
2020-03-04 18:02:21 +01:00
Harald Welte 5b5d6cee9b configure/automake: Remove work-arounds
Change-Id: I97a085248e6cbcd15daf96c0c23f31cdcd02e06b
2020-03-04 18:02:21 +01:00
Harald Welte 1b0a68a3d8 fix debian build after introducing hack around usbdropdir
In Change-Id I87c68e8d14f8ddb6054178118ff1f96216483f5c we introduced
a hack to fix 'make distcheck' which in turn broke debian packaging.

Let's make sure the latter works while the formar also still does.

Change-Id: I16f7d0e8b7f63ed58dd4939c88e5276185bc3178
2020-03-04 16:38:03 +01:00
Harald Welte b266d508be rspro_client_fsm: Add optional notifiation of parent on connect/disconnect
This will be useful once we introduce a 'main' client FSM that is a
parent to the rspro_client_fsms.

Change-Id: Ifddb8e0b5c991e5348392c9e44612669ce207bc4
2020-03-04 16:21:34 +01:00
Harald Welte 8da220911d rspro_client_fsm: Migrate to ipa_client_conn_create2()
libosmo-abis 0.8.0 has deprecated ipa_client_conn_create() and this
follow-up patch avoids the related deprecation compiler warnings.

Change-Id: I0057c5b6a79e7226e87983c14eb2b0ed2af2a131
2020-03-04 16:21:34 +01:00
Harald Welte 830026a9c0 doc: Add documentation for
Change-Id: I0e280cd4276e1aff7d6f694ac4affbca0336eba5
2020-03-04 16:21:34 +01:00
Harald Welte 5103ea0a43 doc: More cross-references; Expand overview slightly
Change-Id: Ic290627ec2512a2b59cb9d81704b9cec4d14ccf4
2020-03-04 16:21:34 +01:00
Harald Welte ddbe43a366 doc: Add WARNINGs about lack of security in protocols
Change-Id: I72c0b797fda220b9efcc86bd08717585063db591
2020-03-04 16:21:34 +01:00
Harald Welte e18069aa81 doc: generalize the remsim-client part in the overview section
Change-Id: I56f7955b05395abe70bf6ad2f0d33843bc6f77b9
2020-03-04 16:21:34 +01:00
Harald Welte d2dcb34ded client: Fix 'make distcheck' bypassing pkg-config usbdropdir
For some strange reason, 'make distcheck' wants to do a 'make install'
without using DESTDIR.  In this case, asking pkg-config for the
various directories as described in the libpcsclite.pc is of course
not working.

Change-Id: I87c68e8d14f8ddb6054178118ff1f96216483f5c
2020-03-04 16:21:34 +01:00
Harald Welte 9fac496046 client: ifd_handler (PC/SC reader driver) as remsim-client
This adds a "" PC/SC driver that can be
used to make normal PC/SC client programs (like pySim, sysmo-usim-tool,
osmo-sim-test, osmo-usim-auth, ...) talk to a remote SIM bank.

Change-Id: Ib8707c6e0e46407ab39a693adfec2fa71892f6ee
2020-03-04 15:49:37 +01:00
Harald Welte 8c0adf681f client: Add diagram for osmo-remsim-st2 use case
Change-Id: Iddd870ddbadc2b6570deb00ea6886c3b34ea1e38
2020-03-04 15:17:59 +01:00
Harald Welte a8e2db9ae3 client: document osmo-remsim-client-shell
Change-Id: I7db510982194ae4f6b9ab8bc442587ecdbf52684
2020-03-04 15:17:59 +01:00
Harald Welte d938e4344f src/ Build src directory (libosmo-rspro) before sub-directories
This ensures that libosmo-rspro is first built/installed, before the
programs that depend on it are.

This resolves warnings like
libtool: warning: '../../src/' has not been installed in '/tmp/osmo-remsim/osmo-remsim-'
during the build process.

Change-Id: I928ff36406986cd0d3fe493f258864a38ce37798
2020-03-04 11:21:09 +01:00
Harald Welte 2637f4da22 contrib: Add for osmo-remsim-client
This is a sample event-script that can be used in conjunction
with osmo-resim-client to trigger certain board-specific functions
such as modem reset on the OWHW.

Change-Id: I69f7f9b0c09421b8c14b909627ffe7b9f1acec77
2020-03-03 22:59:10 +01:00
Harald Welte 951642a80c update .gitignore
Change-Id: Ifa91ec3e8c75becd5652be29c964b0865c2e7b5a
2020-02-22 22:11:05 +01:00
Harald Welte 38d990b0be client: Work around "stock on PTS" problem
I can occasionally see osmo-remsim-client-st2 get stuck when the Modem
(in this case a Quectel EC20) is performing PTS with the card.

In the log of osmo-remsim-client-st2 I can see:

SIMtrace => PTS req: ff 10 94 7b 00 00
SIMtrace -> 01 07 00 00 00 00 15 00 04 ff 10 94 7b 00 00 ff 10 94 7b
SIMtrace => PTS req: ff 10 94 7b 00 00
SIMtrace IRQ 01 04 00 00 00 00 15 00 13 00 00 00 00 00 09 04 0a 80 25 00 00

after which the communication doesn't proceed. After a long time, the
modem seems to retry without PTS and then proceeds with normal SIM card

Interestingly, both the firmware and a usbmon trace agree that the first
APDU header after the PTS is actually sent in an USB IN transfer:

-I- 0: computed Fi(1) Di(1) ratio: 372
-I- 0: computed Fi(9) Di(4) ratio: 64
-I- 0: send_tpdu_header: 00 a4 00 04 02
-I- 0: flush_rx_buffer (5)

usbmon shows 010600000000130001000000050000a4000402

It's unclear why the host program doesn't get the data from the IN
transfer.  However, if multiple asynchronous IN EP URB are submited,
the problem can be reproducibly avoided.  Let's do that.

Change-Id: I2fa5f71869b124b73e0c312befce1ca268e9a9a2
Closes: OS#4409
2020-02-21 22:09:45 +01:00
Harald Welte f43babac56 server: Don't accept out-of-range bank/client/slot numbers on REST
Change-Id: Id0c9dcda58d1f85df431a74bbfba06cfaa0af69d
2020-02-20 18:52:24 +01:00
Harald Welte 44866d501b client: user_shell.c: Don't echo stdin on stdout
This is a debug statement that shouldn't be in the code anymore

Change-Id: I6601e06c843ee7c8d151011af072186bfc5d3efa
2020-02-18 23:02:51 +01:00
Harald Welte 82368402af client: user_shell.c: fflush() after writes to stdout
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

Change-Id: I6879f9f186ce87e0644b3d7868fc5ea031b82c62
2020-02-18 23:02:51 +01:00
Harald Welte 1b6696f144 client: Make ConfigClientBankReq with bankd_port == 0 trigger SRVC_E_DISCONNECT
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
2020-02-18 23:02:51 +01:00
Harald Welte 16c81ea52b rspro_client_fsm: Add SRVC_E_DISCONNECT to disconnect from RSPRO server
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
2020-02-18 23:02:51 +01:00
Harald Welte 3598c58eb8 server: Send ConfigClientBankReq with bankd_port == 0 on map delete
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
2020-02-16 15:46:19 +01:00
Harald Welte ea3eefe433 server: don't dereference map before OSMO_ASSERT() in _update_client_for_slotmap()
Change-Id: Ib36d2ba7928ea17a508cb68748e6c50f22784227
2020-02-16 15:46:19 +01:00
Harald Welte a9caad86e0 client: Split into remsim_client.c and remsim_client_main.c
Change-Id: Ie1d21c2cd84756d5c8aa2c41bcc37f5951a3a285
2020-02-16 15:41:56 +01:00
Harald Welte 879ee414f0 client: Remove g_client completely; separate 'main' code
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
2020-02-16 15:41:56 +01:00
Harald Welte 8e46ab6755 client: Work without global g_client variable
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
2020-02-16 15:41:56 +01:00
Harald Welte 1200c820f0 client: Add new osmo-remsim-client-shell binary
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
2020-02-16 15:41:56 +01:00
Harald Welte d5a8729291 client: Adjust to API changes; enable build of remsim-client again
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
2020-02-16 15:41:56 +01:00
Harald Welte 55c7f44194 remsim-client: Call an external script in specific situations
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
2020-02-16 15:41:56 +01:00
Harald Welte 499e1d90b5 remsim-client: Query + Store the USB device path
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
2020-02-16 15:41:56 +01:00
Harald Welte 943ae6286a remsim-client: store last 'status'
Keep a local copy of the last status message of the cardem

Change-Id: I5b348035da8f0905364b67f21f5c7be112b20e70
2020-02-16 15:41:56 +01:00
Harald Welte 6a0248b224 remsim-client: Move client_config from .c to .h file
Change-Id: I158fe0f2791c164adc74cf851d5a139990bce852
2020-02-16 15:41:56 +01:00
Harald Welte 5ed4693a84 remsim-client: Avoid using 'ci' global variable
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
2020-02-16 15:41:56 +01:00
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

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