summaryrefslogtreecommitdiffstats
path: root/src/host/layer23
AgeCommit message (Collapse)AuthorFilesLines
2018-10-03(WIP) mobile: add RTP related primitivesfixeria/mnccVadim Yanitskiy2-0/+19
Change-Id: I61c058eb1c6a5d2a8acc295367eea51391ec6640
2018-10-03(WIP) mobile/gsm48_cc.c: ignore MNCC_FRAME_{RECV|DROP} messagesVadim Yanitskiy3-30/+4
Using both MNCC_FRAME RECV/DROP messages, an external MNCC application could enable / disable forwarding of the traffic frames from L1 through MNCC-socket. Now it can be done by user from the VTY configuration (see 'io-target' of 'audio' section), so there is no need to control this from outside. Change-Id: I41a0c9bc44b3ca6784f4190931773637f9fab40c
2018-10-03mobile/mncc_sock.c: ensure MNCC_SOCKET_HELLO message is sentVadim Yanitskiy2-0/+54
This message is used to negotiate MNCC protocol version, and also in order to make sure that the sutructure alignment is equivalent for both sides. Change-Id: I7c5d8aa17540dd61bbe003a6468d97ecea415636
2018-10-03mobile/gsm48_cc.c: handle more GSM_TCH* messagesVadim Yanitskiy1-0/+3
Change-Id: I173ca8df6ca3bb8b462b54b4893e382ef0f7d723
2018-10-03mobile/voice.c: properly set frame type and lengthVadim Yanitskiy1-5/+45
Change-Id: I4e850d2637a338032395cedd5ad540d61899eb75
2018-10-03mobile/mncc.h: migrate some GSM_TCH* messages from LCRVadim Yanitskiy1-0/+2
Change-Id: If8f391b171155f73da4ed4ba76a49b6ef63bb89f
2018-10-03host/mobile: integrate GAPK based audio I/O back-endVadim Yanitskiy7-17/+685
This change introduces a new feature of the mobile application - audio I/O support, which allows one to speak right from PC running mobile through its ordinary mic and speakers. The audio I/O is based on GAPK library, which relays on ALSA sound framework. The API of GAPK implies to use the processing queues (chains), which basically consist of a source block, several processing blocks, and a sink block. So, there are two voice processing chains: - 'pq_audio_source' (voice capture -> frame encoding), - 'pq_audio_sink' (frame decoding -> voice playback). Both of them exchange frames from two dedicated buffers: - 'tch_fb_ul' - a buffer for to be played DL TCH frames, - 'tch_fb_dl' - a buffer for encoded UL TCH frames. In its turn, both buffers are served by a new gapk_io_dequeue() function, which is being called within the mobile_work() loop. Change-Id: Ib86b0746606c191573cc773f01172afbb52f33a9
2018-10-03mobile/voice.c: abstract gsm_send_voice() from MNCCVadim Yanitskiy3-5/+22
Change-Id: I37241555cd648a8e2b57fa072c708f93cd1ba5a9
2018-10-03mobile/voice.h: use '#pragma once' include guardVadim Yanitskiy1-4/+1
Change-Id: I024e13c0f66ae1e42b0c8e2ff77874fcb883e85a
2018-10-03common/l1ctl.c: cosmetic: drop dead codeVadim Yanitskiy1-2/+0
Change-Id: I941899ab27282a495f965ae9a0f41076dceef953
2018-10-03common/l1ctl.c: fix: drop TCH frame length / magic checkVadim Yanitskiy1-14/+0
It was assumed that only FR frames (with magic 0xd) can be carried by the L1CTL_TRAFFIC messages, but there are also EFR, HR, and AMR frames, and dropping them is not a good idea. Change-Id: I4b7b85d94f11deb7525b63f3549a182c6e76da08
2018-10-03l1ctl_proto.h: use flexible array member to store a traffic frameVadim Yanitskiy1-9/+25
Unlike the LAPDm messages, traffic frames may have different length. Instead of having a buffer with fixed length, let's use flexible array member. This would allow one to calculate a frame length using the MSGB API (i.e. msgb_l3len()). Change-Id: I119fa36c84e95c3003d57c19e25f8146ed45c3c6
2018-10-03mobile/gsm48_rr.c: drop TCH/F channel limitationVadim Yanitskiy1-8/+0
Change-Id: I06e84ad47bafd4676af0e136b825e77471587b23
2018-10-03mobile/gsm48_rr.c: properly handle CHANNEL MODE MODIFYVadim Yanitskiy1-7/+23
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
2018-10-03mobile/gsm48_rr.c: fix copy-paste error in commentVadim Yanitskiy1-1/+1
Change-Id: I45212cd02ac50d0d363918709720e997500e45a9
2018-10-03mobile/gsm48_rr.c: print error if ch_type is not TCHVadim Yanitskiy1-2/+4
The CHANNEL MODE MODIFY message only applies to TCH channels, and in general should not arrive on non-traffic channels. Let's print error message if this happens in order to facilitate finding possible bugs. Change-Id: I4ab63c4ae4262c8166de37e4873fc3f1b8ec6fe7
2018-10-03mobile/gsm48_rr.c: prevent uninitialized memory accessVadim Yanitskiy1-1/+8
The rsl_dec_chan_nr() may fail to decode RSL channel number, so the 'ch_type' variable would be uninitialized. Let's check rc. Change-Id: I9ab18bdaf41a29fcd32a7060668ef9db07b8cf7e
2018-10-03mobile/gsm48_rr.c: print name of channel modeVadim Yanitskiy1-2/+2
Change-Id: I615e89bdd7e1cc01b3258fefa26f7ab5705ae8cc
2018-10-03mobile/gsm48_rr.c: set audio mode according to configurationVadim Yanitskiy1-1/+13
In the prevoius change a new configuration option was introduced as a part of new 'audio' node - 'io-target'. This change makes it to take an effect, instructing the L1 to use one of the following possible TCH frame I/O targets: - gapk - build-in (WIP) GAPK-based audio back-end (default); - hardware - L1 hardware (e.g. Calypso DSP); - socket - External MNCC application (e.g. LCR). Change-Id: I2a36d9c30da6746995dcea3a33cb13e0d2f6549a
2018-10-03mobile/vty_interface.c: add new 'audio' sectionVadim Yanitskiy4-0/+152
This change introduces a new node named 'AUDIO', which is intended to organize some audio related settings, such as: - io-target - TCH frame I/O back-end (e.g. gapk, hardware); - alsa-output-dev - ALSA playback (i.e. speakers) device name; - alsa-input-dev - ALSA recording (i.e. mic) device name. The last two are actual when 'io-target' is set to 'gapk'. For now, all introduced parameters don't affect anything. Change-Id: I62cd5ef22ca2290fcafe65c78537ddbcb39fb8c6
2018-10-03host/layer23: add a new logging category for GAPKVadim Yanitskiy3-1/+8
Change-Id: I5c3e8553f9bca2ca2e1bf17ee5934e04bd12f605
2018-10-03mobile: link the binary against libosmogapkVadim Yanitskiy2-0/+3
Since GAPK has became a shared library - libosmogapk, it can be used for the voice capture / playback directly on the host side. This change adds the library as a dependency, and links the mobile application against it. Change-Id: I47054f32fec6780bdbe6f73b82aa446c4c7c1df4
2018-10-03mobile/Makefile.am: consistently format variablesVadim Yanitskiy1-10/+58
Change-Id: I309d94c4a381c21486e5b424c9504ea6d272af05
2018-10-03mobile: add MNCC handler selection to settingsVadim Yanitskiy6-34/+109
Since the mobile application is potentionally able to work with multiple MS instances, it's better to have a possibility to choose an MNCC (Call Control) handler per each MS separately. This change cleans up the code, removing a dedicated command-line option '-m' intended for enabling extarnal MNCC. Now it's possible to set an MNCC-handler for each MS via VTY interface and settings. The following MNCC-handlers are available: - mobile - build-in MNCC-handler (default); - socket - external MNCC-handler via UNIX-socket (e.g. LCR); - dummy - dummy handler without CC support. Change-Id: I2df91c7a79ba5c39bc6ceae900ef649129dd0346
2018-10-03mobile: add MNCC socket path to settingsVadim Yanitskiy4-6/+32
Previously the MNCC socket path was generated automatically, using concatenation of the '/tmp/ms_mncc_' prefix and MS name. Let's allow user to specify this manually, keeping a similar generation method for default value. Change-Id: I643356ac579bc5e765f668265ec803b22a73739c
2018-10-02layer23/app_ccch_scan.c: omit dummy (fill) framesVadim Yanitskiy1-0/+32
In some conditions it's required to maintain continuous burst transmission (e.g. on C0). If there is nothing to transmit at a given moment, either a LAPDm func=UI fill frame, or a "dummy" Paging Request is used. In case of 'ccch_scan' application, they are useless. Let's detect and omit them. Change-Id: I6ccecb1a78bdac3e467bdc14b7a01afbe17aa53c
2018-10-02layer23/app_ccch_scan.c: hexdump unhandled PCH/AGCH messagesVadim Yanitskiy1-2/+3
Change-Id: I81d6558525e7f68c4fcd6c6272224d58532e2efb
2018-10-02layer23/app_ccch_scan.c: print pdisc in error messageVadim Yanitskiy1-1/+2
Change-Id: Ic88f5d4b263610a376bbb9729e882097393ef2be
2018-10-02layer23/app_ccch_scan.c: clean up System Information handlingVadim Yanitskiy1-59/+64
Change-Id: I8c2594920fcad8a3e346b938bd0c20409f4d01c9
2018-10-02layer23/app_ccch_scan.c: print 'new-line' char locallyVadim Yanitskiy1-3/+2
Change-Id: I03da1329501ce9b3c5cca49a1654ba68e9bb6a98
2018-10-02layer23/app_ccch_scan.c: clean up copy-pasted codeVadim Yanitskiy1-47/+1
By definition, 'ccch_scan' application is intended to be used for monitoring of CCCH channels on C0/TS0. There is no need to send RACH requests, therefore there is no need to care about the mobile allocation from SI1 message. Most likely, this "dead" code was copy-pasted from mobile application. Let's clean it up! Change-Id: I7c2f47cbc825a5e5a50863d842729d3d8408b9dd
2018-09-21layer23/l1ctl.c: replace printf() calls by LOGPVadim Yanitskiy1-2/+2
Change-Id: I863fb668500b2010dfef7a63217255fd010c06d7
2018-09-21layer23/l1ctl.c: drop redundant printf() callVadim Yanitskiy1-1/+0
Change-Id: I02bc581afb5a76c51fdef50ed40e2669c3eb3f2e
2018-09-16lua: Expose API to trigger a network reselectionHolger Hans Peter Freyther3-0/+27
Same as the "network search" VTY command but implemented as primitive and exposed to LUA. Change-Id: I096233a2ca9dd7daa358cebed0523cb8c0dbf593
2018-09-16Add includes so the file can be included by itselfHolger Hans Peter Freyther1-0/+5
Add missing dependencies to make this file be includeable as the only file. Change-Id: I05b5f689f389b89deb5ff49507486b246111fc59
2018-09-07common/l1ctl.c: fix: use signed type for TA in l1ctl_tx_param_req()Vadim Yanitskiy2-2/+2
Despite the correct range of Timing Advance value is [0..63], there is a special feature in OsmocomBB which allows one to simulate the distance between both MS and a BTS by playing with the signal delay. It was discovered that l1ctl_tx_param_req() is using an unsigned 'uint8_t' type for Timing Advance value, while other code and L1CTL protocol is using signed 'int8_t'. This may result in distortion of negative values, so let's fix this! Change-Id: I6ee42b5fa2ca9ebe187f0b933465c49f840a55c2
2018-09-06layer23: Use osmo_sock_unix_init_ofd() from libosmocoreHarald Welte3-105/+11
We don't need to hand-code unix domain socket initialization but can simply use our library function for it. As an added benefit, the library code already contains corner case handling for non-NUL terminated unix domain socket path. Change-Id: I57c724c78dbbbce0546ebe914e370f32c8c89703
2018-08-24Allow lua code to register a fd for reading with the runtimeHolger Hans Peter Freyther1-0/+103
To have bi-directional communication we can pass credentials to the registry server and now we can register a callback when the registry is sending data to us. The callback needs to return if the fd should continue to be selected as I found no way to push the userdata as parameter on the stack. Lua code will look like: local host, port = "www.osmocom.org", 80 local tcp = socket.tcp() tcp:connect(host, port); tcp:send("GET / HTTP/1.0\r\n\r\n"); local cb = function() local s, status, partial = tcp:receive() print(s) if status == 'closed' then tcp:close() return 0 end return 1 end local foo = osmo.register_fd(tcp:getfd(), cb) Change-Id: I8254bdda1df2f8fe0a5eac894b931e7de5b426df
2018-08-24Forget about the callback after use and cancellationHolger Hans Peter Freyther1-0/+5
Don't try to unref something else after we have given up our spot in the table. Change-Id: I4e8db297e816d3d07a46147d5d3bdc0e8fae6c9a
2018-08-11layer23: Replace all instances of strncpy() by osmo_strlcpyHarald Welte7-23/+15
This gives us working/safe zero termination without overflowing the destination string size. Change-Id: Ica6098ceba2bd01ce3b216085442cc5eed0ca507
2018-08-11layer23: Fix possible buffer overflow writing NUL beyond end of stringHarald Welte1-1/+1
settings.c: In function ‘gsm_random_imei’: settings.c:188:26: warning: ‘sprintf’ may write a terminating nul past the end of the destination [-Wformat-overflow=] sprintf(rand + 8, "%07ld", random() % 10000000); ^ settings.c:188:2: note: ‘sprintf’ output between 8 and 9 bytes into a destination of size 8 sprintf(rand + 8, "%07ld", random() % 10000000); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Change-Id: Id949487111235cd4af5ff068f1dce2f4b0801480
2018-08-11layer23: Use osmo_strlcpy() to avoid non-terminated stringsHarald Welte3-3/+3
settings.c:191:2: warning: ‘strncpy’ output may be truncated copying 15 bytes from a string of length 15 -Wstringop-truncation] strncpy(set->imeisv, set->imei, 15); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CC subscriber.o CC support.o CC transaction.o CC vty_interface.o CC voice.o CC mncc_sock.o CC primitives.o mncc_sock.c: In function ‘osmo_unixsock_listen’: mncc_sock.c:318:2: warning: ‘strncpy’ specified bound 108 equals destination size [-Wstringop-truncation] strncpy(local.sun_path, path, sizeof(local.sun_path)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CC script_lua.o vty_interface.c: In function ‘cfg_gps_device’: vty_interface.c:1144:2: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation] strncpy(g.device, argv[0], sizeof(g.device)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AR libmobile.a Change-Id: Id52978f3bf7a8abea62237d7c32f8f87e1bb34a1
2018-08-11layer23: Fix compiler warnings about string operation truncationHarald Welte1-4/+4
This fixes the below warnings: gsm322.c: In function ‘gsm322_cs_ba_range’: gsm322.c:3480:3: warning: ‘strncpy’ specified bound 10 equals destination size [-Wstringop-truncation] strncpy(lower_text, gsm_print_arfcn(index2arfcn(lower)), ARFCN_TEXT_LEN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gsm322.c:3480:3: warning: ‘strncpy’ specified bound 10 equals destination size [-Wstringop-truncation] gsm322.c:3480:3: warning: ‘strncpy’ specified bound 10 equals destination size [-Wstringop-truncation] gsm322.c:3480:3: warning: ‘strncpy’ specified bound 10 equals destination size [-Wstringop-truncation] gsm322.c:3481:3: warning: ‘strncpy’ specified bound 10 equals destination size [-Wstringop-truncation] strncpy(higher_text, gsm_print_arfcn(index2arfcn(higher)), ARFCN_TEXT_LEN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gsm322.c: In function ‘gsm322_cs_powerscan’: gsm322.c:2862:2: warning: ‘strncpy’ specified bound 10 equals destination size [-Wstringop-truncation] strncpy(s_text, gsm_print_arfcn(index2arfcn(s)), ARFCN_TEXT_LEN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gsm322.c:2863:2: warning: ‘strncpy’ specified bound 10 equals destination size [-Wstringop-truncation] strncpy(e_text, gsm_print_arfcn(index2arfcn(e)), ARFCN_TEXT_LEN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Change-Id: I08f938cfb2589574e90d5831a00c0140f71d5bfe
2018-08-11layer23: Fix compiler warning about snprintf buffer too smallHarald Welte1-1/+1
gsm322.c:366:22: warning: ‘sprintf’ may write a terminating nul past the end of the destination [-Wformat-overflow=] sprintf(string, "-%d", 110 - rxlev); ^ gsm322.c:366:2: note: ‘sprintf’ output between 3 and 6 bytes into a destination of size 5 sprintf(string, "-%d", 110 - rxlev); Change-Id: I7b19fef89ba0cb0c1edbdd62c46ad8395e44145b
2018-08-11layer23: fix unaligned store in osmo_send_l1()Harald Welte1-5/+2
This fixes the following alignment issue uncovered by asan: l1l2_interface.c:169:7: runtime error: store to misaligned address 0x61600001ab99 for type 'uint16_t', which requires 2 byte alignment 0x61600001ab99: note: pointer points here 00 00 00 00 00 00 06 0a 01 19 19 40 18 00 07 00 01 03 49 06 15 00 40 01 c0 00 00 00 00 00 00 00 ^ Change-Id: Ie65b428107d35bac99bc870fdbc4dc509ca2f33c
2018-08-11layer23: Add --enable-sanitize and --enable-werror configure flagsHarald Welte1-0/+27
We use this in the network-side Osmocom projects (CNI) and it's useful to have the same flags also for the OsmocomBB host software. Change-Id: I45800c937d665fdbd2dd6b0cee38408f587f1a9f
2018-07-23Move from libc random() to osmo_get_rand_id (2nd attempt)Holger Hans Peter Freyther8-8/+61
When starting multiple mobile in the same second, the libc random number generator will be seeded to exactly the same value. The random bits inside the RACH request(s) will be exactly the same across multiple mobile and when the channel fails they all pick the same randomized back-off timing. Use stronger random numbers and replace all calls to random(2) with osmo_get_rand_id. Add a fallback to try random(). [v2: Add helper to make sure the result is int and between 0 and RAND_MAX] Change-Id: Icdd4be88c62bba1e9d954568e48f0c12a67ac182
2018-07-17mobile: use osmo_init_logging2 with proper talloc contextVadim Yanitskiy1-13/+5
Change-Id: I231ac9987ff3c13fafcd272b7d9aae3938ab5972
2018-07-17Revert "Move from libc random() to osmo_get_rand_id"Vadim Yanitskiy4-18/+5
It was decided to migrate to osmo_get_rand_id() and use random() as a fall-back. But there is a critical difference between both functions: osmo_get_rand_id() fills an input buffer with random bytes (0x00 - 0xff), while *random() returns a value in range between 0 and RAND_MAX. osmo_get_rand_id() was used in a wrong way, so in some cases we could get a negative value (how about IMEI starting from '-'?), what isn't expected in many cases and could lead to unexpected behaviour and segmentation faults... This reverts commit 6d49b049ee304f1ea0e4801df61e69713b01f0f8. Change-Id: I7b2a8a5c63cf64360a824926a2219fd7e419b1bb
2018-07-11Move from libc random() to osmo_get_rand_idHolger Hans Peter Freyther4-5/+18
When starting multiple mobile in the same second, the libc random number generator will be seeded to exactly the same value. The random bits inside the RACH request(s) will be exactly the same across multiple mobile and when the channel fails they all pick the same randomized back-off timing. Use stronger random numbers and replace all calls to random(2) with osmo_get_rand_id. Add a fallback to try random(). Change-Id: Ie0cc64663cd4b90c027b79545dc5d3ac9d87b9dd