119 Commits

Author SHA1 Message Date
Harald Welte
e1961beea1 Use gsmtap_inst_fd2() to remove compiler warning
gsmtap.c: In function 'osmo_st2_gsmtap_send_apdu':
gsmtap.c:69:9: warning: 'gsmtap_inst_fd' is deprecated: Use gsmtap_inst_fd2() instead [-Wdeprecated-declarations]
   69 |         rc = write(gsmtap_inst_fd(g_gti), buf, gross_len);
      |         ^~

Change-Id: I62de38175e63cb563635a01b025b805981e4b7a9
2026-02-27 11:18:45 +01:00
Oliver Smith
d0ad985eb0 Generate a version.h file
Related: OS#6626
Change-Id: Ia894a9d9a20e343755d8060822d33b8a1c59b4db
2025-06-23 16:00:59 +02:00
Oliver Smith
c38ad746f2 Bump version: 0.8.1 → 0.9.0
Change-Id: I6965017fcd5323677ce11fd9860d4355eb8f770f
2025-02-12 16:09:26 +01:00
Alexander Couzens
f9885fe019 simtrace2-cardem-pcsc: allow to set sim presence polarity
Add api call osmo_st2_cardem_request_config2(struct cardemu_usb_msg_config *)
which contains a full cardemu_usb_msg_config.

Related: SYS#6946
Change-Id: Iacde63e667472a85a5f18cb4ca99dcfa1a84dd59
2024-06-23 18:47:42 +02:00
Oliver Smith
69deee859f contrib: remove rpm spec file
Related: https://osmocom.org/news/255
Related: OS#6446
Change-Id: I0cc8d753b26648efa7c9fb5798f7c4227c328547
2024-05-08 14:41:11 +02:00
Philipp Maier
1f77d673e2 simtrace2-cardem-pcsc: mark reset events in GSMTAP trace
At the moment only APDUs are logged to GSMTAP. It is not uncommon that a
card is resetted by the UE multiple times during normal operation. When
the trace lacks the reset events (ATR) it becomes difficult to follow in
which state the card actually is. Let't mark reset events by sending the
ATR via GSMTAP (like simtrace2_sniff already does it)

Related: OS#6094
Change-Id: I6b4d82b6ee369c95eeca8f7d59478452395fbe54
2023-07-21 13:03:38 +02:00
Harald Welte
da078c090b Fix unchecked return value of osmo_libusb_init()
Fixes: CID#307501: Unchecked return value (CHECKED_RETURN)
Change-Id: Ic1f600dfd44d15da165a17d84f0faab6f6fd69c3
2023-07-18 15:04:24 +02:00
Vadim Yanitskiy
fdfb02418f host/cardem: fix integer overflow in process_do_rx_da()
osmo_apdu_segment_in() may return a negative number on receipt of
"unknown APDU case", and that would crash simtrace2-cardem-pcsc:

  msgb(0x55d2cf7aa8a0): Not enough tailroom msgb_put
    (allocated 920, head at 0, len 7, tailroom 1017 < want tailroom 65534)
  backtrace() returned 19 addresses

Whenever osmo_apdu_segment_in() fails to recognize an APDU, the
communication is broken, because we don't know if we should continue
transmitting or receiving.  Only a successful return value by would
allow us to know this.  Do not crash, exit() gracefully.

Change-Id: I9e97b955a28ec886a429d744f9316e7e71be4481
Related: OS#5600
2022-07-11 16:30:47 +07:00
Harald Welte
9088ca86ff simtrace2-cardem-pcsc.c: Send APDUs via GSMTAP
Previously, only simtrace2-sniff generated GSMTAP protocol traces.

Let's add the same functionality to simtrace2-cardem-pcsc.

Change-Id: Iba6adf41b480d127bf11ee361c66d80fe8296313
Closes: OS#5494
2022-04-05 17:29:20 +00:00
Harald Welte
b01dc91c0b simtrace2-cardem-pcsc: continue in case of LIBUSB_TRANSFER_ERROR
Sometimes I get LIBUSB_TRANSFER_ERROR particularly when the USB bus
is very busy.  We shouldn't terminate the program, but simply resubmit
it.  That's what we have multiple transfers for...

Change-Id: I77d7bc636c21171fcff7e70e87c0109cbaee9b51
2022-03-03 17:48:14 +01:00
Harald Welte
5cc3add0b0 simtrace2-cardem-pcsc: Fix copy+paste error in log message
Change-Id: I98e4356900a22f69d0ff262cb112194b1e11d4af
2022-03-03 17:48:14 +01:00
Harald Welte
ca62121c19 host: Don't pass -1 (converted to 255) as address
We initialize a local variable to -1, and if the user specifies
no address from the command line, we use this in the interface match
struct, which uses a uint8_t.  This means 255 ends up in there, and
as a result no usb interface ever matches unless the user explicitly
specifies the -A command line argument.

With this patch any absent -A argument will result in ifm.addr == 0,
which means "don't match on address", and which is what we want here.

Change-Id: Iffb5fa406ddef00c7c15570ffca2c109b98d7a2d
2022-03-03 17:48:14 +01:00
Harald Welte
8b52b44f1b simtrace2-cardem-pcsc: Detect card power-up without RESET
In some readers (at least CardMan 3121), the simtrace2-cardem firmware
claims there are power-up sequences where RESET is released before VCC
becomes active.  Let's detect such spec-incompliant power-up sequences
and use them to trigger a cold reset of the card.

Change-Id: I682ac3d0c2b98749a6ed44f9a73e4b39354a4284
Closes: OS#5421
2022-03-03 15:27:35 +01:00
Harald Welte
71ac54d7bf simtrace2-cardem-pcsc: Move all logging into libosmocore
* drop log statements that are already in libosmo-simtrace2
* don't printf directly, but go via LOGCI
* make LOGCI use libosmocore logging
* configure libosmocore logging in a 'convenient' way

Change-Id: I6fa0da966e6d8e723c187404c17e90cfb3f3dd9f
2022-03-03 15:27:34 +01:00
Harald Welte
ab5b2ffe1d simtrace2-cardem-pcsc: rename 'flags' to 'status_flags'
there are other flags in the simtrace/cardem protocol...

Change-Id: I6362936c642e7abf4c501b4526a1654a25afedfe
2022-03-03 15:27:15 +01:00
Harald Welte
ee9ddb8da1 host: Always initialize libosmocore logging before using it
This avoids related ASSERTs or error messages in case any of the
libosmocore / libosmousb API functions internally tries to log
something.

Change-Id: I611c435516856c5c8928d7810fd9a9b831adc199
2022-03-03 15:27:13 +01:00
Harald Welte
94cc319b8e host: properly zero-initialize interface match structures
This can lead to some fields not properly zero-initialized, fooling
our matching code into the application having requested certain
fields to match ('0' is usually assumed to be unspecified).

Change-Id: I304d55b584e37d9dccb75b24057bb682f799beb2
2022-01-25 16:40:27 +01:00
Harald Welte
7a450041bf cosmetic: Fix indent of printf() statement
Change-Id: I9f5c9f7720b3bc3c8d5df9750b031d8bcf2dd435
2022-01-25 16:39:46 +01:00
Harald Welte
3f0d92f282 host: Print strerror(errno) in case of problems opening the USB device
Change-Id: If446bf08655739281f616df952714751fe9a3b18
2022-01-25 16:09:55 +01:00
James Tavares
aeaf12853e simtrace2-tool: add "modem sim-card (insert|remove)" command
Add a new command to request that the simtrace2 firmware manipulate the
card detect signal, causing the downstream cellular modem to believe
that the SIM card has been inserted or removed, respectfully.

Change-Id: I8c79eb29379a789d9d0d21495e30d66ddbdfb022
2022-01-10 18:06:45 -05:00
Oliver Smith
f721e69bc1 treewide: remove FSF address
Remove the paragraph about writing to the Free Software Foundation's
mailing address. The FSF has changed addresses in the past, and may do
so again. In 2021 this is not useful, let's rather have a bit less
boilerplate at the start of source files.

Change-Id: Ie0a3b2273383adbb3303faffd6ff96be7f4cae99
2021-12-14 11:47:21 +01:00
Oliver Smith
8dada9b454 host/contrib/simtrace2.spec.in: update
Apply various improvements from Martin Hauke, thanks!

* Put sover into a variable
* Sync BuildRequires with configure.ac
* Update libosmo-simtrace2 summary
* Use %make_build instead of make %{?_smp_mflags}

Change-Id: I35ce3865702f72365b38b0eaa8b28f332dabcd1f
2021-12-10 14:50:18 +01:00
Oliver Smith
24a9ee8ae6 host/contrib/simtrace2.spec.in: fix soname
Adjust the soname in the rpm recipe too, to fix:
  error: File not found: /home/abuild/rpmbuild/BUILDROOT/simtrace2-0.8.0.202112100026-1.1.x86_64/usr/lib64/libosmo-simtrace2.so.0*

Change-Id: I748f44409ac736abbd5c18e31ae02d025dee2c77
2021-12-10 10:04:13 +01:00
Harald Welte
45a8f2beee Bump version: 0.7.0.166-61b4-dirty → 0.8.0
Change-Id: I1650f7181cf514ba00e6f70e8133ee88780ebf41
2021-12-09 08:12:56 +01:00
Harald Welte
155c237504 host: Upgrade libosmocore dependency to 1.4.0
1.4.0 contains the most recent changes to libosmousb, so let's use
that as a minimum basis.

Change-Id: Ia44377cd6a8d7998c6995a3f89adb22cdc675601
2021-12-09 08:05:58 +01:00
Harald Welte
020edca678 cardem-pcsc: Fix return of uninitialized variable
Fixes: CID#240740
Change-Id: I97431f491f60e2a6537502ef88042907723b7de6
2021-10-25 08:12:08 +02:00
Harald Welte
651050922a simtrace2-tool: Initialize logging to avoid error on first log output
This avoids
 ERROR: osmo_log_info == NULL! You must call log_init() before using logging in log_check_level()

Change-Id: Id355ef33e10164f8e8eb40c2fd0b606bc8e9b6f7
2021-10-06 21:10:44 +02:00
Harald Welte
5b7a608277 simtrace2-cardem-pcsc: Remove double libusb initialization
This code already calls osmo_libusb_init further above in the top
of the main() function, so there's no use of calling libusb_init()
directly in the same function lines below.

Change-Id: I2e0c7446aaa644c5aae1059ce91ff9f729903cbc
2021-10-06 21:06:21 +02:00
Harald Welte
e304015b3c Use osmo_libusb_{init,exit}() instead of libusb_{init,exit}()
We use other osmo_libusb_* functions later in the code, so it is best
to initialize the library via libosmousb, and not directly.

Change-Id: I2fd981935e1420e529f5dd8a98edd347c317284c
2021-10-06 21:06:06 +02:00
Harald Welte
a951c4ae02 simtrace2.spec: Add simtrace2-tool binary to package
This fixes RPM build issues reported as

[   59s] error: Installed (but unpackaged) file(s) found:
[   59s]    /usr/bin/simtrace2-tool

Change-Id: I1fd5980a686652afb47cd1c30e12919de626aec7
2021-08-03 09:02:34 +02:00
Eric Wild
a755b53768 simtrace2-cardem: use local sim on exit
There is no obvious reason why the st should be stuck in cardem mode
without a working running util on the host side since there is no state
that is being kept, so switch back to using the local sim upon reset.

Change-Id: Ib622af0027d40b4e8afbb0fa0d3689f0dbfcac92
2021-08-02 09:23:19 +00:00
Harald Welte
4fe93be725 introduce support for new ngff_cardem board
This adds support for the new ngff_cardem board, a board that
basically combines a ngff breakout board with a built-in SIMtrace2.

Cardem works, but depending on the modem it might need a adjusted ATR to
ensure a lower baud  rate is used by the modem, high rates might lead
to weird power cycling of the card after a few transfers.

Trace was also tested and appears to work as expected.

Change-Id: Ia96124fbe8a752c98e7fd4096d542a3b2b9bc255
2021-08-02 09:22:46 +00:00
Harald Welte
51d87fbb66 Introduce simtrace2-tool
The simtrace-tool is a command line tool which can be used to e.g.
manually request a modem reset.

Change-Id: I3a8896ac2b3caef7590b51118359e5caed820a40
2021-08-02 09:22:46 +00:00
Harald Welte
06fe3b8295 99-simtrace2.rules: Add OCTSIMTEST
Change-Id: I226ee21e0937f851428578578f81075fa703dd54
2021-07-09 11:46:11 +00:00
Harald Welte
3ef40d1ca6 simtrace2-list: Use osmo_st2_compatible_dev_ids[]
we shouldn't use a local copy of the device id list, which is already
outdated now that OCTSIMTEST support has been added to libosmo-st2

Change-Id: I2231006b94c33fe3b28ce37b0d54c67206751058
2021-06-30 08:17:58 +00:00
Harald Welte
dcfea28a4f don't printf() directly from library code, go via libosmocore logging
This allows us to use different log levels, and permits the user to use
other log targets.

Change-Id: I08ef7cfa5d8734882746a11ccd5f059d757401ae
2021-06-30 08:17:58 +00:00
Harald Welte
054d7ca499 cardem-pcsc: initialize libosmocore logging
Change-Id: I815d39190e944d9512ffc8e5f581515d7be9834f
2021-06-02 22:57:10 +02:00
Harald Welte
913c86b95d Add usb product ID of sysmoOCTSIMTEST
This is a custom board for production testing of the sysmoOCTSIM,
an 8-slot smart card reader.

Change-Id: I65839be50ac896c76f34755fb2800f836f6cdae4
2021-06-02 10:09:40 +02:00
Harald Welte
c1033c8611 simtrace2-cardem-pcsc: Reset the real card if reader resets cardem
When the cardem detects a reset from the phone/modem, pass this on
to the actual card via the PC/SC reader.  This is important to
reset the card state whenever requested by the stack/driver on the
phone/modem.

Change-Id: I7056476c5f81e8aa8f550afb86bf2380d1497ebb
Depends: libosmocore 20199da02d37a6d284915a27ec12641e79b8781c
2021-06-01 21:09:05 +02:00
Harald Welte
644c2131ca simtrace2-cardem-pcsc: Decode STATUS flags to strings
SIMtrace IRQ STATUS: flags=0x13, fi=9, di=6, wi=10 wtime=9600 (RESET VCC  CLK )

is more understandable than

SIMtrace IRQ STATUS: flags=0x13, fi=9, di=6, wi=10 wtime=9600

Change-Id: I5bbfa1d99ebee4b297d894a5f444dbe743c7ab70
2021-06-01 21:09:05 +02:00
Harald Welte
c690a1f130 st2-cardem-pcsc: Use ATR of real card by default
Before this patch, we would always use either a hard-coded default
ATR from the source code, or we would use one that the user specified
on the command line.

The more sane default is to pass-through the real ATR of the card.

Change-Id: I75bf618a6b0d983727de4c2f19b4b48ec3e12af8
Closes: OS#5107
Requires: libosmocore.git 22117a7164012d6d88fc202cd63df79c6068484d
2021-04-25 21:30:47 +02:00
Harald Welte
8e6ba005d4 st2-cardem-pcsc: Fix goto-in-while mess
There's some code that wasnts to goto within the while loop, and there's
some other code that wants to goto after the while loop.  Don't jump
from outside the while loop into the while loop.

Change-Id: Ic2a94ad034dd259f15712687443b569f0d18ff3f
2021-04-25 21:30:47 +02:00
Harald Welte
9ec3de9346 simtrace2-cardem-pcsc: Make it work again
* support Interrupt STATUS notifications
* use osmocom libusb abstraction
* use asynchronous URBs for interrupt + bulk

Change-Id: Ib04798572295f25477719124530b6584780c5b75
2021-04-05 20:37:00 +02:00
Eric Wild
0b1a3b4105 cardem: choose a more reasonable default ATR
PCSCd does not like invalid ATRs

Change-Id: I1eebfdc06be55931c2e80e2b515ac3a559737c38
2021-04-04 19:54:19 +02:00
Oliver Smith
90e351f4a7 host: use git-version-gen/tarball-v. from topdir
Use .tarball-version from the topdir, because it only gets written there
when generating the OBS package. Remove the duplicate git-version-gen
script and use the one from the topdir to generate a version string if
building from the git tree.

Related: OS#4413
Change-Id: I4b197a218ab44632ff182ffbd72e15c2b20db341
2021-03-05 12:41:22 +01:00
Harald Welte
aadd995664 remove old pre-autoconf makefile
Change-Id: Icd519a69a5cb1950daa79df4d9864e8dea091289
2020-10-27 15:55:07 +01:00
Harald Welte
b1a56e0f77 rename simtrace2-remsim to simtrace2-cardem-pcsc
This renaming is to avoid any confusion with the osmo-remsim
project, living in its separate git repository.

The simtrace2-cardem-pcsc doesn't feature any 'remote' part.  Rather,
it emulates the SIM card interface towards the device/phone/modem,
and forwards it to a local PC/SC card reader.

Change-Id: Ic15f0a89964a72fe3ab7a5145a073720f6207e24
2020-10-27 15:48:37 +01:00
Harald Welte
80b8877a23 remove usb2udp
The UDP based forwarding really only ever was a quick hack to
demonstrate the capabilities.

Meanwhile, we've had the proper osmo-remsim project implemented,
which provides a much more reliable and comprehensive way of
managing SIM card emulation devices (SIMtrace2, sysmoQMOD, ...)
and collection of card readers (sysmoOCTSIM or any other PC/SC
supported readers).

Hence, remove the "UDP forwarding part.

Change-Id: Ia4b9447b95872b6e0dda6dca644f1ed4a87355a0
2020-10-27 15:48:35 +01:00
Leonard Hübner
1372aca28e remsim: adding cli argument to set the atr
Change-Id: I554b515e7954148f9ca5ba29417699da70b0945b
2020-10-27 15:34:36 +01:00
Harald Welte
a124c1714e migrate from BSC_FD_* to OSMO_FD_*
Change-Id: I01c834537e18eacdd1658f88a4b4a6d4690d87a6
2020-10-18 22:32:24 +02:00