Commit Graph

1032 Commits

Author SHA1 Message Date
Pau Espin 7626d0816f layer23: Use GSM_RESERVED_TMSI from libosmocore everywhere
Change-Id: Ib9483b8ae4067994aef523291733ae706ffabe7a
2023-04-26 14:14:29 +02:00
Pau Espin 3c348f5893 layer23: Call telnet_exit() during app exit if VTY support is enabled
Change-Id: Ic8540c73b1b13134e11f254beb6a16f7e4452317
2023-04-26 14:14:29 +02:00
Pau Espin 8cc6740448 layer23: mobile: Mark several functions static
Change-Id: Ifdeef9373b903d14fb2f4ec4caa1bf8c42b45aa1
2023-04-26 14:14:29 +02:00
Pau Espin e8fc1e9228 layer23: modem: Unregister registered callbacks upon app exit
It's just a good practice to delete all resources allocated during startup.
The main aim here is to keep resemblance to what the mobile app is doing,
so that they can slowly be merged and some functionalities from the mobile app can be
added to the modem app, like shutting down the MS without killing the process eventually.

Change-Id: I5a641fa3dadb6ea7346b25a20215896ab32eb805
2023-04-26 14:14:08 +02:00
Pau Espin 0683b9033f layer23: modem: Set on tun the IP address received during PDP Ctx Act Accept
Change-Id: I39c27caeff0ccd08d8d8b5fcba5a1d69238d53ca
2023-04-25 22:16:26 +00:00
Pau Espin 651426fee4 layer23: Decouple SIM events from MMR events
let the specific app handle the events generated from the
subscriber/SIM.
All the MMR specific code can for now stay in mobile/ while SIM support
can be in common/ without violating layers (common/ calling functions in
mobile/).

Change-Id: I473887e0fd9338d76a69a9774145a04575f14b64
2023-04-25 18:14:33 +02:00
Pau Espin f99819a4f2 mobile: Fail VTY command if attching test SIM card fails
Change-Id: Ie5a395de6c926f13ce9324b93da0e348da5438d1
2023-04-25 18:14:33 +02:00
Pau Espin 65cde7dd04 layer23: modem: Fix wrong 'radio not started' vty message
Change-Id: I8871c9d0e820beb75d7820b5a2d8d3c77dac379d
2023-04-25 18:14:33 +02:00
Pau Espin 7019f1bf2b layer23: Move testsim node to common/
Change-Id: Ife34403a715809b43e7a4cd5ce4dec8616fc08af
2023-04-25 18:14:25 +02:00
Pau Espin 234c1f14fd layer23: Use libosmocore API to validate IMSI string
Change-Id: I2d4737dabcfb83a7b675c35ad973029a36658d5b
2023-04-24 17:06:10 +02:00
Pau Espin a78c3927a0 layer23: common/vty: Drop includes pointing to mobile app
Change-Id: I025b09500547a739240fc07fa04cb38378ed71db
2023-04-24 16:56:15 +02:00
Pau Espin a7bf51ac0e layer23: Move vty_notify() to common/
Change-Id: Ic0a98e66adffa9fefeee6e69a4b5c691e0e9c789
2023-04-24 16:54:11 +02:00
Max 46f49131da mobile: log unhandled event name
Change-Id: Id8e6e8af5756e3527ca1968b24f25e4238f0aa40
2023-04-23 12:51:18 +00:00
Pau Espin 1cb78f3114 layer23: modem: Forward SNSM primitives SNDCP<->SM layers
Related: OS#5501
Depends: libosmo-gprs.git Change-Id Ic5525bfa92e2591757d999610c0d59849d022d8d
Change-Id: Iad63f41557fbd078588dd890e2f18ed9606a25f7
2023-04-14 19:05:04 +02:00
Pau Espin 4ba8db561e layer23: modem: sndcp: Apply API change in libosmo-gprs-sndcp
Depends: libosmo-gprs.git Change-Id Iebce37a50917b13c23de1528469d66c310ced7f2
Related: OS#5502
Change-Id: I4f559e4a882a85742c45609dec596f0485eafed0
2023-04-14 18:34:18 +02:00
Pau Espin 7035b8095c layer23: modem: llc: Fix typo LLGM -> LLGMM
Depends: libosmo-gprs.git Change-Id I59577d27bedd26903c9b1bfc64792f0891cea728
Change-Id: I786661894fc6772784ba6f0d2fdb45bbdca5254c
2023-03-30 14:17:47 +02:00
Pau Espin a89939a68b modem: initial SM layer support through libosmo-gprs-sm
Depends: libosmo-gprs.git Change-Id I9b4a9a6364f7799540475e7e1d10ab2310768281
Related: OS#5501
Change-Id: I9476d93954c7dc348e6f97ca89eaa651f802f9a0
2023-03-30 13:52:50 +02:00
Pau Espin 79ea13fccc layer23: Support cpu-sched vty node from libosmocore
Change-Id: I1affb401bf355360fe306568c9b5c005dbd0746c
2023-03-29 13:08:17 +02:00
Pau Espin 7b8cc36ad0 layer23: modem: fill imsi & imei in vty 'test gmm attach'
Related: OS#5501
Change-Id: If93f7e2cbb421d0aa2702b8e130c8602fbc18a97
2023-03-28 10:59:23 +02:00
Pau Espin 3e31b3232d layer23: modem: Forward GMMRR primitives between GMM and RLCMAC layers
Related: OS#5501
Change-Id: I7603d8bbda0cdd437eb7557267efb7bbc3552565
2023-03-28 10:59:20 +02:00
Pau Espin 574177d2ce layer23: rlcmac: Support GMM detaching from VTY
Related: OS#5501
Depends: libosmo-gprs.git Change-Id If6cbb1d425b3a9f713348f1dea4747e2b6be0a44
Change-Id: Idca0bff6fc3e6a16b5e8379eae3315e3af012d78
2023-03-27 11:23:40 +02:00
Vadim Yanitskiy d692e6ca9c modem: set logging cat for OSMO_GPRS_RLCMAC_LOGC_TBF{UL,DL}
... otherwise the library will be using default DLGLOBAL.

Change-Id: I98efa4c8137c7ec57da6ef7ea1307b4e46b4fc98
Related: OS#5500
2023-03-25 06:04:19 +07:00
Vadim Yanitskiy 848b859f30 layer23: add missing log_info_cat[] entry for DGMM
Change-Id: Icdc09b6edce7abb3ff88f12650d3b304447d39a6
Fixes: 1612c8f86 "layer23: modem: Depend on libosmo-gprs-gmm"
Related: OS#5501
2023-03-25 06:04:19 +07:00
Pau Espin e8a3ad2216 layer23: modem: Test GMM layer through VTY
Recent work on libosmo-gprs-gmm already allows triggering GPRS Attach
procedure. Let's add some code to use it so we can already test the
entire stack GMM->LLC->RLCMAC (SM layer still missing).

Depends: libosmo-gprs.git Change-Id I212053b3a3f27ef7d63503c3d5ef08453b2d2056
Related: OS#5501
Change-Id: Iba0663075468670a29aceafe5196cae3cab050eb
2023-03-23 15:50:13 +01:00
Vadim Yanitskiy 3b582af2eb modem: route L1CTL prims to/from libosmo-gprs-rlcmac
Change-Id: I38e9a686f8edc3fe55f961d75e68602c33bbbaaf
Related: OS#5500
2023-03-17 12:15:29 +00:00
Vadim Yanitskiy bb6df124d2 layer23: implement Rx/Tx API for GPRS related messages
Change-Id: I87950e893ef96ff8328f43f1548111aa9f66439b
Related: OS#5500
2023-03-17 12:15:29 +00:00
Vadim Yanitskiy e15996378f modem: fix modem_gmm_prim_up_cb(): add missing break
Change-Id: Ibd16232d76d83d90f27d08b47aa38509161270b6
Fixes: CID#311019
2023-03-17 16:21:00 +07:00
Vadim Yanitskiy 4949ab7471 layer23/{mobile,modem}: prefix VTY prompt with project's name
Change-Id: If7ce89362c75e2c15995dfb08cfcfdcad24e2529
2023-03-17 16:11:48 +07:00
Vadim Yanitskiy b2dfbb8859 layer23/{mobile,modem}: fix segfault on VTY connection
It was a mistake to call vty_init(), passing it a pointer to the
vty_app_info structure allocated on the stack, because it gets
overwritten when the calling function _vty_init() returns.

Change-Id: I75843a964254243c70bedcf8ff97d854107ee21a
Fixes: 9feb5057 "layer23: refactor the application API concept"
2023-03-16 23:41:48 +00:00
Vadim Yanitskiy 42ca40dd1e modem: add test VTY command for sending raw LLC PDUs
Change-Id: I14f58e715d77a1b1cb40fdd3ddd09084360f2274
Related: OS#5500
2023-03-16 13:47:06 +00:00
Vadim Yanitskiy b29a26c620 modem: add test VTY command to send CHANNEL REQUEST
Do not call grr_tx_chan_req() unconditionally from grr_rx_bcch().
Add a special (hidden, expert mode) VTY command for that.

Change-Id: I049a8d7f58ae9703d06dff235973ba376702c873
Related: OS#5500
2023-03-16 13:46:53 +00:00
Pau Espin 1612c8f862 layer23: modem: Depend on libosmo-gprs-gmm
Related: OS#5501
Change-Id: I82a2b9c043eae42435ca781689fc3381e7a31bea
2023-03-15 15:38:54 +01:00
Vadim Yanitskiy 7ea900525c modem: clean up #includes (using include-what-you-use)
Change-Id: I728f3eea1590f46bef6e0eb4beb9714f6c9a1614
2023-03-14 15:06:26 +00:00
Vadim Yanitskiy 8240ef74fc modem: move GRR specific code into its own file
Change-Id: I25caa0bd01e3d090803512f5b13cad58439f44f8
Related: OS#5500
2023-03-14 15:06:26 +00:00
Pau Espin b8c3bef737 layer23: Call osmo_fd_unregister() before closing and changing bfd->fd
Change-Id: I886062c1a944acf0982755a7acddf7e2233d13a8
2023-03-14 12:17:36 +00:00
Vadim Yanitskiy 6db5f8b9ce modem: get rid of app_data.chan_req, use ms->rrlayer
Change-Id: I77d0a834a73c511f157c6f1524b9e98df3f4def4
Related: OS#5500
2023-03-14 18:51:09 +07:00
Vadim Yanitskiy 7f9c01f00f modem: get rid of app_data.{ccch_mode,si}, use ms->cellsel
Change-Id: Ib711a3b893c43c0875c431c90cd0a2ebfafe1926
Related: OS#5500
2023-03-14 18:51:09 +07:00
Vadim Yanitskiy 67943df4b7 layer23: fix parsing of command line options
After the recent refactoring, parsing of the command line options is
broken for some arguments.  Specifically, the value of '-a'/'--arfcn'
is ignored and hard-coded ARFCN=871 is used instead.

The problem is that l23_app_init(), which allocates an MS state and
sets the initial ARFCN, is called *before* handle_options().  So the
cfg_test_arfcn is used before it gets overwritten from the argv[].

The usual approach in osmo-* apps is to parse the command line
arguments first, and only then execute code which depends on
configurable parameters.  Let's follow this approach too.

Change-Id: I77ca11c14561fa3fcb9add60ccea5b0b847a20c4
2023-03-13 06:18:02 +07:00
Vadim Yanitskiy 9feb5057da layer23: refactor the application API concept
With this set of changes we have a cleaner l23 app architecture:

* struct vty_app_info: all l23 applications must define this struct;
* struct vty_app_info: *cfg_supported() becomes a mask of L23_OPT_*;
* struct vty_app_info: explicitly set L23_OPT_* in all l23 apps;
* drop l23_app_info(), there can be only one vty_app_info per an app;

It's no more needed to obtain the vty_app_info by calling a function
and checking the returned value against NULL everywhere.  This kind
of information is rather static (not dynamically composed) and needs
not to be encapsulated into functions.

Change-Id: I89004cd5308927305f79b102f7b695709148df6d
2023-03-13 06:16:48 +07:00
Max 22f12ba92e vty: fix local-host docs
Change-Id: I69d0fa32105a3d114cdcae84ef2cc3ada578f13a
2023-03-08 22:05:07 +03:00
Max 736438693e mobile: allow configuring local GSMTAP address
Change-Id: Ia1555db653cf0bb20af74617f33aad31c971bfdb
2023-03-08 17:47:04 +00:00
Max e2930dad35 mobile: log state/event details on error
Change-Id: I24a4635e9a9a0984c0e1036e8b6ea19b08a06223
2023-03-06 17:27:39 +00:00
Max 9a9fca7e1d mobile: deprecate --gsmtap-ip option
Change-Id: I44b355f9a0bafee16a284537de76662a61111b09
2023-03-06 15:19:56 +00:00
Max 69bbbc5249 mobile: log MCC/MNC of the network while registering
Change-Id: I114eade36303f161fea171745a1a9b05e461e349
2023-03-06 15:16:35 +00:00
Max 42beda4557 mobile: drop duplicated #define
Change-Id: If5bda46dcc5b541a9d08cfd880a2a8f181426484
2023-03-04 23:15:18 +03:00
Pau Espin 35f93ac454 modem: Use libosmo-gprs-rlcmac L1CTL primitives
Related: OS#5500
Change-Id: I9d3066f19077796b2ccf70b15cc57b6488f015be
2023-02-27 14:50:56 +00:00
Max 0fb9853582 mobile: add vty statsd support
Change-Id: I7905b44478dcb9bcf0a1a68fde95f470c07edca3
2023-02-21 08:49:13 +00:00
Oliver Smith 65957cf877 Run struct_endianness.py
Ensure there is no diff to prepare to run this in CI.

Related: OS#5884
Change-Id: I617c967c5f34c0be2cf6fd43ceb1af17897f2bf1
2023-02-20 11:18:43 +01:00
Pau Espin f1e99e59e2 layer23: Support configuring GSMTAP through VTY in l23 apps.
This allow all l23 apps supporting L23_OPT_VTY and L23_OPT_TAP to
dynamically configure gsmtap through a "gsmtap" VTY node:

gsmtap
 remote-host 127.0.0.1
 lchan sacch
 lchan lsacch
 lchan sacch/4
 lchan sacch/8
 lchan sacch/f
 lchan sacch/h
 lchan unknown
 lchan bcch
 lchan ccch
 lchan rach
 lchan agch
 lchan pch
 lchan sdcch
 lchan sdcch/4
 lchan sdcch/8
 lchan facch/f
 lchan facch/h
 lchan pacch
 lchan cbch
 lchan pdch
 lchan pttch
 lchan cbch
 lchan tch/f
 lchan tch/h
 category gprs dl-unknown
 category gprs dl-dummy
 category gprs dl-ctrl
 category gprs dl-data-gprs
 category gprs dl-data-egprs
 category gprs ul-unknown
 category gprs ul-dummy
 category gprs ul-ctrl
 category gprs ul-data-gprs
 category gprs ul-data-egprs

VTY cmd "lchan" enables/disables tapping on general channel types,
while "category" allows fine-grained selection of messages being
tapped within the enabled lchan which would tap those messages.

Change-Id: I2582a1633d37d350a7f4c2bb5e03793bdf46e839
2023-02-02 18:18:21 +01:00
Pau Espin 3531b9afb6 layer23: Use updated libosmo-gprs-rlcmac header name
header file name gprs_rlcmac.h was renamed to csn1-defs.h during recent
libosmo-gprs-rlcmac development. Use the new names everywhere.

Depends: libosmo-gprs.git Change-Id I84ea63ed0b804699fd995a2e0c07ced17b3ad4c8

Change-Id: I205536907d9062b78453ce9bc404db1633e9a616
2023-02-01 17:38:52 +01:00
Pau Espin 59f3e4d4fb Get rid of openbsc leftover references
Get rid of the global variable since it's only used once inside a
function anyway.

Change-Id: I0b4f536b16f3693ef16de8505036943c3a30b1df
2023-01-31 12:30:07 +01:00
Pau Espin 738b65d240 layer23: Integreate mobile further into l23_app
Several functions and data structures in mobile app are refactored to
follow more closely the l23_app API and structures. These movements
allow starting to use already some shared infrastructure defined under
layer23/common.
This is not a full migration to l23_app, since mobile still keeps a
separate main() with a few extra code. This commit is rather a step
towards an eventual merge of mobile's main.cpp into
layer23/common/main.c

This is a preparation commit to later one adding gsmtap VTY configuration
to all l23 apps.

Change-Id: I3141b6cb4a0482970f434180ef8dda3af1d4aa0c
2023-01-31 11:59:08 +01:00
Pau Espin 60716bcfe6 modem: Initial integration of libosmo-gprs-rlcmac
This commit places code to forward unitdata LLC<->RLCMAC.

Depends: libosmo-gprs.git Change-Id I1870fa6a264612c5a669bfb832e6e8c0a892cb74
Related: OS#5500
Change-Id: I0e628d9ddaa5ad6a205f07746d4176d1b8df7eb0
2023-01-30 19:57:36 +00:00
Pau Espin 53996bb3d8 modem: Initial integration of libosmo-gprs-{llc,sndcp}
Change-Id: I820328009ccdd1f8112aeb163efa064ec1465d2a
2023-01-30 19:57:36 +00:00
Pau Espin c9cc4c305d Depend on libosmo-gprs-{llc,sndcp}
These will be needed for the MS to speak SNDCP and LLC.

Change-Id: I80811f73b798151257107bc94aedabe71fee0300
2023-01-19 20:02:17 +01:00
Pau Espin 3da09d1f7e layer23: Initial integration of tun device
Use the new tundev API from libosmocore to create tun devices for each
configured (and enbled) APN.
No address nor routes are yet set on the tun devices because we still
lack GMM/SNDCP/LLC/RLCMAC layers to negotiate them.

A follow up patch will add some code to interact with the SNDCP layer.

Depends: libosmocore.git Change-Id I3463271666df1e85746fb7b06ec45a17024b8c53
Change-Id: I86cac406843157aa2e51727cf8ccac9804d7961d
2023-01-19 20:02:07 +01:00
Pau Espin 6327f40be6 layer23: Introduce APN VTY node
This commit adds an initial set of VTY commands to manage APN
configuration and set up, which is used by the modem app.

The sample modem.cfg file is updated to showcase how to configure APNs.
The app doesn't do anything with them yet. A follow up patch will add
code to create tun devices for each configured APN.

Change-Id: I7b4eaa0de428b418bb1d89bd544694e89beb3e6e
2023-01-19 19:12:09 +01:00
Pau Espin c1bddf20b5 layer23: main: Log line about using config file before parsing it
Change-Id: I66b5b18887b8deb37c3784fec90644470498d7b5
2023-01-17 19:49:10 +01:00
Pau Espin 50097dd4c0 layer23: Use shift operand to define bitmask values
Change-Id: I22e2f543c077a4df4623c5e3bd44f8f068596baf
2023-01-17 19:49:10 +01:00
Pau Espin b8cc5b8c9a layer23: generate config.h
Follow-up commits will add some extra checks we want to have in config.h
Include config.h in files using PACKAGE_VERSION.

Change-Id: Ic779a3168012780feef8d173371387d09d383bfd
2023-01-17 18:16:34 +00:00
Pau Espin 0621ff9cbd layer23: ms.h: Use enum type in ms->shutdown
Change-Id: I5456f7a8675e6ab620bc93b56e2c4ad22d3900e8
2023-01-17 18:16:34 +00:00
Pau Espin 3d3505b726 layer23: Let each app allocate its ms obj and start layer2 when needed
This allows apps to allocate the objects as they please: simple apps can
statically allocate it at startup. Others may want to allocate them
through VTY.
Some apps may also want to dynamically start and stop layer2.

Change-Id: I32f99df76a5513eff9df5489d28d60aedf96dec3
2023-01-17 18:16:34 +00:00
Pau Espin 8f59b1a0b9 layer23: Move layer2-socket VTY command to common/
This allows configuring layer2-socket for other apps than mobile, like
the "modem" one.

Change-Id: If7419f8fc54a54eed68a076968d93dba5ac977b7
2023-01-17 18:16:34 +00:00
Pau Espin 3b8d5bb26a layer23: Move '(no) shutdown' VTY code to common/vty.c
Change-Id: Ib5c9b6f3efa255d67980945db9f98dd8a112af0e
2023-01-17 18:16:34 +00:00
Vadim Yanitskiy eb654c07d2 layer23: fix integer overflow in l1ctl_tx_data_req()
Found by clang:

  l1ctl.c:397:52: warning: implicit conversion from 'int' to 'int8_t'
                  (aka 'signed char') changes value from 255 to -1
                  [-Wconstant-conversion]

Change-Id: I23e9ea5ad59099c24db60057c8e7da1e6a0d2293
2023-01-17 18:10:55 +00:00
Pau Espin 0fe3f7d4e5 layer23: Move settings.{c,h} under common/
Some of those can be reused by other apps (like modem).

Change-Id: I0a741b2384195d512fdc49eda6762241f385b1f1
2023-01-16 13:34:31 +01:00
Pau Espin 93aa93b6c4 layer23: Move script_lua_close() call outside of settings.c
The only caller of gsm_settings_exit() is in app_mobile so far, which is
the only app supporting/using lua scripting so far.

Change-Id: I634a4514ead9d064e7509c3fbbb3a2c89c7f3a56
2023-01-16 13:34:31 +01:00
Pau Espin f15eeadb21 layer23: Move subscriber.{c,h} under common/
Some of those can be reused by other apps (like modem).

Change-Id: I3727e40bcc9a4ee93aaf2c4ced070cc789653e80
2023-01-16 13:34:31 +01:00
Pau Espin 2b03270b30 layer23: Move support.{c,h} under common/
Some of those can be reused by other apps (like modem).

Change-Id: I3c5af4db8e603aa004d0b6410b09b5143173b874
2023-01-16 13:34:31 +01:00
Pau Espin adb67e5106 layer23: Initial VTY framework to share VTY code between apps
A small layer23 framework is added which allows apps to easily share/reuse
VTY commands while giving some flexiblity to add new per-app
specific configs/cmds, since not all commands may be relevant for all
apps.

Some of the mobile app code is moved to common, and sample infra is
added to modem app.
Future commits will most probably keep moving more stuff mobile->common
and then reusing those in modem app, as found needed.

Change-Id: Iabfb3129199488d790b89884bc1e424f2aca696f
2023-01-16 13:34:28 +01:00
Pau Espin b54dbfcde9 mobile: settings.h: Add missing type forward declaration
Change-Id: Ibdfa905e2bd24f03d23ce114e969647b07a2009f
2023-01-16 10:31:01 +01:00
Pau Espin fb030a8897 layer23: Initialize osmocom_ms further in common code
Change-Id: Ic629cf229167ddd4c533a2abf1b82ad78d1144a9
2023-01-16 10:30:56 +01:00
Pau Espin 9010a6be52 layer23: mobile: Several fixes and improvements in show_ms_cmd
Fix missing VTY param description.
Fix wrong indentation.
Fix unneeded else after early return.

Change-Id: I4a55328e71ec16355974c20275c0e525077252e1
2023-01-16 10:30:15 +01:00
Pau Espin ea03422cd8 layer23: mobile: Fix typo in vty string
Change-Id: I05238b72735600aae46126c24d5e96444e91ef06
2023-01-16 10:30:15 +01:00
Pau Espin 1953a21515 layer23: Move osmocom_ms to a separate file
This way we can extend its API and contents more easily,
and keep most of it together in one place.

Change-Id: Icb4891cc1e4a0ecb5f09cb8a84b0ebe1b91a46b8
2023-01-16 10:30:12 +01:00
Pau Espin ed9ae46f1d layer23: Add missing header dependencies to several files
Change-Id: I9819b12d1c24f6ee197daa887452b09418d689e8
2023-01-16 10:19:34 +01:00
Pau Espin cf2d8296bb cosmetic: layer23: Fix trailing whitespace
Change-Id: Ibc464923ac8add74b2b6d57d183fb307be650679
2023-01-16 10:19:34 +01:00
Pau Espin 463b3634ed layer23: misc/log.h: Fix missing pragma once
Change-Id: Ie57357224ba5ed2bf691e2912ede7ee19012b6dd
2023-01-16 10:19:34 +01:00
Pau Espin 1eb8614b9d layer23: common/sim.h: Fix missing pragma once
Change-Id: Icebe803c7896347915ed72b80d5504d15d717ef3
2023-01-16 10:19:34 +01:00
Pau Espin aef45d8008 cosmetic layer23/mobile/gsm322: Fix trailing whistespace
Change-Id: I32d28ac219d2a573a77a0041a774ca7427388fb0
2023-01-16 10:19:30 +01:00
Pau Espin 1412c49fed cosmetic: layer23/include/common/Makefile.am: Set one item per line
Change-Id: I2e385d403bd37ad9491fd421509fe7e4104225f9
2023-01-13 12:16:47 +01:00
Pau Espin 73abbc235e layer23: Add initial VTY support for l23_apps
Initial VTY "boilerplate" code for modem app is already added in
this commit as a showcase what's needed by an app to have the VTY
config file read and VTY interface initialized.

Change-Id: Ife3a3373e5a9c0c8e5959ac714e140e72d6c363a
2023-01-13 12:16:47 +01:00
Pau Espin 2b9191f08b layer23: Move extern declaration of l23_ctx to l23_app.h
This way all apps can access it.

Change-Id: I570d31cc4014b54b47b11a3a52791f62c999cad8
2023-01-13 12:16:47 +01:00
Pau Espin cd76fcc4ec layer23: Introduce l23_app_start() API step
This commit is a preparation towards having shared VTY infrastructure
for layer23 apps. Having 2 steps (first init(), then start()) allows
the apps easily struct allocation & initialization, and then start doing
work after VTY config has been read.

Change-Id: I1d232809764962f82fee86159bc61cdbc3eb3c48
2023-01-13 12:16:47 +01:00
Vadim Yanitskiy 522b92eae4 modem: fix wrong chan_nr (missing tn) in modem_rx_imm_ass()
Change-Id: Iba68424e6db0ad655c6146d92edd3cc90e2e2566
Fixes: 49d993e4ab
Related: OS#5500
2023-01-12 23:21:46 +06:00
Vadim Yanitskiy fe240d613b modem: fix -Wmaybe-uninitialized in modem_rx_imm_ass()
Change-Id: I773b13e3c7b7546a6cdd7d0b729cca8687b0a131
Fixes: 49d993e4ab
Related: OS#5500
2023-01-12 22:55:42 +06:00
Vadim Yanitskiy 1e8c6defaf modem: fix modem_tx_chan_req(): check if SI13 was received
There was no need for this check because the channel establishment
logic was at the end of handle_si13(), so I overlooked this.

Change-Id: I829948de325461ab5d7e950493497a7537ba06ac
Fixes: 8a506dcd4e
Related: OS#5500
2023-01-12 21:25:25 +06:00
Vadim Yanitskiy c209242d19 modem: send CHANNEL REQUEST from modem_rx_bcch()
Sending CHANNEL REQUEST from handle_si13() was a bad idea because
this function returns early if SI13 was received before SI1.

Change-Id: I21f1d68cb9b1d20b356697ba1efe28c3d87fa004
Fixes: 49d993e4ab
Related: OS#5500
2023-01-12 14:55:01 +00:00
Pau Espin 372f65d172 cosmetic: layer23: Drop unnecessary space before function pointer arguments
As requested by linter.

Change-Id: I87e1857722b9181d0187bdeabe3fa1f4e63463d0
2023-01-12 13:18:02 +00:00
Pau Espin 7c3eb69c67 layer23: Fix gcc warning sprintf() writing on too short buf
Triggered with gcc 12.2.0:
/osmocom-bb/src/host/layer23/src/common/sysinfo.c: In function ‘gsm48_sysinfo_dump’:
/osmocom-bb/src/host/layer23/src/common/sysinfo.c:198:42: warning: ‘sprintf’ may write a terminating nul past the end of the destination [-Wformat-overflow=]
  198 |                 sprintf(buffer + 69, " %d", i + 63);
      |                                          ^
/osmocom-bb/src/host/layer23/src/common/sysinfo.c:198:17: note: ‘sprintf’ output between 3 and 13 bytes into a destination of size 12
  198 |                 sprintf(buffer + 69, " %d", i + 63);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change-Id: I29a64fbb7aca0d1b469b6d278d4a24ddc6f57b3a
2023-01-12 13:18:02 +00:00
Vadim Yanitskiy 49d993e4ab modem: request an Uplink TBF, match Immediate Assignment
Change-Id: Iec0dcc629d29dec270649cf7428f71af0dfd2dbb
Related: SYS#5500
2023-01-12 19:05:42 +06:00
Vadim Yanitskiy e9abf7b61d layer23/sysinfo: fix copy-paste in gsm48_decode_sysinfo13()
Change-Id: Ia9309a037cc09c2a0de2f64521a57e0567fbec11
Fixes: CID#307087, CID#307088
2023-01-12 09:17:27 +06:00
Vadim Yanitskiy befe5d5d33 modem: fix unusual argument order: *ms always first
Change-Id: I9fabe39575f191ce6c893a1fecaa7ac040ef0e3e
Related: SYS#5500
2023-01-07 08:30:02 +07:00
Vadim Yanitskiy bc6cab1947 modem: do not depend on $(top_srcdir)/src/misc/rslms.c
Change-Id: Ic4d7e1956530aa10ff3125d6d857efe47ea37d38
Related: SYS#5500
2023-01-07 08:23:59 +07:00
Vadim Yanitskiy afd13e9adf modem: passive decoding of SI{3,4,13} and IA Rest Octets
Use the existing application skeleton from '$(top_srcdir)/src/common/'.
Use the LAPDm glue from '$(top_srcdir)/src/misc/rslms.c'.
This is what the misc applications like ccch_scan are using.

Change-Id: I8566a3cdc9f818bed7e28ea4b1957dce735c298b
Related: SYS#5500
2023-01-07 01:42:28 +07:00
Vadim Yanitskiy 413bcf8ef4 layer23/sysinfo: implement decoding of SI13 Rest Octets
Change-Id: Ia6ff7d4e37816c6321b54c1f7f8d7110e557f8c5
Related: SYS#5500
2023-01-07 01:42:28 +07:00
Vadim Yanitskiy eee91ab17d host/*/configure.ac: set -std=gnu11
Avoid using different dialects by accident (and resulting compiler
errors if compiler assumes a different dialect), like in [1].

Related: https://lists.osmocom.org/pipermail/openbsc/2019-September/013030.html
Related: https://lists.osmocom.org/pipermail/openbsc/2021-January/013360.html
Related: [1] libosmocore.git I72310886bef4db635078b75715c9d98ee45391cc
Change-Id: I48ec1703de04f40ea530f4b4442084fdc94dc966
2023-01-05 22:24:37 +07:00
Vadim Yanitskiy 5d634b6118 gsmmap: move this utility to 'layer23/src/misc/'
What I find weird is that the gsmmap is using files from layer23,
and vice-versa cell_log from layer23 is using files from this
utility.  And somehow they are separate sub-projects.

I see no reason why gsmmap must be in its own sub-project.

Change-Id: I2bc9c8897f3c7ccf207be0146f7b55fc733a6abb
2023-01-03 02:43:57 +07:00
Vadim Yanitskiy 621214c802 layer23: make all apps depend on libosmo-gprs-rlcmac
This will be needed for the modem application, and is also used
in a follow-up commit adding support for parsing SI13 Rest Octets.

Change-Id: I8e0f826c9b2a886f94624176e34e7d197e93d25f
Related: OS#5500
2023-01-03 00:18:34 +07:00
Vadim Yanitskiy cad5af50cc mobile: gapk_io_init_ms(): fix 'phy_fmt' may be used uninitialized
Change-Id: I193de6e0e831aa4201f5edec80e40abc43f4a861
2023-01-02 20:41:41 +07:00
Vadim Yanitskiy 3432c6cfe0 layer23/sysinfo: update coding style, make pointers const
Change-Id: Ia518251eae1b45ad573d076d97cba83ed25ea9ea
Depends: libosmocore.git Ide9110b984d3302aec6b439c563eb10e2dcdec9e
2023-01-02 20:24:50 +07:00
Vadim Yanitskiy e25fb14f6d layer23/sysinfo: use OSMO_MIN from libosmocore
Change-Id: Ic01cadda13a7d7a3d34ddb94bd3964044f38959c
2022-12-31 02:36:03 +07:00
Vadim Yanitskiy ed29bd3e41 modem: Makefile.am: remove unneeded CFLAGS and LIBS
Change-Id: I2bb04f526c4e3019c548786f2cdfb96b018826ec
2022-12-30 20:27:43 +07:00
Vadim Yanitskiy 9b1df1231f layer23: configure pretty logging for misc apps
Change-Id: I827055bcf04f8003fcb90e6c8c90813ecda2efed
2022-12-30 20:27:43 +07:00
Vadim Yanitskiy 00a67a0e9d layer23: use osmo_stderr_target in misc apps
Change-Id: I56770f04fa3c440e6ccabe6f6fccfe171d41d751
2022-12-30 20:27:43 +07:00
Vadim Yanitskiy 6391546181 mobile: rework writing BA to file, move to a function
Sometimes I am seeing error messages like this:

  DCS ERROR Failed to write BA list

The problem is that there can be several BA entries which need to
be written, and for each of them we're calling fwrite() twice.
This function returns number of items written, so the final sum
of returned values would be: len(BA list) * 2.  Thus expecting
it to be 2 regardless of len(BA list) is wrong.

Fix this by checking the sum in each iteration, not at the end.
Take a chance to refactor the code and move to a function.

Change-Id: Id8bc216c146127d9c9995379c9e56450d328f46d
2022-12-21 15:07:21 +00:00
Vadim Yanitskiy 7c2a471103 layer23: fix rx_l1_sim_conf(): msg->l2h is NULL, use msg->l1h
The mobile app crashes when using a Calypso phone and specifically
when using its built-in SIM reader.  The problem is that msg->l2h
is NULL in rx_l1_sim_conf(), so msg->l1h must be used instead.

  Assert failed msgb->l2h /usr/local/include/osmocom/core/msgb.h:162

Change-Id: I7c68a3ad393be5fd0413e00e119a06db59672357
2022-12-21 15:07:21 +00:00
Vadim Yanitskiy 5e331c196a mobile: gsm48_rr_rx_acch(): clarify logging messages
Change-Id: Ibc2d54c2879fa28225d46222239829f699277f6c
2022-12-10 19:11:20 +07:00
Vadim Yanitskiy 67d45c054a mobile: do not enforce RTP format for Uplink TCH frames
This is a partial revert of 8f04fa9758.

The GAPK based audio I/O implementation of the mobile app is now capable
of handling TI's specific TCH frame format, which can be configured via
the VTY interface ('io-tch-format ti').  TCH frames in this format are
different from the ones in RTP format and may have different length and
different bit ordering.  Remove voice_frame_verify().

Change-Id: I6113ba443e65ddaae091b643af54c873b7da4de8
Related: OS#3400
2022-12-06 06:28:56 +07:00
Vadim Yanitskiy 12dd3af2a0 mobile: support RTP and TI specific TCH frame I/O formats
Change-Id: Ib41f8c39c82c243b62a76433f59a2b98e175f894
Related: OS#3400
2022-12-06 06:28:56 +07:00
Vadim Yanitskiy 97deddcd45 mobile: clean up GAPK I/O state on channel release
Do not assert() in gsm_recv_voice(), because channel release does
not happen immediately and the PHY may be still sending TCH frames.

Change-Id: I8943ee9bd46afc96e6d7cfd52c95c34fd311ce11
Related: OS#3400
2022-12-06 06:28:56 +07:00
Vadim Yanitskiy df7fa3e296 mobile: integrate GAPK based audio (voice) I/O support
This change introduces a new feature to the mobile application -
audio I/O support, which allows the user to speak right from the
host side running mobile through its ordinary mic and speakers.

The audio I/O is based on libosmogapk [1][2], which in its turn
uses the ALSA sound system for the playback and capture.  This
is a new optional dependency of mobile, which is automatically
picked up if available during the build configuration.  Whether
to depend on it or not can be controlled using '--with-gapk-io'.

The API offered by libosmogapk implies to use the processing chains,
which generally consist of a source block, several processing blocks,
and a sink block.  The mobile app implements the following chains:

  - 'pq_audio_source' (voice capture -> frame encoding),
  - 'pq_audio_sink' (frame decoding -> voice playback).

both taking/storing TCH frames from/to the following two buffers:

  - 'tch_fb_ul' - a buffer for to be played DL TCH frames,
  - 'tch_fb_dl' - a buffer for encoded UL TCH frames.

The buffers are served by a new function gapk_io_dequeue().

[1] https://gitea.osmocom.org/osmocom/gapk/
[1] https://osmocom.org/projects/gapk

Change-Id: Ib86b0746606c191573cc773f01172afbb52f33a9
Related: OS#5599
2022-12-01 01:05:38 +07:00
Vadim Yanitskiy b1cfa18d77 mobile: gsm_forward_mncc(): properly mark TCH/H frames
Change-Id: Id3f459bc767ebf31469287fa672893239c5977d9
Related: OS#5599
2022-12-01 01:05:38 +07:00
Vadim Yanitskiy e69d3f4ba1 mobile: gsm_forward_mncc(): call mncc_sock_from_cc() directly
This way we can avoid allocating another msgb and enqueue the given
msgb directly to the write queue of the MNCC socket.

Change-Id: I29305866e61a0bc3bd082108af6a9ba8ff86bcf2
Related: OS#5599
2022-12-01 01:05:38 +07:00
Vadim Yanitskiy 100ec4ca6f mobile: rework gsm_recv_voice(), add AUDIO_IOH_MNCC_SOCK
Do not send voice frames to the external MNCC unconditionally.
Add a new I/O handler type for the external MNCC application.

Change-Id: I406b169963e6654110329d741728fa12c8c8eeec
Related: OS#5599
2022-12-01 01:05:38 +07:00
Vadim Yanitskiy 37a6a2c5c4 mobile: improve function comments in voice.c
Change-Id: I0285a07841bdc2568374f9e9cd0214eef1415186
Related: OS#5599
2022-12-01 01:05:38 +07:00
Vadim Yanitskiy 290ea6b7fa mobile: add missing TCH MNCC messages and handle them
Change-Id: I28a1ae1ed504748c33c64c86ca7d57a94c7c7c6d
Related: OS#5599
2022-12-01 01:05:38 +07:00
Vadim Yanitskiy 7304b1720d mobile: timeout_rr_meas(): use osmo_strbuf API
Change-Id: I0c505b753bcfb06d9f2f085d56d7d56fb1c44d50
2022-11-30 18:35:14 +07:00
Vadim Yanitskiy ff44b9c3ed mobile: timeout_rr_meas(): fix sprintf() formatting
Change-Id: Ia8a101005d027fb5d0ddc2566f92ab2060f21c36
2022-11-30 18:27:58 +07:00
Vadim Yanitskiy e4541c35db mobile: timeout_rr_meas(): fix uninitialized variable
Change-Id: I956a1cafe9fed1a881574f59d0532e5cf931a1f7
Fixes: c9e579cea137fd147173434b7fa128d37685011
Fixes: CID#300084
2022-11-30 17:22:48 +07:00
Vadim Yanitskiy 16ad87bf52 mobile: make LUA support configurable via --with-lua53
Change-Id: If440cee52410421034823a3749709e28c4136b95
2022-11-29 06:05:55 +07:00
Vadim Yanitskiy 993d2ab501 mobile: split gsm_send_voice() -> gsm_send_voice_{msg,frame}()
This is needed to avoid sending voice frames to the L1PHY without
having to use MNCC specific struct gsm_data_frame.

Change-Id: I37241555cd648a8e2b57fa072c708f93cd1ba5a9
Related: OS#5599
2022-11-29 02:21:57 +07:00
Vadim Yanitskiy a3b86ad4dd mobile: voice.h: add missing forward declarations
Change-Id: I854abdcde5bc324f6d0cf309792b36fc64601070
Related: OS#5599
2022-11-29 02:21:57 +07:00
Vadim Yanitskiy 7900ba1a13 mobile: voice.h: use '#pragma once' include guard
Change-Id: I024e13c0f66ae1e42b0c8e2ff77874fcb883e85a
Related: OS#5599
2022-11-29 02:21:57 +07:00
Vadim Yanitskiy 7fed41388c mobile: gsm48_rr_tx_voice(): also permit TCH/H frames
The idea behind checking the ch_type in gsm48_rr_tx_voice() was likely
to prevent sending of the (LCR originated) Uplink TCH frames before
the actual traffic channel is established/modified.

The problem is that this check allows TCH/F frames, but not TCH/H.
Most likely, TCH/H was forgotten or never tested.  Fix this.

Change-Id: I06e84ad47bafd4676af0e136b825e77471587b23
Related: OS#5599
2022-11-29 02:21:57 +07:00
Vadim Yanitskiy fd0baabed3 mobile: properly handle RR CHANNEL MODE MODIFY message
According to 3GPP TS 04.08, section 3.4.6.1.3 "Abnormal cases"
of "channel mode modify procedure", if the MS doesn't support
the indicated channel mode, it shall retain the old mode and
return the associated channel mode information in the
ACKNOWLEDGE message.

Previously, if an indicated mode is not supported, we used to
indicate the 'CHAN_MODE_UNACCT' RR case without sending the
ACKNOWLEDGE message. Also, the result of gsm48_rr_set_mode()
was ignored. Let's fix this!

Change-Id: I952436ec796273e56341f9d3492b4a3b3a5dc410
Related: OS#5599
2022-11-29 02:21:57 +07:00
Vadim Yanitskiy d2d5fabee5 mobile: gsm48_rr_set_mode(): fix copy-paste in comment
Change-Id: I45212cd02ac50d0d363918709720e997500e45a9
Related: OS#5599
2022-11-29 02:21:57 +07:00
Vadim Yanitskiy 73da4bac97 mobile: gsm48_rr_set_mode(): print name of channel mode
Change-Id: I615e89bdd7e1cc01b3258fefa26f7ab5705ae8cc
Related: OS#5599
2022-11-29 02:21:57 +07:00
Vadim Yanitskiy c1d3c01768 mobile: allow enabling/disabling handling of voice in the L1PHY
Some L1PHY targets (e.g. Calypso based Mot C1xx phones) have built in
microphone and speaker.  Some targets do not have them.  Currently we
unconditionally instruct the L1PHY to handle TCH frames internally.
Make this behavior configurable via the VTY interface.

Change-Id: I131f213ef7c2736f7310f0183b83f3bc3064cd98
Related: OS#5599
2022-11-29 02:21:57 +07:00
Vadim Yanitskiy 8d875f3c3d mobile: add MNCC handler selection to settings
Since the mobile application is potentially able to maintain
multiple MS instances, it's better to have a possibility to
choose an MNCC (Call Control) handler per each MS separately.

This change removes the command-line option '-m', which was used
for enabling the external MNCC.  Now it's possible configure the
MNCC handler for each MS via the VTY interface and settings.

The following MNCC-handlers are available:

  - internal - built-in MNCC-handler (default);
  - external - external MNCC-handler via UNIX-socket (e.g. LCR);
  - dummy - dummy handler without CC support.

Change-Id: I2df91c7a79ba5c39bc6ceae900ef649129dd0346
Related: OS#3400
2022-11-29 02:21:57 +07:00
Vadim Yanitskiy c46d0699cd mobile: timeout_rr_meas(): also print sub-slot for TCH/H
Change-Id: I208c159ba610450e1850e601daa2712eef8c23e1
Related: OS#5599
2022-11-29 02:21:57 +07:00
Vadim Yanitskiy fe6345e1c4 layer23: always check return value of rsl_tlv_parse()
Similar to rsl_dec_chan_nr(), this function may also fail, leaving
the given struct tlv_parsed uninitialized.

Change-Id: I13f2a97eeff78ca8ed7d0a2844e4fca430ec7768
Related: OS#5599
2022-11-29 02:21:57 +07:00
Vadim Yanitskiy c9e579cea1 layer23: always check return value of rsl_dec_chan_nr()
The rsl_dec_chan_nr() may fail to decode RSL channel number, so
variables ch_type/chan_ss/chan_ts would remain uninitialized.

Change-Id: I9ab18bdaf41a29fcd32a7060668ef9db07b8cf7e
Related: OS#5599
2022-11-29 02:15:39 +07:00
Vadim Yanitskiy b76743df71 mobile: add MNCC socket path to settings
Previously the MNCC socket path was generated automatically,
using concatenation of the '/tmp/ms_mncc_' prefix and MS name.
Let's allow the user to specify this manually, keeping the same
naming generation method for default value.

Change-Id: I643356ac579bc5e765f668265ec803b22a73739c
Related: OS#3400
2022-11-27 06:12:38 +07:00
Vadim Yanitskiy bdc5acdb13 layer23: l1ctl_tx_traffic_req(): cosmetic: drop dead code
Change-Id: I941899ab27282a495f965ae9a0f41076dceef953
Related: OS#5599
2022-11-27 06:12:38 +07:00
Vadim Yanitskiy 887b141699 layer23: add 'src/modem/modem' to .gitignore
Change-Id: I37e536493ddfd3bff1674d5bc85f40a0bbd0f317
2022-11-25 22:26:20 +07:00
Pau Espin e9f24d734a host/layer23: Add modem app
This app will allow setting up a tun device to transmit/receive data
as a GPRS MS against a GSM network.

This is just the initial skeleton so that people can work on it further
in follow-up commits.

Related: OS#5503
Change-Id: I8a1121b3287da7d7330c30e3118affa8fd1da61b
2022-11-21 19:56:54 +01:00
Pau Espin dd03ea6a82 layer23/mobile: Add missing dependency cflags
The *_LIBS vars were already added, but the *_CFLAGS were missing.

Change-Id: If904589b33357395e10f078857979aaecf5dbf68
2022-11-21 18:16:09 +00:00
Vadim Yanitskiy 136cf481c7 layer23: fix -Werror=old-style-definition problems
Change-Id: I0187acb02de6fd22ccc86c112640caa8aa3fa2bc
2022-11-05 19:18:42 +07:00
Vadim Yanitskiy 6ba147556b layer23: add -Werror={implicit-int,int-conversion,old-style-definition}
Change-Id: Ia6e0c717c782ea000f1d40ad11af2ee725f9c309
2022-11-05 19:10:55 +07:00
Vadim Yanitskiy 671ac36b11 layer23: configure.ac: print CFLAGS/CPPFLAGS using AC_MSG_RESULT()
Change-Id: Ib8d7138f7d5504176156ea5349336f5994c8fa80
2022-11-05 19:10:02 +07:00
Eric Wild 0f64b7c124 Revert "mobile/gsm48_rr.c: fix ACCH System Information parsing"
This reverts commit 1a8a80aeae.

We currently get ALL SI messages wrong - the protocol disseminator is
accidentally being used as SI msg type, and
6=radio resources management - but 6 is also type=si5ter.. so all SI we
receive end up being parsed as SI5, what a coincidence!

Change-Id: I3822f74295920680a935f3031c642ba00162d09d
2022-10-26 15:52:58 +00:00
Vadim Yanitskiy 1b0ff8ea6f mobile: check return value of gsm_arfcn2band_rc()
Change-Id: Ia5bc9f8bf4aa3ea7374c67e329db22612bb350ca
Fixes: CID#282374, CID#282375, CID#282376
2022-10-07 14:56:21 +07:00
Pau Espin a53e93fe9c trxcon: Initial support for forwarding AMR
This allows TTCN3 L1CTL module (used in BTS_Tests) to transmit and
receive AMR payloads towards osmo-bts-trx.

Related: SYS#5987
Change-Id: Ia20bc96e39726a919a556c83c8be48cb31af7331
2022-09-07 00:01:53 +07:00
Vadim Yanitskiy c2d022d348 mobile: lapdm_channel_init() is deprecated, use lapdm_channel_init3()
Change-Id: I320381488046f9b1780a53b8d5d27e470da727c4
2022-08-30 12:00:04 +00:00
Vadim Yanitskiy c67a9a6a01 mobile: mobile_start(): fix grammar in logging messages
Change-Id: Ibe8afb6a79613096c4ace86cc44867d0e9f8de76
2022-08-23 20:32:56 +00:00
Vadim Yanitskiy 8f6338c4f5 mobile: fix description of 'test re-selection' command
Change-Id: I254effd067b64ae0bfe1afe646701c0c6ea942ea
2022-08-23 09:05:04 +00:00
Vadim Yanitskiy 8738627763 layer23: explicitly set chan_nr / link_id in L1CTL_RACH_REQ
The underlying L1 implementation uses both chan_nr and link_id to
determine a logical channel for sending an Access Burst.  If not
set (both 0x00), RSL_CHAN_RACH is assumed.  Indicate it implicitly.

Change-Id: Ia40f67920bd712e572b8ea5219eb83064106bd5d
2022-08-21 20:45:05 +07:00
Vadim Yanitskiy dd4d0d0354 layer23: use $(top_builddir) instead of relative paths
Change-Id: Ib2c9264b2a3cdef9b9852bdead94bae03185fec8
2022-08-21 20:45:05 +07:00
Vadim Yanitskiy 350b605e89 layer23: use $(top_srcdir) instead of relative paths
Change-Id: I320ed2295c0c8e12a46be416e3dbda8865987424
2022-08-21 20:45:05 +07:00
Vadim Yanitskiy 26edb66906 layer23: cosmetic: make Makefile.am files git-friendly
Change-Id: I26d7ff4ae278b5b465863252fe12ac1b46780dc7
2022-08-21 20:45:05 +07:00
Vadim Yanitskiy 095b360bc8 layer23: chantype_rsl2gsmtap() is deprecated, use chantype_rsl2gsmtap2()
Change-Id: Id54b973cec8479fc32775be260f8a9fac8f09bae
2022-05-13 23:16:42 +03:00
Oliver Smith e634dec487 mobile/subscriber.c: fix auth resp with test sim
Do not send a dummy authentication response with the test sim.

Fixes: 39dc9c46 ("mobile/subscriber.c: consider GSM_SIM_TYPE_SAP too")
Change-Id: I0ee910c171d383fb2cdcaf5eb54eafe18da3430b
2022-02-23 17:59:32 +01:00
Oliver Smith 1741372556 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: I73be012c01c0108fb6951dbff91d50eb19b40c51
2021-12-14 12:52:04 +00:00
Philipp Maier 0af84f408d logging: use meaningful default loglevels
Some logging categories use LOGL_INFO or even LOGL_DEBUG. Lets set those
to LOGL_NOTICE to have a less crowded default log output.

Change-Id: I3faefccae2218b17bd942bc2afac7d8e515897b7
Related: OS#2577
2021-11-15 17:12:22 +00:00
Harald Welte 3e8518a44b layer23/osmocon: require libosmocore >= 1.5.0 in configure.ac
This should give a meaningful error message if people use too old
libosmocore.

Change-Id: I7d9950b5eaa836ed1ac86045bd5364fed221e369
2021-10-16 10:55:33 +02:00
Harald Welte 98219554b6 262-10 is "DB Netz AG" and not "DB Systel"
Change-Id: Idbce4bade4305fabbedcf15c5bd9253fbb371744
2021-10-08 05:46:57 +00:00
Vadim Yanitskiy 825716851e host/layer23/ccch_scan: skip CCCH frames with wrong length
It's not clear why do we get frames with unexpected length, but
we definitely should not crash.  Just log and ignore them.

Change-Id: I85392becbffdb3ba7365decfd8f3769abe3c02c7
Related: OS#5171
2021-06-09 22:51:07 +02:00
Pau Espin e5a9077dbd mobile: generate coredump and exit upon SIGABRT received
Previous code relied on abort() switching sigaction to SIG_FDL +
retriggering SIGABRT in case the signal handler returns, which would
then generate the coredump + terminate the process.
However, if a SIGABRT is received from somewhere else (kill -SIGABRT),
then the process would print the talloc report and continue running,
which is not desired.

Change-Id: Ied0f47378a5d348b857424adb5c874c1c093b485
Fixes: OS#4865
2020-11-25 18:45:26 +01:00
Harald Welte c6fb802252 Use osmo_fd_*_{disable,enable}
Change-Id: If4c7f946852d153bd472e5c704f8d517d26ca22e
Depends: libosmocore.git Idb89ba7bc7c129a6304a76900d17f47daf54d17d
2020-11-11 20:14:58 +00:00
Harald Welte 46cf9b1043 gsm48_rr: Don't swap ber with snr in "MON:" log line
I was quite confused why I constantly see a bit error rate reported
by gsm48_rr, while at the same time the actual L1CTL_DATA_IND did
all state num_biterr == 0.

So the log statement was broken ...

Change-Id: I09bb6c606a8437b213bb444949c78a7c8a10542c
2020-10-23 23:32:10 +02:00
Harald Welte d90ae30caa mobile: Use osmo_fd_setup() in script_lua.c
Change-Id: Ib6f97b9b8f3af63b81b92071b7fdb1fd55da89a5
2020-10-21 11:56:43 +00:00
Harald Welte de31aa3af7 Use osmo_fd_setup() whenever applicable.
Change-Id: If9b636c295fc6b5349a54c70662f09efa616ee63
2020-10-18 23:34:46 +02:00
Harald Welte 508d8523c0 Use OSMO_FD_* instead of deprecated BSC_FD_*
Change-Id: Ibf64b18288b9109927035f650d6ef7ad9f15d688
2020-10-18 22:43:05 +02:00
Vadim Yanitskiy e42e5a0789 layer23/cbch-sniff: fix: use Osmocom specific RSL channel number
This way the layer1 can activate proper CBCH task and send us
CBCH block with proper RSL channel number, so they do not end
up being routed to LAPDm and rejected there.

Change-Id: Ib1d5c99587202a9d94aeb7b63de7ae8c4fb15af0
2020-10-13 08:46:11 +00:00
Vadim Yanitskiy 3c39ba4b94 layer23/cbch-sniff: fix: do not blindly assume presence of CBCH
We cannot blindly assume that CBCH is present on TS0/SDCCH4 before
decoding CBCH Channel Description in System Information Type 4.

Change-Id: Ie8ce572df292d0b03c0f743bcf26184619176321
2020-10-13 08:46:11 +00:00
Vadim Yanitskiy 8194febb09 layer23/mobile: implement handling of TCH test loop commands
For more information, see 3GPP TS 44.014, sections:

  - 5.1 "Single-slot TCH loops", and
  - 8 "Message definitions and contents".

This feature has nothing to do with the Mobility Management, so
let's handle GSM48_PDISC_TEST messages in the Radio Resources
layer implementation (gsm48_mm.c -> gsm48_rr.c).

Change-Id: If8efc57c7017aa8ea47b37c472d1bbb1914389ca
2020-07-31 00:48:06 +07:00
Vadim Yanitskiy 8208a336ab layer23/mobile: fix a memory leak (msgb) in gsm48_rr_data_ind()
Change-Id: I55dcccf5b7d27d012908759954182eaec434d26b
2020-07-30 16:46:50 +07:00
Vadim Yanitskiy df2b46471d layer23/mobile: fix wrong message type in gsm48_rr_tx_rr_status()
Change-Id: I57c6a4e1e725da52c50e2a28e56627a3f3827c62
2020-07-30 16:07:27 +07:00
Vadim Yanitskiy e7e4d86f0e layer23/mobile: cosmetic: use GSM48_PDISC_TEST from gsm_04_08.h
Change-Id: Ie1f14b37f6138f5a019a25bdbc8a3531418df6c2
2020-07-29 03:58:23 +07:00
Oliver Smith 901ac89735 mobile: loopback: support EFR
Related: SYS#4924
Change-Id: I73d1f88b0865ad97b85418ff76739febf2e128a7
2020-05-05 12:22:32 +02:00
Oliver Smith 8f04fa9758 mobile: traffic req check: support EFR
L1CTL handling code should not be involved in such high level checks, so
while at it, move the check into a separate function in gsm48_rr.c and
add a length check. gsm48_rr_tx_voice() is the only caller of
l1ctl_tx_traffic_req().

Related: SYS#4924
Change-Id: Iba84f5d60ff5b1a2db8fb6af5131e185965df7c9
2020-05-05 12:22:26 +02:00
Neels Hofmeyr 3622522664 mobile: implement 'loopback' TCH frame I/O handler
Use newly added audio / loopback config vty node to provide audio
loopback from mobile app. Only FR is supported for now.

Change-Id: Icd0b8d00c855db1a6ff5e35e10c8ff67b7ad5c83
2020-05-05 12:19:58 +07:00
Neels Hofmeyr 785450c4bf mobile: add audio config, with unused audio loopback setting
The aim is to add configurable audio loopback to mobile. An existing patch on a
branch from fixeria [1] adds the audio config section. Add a reduced version of
this audio config to be compatible with the future merge.

Add the audio loopback setting, so far without functionality.
Subsequent patch adds the actual loopback.

[1] osmocom-bb branch fixeria/audio,
    patch "mobile/vty_interface.c: add new 'audio' section"
    Change-id I62cd5ef22ca2290fcafe65c78537ddbcb39fb8c6

Change-Id: Ie03e4a6c6f81ea3925266dd22e87506d722a6e1a
2020-05-05 12:02:31 +07:00
Vadim Yanitskiy 4162b27dae layer23/l1ctl: fix: do not pass PDCH and CBCH frames to LAPDm
GPRS (PDCH) and CBCH related frames have nothing to do with LAPDm.
The former uses LLC for the user-plane data, while CBCH involves
its own segmentation described in 3GPP TS 23.041 and TS 44.012.

There is currently no code for handling these kinds of frames, so
let's just send them to GSMTAP and release the memory (msgb).

Change-Id: I59b4acbe22217f8989f73b79b128a43e8bcdfa2f
Related: OS#4439
2020-03-17 18:25:04 +07:00
Harald Welte a1be0a6b62 cbch_sniff: Use CCCH_MODE_COMBINED_CBCH, not CCCH_MODE_COMBINED
In Change-Id Ia94ebf22a2ec439dfe1f31d703b832ae57b48ef2 we
introduced a new member to the ccch_mode enum: CCCH_MODE_COMBINED_CBCH,
which is to be used to tell the PHY if a CBCH is present on the combined
CCCH+SDCCH/4+CBCH or not (CCCH+SDCCH4).

This was implemented in trxcon + calypso firmware, but cbch_sniff has
not been updated accordingly.

Related: OS#4439
Change-Id: I429d45cfb181da4a2e767e92f1213ccd08c6d440
2020-03-07 16:25:46 +01:00
Neels Hofmeyr 0c77a7f4cf mobile: fix gsm_recv_voice: pull l1ctl header from TCH payload
That function encapsulates the RTP payload in an MNCC header, but the l1ctl dl
header has to be removed first to get only the RTP payload in the MNCC
structure.

Change-Id: Id6ddc9b1da43e88c5b9468d4397a39953bdf533a
2020-03-05 13:32:58 +01:00
Vadim Yanitskiy 60ce345755 mobile/gsm322: fix use-after-free of cs->si reported by ASan
This pointer cs->si stores an address to the System Information of
a currently selected cell. When we release System Information,
ensure that it does not point to free()d memory.

Change-Id: Ife2ddf7274a48447a9ded9035f9dd01befaf2e6c
2020-03-01 02:22:13 +07:00
Vadim Yanitskiy c083e2ce90 layer23/l1ctl: fix NULL-pointer dereference reported by ASan
Some applications (e.g. ccch_scan) may not initialize ms->cellsel.si,
some (e.g. mobile) may need some time to initialize it. Let's assume
that 'bs_ag_blks_res' is 1 if System Information is not available.

Change-Id: Ie695d9700c01ee1e6778950a2f3c8610b69d2143
2020-03-01 02:22:13 +07:00
Harald Welte 938faa16e4 layer23: Terminate process if L2 socket fails/dissappears
We don't recover from this situation at all, so it's best to
terminate the process.

Change-Id: I487d18e4afe2cae9f777a30864e680b5dc821fc1
2020-02-26 00:13:04 +01:00
Pau Espin 5738e579b2 layer23: Fix build against gpsd >= 3.20
During 3.19->3.20 dev cycle, some fields were transformed from
timestamp_t or double to timespec_t. See for instance gpsd.git
f7c230fceb6d64483757f8c32afb98e6a2cb9413.

Change-Id: Ie8ba19d030b6f46f2d8afc270a732ce8c26c438f
2020-01-13 17:28:25 +01:00
Pau Espin 6970755342 layer23: Avoid sending downlink AGCH/PCH fill frames over GSMTAP
Some bits are taken from osmo-bts l1sap.c.

Change-Id: Id21e9334b620b8ab3ad404708bfd5358e3555ab6
2019-12-31 17:05:50 +00:00
Pau Espin ae431deae4 layer23: Identify AGCH from PCH on tx of GSMTAP downlink messages
Some bits are taken from osmo-bts l1sap.c

Change-Id: I0adab003a4060c9cef730e0432859659c51bd087
2019-12-31 17:05:50 +00:00
Pau Espin 750faef5ba mobile: Send correct ARFCN in UL gsmtap
Change-Id: I9f677866095413a0efeb8a336ce15a2dbca2228c
2019-12-31 17:05:50 +00:00
Pau Espin 4ddb2e61c7 layer23: Fix trailing whitespace
Change-Id: I295f285e5fc3cdc372723f6b4de2415a94d4979a
2019-12-20 16:47:21 +01:00
Vadim Yanitskiy 65dbd471fc mobile/gsm48_mm.h: use fixed-size integer types in packed structures
Change-Id: I54ed93c03ebe776bdc7eb761a8194da3ab0b67fb
2019-11-17 19:09:59 +07:00
Vadim Yanitskiy 62164b9eab mobile/gsm48_mm.h: mark some structures as 'packed'
In several code paths we put / push structures from 'gsm48_mm.h' into
the message buffers, so then they're unpacked by the message receivers.

The AddressSanitizer complains about unaligned pointer access and
potentially unexpected behaviour. Let's fix this by explicitly
marking those structures as 'packed'.

Change-Id: I6af7475c609b3293af708540d569fe1616fab43f
2019-11-17 18:49:11 +07:00
Vadim Yanitskiy afd5b8247f mobile/gsm48_rr.c: fix NULL-pointer dereference in gsm48_rr_check_mode()
In some cases (e.g. at start up) ms->rrlayer may not be initialized.
Let's access ms->settings directly since we already have a pointer
to struct osmocom_ms.

Change-Id: Ia9720132fcda960dcecefab9ae48398946503dc4
2019-11-17 17:46:48 +07:00
Martin Hauke 1f7a2ab5d3 Fix common misspellings and typos
Change-Id: I962b42871693f33b1054d43d195817e9cd84bb64
2019-10-17 08:07:39 +00:00
Pau Espin 94b1dce6d1 Remove undefined param passed to logging_vty_add_cmds
Since March 15th 2017, libosmocore API logging_vty_add_cmds() had its
parameter removed (c65c5b4ea075ef6cef11fff9442ae0b15c1d6af7). However,
definition in C file doesn't contain "(void)", which means number of
parameters is undefined and thus compiler doesn't complain. Let's remove
parameters from all callers before enforcing "(void)" on it.

Change-Id: I25baaa30b097dad2fae507c5321778f43e863611
Related: OS#4138
2019-08-05 16:24:40 +02:00
Harald Welte d0a8b49d51 gsm411_sms.c: Handle negative return of gsm340_gen_oa()
Change-Id: I36f56e1fbd72d9b31350dc2f8a53e763f79f4c08
Closes: CID#198533
2019-07-21 15:46:57 +00:00
Vadim Yanitskiy e6f5a88463 mobile/gsm480_ss.c: gsm480_tx_release_compl(): fix cause IE encoding
According to GSM TS 04.08, section 10.5.4.11, location and coding
standard are encoded before the cause value, not vice-versa!

Also, coding standards other than "1 1 - Standard defined for the
GSM PLMNs" shall not be used if the cause can be represented with
the GSM standardized coding.

Change-Id: Ic6abcfb9a9589f5b0c9c40def863f15ae04d0bdd
2019-07-21 16:05:28 +07:00
Harald Welte 6b9df297dc mobile: Fix encoding of cause in gsm480_tx_release_compl()
Change-Id: Iba2ace7d82be5677d28b25f60ab0312fed76f5e5
Closes: CID#198577, CID#198576, CID#198575
2019-07-21 08:53:50 +02:00
Harald Welte 5c2a64ca96 gsm322: Fix resource leak in gsm322_init() while reading BA
Change-Id: Id42102ab8581e247f495fb7e05dc62a6743d28c5
Closes: CID#198546
2019-07-21 08:29:34 +02:00
Harald Welte d5ff9bb1aa layer23: fix tons of compiler warnings, mostly OSMO_DEPRECATED related
Change-Id: I03918bd864c711b377a795186123c85bb6f4dc4a
2019-05-28 06:32:34 +00:00
Harald Welte 00513d65c8 common/sap_fsm.c: fix missing pointer dereference
sap_fsm.c: In function ‘sap_negotiate_msg_size’: sap_fsm.c:103:15:
warning: passing argument 1 of ‘__bswap_16’ makes integer from pointer
without a cast [-Wint-conversion]:

  size = ntohs((uint16_t *) param->value);
               ^~~~~~~~~~~~~~~~~~~~~~~~~

Change-Id: Ie58af6162c67ae377809b42daa897ca3f3d72af1
2019-05-23 16:02:16 +03:00
Harald Welte e6a5342272 layer23: Fix 'make distcheck'
Change-Id: Ic48e240ee1484aaa793af23c62a24d2949900b86
2019-05-22 21:39:38 +02:00
Harald Welte 808998c3f8 bcch_scan: Fix compiler warning about undefined functions
Change-Id: I435ef2032b9cefe844c37f395d9087be6af8934a
2019-05-22 21:39:38 +02:00
Vadim Yanitskiy 507781ee70 common/sim.c: add missing break to sim_apdu_resp()
Change-Id: Id5c325ffcfea8175bc5d5499a0904c0984e00349
Fixes: OS#198542
2019-05-14 20:52:39 +07:00
Vadim Yanitskiy cb9e020471 mobile/gsm48_mm.c: use proper types for gsm48_rr_hdr
Change-Id: I29ed122b8956260b9f847cc0e3e81a28d6762632
2019-05-03 00:57:50 +02:00
Vadim Yanitskiy 04a46d091b mobile/gsm48_rr.h: mark gsm48_rr_hdr struct as packed
In both gsm48_mm.c and gsm48_rr.c we put / push 'gsm48_rr_hdr'
structure into the message buffers, so then it's retrieved by
the message receivers. The AddressSanitizer complains about
unaligned pointer access and potentially unexpected behaviour.

Change-Id: I8aa2c0074b405afd0e76044ef076b6819fe1083b
2019-05-03 00:48:35 +02:00
Vadim Yanitskiy e8c179a575 mobile/gsm322.c: fix heap-use-after-free in gsm322_unselect_cell()
In gsm322_l1_signal(), if S_L1CTL_FBSB_ERR is received, we free
stored System Information of the current cell, but cs->si may
still point to it. Let's set it to NULL.

Found with AddressSanitizer:

  DL1C ERROR l1ctl.c:96 FBSB RESP: result=255
  DCS INFO gsm322.c:2995 Channel sync error, try again
  DCS INFO gsm322.c:467 Sync to ARFCN=860(DCS) rxlev=-106
  DRR INFO gsm48_rr.c:665 MON: no cell info
  DRR INFO gsm48_rr.c:665 MON: no cell info
  DRR INFO gsm48_rr.c:665 MON: no cell info
  DRR INFO gsm48_rr.c:665 MON: no cell info
  DL1C ERROR l1ctl.c:96 FBSB RESP: result=255
  DCS INFO gsm322.c:3008 Channel sync error.
  DCS DEBUG gsm322.c:3013 free sysinfo ARFCN=860(DCS)
  DCS INFO gsm322.c:3020 Unselect cell due to sync error!
  DCS INFO gsm322.c:509 Unselecting serving cell.
  =================================================================
  ==6014==ERROR: AddressSanitizer: heap-use-after-free on address
                 0x61b0000000e6 at pc 0x00000050d6dd
		 bp 0x7fff7f84aa60 sp 0x7fff7f84aa58

Change-Id: I9cc526c18d69695d810de98703579818408de011
2019-05-03 00:34:40 +02:00
Holger Hans Peter Freyther b4bd78a8ee lua: Add a sentinel for the fd function table
Change-Id: I4fe2fd6584a453a951361e1b67fb986583b176be
2019-04-27 10:15:28 +01:00
Vadim Yanitskiy 1c6263b2be common/sim.c: use msgb_get() in gsm_sim_reply()
Change-Id: Ie5843c8adafc37da0d69c335c97b422552b85049
2019-02-02 12:37:50 +03:00
Vadim Yanitskiy 6c04bd39c4 common/sim.c: get rid of unused 'payload' pointer
This change fixes the following compiler warning:

  sim.c: In function ‘gsm_sim_reply’:
  sim.c:149:11: warning: variable ‘payload’ set but not used
                         [-Wunused-but-set-variable]
    uint8_t *payload;

Change-Id: I3767b23bb1b28d3f4bb515d399bce160ba2eee09
2019-02-02 12:36:35 +03:00
Vadim Yanitskiy 7ad1df2582 common/osmocom_data.h: use proper type for SAP card status
Change-Id: I7388ec60ca2dff59c0a0e3fdacf5a3af0c244c73
2019-02-02 12:26:11 +03:00
Vadim Yanitskiy ea5804398a common/sap_fsm.c: register SAP FSM on DSO load
Change-Id: Id539c2a3477526b816918070bab93b26c900998a
2019-02-02 12:16:44 +03:00
Vadim Yanitskiy f4ba6382f5 mobile/gsm322.c: fix: properly print stored BA list entities
As we do iterate over all entities in the BA list, it makes more
sense to print each one separately instead of printing the last
one. Moreover, as soon as the iteration is finished, *ba points
to some zero-initialized part of memory:

  gsm322.c:5170 Write stored BA list (mcc=000 mnc=000  Marshall Islands, 000)

After this patch:

  gsm322.c:5162 Write stored BA list (mcc=250 mnc=99  Russian Federation, Beeline)
  gsm322.c:5162 Write stored BA list (mcc=250 mnc=01  Russian Federation, MegaFon)
  gsm322.c:5162 Write stored BA list (mcc=250 mnc=02  Russian Federation, MTS)
  gsm322.c:5162 Write stored BA list (mcc=544 mnc=31  Serbia, Telenor)

Change-Id: I5160492e6125401c6a1765f54d129b1f1cd503fc
2019-02-02 11:51:16 +03:00
Vadim Yanitskiy 9ec58916d9 mobile/gsm480_ss.c: fix build: apply msgb_wrap_with_TL() rename
In If1e851ac605c8d2fde3da565b0bd674ea6350c2e, msgb_wrap_with_TL()
was renamed to msgb_push_tl(). Let's use the new symbol name.

Change-Id: Ief37424e0ca3cd696054518a0ffb07b7ef17a462
2019-01-23 22:52:58 +07:00
Vadim Yanitskiy 2986a318b1 layer23/sap_interface.c: reimplement (BT)SAP interface
The (BT)SAP (Bluetooth SIM Access Profile) is a part of Bluetooth
specifications, that defines the protocol and procedures that
shall be used to access a smart card (usually GSM SIM) via
a Bluetooth link.

The profile defines two roles:

  - Server - the side that has direct access to a smart card.
    It acts as a SIM card reader, which assists the Client
    in accessing and controlling the smart card.

  - Client - the side that accesses and controls the smart card
    inside the Server through the connection with Server.

Typical examples of a Server are a simple SIM card holder or
a portable phone in the car environment. A typical example of
a Client is a car phone, which uses a subscription module in
the Server for a connection to the cellular network.

OsmocomBB implements the Client role providing abstract SAP
interface API to the higher layers. Instead of Bluetooth,
a UNIX socket is used to communicate with a Server.

The previous implementation of (BT)SAP interface was incomplete
and hard to maintain. This change (re)implements it almost from
scratch on top of the Osmocom FSM framework.

Besides that, the most significant changes are:

  - The implementation is separated into three parts:
    - sap_interface.{c|h} - public SAP interface API,
    - sap_proto.{c|h} - SAP protocol definition,
    - sap_fsm.{c|h} - SAP FSM implementation.

  - Both 'sap_message' and 'sap_param' structures follow the
    SAP message format definition according to 5.1 and 5.2.

  - The message parsing is done more carefully in order to
    prevent buffer overflow and NULL-pointer dereference.

  - Introduced public API for getting / adding message
    parameters, and checking the ResultCode.

  - Introduced public API for opening / closing a connection
    with the server, powering on / off and resetting the SIM
    card, sending ATR and APDU.

  - Introduced a call-back for handling the response message.

  - Card reader state is also a part of the public API.

The new implementation was tested against softsim [1]. The
only limitation is Server-initiated Release, that allows the
Server to 'ask' a Client to release connection as soon as
communication with the smart card is finished. This is not
implemented (yet), and leads to immediate release.

[1] https://git.osmocom.org/softsim/

Change-Id: I77bb108615bb2c94c441568f195b04e0a5421643
2019-01-15 04:26:46 +07:00
Vadim Yanitskiy d2004ae4f6 layer23/sap_interface.c: separate protocol definition
Change-Id: Iad9b3d88b02cc7ec4cf64483bbc85e3a61c9ad10
2019-01-07 15:39:52 +00:00
Vadim Yanitskiy cfc94aaa73 layer23/include/Makefile.am: add missing header
Change-Id: I0a379718eeb7db63696cabd5689e0625fb85d85e
2019-01-07 15:39:52 +00:00
Vadim Yanitskiy 221d3121b7 layer23/sap_interface.c: avoid using 'osmo' prefix
The 'osmo' prefix is usually used by libosmo-* symbols.

Change-Id: Id37d8553c2f2c20012fb1b729967b92a9a03f612
2019-01-07 15:39:52 +00:00
Vadim Yanitskiy 28a385aad5 layer23/sap_interface.c: define missing enums and use them
Change-Id: I4ba5a8a42bf25d04b152ac3f1f0e4d7eac7f068f
2019-01-07 15:39:52 +00:00
Vadim Yanitskiy 50d5995137 layer23/sap_interface.c: terminate value_string definitions
Change-Id: I0776bc43360dfa2229243fb022cd318242ca6400
2019-01-07 15:39:52 +00:00
Vadim Yanitskiy f1a948f71a layer23/sap_interface.c: prettify value_string definitions
Change-Id: Ib3aa81986987027718e2a8b461afd28787bda4c2
2019-01-07 15:39:52 +00:00
Vadim Yanitskiy cec6573cb5 layer23/sap_interface.c: fix: properly call sap_msg_free()
Passing NULL to sap_msg_free() is not only meaningless, but also
would result in NULL pointer dereference. We should call it in
successful case only, so let's fix this.

Change-Id: Icf868c4299e292a17c4b7aad1f9e728ea3653494
2019-01-07 15:39:52 +00:00
Vadim Yanitskiy 684fa75b49 layer23/sap_interface.c: use LOGP() instead of fprintf()
Change-Id: I054be24666fcd5eb8a70cfcac0e7ed566e909b90
2018-12-26 20:52:18 +00:00
Vadim Yanitskiy d83716d315 layer23/sap_interface.c: use int for rc in sap_open()
Change-Id: I683f87ae09393c45377c39317b08c613055ceb16
2018-12-26 20:52:18 +00:00
Vadim Yanitskiy e9bc2ae671 layer23/sap_interface.c: remove redundant socket_path argument
Change-Id: I408b3e1fa40e9b5daf88fa6ed5f3930b83dffe6f
2018-12-26 20:52:18 +00:00
Vadim Yanitskiy f01dc598a0 layer23/sap_interface.c: drop unused osmosap_sapsocket()
Change-Id: Ie3040c75bb61094b9b601aef9d699db603d292f4
2018-12-26 20:52:18 +00:00
Vadim Yanitskiy 28c56e582b layer23/sap_interface.c: return rc from osmosap_send_apdu()
Change-Id: I3965843c4d49e31b1b5156d9ee8439eef6ecaab1
2018-12-26 20:52:18 +00:00
Vadim Yanitskiy 1bd795c951 layer23/include/sap_interface.h: use #pragma once
Change-Id: I98e407c2b6604438d2495700cb62753ad55369ea
2018-12-26 20:52:18 +00:00
Vadim Yanitskiy 39dc9c463c mobile/subscriber.c: consider GSM_SIM_TYPE_SAP too
There are several SIM card interfaces, two of which:

  - GSM_SIM_TYPE_L1PHY (using built-in SIM reader of the L1 PHY),
  - GSM_SIM_TYPE_SAP (using remote reader via (BT)SAP protocol),

can actually deal with a physical SIM card. But, for some reason,
only GSM_SIM_TYPE_L1PHY was considered as such. Let's also get
along with GSM_SIM_TYPE_SAP for the following procedures:

  - PIN management and verification,
  - FPLMN / LOCI updating,
  - A3 authentication.

Change-Id: I4b3080fa7a5332467a449a314ba3cc3a07a9b7df
2018-12-26 20:52:18 +00:00
Vadim Yanitskiy e11725aa86 host/layer23: rename GSM_SIM_TYPE_READER to GSM_SIM_TYPE_L1PHY
Since we have two ways to interact with a physical SIM:

  - using built-in SIM reader of the L1 PHY (via L1CTL),
  - using remote reader via (BT)SAP protocol,

name 'GSM_SIM_TYPE_READER' looks quite confusing. Let's rename it
in order to explicitly indicate the role of L1 PHY.

Change-Id: I0f83f365ed50cfd658fdd3a9d6866ed76c8c4009
2018-12-26 20:52:18 +00:00
Vadim Yanitskiy b9073067c6 layer23/common/sim.c: don't ignore rc of sim_apdu_send()
Change-Id: I8cab7cc72f026947859cc607f65d925803424cf7
2018-12-26 20:52:18 +00:00
Holger Hans Peter Freyther 271993c282 mobile: Use new VTY telnet API to allow binding to random port
Change-Id: I5a6214aec2dcb92495038ea8311c0df22fa8d07b
2018-12-23 05:25:37 +00:00
Vadim Yanitskiy 2e861308d6 layer23/mobile: drop dead SAP initialization code
SAP connection can be initialized upon request.

Change-Id: Ic89089c4850ab2c9252bfd43a05d5271e2e3a160
2018-12-19 19:18:42 +07:00
Vadim Yanitskiy a1473ab10e host/layer23/sap_interface.c: cosmetic: use ARRAY_SIZE()
Change-Id: I3a2908bf11300ec681beddb5a54f9a62ca5430ae
2018-12-18 23:50:37 +07:00
Vadim Yanitskiy e42629e897 host/layer23: don't init SAP interface by default
Almost all layer23 applications, excluding mobile, have nothing
to do with SAP interface. Moreover, the current implementation
does initialize SAP connection automatically, as soon as the
first message is sent.

Change-Id: I62cc69c06fa15468a55bb0a9d408267d0745174c
2018-12-18 23:38:21 +07:00
Vadim Yanitskiy da96b3c0ae mobile: use VTY bind addr from config, deprecate cmd line options
This change revives the main idea of:

  Change-Id: I32517567847fd5c54b1742f18bf409ff81e316fa

to stop ignoring the VTY bind address from the config file.

Furthermore, it deprecates (and disables) both 'u' and 'v'
command line options, because they are redundant.

Change-Id: I99e0ec1717edd29b3be231be86616cc7effe5d95
2018-11-21 10:36:57 +07:00
Vadim Yanitskiy 65110d2d99 mobile: abort in case of argv handling errors
The process should be aborted if a non-existing command line
option or an incorrect parameter value is passed.

Change-Id: Ib656ad12f12429ed15dc2a1554901ffa51148ff6
2018-11-21 10:22:52 +07:00
Vadim Yanitskiy 0e8f447c4d mobile/app_mobile.c: use LOGP() instead of printf()/fprintf()
Change-Id: I6af76afbaa34dde5ddfc31a65700030862442dba
2018-11-21 10:02:42 +07:00
Vadim Yanitskiy d21f22c128 mobile/app_mobile.c: drop redundant printf() call
The VTY requisites are always being printed by libosmovty,
there is no need to duplicate this information.

Change-Id: I688f66175ea67d4c6a46819bee7d300ad9ce7cc7
2018-11-21 09:42:31 +07:00
Vadim Yanitskiy d7e2337361 Revert "mobile: fix vty bind ip override"
This reverts commit c8de8cb1e1
(Change-Id I32517567847fd5c54b1742f18bf409ff81e316fa by Max),
because several problems were introduced, in particular:

  a) Help message of mobile application is broken:

      "The VTY IP to telnet to. (default (null))",
      "The VTY port number to telnet to. (default 127.0.0.1)".

  b) Default VTY bind addres != parsed from the config file.

  c) The (vty_ip == NULL) is resolved only when an external
     MNCC handler is used, otherwise NULL is passed to
     l23_app_init().

Change-Id: Ic63a4eb828ff32d3744886b4f5f6f5019c798620
2018-11-21 09:35:21 +07:00
Max c8de8cb1e1 mobile: fix vty bind ip override
Previously the vty bind config parameter was always ignored. Fix this by using proper
default value from the config unless it's explicitly set via command-line parameter.

Change-Id: I32517567847fd5c54b1742f18bf409ff81e316fa
2018-11-19 17:20:11 +01:00
Max dcc7e6074a Fix build with latest libosmocore
Remove locally defined function which conflicts with the one in
libosmocore.

Change-Id: I1be1d39f7c93c959ca33f6296ecda71996865cca
2018-11-19 10:26:19 +01:00
Max bfa7b3335b l1l2 interface: use LOGP for socket errors
Log via LOGP() like the rest of the file instead of fprintf() for
consistency. While at it, also print error cause.

Change-Id: Id205bcd9bdb7c3e4b96493d50be8381a6fa80ac6
2018-11-19 09:17:09 +00:00
Max 264378a867 mobile: log socket path on error
Change-Id: I18eb46743e4c0e4e8f8032883f39fec355f03c78
2018-11-19 09:17:09 +00:00
Max d44503337d mobile: use proper type for boolean flags
This makes reading code easier and simplifies further modifications.

Change-Id: I7eff2a61495ff167dc19fc9a41882a7a11fbf32d
2018-11-16 21:37:55 +01:00
Max aa4dbe2b8e mobile: add header for MS' MNCC functions
This simplifies adding new functions and re-using them from other parts
of the code.

Change-Id: Ibad400a99afe052f011f54fc706836b6bf89f4b9
2018-11-16 21:37:55 +01:00
Pau Espin 927d030ae8 layer23: Avoid mempcy with NULL src
Fixes following ASan warning:
git/osmocom-bb/src/host/layer23/src/misc/../common/main.c:146:2: runtime error: null pointer passed as argument 2, which is declared to never be null

The warning however is harmless since in that case, app_len = 0 and thus
size to copy is 0.

Change-Id: I009a5b53f1e5be72ce347d64d3a7cb1d95d37ea3
2018-11-08 15:46:50 +01:00
Pau Espin 4f85fb30bc layer23: Fix build against gpsd >= 3.18
Change-Id: I0e97d3e8c3688064c959ea60ecef50cfbbc1bcd6
2018-11-05 20:22:45 +01:00
Pau Espin 9cdee8f66a cosmetic: fix trailing whitespace
Change-Id: I5c1a6d98079ad846d114584a17ba9d80d95e0595
2018-11-05 20:21:58 +01:00
Vadim Yanitskiy 219ed20cb5 l1ctl_proto.h: use flexible array member for traffic messages
Unlike the DATA messages, traffic frames may have different length.
Instead of having fixed payload (i.e. TCH frame) length, let's
introduce a flexible array member. This would allow one to
calculate the frame length using the MSGB API.

Change-Id: I119fa36c84e95c3003d57c19e25f8146ed45c3c6
2018-11-05 05:13:57 +00:00
Vadim Yanitskiy d350e9f30c layer23/l1ctl.c: fix: use host byte order for TDMA fn
Change-Id: Iad00eebf03b38b9c4fc2d7ed66697d23a953d8b2
2018-10-27 05:54:25 +07:00
Vadim Yanitskiy f8edc45506 layer23/common: move SIM APDU caching from l1ctl.c
L1CTL implementation (i.e. l1ctl.c) is not a good place for the
SIM specific stuff. Let's move it to the proper place (i.e. sim.c).

As a bonus, this change fixes a possible problem of loosing the
cached APDUs if two or more L2&3 applications are using a single
LAPDm connection. The APDU buffer is dedicated per MS now.

Change-Id: I564c610e45aa3b630ca5d1ec6bc1cace0dc9c566
2018-10-27 05:49:45 +07:00
Max 8bda1c2f52 Report socket path on errors
Change-Id: Ib63e1205d7b845c8779eb511635f26bae3a18085
2018-10-26 11:11:41 +02:00
Vadim Yanitskiy 1a892eeb2a layer23/l1ctl.c: clean up & fix message length checking
Almost all handlers for received L1CTL messages are also affected
by the bug fixed in I7fe2e00bb45ba07c9bb7438445eededfa09c96f3. In
short, they do verify the length of 'msg->l2h' or 'msg->l3h', but
not the 'msg->l1h'. Let's fix this, and also add missing checks.

Change-Id: I866bb5d97a1cc1b6cb887877bb444b9e3dca977a
2018-10-03 19:46:25 +07:00
Vadim Yanitskiy 7bf8aea33a layer23/l1ctl.c: avoid confusion between L1CTL / L1 headers
As we assign the payload following L1CTL header to 'msg->l1h',
it makes sense to avoid possible naming confusion.

Change-Id: I5d21ca8664b3445f472d3ffde90d0e11805dcb16
2018-10-03 19:40:19 +07:00