Commit Graph

163 Commits

Author SHA1 Message Date
Pau Espin f473ec9d7a Move llc_* fields from BTS to PCU
Change-Id: Iffb916e53fdf99164ad07cd19e4b35a64136307e
2021-01-18 11:54:57 +01:00
Pau Espin e891222920 Move fc_* fields from BTS to PCU
Change-Id: I816d49e732d0fc7a3c9aa1f0e9a83b83d25e6a32
2021-01-18 11:54:57 +01:00
Pau Espin 113fb419ec Move ns_dialect field from BTS to PCU
Change-Id: Iffb22b776b91f93d6d2a7ccfa47deeecc22c33f0
2021-01-18 11:54:57 +01:00
Pau Espin e8dcf64881 Move cs_adj* fields from BTS to PCU
Change-Id: I2b00a83279dccd4feeeeb95e34878c4405e7972c
2021-01-18 11:54:57 +01:00
Pau Espin 924aaad4bc Move T_defs_pcu from BTS to PCU object
Change-Id: I0cac5c12dff2e90b52d00383a00b4b94a9603a0a
2021-01-18 10:37:05 +00:00
Pau Espin ac3fd12026 Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.

This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.

This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.

The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.

Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-18 10:37:05 +00:00
Alexander Couzens 1e6c350a9f ns2: follow ns2 sns api changes
Related: OS#4472, OS#4890
Depends: libosmocore.git I71cdbfb53e361e6112fed5e2712236d797ef3ab2
Change-Id: Id530e5497c17885817493f8a8a9436bc187c88aa
2020-12-16 12:51:08 +01:00
Alexander Couzens b644fd1f09 ns2: follow changes to add a unique name to all binds
Related: OS#4472, OS#4890
Depends: libosmocore.git I8f1d66b7b3b12da12db8b5e6bd08c1beff085b3e
Change-Id: I3638c7204db576116ba2e20dae27539ce6143bd7
2020-12-16 12:51:04 +01:00
Alexander Couzens 5012e07685 ns2: follow ns2 dialect changes
NS2 introduce a ns dialect to differentiate
between the 4 possible dialects.

Related: OS#4472, OS#4890
Depends: libosmocore.git Ia118bb6f994845d84db09de7a94856f5ca573404
Change-Id: I16dc82c38eb75c2b9d1197640a955fec7df84efc
2020-12-16 12:50:50 +01:00
Alexander Couzens 30d9a5989e NS2: rework handling of unknown primitive
Use prim_str() method to get the human readable string.
Define unhandled events with a nop in the switch()

Depends-on: Ibf610fbd929dddc4a4e235152447caff522d4eb2 (libosmocore)
Change-Id: I50188afb83ac142e22d4bda4e8050eb4de962e70
2020-12-01 12:07:18 +00:00
Alexander Couzens 4e8f2c310f gprs_bssgp_pcu: follow ns2 library changes
Depends-on: I18dfd40a2429cd61b7c4a3dad5f226c64296f7d8 (libosmocore)
Change-Id: I056fe624160f2fe01d405690eba5cc0032780837
2020-11-25 20:53:37 +00:00
Vadim Yanitskiy cb98894eb1 TLLI 0x00000000 is a valid TLLI, use 0xffffffff instead
The assumption that TLLI 0x00000000 is invalid and can be used
as the initializer is wrong.  Similar to TMSI, 0x00000000 is a
perfectly valid value, while 0xffffffff is reserved - use it.

According to 3GPP TS 23.003, section 2.4, a TMSI/P-TMSI with
all 32 bits equal to 1 is special and shall not be allocated by
the network.  The reason is that it must be stored on the SIM,
where 'ff'O represents the erased state.  According to section
2.6 of the same document, a local/foreign TLLI is derived from
P-TMSI, so the same rule applies to TLLI.

I manually checked and corrected all occurances of 'tlli' in the
code.  The test expectations have been adjusted with this command:

  $ find tests/ -name "*.err" | xargs sed -i "s/0x00000000/0xffffffff/g"

so there should be no behavior change.  The only exception is
the 'TypesTest', where TLLI 0xffffffff is being encoded and
expected in the hexdump, so I regenerated the test output.

Change-Id: Ie89fab75ecc1d8b5e238d3ff214ea7ac830b68b5
Related: OS#4844
2020-11-10 17:06:39 +00:00
Pau Espin 87eec1fd74 Get rid of bts->egprs_enabled
BTS simply notifies the PCU about the supported MCS, and PCU is
responsible for providing correct data formatting supported for the BTS
and the target MS.

Related: OS#4544
Change-Id: Ifcf23771bd23afc64ca6fea38948f98f2d134ecb
2020-11-04 21:39:43 +01:00
Pau Espin 343ec9b9fd Take into account BTS supported (M)CS values when retrieving the maximum
Change-Id: I2d3a8bbae2f9887400ce56d2f8303ea30abaecfa
2020-11-04 21:39:42 +01:00
Pau Espin d87722d03c pcuif: Improve BTS-supported CS/MCS handling
Take into account the MCS values supported by the BTS. In osmo-bts,
in general all MCS are enabled if "mode egprs" is selected in BSC,
and none otherwise.

Change-Id: Ie8f0215ba17da1e545e98bec9325c02f1e8efaea
2020-11-04 21:39:42 +01:00
Alexander Couzens a2848546d2 NS2: follow the change of ownership
When receiving a primitive from the NS2 layer
the PCU must free the msg buffer if given.

Change-Id: I180433735bfbb3375c41318d7a7709d5845199ba
2020-11-03 22:37:49 +00:00
Vadim Yanitskiy 2c1fed20ab BSSGP: constify argument 'tp' of gprs_bssgp_pcu_rx_paging_{cs,ps}
Change-Id: I24e48964a0ff86c2ca962ab3928d07b1c9200390
2020-11-02 09:10:00 +00:00
Vadim Yanitskiy e9bddabc01 BSSGP: use tlvp_val8() in gprs_bssgp_pcu_rx_paging_cs()
Change-Id: Ic1e37cb9938323c9b9f0466be5cf7251a6db1008
2020-11-02 09:10:00 +00:00
Alexander Couzens 5bece2a0ed Rework NS configuration over the info indication
Add support of the second NSVC in the info indication.
Add support to update a previous NS configuration.
Allow to update of a NS-VC while the NSE is still available over the
second.

Depends-on: I917f25ebd1239eae5855d973ced15b93731e33a0 (libosmocore)
Depends-on: I3a0cd305fd73b3cb9ec70246ec15ac70b83e57f2 (libosmocore)
Depends-on: I5a2bb95d05d06d909347e2fb084a446ead888cb3 (libosmocore)
Depends-on: I54f110acc3acccb362f6e554324d08cc42b7c328 (libosmocore)
Depends-on: Ia00753a64b7622a0864341f51ea49b6963543755 (libosmocore)
Depends-on: Ic8f6f8aca10da23a18fab8870be7806065a34b47 (libosmocore)
Depends-on: I5f67e6a9bf4cb322bd169061fee0a528012ed54d (libosmocore)
Change-Id: I589ebaa2a2b7de55b7e4e975d8fd6412dd5f214b
2020-10-13 08:45:30 +00:00
Vadim Yanitskiy 974cc7b324 gprs_bssgp_pcu: fix: do not crash on receipt of subsequent INFO.ind
It's expected to receive subsequent INFO.ind messages at run-time,
e.g. when a dynamic TCH/F_TCH/H_PDCH timeslot is switched from
PDCH to TCH/F or TCH/H, osmo-bts would send us INFO.ind with the
updated PDCH slot-mask indicating that this timeslot is disabled.

In gprs_nsvc_create_and_connect(), do not bind() on the received
NSVC address unconditionally - we may already be bound to it.
Instead, return early and keep everything unchanged.

I don't know how the PCU is supposed to handle NSVC address change,
at least the new NS2 library does not handle this internally, nor
it provides any API for that.  Let's leave it for later.

Change-Id: I159138e41e147cd30212da548b0ccd3f81d61b4e
Related: I4c3bc883d795e5d1ee5ab175ac03684924692a7c
Fixes: Ib389925cf5c9f18951af6242c31ea70476218e9a
Related: SYS#5108
2020-10-10 06:16:11 +07:00
Vadim Yanitskiy d038361e95 struct gprs_rlcmac_bts: remove unused 'nsei' field
The code in gprs_nsvc_create_and_connect() stores NSEI there for
no reason, despite it's already stored in struct gprs_ns2_nse.

Change-Id: Ib30152a12384cf0448104a1ee1cfb949f4a27553
2020-10-10 05:05:33 +07:00
Vadim Yanitskiy 0d0ac1b949 gprs_bssgp_pcu: fix possible memleak in gprs_nsvc_create_and_connect()
Change-Id: I9f44cd22b1353ded6eeb2fe9f8dd4818de758003
2020-10-10 05:05:33 +07:00
Vadim Yanitskiy 194b6f06a0 gprs_bssgp_pcu: make osmo_sockaddr local/sgsn arguments const
Change-Id: I40e51de300533cfcbb3c9f90a0858a489a3c2b6b
Depends: I0df6a00ac1830bd64a10b9336b827e113fa772bb
2020-10-09 21:43:09 +00:00
Alexander Couzens 290d9030e9 Use the new NS2 lib
Depends: Id7edb8feb96436ba170383fc62d43ceb16955d53 (libosmocore)
Depends: I2a9dcd14f4ad16211c0f6d98812ad4a13e910c2a (libosmocore)
Change-Id: Ib389925cf5c9f18951af6242c31ea70476218e9a
2020-10-06 16:38:38 +02:00
Pau Espin 1d68cdff92 Fix recent typo preventing MS from registering
Fixes: 0052051c07
Change-Id: Icbbf7340d78ef709ea00d527036533a14e9c21f9
2020-08-26 13:43:39 +02:00
Neels Hofmeyr 59fc0bda6e paging: pass struct osmo_mobile_identity, not encoded IE bytes
In get_paging_mi(), before this, an encoded buffer of Mobile Identity bytes is
returned. Code paths following this repeatedly decode the Mobile Identity
bytes, e.g. for logging. Also, in get_paging_mi(), since the TMSI is read in
from a different encoding than a typical Mobile Identity IE, the TMSI was
manually encoded into a typical Mobile Identity IE. This is essentially a code
dup of osmo_mobile_identity_encode(). Stop this madness.

Instead, in get_paging_mi(), return a decoded struct osmo_mobile_identity. Code
paths after this use the struct osmo_mobile_identity directly without repeated
decoding.

At the point of finally needing an encoded Mobile Identity IE (in
Encoding::write_paging_request()), do a proper osmo_mobile_identity_encode().

Since this may return errors, add an rc check for the caller of
write_paging_request(), gprs_rlcmac_paging_request().

A side effect is stricter validation of the Mobile Identity passing through the
Paging code path. Before, invalid MI might have passed through unnoticed.

Change-Id: Iad845acb0096b75dc453105c9c16b2252879b4ca
2020-08-24 01:12:16 +00:00
Neels Hofmeyr 0052051c07 use new osmo_mobile_identity api (avoid deprecation)
Note: subsequent patch Iad845acb0096b75dc453105c9c16b2252879b4ca will change to
passing a struct osmo_mobile_identity in the Paging code path, instead of
passing the encoded IE data.

Change-Id: Ibb03b8e601160427944f434761ca59811d1fc12f
2020-08-21 16:40:14 +02:00
Pau Espin 2ae8337669 Get rid of class GprsCodingScheme
We have same kind of object splitted into two layers, in coding_scheme
and gprs_coding_scheme. Let's merge them together and get rid of the
class, which is not really useful because it's only a set of functions
operating on one enum value.

This change also fixes gcc 10.1.0 error about memseting a complex type
in rlc.h init().

Change-Id: Ie9ce2144ba9e8dbba9704d4e0000a2929e3e41df
2020-05-20 11:07:07 +00:00
Vadim Yanitskiy 0b25f693b3 BSSGP: fix: properly encode P-TMSI in RR Paging Request
The TMSI/P-TMSI IE in BSSGP PAGING-PS/CS comes without the MI type
header, that must be present in RR Paging Request. Prepend it.

TTCN-3 test case: I7fbec5b2c5c3943a7413417b623f55c135c152d7

Change-Id: I97fd5ffc15a4a58112d7c37c69b7ac42b0741a0e
2020-03-27 14:55:22 +00:00
Vadim Yanitskiy f497412f20 BSSGP: cosmetic use OSMO_IMSI_BUF_SIZE from libosmocore
Change-Id: I2079118100a3422e9c2ee63a5ac74e3ee81080b3
2020-03-27 14:55:22 +00:00
Pau Espin de7bb75ccf Use downlink BSSGP RA Cap IE
This commit is basically a revert of
f4bb42459c, which disabled the code. That
commit claimed the SGSN may have providen inacurate or wrong data at the
time, but then it should be fixed in the SGSN.

Related: OS#1525, OS#3499
Change-Id: Ie36ae23203110018d4b5ae47591e0a64989e23a0
2020-03-18 14:01:24 +01:00
Pau Espin 1de6873810 Use clock_gettime(CLOCK_MONOTONIC) and timespec everywhere
We should really be using monotonic clock in all places that
gettimeofday is used right now. Since clock_gettime() uses timespec,
let's move all code to use timespecs instead to avoid having to convert
in several places between timespec and timeval.
Actually use osmo_clock_gettime() shim everywhere to be able to control
the time everywhere from unit tests.

Change-Id: Ie265d70f8ffa7dbf7efbef6030505d9fcb5dc338
2020-03-16 10:31:56 +00:00
Vadim Yanitskiy 3568fcfa7d gprs_bssgp_pcu: fixup: fix length check in gprs_bssgp_pcu_rx_dl_ud()
Change-Id: I7d49b27a615350a7707154aa3cc903db7c1df374
Fixes: I7f84bd776cc780a45880f136107f6e0bc56241d1
2020-02-03 16:39:12 +07:00
Vadim Yanitskiy 3898cd6843 gprs_bssgp_pcu: fix invalid use of non-static data member 'frame'
The 'gprs_llc' is defined as a pure C structure with C++ specific
extensions (methods), so it's rather a class. Accessing its field
'frame' statically causes Clang to throw a compilation error:

  gprs_bssgp_pcu.cpp:111:29: error: invalid use of non-static data member 'frame'
      if (len > sizeof(gprs_llc::frame))

Let's avoid this and use LLC_MAX_LEN as the size limitation.
God knows what to expect from such a mix of C++ and C...

Change-Id: I7f84bd776cc780a45880f136107f6e0bc56241d1
2020-01-29 06:17:50 +07:00
Pau Espin 771de1f439 Support PAGING-CS and PAGING-PS on on PTP-BVCI
Related: OS#2403
Change-Id: I5c52b5af740460c48bb3ba858243b1d20e624268
2020-01-06 10:26:46 +00:00
Pau Espin 65a0d1d19b Support Gb PAGING-CS
The paging is sent over PACCH towards MS with an active TBF.

Related: OS#2406
Change-Id: I9501e02e1d7f6944497e724dbccb9a19c3f5221f
2020-01-06 10:26:46 +00:00
Pau Espin 5530f12f71 Allow Gb PAGING-PS without P-TMSI
P-TMSI is optional IE, but IE is mandatory and hence always available.
Since the encoding is actually a Mobile Identity, the IMSI is used in
case P-TMSI is not available.

Change-Id: I4dbf8db04e81f98352a42ce34a5d91326be9bfd1
2020-01-06 10:26:46 +00:00
Pau Espin d7c3265223 Pass paging group instead of imsi where later is not needed
Change-Id: Id0663a81f439f2d0b893b0d34f85a6db1927ef8e
2020-01-06 10:26:46 +00:00
Pau Espin db12f254ce Log BVCI PTP value upon msg recv
Change-Id: I47c5902112d568cd5a48e003010d8085b02d64e8
2020-01-01 16:10:05 +00:00
Pau Espin 3f064f516d prs_bssgp_pcu.cpp: Mark priv funcs as static and remove trailing whitespace
Change-Id: I93b7ee33cc33c773675c85ace7b8f1afa86fbf06
2019-12-10 17:09:51 +01:00
Vadim Yanitskiy 0bf622e057 gprs_bssgp_destroy(): fix memleak and NULL-pointer dereference
So far there was a memory leak, because free()ing 'the_pcu.bctx'
would cause ASAN to complain. And that's reasonable, because it
needs to be freed properly. Moreover, 'the_pcu.bctx' may simply
be uninitialized in some cases, e.g. when OsmoPCU is terminated
before connecting to the SGSN.

Let's use the new bssgp_bvc_ctx_free() from libosmogb.

Change-Id: I274e79e1746c7678b81720ec11e8a564befe38ba
Depends: Ia78979379dbdccd6e4628c16f00d0c06d9212172
2019-11-10 09:04:21 +00:00
Vadim Yanitskiy ce27d1e126 BSSGP: properly print BVCI for signalling messages (BVCI=0)
Change-Id: I4ac0f48d2e62cd0545e8a1e1b26c9e43ef5e8dde
2019-11-08 04:18:46 +07:00
Vadim Yanitskiy ef444142c8 BSSGP: do not reject SUSPEND ACK / NACK messages
Both BSSGP SUSPEND ACK and NACK messages use BVCI=0 (signaling),
which always exists. Claiming that BVCI=0 is unknown is wrong.

Instead of adding both BSSGP_PDUT_SUSPEND_{ACK,NACK} to the 'if'
statement, let's rather avoid rejection for all BVCI=0 messages,
as there may be other unlisted message types.

Change-Id: I780657c1e8f67e0bef0e92a31db7ba61b57d7ec4
Related: OS#4111
2019-11-08 04:11:20 +07:00
Pau Espin 5211d9deca Use osmo_tdef for BSSGP T1 and T2
Change-Id: I477e5b702c8b956136d93fc1cee01991233e381f
2019-09-16 14:21:21 +00:00
Pau Espin a8892a69b3 Use proper API osmo_timer_setup() to set up timer struct
Change-Id: Idd2b0c5247870bee3b3c3e460a6731ee50a47404
2019-09-05 16:21:49 +02:00
Vadim Yanitskiy 2c076bcb4d gprs_bssgp_pcu_rx_dl_ud(): use OSMO_IMSI_BUF_SIZE
Change-Id: Ia1da9f005b7f801872c542d31cc8eabd859d997a
2019-07-24 20:39:57 +00:00
Vadim Yanitskiy 6170ac041f gprs_bssgp_pcu.cpp: check return code of gsm48_mi_to_string()
Change-Id: Id1ad279ce9bef38eb3d11ac62337276207e8d8bd
2019-07-24 20:39:57 +00:00
Vadim Yanitskiy aad87b66e8 gprs_bssgp_pcu_rx_dl_ud(): fix: BSSGP_IE_IMSI is optional
Change-Id: I940d220a399166122f33e67a222dd572085e1401
2019-07-24 20:39:57 +00:00
Harald Welte 7b7f2048b8 bssgp: Fix dead code: PDUT_STATUS can never reach this part
Change-Id: Iae4332cd3b87f37164655d3df16554de4876159d
Closes: CID#188855
2019-07-21 09:26:56 +02:00
Max f3038e7b2a Use libosmocore for IMSI parsing
Change-Id: Iec5c65776fc54b2f9e5dd55c711ace2471662db1
2019-07-16 04:19:21 +00:00