Commit Graph

56 Commits

Author SHA1 Message Date
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 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
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
Vadim Yanitskiy d02927b036 layer23/l1ctl.c: fix: verify msg length using l1h, not l2h
The actual L1CTL header is pointed by 'msg->l1h', not 'l2h'!
Since msg->l2h is NULL (because nobody set it), the result of
msgb_l2len() would always be bigger than size of L1CTL header,
as it is calculated in the following way:

  return msgb->tail - (uint8_t *)msgb_l2(msgb);

So, in case if 'msg->l2h' is NULL, it turns into:

  return msgb->tail - 0;

Change-Id: I7fe2e00bb45ba07c9bb7438445eededfa09c96f3
2018-10-03 19:21:58 +07:00
Vadim Yanitskiy 7c04a6066e layer23/l1ctl.c: fix: verify msg length against l1ctl_hdr
In l1ctl_recv() we actually expect to 'see' the L1CTL header
instead of the DL info header. Let's fix this.

Change-Id: Ic7d017bef04f3c186565d5dade36959df1019bd8
2018-10-03 19:20:11 +07:00
Vadim Yanitskiy 5746125696 layer23/l1ctl.c: keep L1 header, drop L1CTL header
There is no need to keep the L1CTL header in messages being sent
towards the upper layers, but the L1 info header can be used by
L2&3 to obtain some information, e.g. TDMA frame number.

Change-Id: Id64249f1b7a1c2be578263ba62aa195c452ab7e8
2018-10-03 19:16:08 +07:00
Vadim Yanitskiy c572682e79 layer23/l1ctl.c: replace printf() calls by LOGP
Change-Id: I863fb668500b2010dfef7a63217255fd010c06d7
2018-09-21 21:19:46 +07:00
Vadim Yanitskiy f5004affc9 layer23/l1ctl.c: drop redundant printf() call
Change-Id: I02bc581afb5a76c51fdef50ed40e2669c3eb3f2e
2018-09-21 21:17:47 +07:00
Vadim Yanitskiy 65f80df492 common/l1ctl.c: fix: use signed type for TA in l1ctl_tx_param_req()
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-07 09:02:19 +00:00
Vadim Yanitskiy d49a748cbb common/l1ctl.c move TCH bit-ordering to the firmware
Previously, TCH frames coming from L1 were reordered to the RTP
format. Moreover, the implementation had a few problems:

  - L1CTL is not the best place for such manipulations;
  - payloads with other than FR codec were corrupted.

Let's use RTP-ordered payloads on the L1CTL interface,
performing TCH frame reordering at the firmware.

Please note, that actual FR reordering was moved to the firmware
as is, without any codec determination. This could be fixed in
a separate change.

Change-Id: I81ec8ed3c9e72a62b22c1720c299cdc68b733cf1
2018-03-14 22:22:43 +07:00
Vadim Yanitskiy a4d255269a L1CTL/L1CTL_CRYPTO_REQ: add key length and channel info
Previously, the L1CTL_CRYPTO_REQ message contained only a ciphering
algorithm and actual Kc key to be used. The key length was
calculated manually using the MSGB API.

Let's avoid manual calculations here, as it may cause unexpected
behavior if the message structure is changed. Also, let's fill
the UL header with minimal information about a channel, which
is going to be encrypted.

Change-Id: I5fab079907c5276322d3ec2b46cab81f10c7ed09
2018-03-14 22:22:39 +07:00
Igor Almeida e6372a2c24 layer23: initialize l2h/l3h pointers in rx_l1_rach_conf
Signed-off-by: Igor Almeida <igor.contato@gmail.com>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2014-09-06 23:47:15 +02:00
Andreas Eversberg fdf7d2f8a5 layer23: Send SIM APDUs via GSMTAP, if enabled 2013-01-12 08:59:05 +01:00
Andreas Eversberg 43b368b66d fix: Use only single CCCH block to determine path loss
The downlink singalling failure counter DSC is decremented by 4
in case of unsuccessfull decoding of CCCH block and incremented
by 1 in case of successfull decoding of CCCH block. The initial
and maximum value of 90 requires to check the signal only once
per 51 multiframe.

If DRX would be supported, only a subset of 51 multiframes are
received, so the initial / maximum value of 90 must be reduced
accordingly.
2013-01-08 09:12:15 +01:00
Harald Welte 73a809e57b Tell L1CTL_FBSB_REQ the expected received signal level
As Dieter points out, this drastically improves the resiliance to high
receive levels on the C155.  We cannot blindly assume a received signal
level of -85 dBm if the BTS is 2m away and we actually receive -40 dBm.

This patch extends the L1CTL_FBSB_REQ data structure in layer 1 with the
respective field, as well as the l1ctl_tx_fbsb_req() API function called
from the various layer23 apps.

"mobile" and "bcch_scan" already did a PM request and thus know the
expected signal power.  "ccch_scan" and "cbch_sniff" apparently don't
do, so the -85 dBm constant is now hardcoded into the host-side source
code there, and should probably be fixed in a follow-up patch.
2012-11-20 10:13:44 +01:00
Sylvain Munaut ce60deff7b host/l1ctl: Make sure to initialize tn in neigh_pm_req
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2012-03-29 09:21:57 +02:00
Andreas Eversberg 8f77cbecb4 host/layer23: Removed local copy of LAPDm, using libosmocore instad
Since libosmocore already has LAPDm implementation, we don't need the
local copy of LAPDm code anymore.

Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-13 20:25:19 +01:00
Andreas.Eversberg 1a5461fb2b layer23: Add mobile support for sending / receiving voice frame through MNCC
Support GSM FR codec only so far.

Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-07-28 21:30:51 +02:00
Sylvain Munaut 98a1051475 l23/l1ctl: Add default values for audio_mode
Theses value should simulate the old behavior

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-07-28 21:30:50 +02:00
Andreas Eversberg 9548ac0a41 [layer23/mobile] Improvement and fixes of idle mode process
This patch introduces cell re-relection. When camping on a cell, it
scanns neighbour cells. If a 'better' cell is found, the cell is selected.
If the cell is in a different location area, a location upating is
performed under certain conditions.

The 'better' cell depends on various informations that are broadcasted on
the BCCH of a neihbour cell and of course the RX level. Most operators
don't set these informations, so the 'better' cell depend on a better
RX level for the same location area, or a much better RX level (6 dBm)
at a different location area.

There were many issues at the idle mode process that has been fixed.
Expecially when moving, the state machines got stuck, so no more cell search
was possible, or no further calls / location updating was possible.

In order to see the process of cell selection, enter the VTY interface and
enable the network monitor:

enable
monitor network 1  (where '1' is the instance of the MS)

In order to see the current state of the processes, enter:

show ms
2011-07-17 11:12:15 +02:00
Andreas Eversberg 87c597abf6 [layer23] Adding neighbour cell measurement to L1CTL interface. 2011-07-17 09:36:49 +02:00
Harald Welte a9da9b730d L1CTL is sending PH-DATA.ind, not PH-DATA.req up to LAPDm 2011-06-24 15:26:59 +02:00
Harald Welte 3538c38835 further decouple lapdm code from osmocom_ms and l1ctl
we introduce a new primitive layer betwen PH and DL, enabling the
use of the LAPDm code in applications that are not based on L1CTL
2011-06-23 23:55:20 +02:00
Harald Welte f36e4fe86c remove l1ctl data structure form l2_ph_chan_conf()
This brings us one step closer to de-couple LAPDm from L1CTL
2011-06-22 23:04:20 +02:00
Harald Welte 4d5f74375a remove l1ctl data structure from l2_ph_data_ind() 2011-06-22 23:01:18 +02:00
Harald Welte 7ad100b94e layer23: make LAPDm code mostly independent of 'struct osmocom_ms'
This is one step in the direction of re-using the lapdm code in osmo-bts.
2011-06-21 19:51:01 +02:00
Harald Welte 308f9e506e layer23: update to new GSMTAP API in libosmocore >= 0.3.1 2011-05-22 12:36:55 +02:00
Pablo Neira Ayuso a1d1680245 src: use namespace prefix osmo_* for utils
Summary of changes:

s/bcd2char/osmo_bcd2char/g
s/char2bcd/osmo_char2bcd/g
s/hexparse/osmo_hexparse/g
s/hexdump/osmo_hexdump/g
s/hexdump_nospc/osmo_hexdump_nospc/g
s/ubit_dump/osmo_ubit_dump/g
s/static_assert/osmo_static_assert/g
2011-05-15 17:33:26 +02:00
Pablo Neira Ayuso 404f634406 src: use namespace prefix osmo_signal*
Summary of changes:

s/signal_cbfn/osmo_signal_cbfn/g
s/register_signal_handler/osmo_signal_register_handler/g
s/unregister_signal_handler/osmo_signal_unregister_handler/g
s/dispatch_signal/osmo_signal_dispatch/g
2011-05-15 14:39:39 +02:00
Pablo Neira Ayuso ade79a0083 src: use new libosmogsm and include/osmocom/[gsm|core] path to headers
This patch changes include paths to get osmocom-bb working with
the current libosmocore tree.

Among all these renames, you can notice several tweaks that I
added on purpose, and that require some explanation, they are:

* hexdump() in osmocon.c and osmoload.c has been renamed to avoid
clashing with hexdump() defined in libosmocore.

* gsmmap now depends on libosmogsm. Actually I had to cleanup
Makefile.am because I was experiencing weird linking problems,
probably due to a bug in the autotools. With the change included
in this patch, I got it compiled and linked here correctly.

This patch has been tested with the phone Motorola C123 and the
following images files:

* firmware/board/compal_e88/hello_world.compalram.bin
* firmware/board/compal_e88/layer1.compalram.bin

Using the osmocon, bcch_scan and mobile tools.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2011-04-26 02:55:30 +02:00
Andreas.Eversberg 837710c285 [l1ctl] Adding missing msgb_free()
When a corrupt frame cannot be delivered, it is dropped. Also it must be freed.
2011-01-27 16:33:04 +00:00
Andreas.Eversberg 4df881932c [layer23] msgb_free() must in l1ctl.c must called after reading its header 2010-11-13 18:23:57 +00:00
Andreas.Eversberg a0246e07ff layer23: Use the new rach_req format in l1ctl and update l23 apps to use it
This removes an old hack

Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-10-30 17:32:09 +02:00
Andreas.Eversberg 6d4915b91b [layer23] Implementation of signal loss criteria as defined in TS 05.08
There are two criterions for lossing a signal, idle mode and dedicated mode.
A counter counts down when a frame is dropped, and counts up when a valid
frame is received on  certain channel. The loss criterion is reached, if the
counter reaches 0. The values added to / removed from the counter and the
limits depend on the process.
2010-10-12 08:26:48 +00:00
Andreas.Eversberg 86f4d80b7f [layer23] Increase sync tollerance by increasing freq_err_thresh1
This is a quick workarround to make synchronizing to a cell more reliable.
Without it, just a few cells will sync. When network search is restarted, no
more sync happens.  By increasing the freq_err_thresh1 to 10000, many cells
sync, even after the first network search.
2010-10-05 15:42:29 +00:00
Sylvain Munaut 9257fe53bf l1ctl: Add initial tch_mode value in DM_EST_REQ
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-09-28 08:04:18 +02:00
Andreas.Eversberg 942bfeab18 [layer23] Cleanup of various 'printf' debugging 2010-09-26 22:02:32 +00:00
Andreas.Eversberg 602dcf4d0d [layer23] Added support for changing TCH mode via L1CTL messages 2010-09-26 17:06:06 +00:00
Andreas.Eversberg 4ed601ae4e [layer23] Adding application generated measurement report
The cell provides SYSTEM INFORMATION 5* and 6. These are used to create a
list of neighbor cells to monitor. Because there is no neighbor cell
monitoring supported by layer1, the list has no valid results yet.

Currently the average RX level of received frames are used to generate a new
report every second. The report is transmitted to layer1 and used there
whenever a measurement report has to be transmitted.

The timing advance and the current transmit power (as requested by network),
is included with every report.
2010-09-26 10:35:46 +00:00
Andreas.Eversberg 0856c8a6a5 [layer23] SIM client completion
The SIM client is now complete. Because it usefull for multiple
applications, i moved it to the layer23/src/common directory.

The SIM reader works together with mobile process. Fixes were made.
Thanx to all for testing, finding bugs, and making it work as it is
supposed to do.

The current version uses special L1CTL messages to send and receive APDUs.
This will change in the future, when BTSAP interface is completed.

Please note that this client will not work until the layer1 SIM reader
fixes and extensions are committed.
2010-09-18 19:15:15 +00:00
Sylvain Munaut e746ca06ca layer23/l1ctl: Add the RX power to the DATA_IND debug print
Useful to know if bad data is due to ciphering/bad sync or to
no/marginal signal.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-09-14 21:21:42 +02:00
Sylvain Munaut 54ff7c5f60 layer23/l1ctl: Remove useless printf debug
There is a proper LOGP statement, no need for a printf

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-09-14 21:21:42 +02:00
Andreas.Eversberg fa686fd4c9 [layer23 / layer1] Added interface for changing crypto mode of DSP
The layer23 will now set crypto mode and key when CIPHERING MODE COMMAND is
received. After crypto mode has been set, CIPHERING MODE COMPLETE is sent.

NOTE: Layer1 implements only the interface, there is no functionality to it
yet.
2010-09-11 12:10:31 +00:00
Andreas.Eversberg 00b9d1e73f [layer23] L1CTL frequency change implementation in l1ctl.c 2010-08-21 15:06:46 +00:00