Commit Graph

232 Commits

Author SHA1 Message Date
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 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
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 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 0fb9853582 mobile: add vty statsd support
Change-Id: I7905b44478dcb9bcf0a1a68fde95f470c07edca3
2023-02-21 08:49:13 +00: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 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 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 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 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 fb030a8897 layer23: Initialize osmocom_ms further in common code
Change-Id: Ic629cf229167ddd4c533a2abf1b82ad78d1144a9
2023-01-16 10:30:56 +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 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 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
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 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 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 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 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 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 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 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 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 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 136cf481c7 layer23: fix -Werror=old-style-definition problems
Change-Id: I0187acb02de6fd22ccc86c112640caa8aa3fa2bc
2022-11-05 19:18:42 +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 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 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