Commit Graph

79 Commits

Author SHA1 Message Date
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
Harald Welte 859f1b0974 Introduce support for asynchronous USB transmission
libosmo-simtrace2 traditionally had only supported blocking, synchronous
I/O, while other osmocom programs such as remsim-client used
asynchronous USB I/O.

Using async USB I/O for IRQ + IN transfers while using blocking I/O for
OUT transfers doesn't seem to work reliably, so we have to offer a way
to perform the OUT transfers generated within libosmo-simtrace2 in async
mode.

Change-Id: Ib8939bdb7f533cd20a34a30a97f12b782b9816c2
2020-05-25 23:00:20 +02:00
Oliver Smith 4e73aaeba8 contrib: integrate RPM spec
Remove OpenSUSE bug report link, set version to 0.0.0, make it build with CentOS 8 etc.

Related: OS#4550
Change-Id: I8595642bc07bf3044720942a0f1802448920cb50
2020-05-19 15:59:01 +02:00
Oliver Smith 45e34c69de contrib: import RPM spec
Copy the RPM spec file from:
https://build.opensuse.org/project/show/home:mnhauke:osmocom:nightly

Related: OS#4550
Change-Id: I47ae01afb38fb18c462bf73501b49d6dc5d9f57f
2020-05-19 15:58:59 +02:00
Harald Welte f46de7b70f simtrace2_siff: getopt_long() returns int, not char
This may be causing unwanted behavior while parsing the command
line arguments, as reported by some Raspi users.

Change-Id: I5b7db0795d16ab071e255c2c689e3b4872a933bb
Related: OS#4223
2020-03-19 09:18:31 +01:00
Harald Welte 13cb311c06 extend osmo_st2_cardem_inst with fields required by osmo-remsim
Change-Id: Ib568e5212abfd1269a12c9e5672cdf23b4abff91
2020-03-03 21:09:50 +01:00
Harald Welte 02712376df simtrace2_api: Add osmo_st2_cardem_request_config()
In Change-Id I7cdd3f9171dbed45de0089defe29d2b59044bd84 we introduced
firmware support for SIMTRACE_MSGT_BD_CEMU_CONFIG.  The respective
host part was so far only implemented in osmo-remsim-client-st2,
but not in libosmo-simtrace2.  Let's fix that.

Change-Id: Ia4822d360a271d2ce9725f761cb95de58663ac3b
2020-02-22 22:13:24 +01:00
Eric Wild 1fad9229bf remsim: allow selecting pcsc reader number
The number can be queried using pcsc_scan -n

Change-Id: I9d347501a9f181f68e74799ad04a810553eb2c9e
2020-01-30 10:21:36 +00:00
Harald Welte 02f01e859c host/lib/gsmtap.c: Add GPLv2 disclaimer
Change-Id: Ie163af869c6aa2f3e2bd9007432dc6945384aaf2
2020-01-17 10:29:03 +01:00
Harald Welte 575214f248 host: Add COPYING file for host software (GPLv2)
Change-Id: I0f89a204939b0648eed94cc4f6e7c4f735c118fa
2020-01-17 10:23:31 +01:00
Harald Welte ce4b5c25e8 library: Add osmo_st2_compatible_dev_idsp[]
This is a list of known-compatible USB VID/PID pairs.

Change-Id: I3ef66ebba307899c57077bfd633f84f30190f4dc
2019-12-26 08:07:59 +01:00
Harald Welte 7f7de1ec1d migrate to libosmousb
the code we used to have in libusb_util.c has been migrated to
libosmousb, a new part of libosmocore.git.  Let's remove our historic
copy and use the new shared library instead.

Change-Id: Ib588c08f873c4da8f3a02815ee2767674a6a5061
2019-12-26 08:07:19 +01:00
Harald Welte 8591495d74 Update .gitignore file for host
Change-Id: Id6449ea1c3e918e8c7748b9af7c8c354c1b607d5
2019-12-26 08:07:19 +01:00
Harald Welte 563601cff2 [lib] apdu_dispatch: Don't print APDU state to stdout
The printing was always only done at the end of osmo_apdu_segment_in(),
so let's leave the decision up to the user if he wants to print the
state at every iteration or not.

We now provide osmo_apdu_dump_context_buf() to the user so he can obtain
a string representation of the internal state for logging at any time he
requires.

Change-Id: Id3e3cf1605dec84077b158c1c5715f8eef2641d5
2019-12-17 12:46:21 +00:00
Harald Welte e9556efe88 [lib] apdu_dispatch: Use DLGLOBAL and don't printf() directly
Change-Id: I2f3ec49d34b6806e13af185fb629cabc486891fb
2019-12-17 12:46:21 +00:00
Harald Welte 17cda3db8a simtrace2-sniff: Reformat value_string to pass our validation scripts
This is a purely cosmetic change in terms of coding style, but it
fixes an [invalid] detection for unterminated value_string arrays
by our verify_value_string_arrays_are_terminated.py script:

Change-Id: Iee905c744065df1dc54f04be752a65700897a92c
ERROR: file contains unterminated value_string 'struct value_string change_flags[]': './deps/simtrace2/host/src/simtrace2-sniff.c'
ERROR: file contains unterminated value_string 'struct value_string data_flags[]': './deps/simtrace2/host/src/simtrace2-sniff.c'
2019-12-17 12:04:56 +01:00
Kevin Redon 24c6fe21ab simtrace2-remsim: Use simplest ATR
this ATR does not encode any data and uses all defaults.
the lower default speed is also better handled by the hardware.
handling faster speeds is upcoming.

Change-Id: I5a4f2f94bea1a15aedbef5a6f2f49344387dc11d
2019-12-02 19:35:45 +01:00
Harald Welte 483a3203fb simtrace2_api: Remove dead code
Change-Id: Iab393a6cf9ae1218e1554d9c0bfb7aab2cc3c35e
2019-12-02 11:23:51 +01:00
Oliver Smith 71cfc2b90d Fix topdir Makefile and debian packaging
Make building the debian packages work again. I've verified that it
works in my own OBS namespace.

This patch also adds missing pkgconf variables in host/Makefile.am, so
libosmo-simtrace2.pc installs properly.

Related: OS#4283
Fixes: 964cda309d ("host: use autotools and split shared code to libosmo-simtrace2")
Change-Id: I2377de1e8b149520922217a1ab16f6e22fe6462a
2019-11-28 11:53:09 +01:00
Oliver Smith 15e943ab8b simtrace2-sniff.c: fix printf usage
Fixes:

simtrace2-sniff.c:113:4: error: format not a string literal and no format arguments [-Werror=format-security]
    printf(flag_meanings[i].str);

Change-Id: I9793c680f070e724ce89272e9e489963c7516d52
2019-11-27 19:10:02 +01:00
Harald Welte 6f41349db9 merge simtrace2-discovery.[ch] to libusb_util.[ch]
Change-Id: I4defbec70986a90c1f0cfb7587393265b73c0163
2019-11-24 23:15:53 +01:00
Harald Welte 208890ad6e use osmo_st2_ or osmo_ prefix for [shared] library symbols
Change-Id: Ie2686b30717b9541b1217802ca967cd0a4cbde9b
2019-11-24 23:15:53 +01:00
Harald Welte 964cda309d host: use autotools and split shared code to libosmo-simtrace2
Change-Id: I57e77f927ee9e169cc794c5dc6b128a2d590201b
2019-11-24 23:15:53 +01:00
Harald Welte 331fa5a237 remove unused function process_do_error()
Change-Id: I02bc23a340b086b0de4e69affb6f965bff6bbc0b
2019-11-24 23:15:53 +01:00
Harald Welte 6fada5604b simtrace2-remsim: Implement/Fix the 'skip_atr' option
Change-Id: Id8206738635af0dd55836bbbcbfbe7381c375e97
2019-11-24 23:15:53 +01:00
Harald Welte 931fe558df fix typo: libisb -> libusb
Change-Id: I0a9505e3eeb7ae4ffda7081dcbb1ed63835600a5
2019-11-24 23:15:53 +01:00
Kevin Redon 7e5cda5732 remsim: fix TPDU response size transmission
the TDPU response data size can be up to 256.
this length cannot be stored in a uint8_t, which would cause the
length to become 0, no data being send, and the reader reset the
card because of misbehaviour of the card (i.e. no/malformed
response leading to the timeout of the waiting time).

Change-Id: Iae7671085aaa3115a02d82530dd7a0e7e2d4155e
2018-10-21 12:29:26 +00:00
Kevin Redon 032fc5f844 remsim: update copyright
Change-Id: Ibcf093877ee53f8446c97bfa50c8370ceda24c53
2018-10-21 12:29:10 +00:00
Kevin Redon b1f99c909c remsim: add already parsed USB path argument info
Change-Id: I03de93ebb92b1d1b5004cbe865cdf1fa0b2b23ac
2018-10-21 12:29:10 +00:00
Martin Hauke 53b4e593aa Fix compiler warning: no-return-in-nonvoid-function simtrace2_usb.c
RPM post-build-checks found some issue and marks these as error:
[   61s] I: Program returns random data in a function
[   61s] E: simtrace2 no-return-in-nonvoid-function simtrace2_usb.c:88

Change-Id: Id16fb7fc4f13176b2b6443af02a5848d8fcfb069
2018-10-13 22:14:06 +00:00
Harald Welte dc85fbc3e1 libusb_util.c: Avoid gcc warning about strncpy()
What we're doing is actually legal: We copy the full size of the
destination array, and then overwrite the last byte with NUL.  However,
gcc isn't smart enough to see that:

libusb_util.c:162:5: warning: ‘strncpy’ specified bound 20 equals destination size [-Wstringop-truncation]
     strncpy(out[out_idx].path, path, sizeof(out[out_idx].path));
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Let's copy one byte less to make it happy.

Change-Id: I30ddacdc73e5245c7c38b92d1e94e39b13fae7d3
2018-10-12 15:15:08 +02:00
Kevin Redon 5b5d24ebf3 owhw: set the right simtrace USB ID in usb2udp
Change-Id: I0b54c2eb98b3fad1e2afaf9b81fbe4518b01fbda
2018-09-08 08:22:56 +02:00
Kevin Redon faf1e88e48 host: clean library dependencies
remsim also needs libpcsclite
`pkg-config --libs libosmocore` and -losmocore are duplicates
`pkg-config --libs libosmosim` is equivalent to -losmosim
pthread it needed (by most applications) for static compilation
LDFLAGS+= allows static compilation when running
LDFLAGS="-static" make

Change-Id: Ic7bd6f2be074d6f652d4f84f4996c8588ea5f851
2018-09-06 23:15:44 +02:00
Harald Welte 82b628524f simtrace2-sniff: Fix build with released libosmocore versions
There's still no released libosmocore defining the GSMTAP_TYPE_SIM
sub-types (Change-Id: I5bd0dff5a4a90cfe96d9c4f3dec6657e1d85bf7a
dated Jul 26, 2018).

Let's make sure users don't need an unreleased version of the library
if it's only about a few #defines that we can just copy here for
backwards compatibility.

Change-Id: I2fd9e14873711d60f194bb404420bbfbb0a00f48
2018-08-26 11:43:12 +02:00
Harald Welte f7f61cd10f Makefiles: Add "make install" target
Change-Id: Ic6835ce55930c60f909e140878c4abab8628e077
2018-08-26 10:09:43 +02:00
Harald Welte 0e95f53588 host: Fix "make clean": remove simtrace2-sniff
Change-Id: Ib233b6a4b3976286196da95036cadcf2d3382f77
2018-08-26 09:54:55 +02:00
Kevin Redon 04ccb770fd remsim: fix USB hanging USB transfer
After a couple of seconds of USB data exchange between remsim and
cardem, the USB transfer hangs.
On host side (remsim) I can see the USB BULK IN request.
On device side (cardem) I see that data has been submitted and
"sent" over USB, but on wireshark with USBmon I don't see the
corresponding USB BULK IN response.
When exiting remsim or just after powering of qmod (causing an
error in remsim) the USB BULK IN is show in wireshark. Thus it
must have been in a buffer, but not read by libusb_bulk_transfer.
By shortening the timeout a new libusb_bulk_transfer is made more
frequently, and the data gets read successfully.

T;his change also fixes the URB data display.

Change-Id: I1d124a41cc90893506933f6d76dc7331e52a74f9
2018-08-04 11:16:15 +02:00
Kevin Redon 8f70c3eb1f remsim: fix payload overwriting
The slot number is in the header, and correctly set in st_push_hdr.
Setting the slot in st_slot_tx_msg will overwrite the payload data.
This caused bytes three of the ATR to be changed from 0x96 to 0x00,
corrupting the ATR. This corruption is caught by the ATR checksum,
and the modem would reset the card (2 additional times) to try to
get correct ATR.

Change-Id: If971699993617fc50557d20582c344ea06645a3f
2018-07-30 15:03:55 +02:00
Kevin Redon 697199676e sniff: ensure the checksum error flag is also printed
the firmware now also use a generic value_string array (as does the
host application)

Change-Id: I861bd8b52e8f2f2a4786bbe1cc834917119dc394
2018-07-28 20:59:41 +02:00
Kevin Redon 8e84f8125c sniff: rename reset hold/release to assert/deassert
this change is to match the nomenclature used in cardem

Change-Id: Ide99e731cad26aec949ad14d54f46fa611a0b7f8
2018-07-26 15:34:08 +02:00
Kevin Redon d1c6536154 sniff: send ATR over GSMTAP
Change-Id: Id35129883f08002a4a796b56954a128e2b533245
2018-07-26 14:51:15 +02:00