Commit Graph

1459 Commits

Author SHA1 Message Date
Vadim Yanitskiy 72ec18ce5a sba: fix possible memleak in SBAController::alloc()
Change-Id: I417eda155cd5b1e46dd0b05db3f507abd79121d1
2020-04-20 11:25:05 +07:00
Vadim Yanitskiy b30f28f38d l1if: fix pcu_rx_rach_ind(): use proper format string specifiers
Change-Id: If95362ef4cc203a60856d6b47d95d441813a5c19
2020-04-02 05:42:57 +07:00
Pau Espin c374ab00ac csn1: Remove code block from CSN_NEXT_EXIST_LH
It was removed in wireshark.git e8407dd6c1378427daee77e8de540d0b5f7a0b73
and it's not there anymore in current master.

Change-Id: I73f4eeca3fd4f00a5bc4f06ef7a9bb9b8a70e37b
2020-03-30 10:08:02 +00:00
Pau Espin c8280a538a csn1: Properly verify CSN_BITMAP length
Change-Id: I9f7672b534f9345caff99095504749eebad25adb
2020-03-30 10:08:02 +00:00
Pau Espin f5e275aec0 csn1: verify enough bits present to decode whole CSN_UINT_ARRAY
Change-Id: I4a762a8fec4153b53e10df1ec8ba3708c1f47649
2020-03-30 10:08:02 +00:00
Pau Espin 70a211747b csn1: Fix Several typos & whitespace
Change-Id: Ibe31d52d4a5a4015196d73681082f68b99a80c77
2020-03-30 10:08:02 +00:00
Pau Espin 99eb353337 rlcmac: add dissection of 2G->3G/4G PS handover
Port from wireshark.git 428ee66ae1c524b49f9043729b1f1e9b4f52f409, from
Pascal Quantin.

The original commit is also changing the RRC_Container field to
M_CALLBACK, but we leave them as M_VAR_ARRAY since the callback is
basically used to add more dissection information in wireshark.

Change-Id: I0f374e78300efddff00c4df26a401adcdee18a12
2020-03-30 10:08:02 +00:00
Pau Espin f3ac06bbaf rlcmac: support decode FDD_CELL_INFORMATION of "UTRAN FDD Description
Port of patch (+ later fixes squashed) of wireshark.git commit
dea5452b95dfaf18e38670a8e2b3b38f9175fdfd, from Lei Chen:
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6856

Squashed wireshark.git fix commits:
774be29de0b4d93d01aecb1518c41d7d551071a9
51c31cd7bd3d8fc196a9f90a8af466ad84e9e6a8
6aca10831f86c562970b13efa811f46e25ee3091
c1ceac58cdb77051e9bd14c1f6f7669cf5779a86

Change-Id: I08523bc1bbdffde479ef974b4c7b56cfa5639591
2020-03-30 10:08:02 +00:00
Pau Espin b2653fe619 Move gsm_rlcmac.cpp -> .c
Original file from wireshark.git (packet-gsm_csn1.c) is being built and
maintained as a C file. There's no real need for us to maintain it as a
C++, and doing so will make both files derive over time (as already
happened). Let's keep it as a C compiler (which btw seems to be more
strict) to make it easier to port patches back and forth wireshark.git.

Take the chance to move some declarations we added to csn1.h to be able
to build it out of wireshark. Let's keep those in a separate header file
to ease looking for differences.

Change-Id: I818a8ae947f002d35142f9f5473454cfd80e1830
2020-03-30 10:08:02 +00:00
Pau Espin 799cf8221a gsm_rlcmac: Disable unused CSN1 descriptors
When switching to C compiler, it will warn/error. Use #if 0 as in the
original wireshark.git epan/dissectors/packet-gsm_rlcmac.c code.

Change-Id: If1be50947c02208f15892d99edeb394fb4f52b75
2020-03-30 10:08:02 +00:00
Vadim Yanitskiy d2e50e7f21 fix: properly include pure C headers from C++ code
Header files included from libosmocore may potentially contain
some language constructions allowed in C but not in C++, such
as type casting. Let's add 'extern "C" { ... }' and be safe.

Change-Id: I7197f7b34f30b49d5397506ce9d67cbf0e2cc196
2020-03-29 01:46:36 +07:00
Pau Espin a0cbde700a tbf.cpp: Include c++ <new> header required for new operator's replacement type
Including the <new> header is required as explained by the c++ specs [1]

osmo-pcu/src/tbf.cpp: In function ‘gprs_rlcmac_ul_tbf* tbf_alloc_ul_tbf(gprs_rlcmac_bts*, GprsMs*, int8_t, uint8_t, uint8_t, bool)’:
osmo-pcu/src/tbf.cpp:1002:39: error: no matching function for call to ‘operator new(sizetype, gprs_rlcmac_ul_tbf*&)’
 1002 |  new (tbf) gprs_rlcmac_ul_tbf(bts->bts);
      |                                       ^

Most of the times this issue is not detected because other STL headers
are already including <new>.

[1] http://www.cplusplus.com/reference/new/operator%20new/

Change-Id: Ie5fb536ae29dcf40e2a0dbe67432bebd61b8c7aa
2020-03-27 15:06:41 +00:00
Vadim Yanitskiy ce160147f4 pdch: cosmetic: use GSM_MI_TYPE_* constants from libosmocore
Change-Id: I1d85c8eded68bc8aa8e90c33b36d335fa775ded2
2020-03-27 14:55:22 +00:00
Vadim Yanitskiy d71c566ee6 pdch: fix packet_paging_request(): properly print paging MI
This problem problem was discovered by the Undefined Behavior Sanitizer:

  pdch.cpp:210:4: runtime error: load of misaligned address
                  0x60c00002abf2 for type 'uint32_t',
                  which requires 4 byte alignment

Do not convert TMSI to number, use osmo_mi_name() from libosmocore.
Also use this function to print other MI types (IMSI or IMEISV).

Change-Id: Icf8836f216793e342b239c8e6645aac1e82bf324
2020-03-27 14:55:22 +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
Keith Whyte 2b6acd8873 Don't check ul_control_block before decoding into it.
This patch corrects an error introduced in
6fd8ffb6fe
That commit allowed us to send the data over GSMTAP even
if the Uplink Control Block had invalid content,
that is to say, if decode_gsm_rlcmac_uplink() returned error.

However the check for ul_control_block->u.MESSAGE_TYPE
was place before decode_gsm_rlcmac_uplink()

Change-Id: Ic47602e5c6a13571b92c0a939fc3514110b82444
2020-03-26 23:32:49 +00:00
Pau Espin e5e2f747c3 csn1.h: Fix trailing whitespace
Change-Id: If17d36378fabeb7d22a513b93b0ecfde899df520
2020-03-26 16:03:56 +01:00
Pau Espin 24fa27453f gsm_rlcmac.cpp: Avoid declaring variable in for loop
That's only allowed under C++.

Change-Id: I0da8849a0fb7f9a7ee5e726edea87e91dc411ea8
2020-03-26 16:03:56 +01:00
Pau Espin 980ef1e38b cosmetic: Do not indent header includes inside extern C block
Change-Id: I3091d917a13e45b3aef8e52a53dcafa308581652
2020-03-26 16:03:56 +01:00
Pau Espin 007056e4ad gsm_rlcmac: Use 'struct bitvec' instead of 'bitvec'
The later is only accepted when compiling as c++.

Change-Id: Ib5004643d4eff3bc9d11b66ddaf262f1c0d2aef6
2020-03-26 16:03:27 +01:00
Pau Espin 754b093d16 pcu_l1_if.cpp: Add missing header ctype.h
The file uses the isdigit() function.

Change-Id: Id06ea25969ad9b964b3207479604132d25160f24
2020-03-26 14:49:04 +01:00
Pau Espin de63548f04 rlcmac: Rename field to MS RA Cap2 in Additional_MS_Rad_Access_Cap_t
This fix was spotted by wireshark.git developers while reviewing port of
osmo-pcu commit e50ce6e45c.

Related: https://code.wireshark.org/review/c/36574/
Fixes: e50ce6e45c

Change-Id: Ic5fc3252f61b6a042d9c3def7a6a32b311dd9d9e
2020-03-25 20:26:07 +01:00
Pau Espin 10ec506cc9 cosmetic: rlcmac: Fix comment typo and whitespace introduced recently
Change-Id: Ie56898e11e2c9426393af0f6558d340c454fe6c4
2020-03-25 14:32:30 +01:00
Pau Espin e50ce6e45c rlcmac: Introduce MS Radio Access Capabilities 2 to fix related spare bits
There's two variants for the Ms Radio Access Capabilities.
* The usual encoding with spare bits (usually to fill up to octet boundary)
as defined in TS 24.008 Table 10.5.146
And there's too:
* MS Radio Access Capabilities 2 IE from TS44.060 section 12.30, which is
the same but removing all spare bits, and which is used in messages like
Packet Resource Request and Additional MS RAC messages.

The later is used basically for messages having extra IEs after the MS
Radio Access capabilities IE, since they are encoded immediatelly
afterwards.

So this patch does:
* Adds the expected spare bits (M_PADDING) to MS_Radio_Access_capability_t
* Creates a new MS_Radio_Access_capability2_t without padding
* Updates code to use the new "2" version where needed.

Note RLCMACTest long de/encoding line logs change only because the name
of the struct changes (the "2" is added).

Change-Id: Ibd756f80a03452a651e2771dbc628d701e55ac4b
2020-03-23 19:02:01 +01:00
Pau Espin 20848c3ae5 rlcmac: Log names of de/encoded rlcmac packet types
Change-Id: I6a6e79d7e12cd5e8e969bf0eaa30ddac6b0aa7d3
2020-03-23 19:02:01 +01:00
Pau Espin 7faa5da209 rlcmac: Fix bug receiving RA cap
It seems the assumptions regarding maximum number of RA capabilitites
in one message were wrong. Doing some rough calculations, each RA
capabilitiy value (without extensions) can take around 20ish bits, which
means for a message containing up to 52 bytes that quite a lot of
different values could be theoretically fed in. Let's be safe and
increase the array size to be able to handle all different access
technologies listed in See TS 24.008 table 10.5.146 following
restrictions:
* "The MS Radio Access capability is a type 4 information element, with a maximum length of 52 octets."
* "Among the three Access Type Technologies GSM 900-P, GSM 900-E and GSM 900-R only one shall be present."
* "the mobile station should provide the relevant radio access
  capability for either GSM 1800 band OR GSM 1900 band, not both".

Wireshark requires similar fix (it's not important though because it
currently uses another ad-hoc decoder for RAcap).

Related: OS#4463
Change-Id: I5334eaacfbc238fae8bea50c9e9667c2117f81ff
2020-03-23 19:01:58 +01:00
Pau Espin efad80bfbf csn1: Validate recursive array max size during decoding
This way if CSN1 encoded bitstream contains more elements than what the
defintion expects it will fail instead of overflowing the decoded
buffer.

RA cap struct placed in unit test is taken from a real android phone
sending the value when attaching to the network. Then SGSN sends it back
and osmo-pcu would crash similar to unit test:
*** stack smashing detected ***: terminated
 Process terminating with default action of signal 6 (SIGABRT): dumping core
at 0x4C62CE5: raise (in /usr/lib/libc-2.31.so)
by 0x4C4C856: abort (in /usr/lib/libc-2.31.so)
by 0x4CA62AF: __libc_message (in /usr/lib/libc-2.31.so)
by 0x4D36069: __fortify_fail (in /usr/lib/libc-2.31.so)
by 0x4D36033: __stack_chk_fail (in /usr/lib/libc-2.31.so)
by 0x124706: testRAcap2(void*) (RLCMACTest.cpp:468)

Related: OS#4463
Change-Id: I9fe0e55e0a6a41ae2cc885fba490c1d4a186231e
2020-03-23 15:34:11 +01:00
Pau Espin 81b40cbaf3 rlcmac: Don't pass array element to CSN1 descriptors
This way the macros can be used to access the arrays themselves and
calculate its static size to enable validation later.

In the case of Packet_Access_Reject_t, modify the description to use a
M_REC_TARRAY_1 object to get rid of access to 2nd element. The new
description is the correct one, since the first element is mandatory
according to TS 44.060 Table 11.2.1.

Change-Id: I6f10350d4734360c7a15a702c72b59efd84987ee
2020-03-23 15:29:48 +01:00
Harald Welte 570f9135cd csn1.c: Almost all of the logging is DEBUG, not NOTICE
low-level text decodes of CSN.1 messages certainly are not NOTICEable
events, but rather something used for debugging.

Right now we get various text CSN.1 log output of osmo-pcu in it's
default configuration.  Despite all log levels being relatively high
(NOTICE), we still see those messages as they simply are logged
at the wrong level.

Related: OS#2577
Change-Id: I7b42c9e21ad8d8a5b54e7a3b68490934ce3d3198
2020-03-19 15:09:45 +01: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 29aeb901e4 csn1: fix: do not return 0 if no bits left in the buffer
Both csnStreamDecoder() and csnStreamEncoder() shall not return 0
prematurely if no more bits left in the input / output bit-vector.

Returning CSN_ERROR_NEED_MORE_BITS_TO_UNPACK might make more sense,
however we don't know in advance (i.e. without entering the loop)
whether it's an error or not. Some CSN.1 definitions have names
like 'M_*_OR_NULL', what basically means that they're optional
and can be ignored or omitted.

Most of the case statements do check whether the number of remaining
bits is enough to unpack / pack a value, so let's leave it up to
the current CSN_* handler (pointed by pDescr) if no bits left.

Return CSN_ERROR_NEED_MORE_BITS_TO_UNPACK only if the number of
remaining bits is negative as this is an error in any case.

Change-Id: Ie3a15e210624599e39b1e70c8d34efc10c552f6c
2020-03-11 19:55:55 +00:00
Vadim Yanitskiy 773cb74ec8 rlcmac: fix encode_gsm_*(): do not suppress encoding errors
Change-Id: Ieec8e6e0823c6f6985f9d343af6d503b8fe9e6ab
2020-03-11 19:55:55 +00:00
Vincent Helfre 1145fd263c gsm_rlcmac: improve dissection of MS RA Capability IE
Port from wireshark.git de028e81c53f9c45ccc5adb3bffd2f16ae2017bf

This commit breaks transcoding of the test vectors containing
the MS RA Capability IE due to the reasons explained in [1].

The more fields we add, the longer gets the output of the CSN.1
encoder. This is not critical, since we never need to encode
messages containing the MS RA Capability IE on practice.

[1] Ibb4cbd3f5865415fd547e95fc24ff31df1aed4c0

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: Ibb4cbd3f5865415fd547e95fc24ff31df1aed4c0
2020-03-07 05:04:40 +07:00
Vadim Yanitskiy 2679ec0a9f csn1: fix csnStreamDecoder(): skip bits unhandled by serialize()
This change fixes a bug that was reported by Keith Whyte and
confirmed in [1]. The problem is that a user-defined handler
in case of CSN_SERIALIZE may parse only a part of the given
bit-stream, leaving some bits unhandled. This is expected
because the sender (i.e. the MS) may use more recent RLC/MAC
message definitions containing new fields at the end.

Those bits that were left unhandled by serialize() shall not be
interpreted as continuation of the message, they shall be skipped.

Note that the encoded vector in the RLCMAC unit test still does
not match the original one. That's a known bug explained in [2].

[1] If5873355d52d7ddb06c2716154a88d34100f6ab5
[2] Ic46d6e56768f516203d27d8e7a5adb77afdf32b7

Change-Id: Id4cc042fed68fc54aca0355dcb986cab3f6b49ea
Related: OS#4338
2020-03-06 21:49:04 +00:00
Keith Whyte 6fd8ffb6fe Send UL-CTRL Packet to GSMTAP even if we fail to decode.
Move the call to send_gsmtap() before the call to decode_gsm_rlcmac_uplink() as if
the latter returns error we return and never get to see the packet on the GSMTAP.

Change-Id: Ia6af9f40590f28fcae3fef50d9c601d8435412cd
2020-03-05 19:51:06 -06:00
Pau Espin 0daf913e0c gsm_rlcmac: fix Packet_Resource_Request_t: s/Slot/I_LEVEL_TN/
This is how this field is named in Wireshark.

Change-Id: I140443c48af8e4bb1b6279e6de986879b7d9c276
2020-03-02 13:33:23 +00:00
Vadim Yanitskiy b47e53b5fa tests/rlcmac: also verify encoding of MS RA Capability
The main idea of this change is to demonstrate a weakness of the
CSN.1 codec that most likely causes a unit test breakage in [1].

The problem seems to be that the transitional structures, where
the CSN.1 decoder stores the results, do not contain any details
about presence of the optional fields (such as M_UINT_OR_NULL).

In other words, it's impossible to know whether some optional
field is omitted in the encoded message (NULL), or is it just
set to 0. This means that the encoder will always include all
optional fields, even if they're not present in the original
message.

[1] Ibb4cbd3f5865415fd547e95fc24ff31df1aed4c0

Change-Id: Ic46d6e56768f516203d27d8e7a5adb77afdf32b7
2020-03-02 13:33:23 +00:00
Pau Espin 5fc6e010a5 llc_queue::{dequeue,enqueue}() refactor
As seen in OS#4420, setting the MetaInfo.recv_time outside of
llc_queue before calling llc_queue::enqueue() and later on using that
value in llc_queue itself at dequeue time is not a good idea, since it
can provoke errors if the recv_time was not set correctly.
For instance, LlcTest was not setting the value for recv_time on some
test, which ended up with a huge millisec value when substracting now()
from it:
"""
llc.cpp:215:29: runtime error: signed integer overflow: 1582738663 * 1000 cannot be represented in type 'long int'
"""
This issue only appeared when started building on a raspberrypi4.

Let's better set/store the MetaInfo.recv_time internally during
llc_queue::enqueue(). Then, enqueue() only needs the
MetaInfo.expire_time, so let's change its arg list to only receive that
to avoid confusions.

Take the chance to move the llc_queue APIs to use osmo_gettimeofday,
since we need to fake the time now that the API itself sets that time.

Also take the chance during this refactor to disallow passing null
pointer by default since no user needs that.

Finally, update the LlcTest accordingly with all API/behavior changes.

Related: OS#4420
Change-Id: Ief6b1464dc779ff22adc2b02da7a006cd772ebce
2020-03-02 12:05:06 +01:00
Vadim Yanitskiy e60d9c7e9d gsm_rlcmac: fix misleading LOGP statement in decode_gsm_ra_cap()
Change-Id: I48fd701566e1364ce7fccaa3e3a1a0296b932988
2020-02-18 05:30:57 +07:00
Vadim Yanitskiy 1553049226 csn1: use proper format specifier for unsigned integers
Change-Id: I33f86b79e72394bdb7d99762f8ec21d80e06dc30
2020-02-17 19:40:15 +07:00
Vadim Yanitskiy 4b57b6da54 csn1: bitvec_get_uint() may return a negative, use %d
Change-Id: I3cfd66643ec140150a4089b0e1c493d911d3d7d4
2020-02-17 19:40:15 +07:00
Vadim Yanitskiy d8e5e8bb3b csn1: fix csnStreamDecoder(): update bit_offset in CSN_EXIST{_LH}
Found while doing differential analysis (comparison against the
original implementation from Wireshark).

Change-Id: Ibd0b7400d78f7873c2a8d45267332f511b5c6fbb
2020-02-17 18:35:37 +07:00
Vadim Yanitskiy e87066d01e csn1: fix csnStreamDecoder(): always keep remaining_bits_len updated
Found while doing differential analysis (comparison against the
original implementation from Wireshark).

Change-Id: I9f7fa9c3f2f4ff5213dded930cee7ec509b9d799
2020-02-17 18:35:37 +07:00
Vadim Yanitskiy 584daba8e9 csn1: fix csnStreamDecoder(): do not subtract no_of_bits twice
Found while doing differential analysis (comparison against the
original implementation from Wireshark).

Change-Id: Id2a4f03035cd8354d3fba0ad37571453d3986d21
2020-02-17 18:35:37 +07:00
Vadim Yanitskiy 39a65056da csn1: get rid of C++ specific code, compile with GCC
The implementation of CSN.1 codec was taken from Wireshark, where
it's implemented in pure C. For some reason it was mixed with C++
specific features, mostly using references in parameter
declaration. Not sure what are the benefits.

Change-Id: I56d8b7fbd2f9f4e0bdd6b09d0366fe7eb7aa327a
2020-02-17 02:31:15 +07:00
Vadim Yanitskiy 8a87f913bd tests/rlcmac: additionally match debug output of the CSN.1 codec
This would allow us to catch more bugs. Note that I had to remove
printing of pointer address to make the output deterministic.

Change-Id: I1a77441eb957353c919bc73f8e3a2e38f4a383a9
2020-02-17 02:30:58 +07:00
Vadim Yanitskiy 74bc150ab2 csn1: fix existNextElement(): use bitvec_get_bit_pos()
As was discovered recently (see OS#4388), bitvec_read_field()
would never return a negative value because its return type
is unsigned (uint64_t).

We don't really need to get more than one bit, so let's just
use the bitvec_get_bit_pos() instead.

Change-Id: I763a295cd955cd33f542292c85d97ff82f6b49bc
Related: OS#4388
2020-02-16 23:41:26 +07:00
Pascal Quantin fa5f91c05f gsm_rlcmac.cpp: fix global-buffer-overflow error reported by ASAN
Port from wireshark.git f751918476bdde65f2289b86245a3c30dace6730.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: I70d4ff3e137b5fd13d367bd4ea6ab501e81e7a87
2020-02-15 09:28:27 +00:00
Pascal Quantin fb65682d34 gsm_rlcmac.cpp: fix another global-buffer-overflow error reported by ASAN
Port from wireshark.git aa3bbe5aebdc180172e7956719b26199e4784fcc.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: I808ec66011cdfe8e1193298f7fb7e92d25b45be4
2020-02-14 19:42:33 +00:00
AndersBroman 2d075be3b8 gsm_rlcmac: Update : PACKET RESOURCE REQUEST to Release 14.0.0
Port from wireshark.git 07fc801684ebff7aff02505cdb2c120caea846e0.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: Iceb59c58406180bc57fe6eb27127b4d11a0a3df7
2020-02-14 19:38:48 +00:00
Vadim Yanitskiy 5574a58cd6 csn1: fix csnStreamDecoder(): catch unknown CSN_CHOICE values
After the recent changes [1], it was noticed that one of the unit
tests fails. In particular, a decode-encode cycle of Packet
Polling Request produces a different vector:

  vector1 = 49 13 e0 08 50 88 40 13 a8 04 8b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
  vector2 = 49 13 01 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
  vector1 == vector2 : FALSE

As it turns out, the original (input) vector itself is malformed
because it contails no valid identity, and thus violates the
specs. The CSN.1 decoder from Pycrate [2] throws an exception
while trying to decode it. I believe we should do the same.

Let's stop decoding the bit stream and return an error in case
if neither of a given list of the choice items matched.

[1] Ia0f8cc224a4c38e80699f834fd83d4c0d99322ea
[2] https://github.com/P1sec/pycrate

Change-Id: I420144773ed5e80372534e0f18db5e74cdb2999d
Fixes: OS#4392
2020-02-11 05:58:44 +07:00
Vadim Yanitskiy fee767f21c csn1: fix some mistaken CSN.1 error names
Change-Id: I3bd9954ee36212c94f0c4d91581da300c56fce60
2020-02-11 05:28:02 +07:00
Vadim Yanitskiy 9a530a2430 encoding: assert return value of bitvec_set_u64()
Change-Id: Ic0de3ae34f06e41aacacb917f5a0214623259bdc
Fixes: OS#182120
2020-02-10 14:52:33 +07:00
Vadim Yanitskiy 9cbfe11ee2 tbf: fix NULL pointer dereference in create_[ul|dl]_ass()
The problem is that bitvec_free() is not NULL-safe. Ideally we
need to fix it in libosmocore [1], but let's also fix it here,
so OsmoPCU can be safely used with older libosmocore versions.

[1] https://gerrit.osmocom.org/c/libosmocore/+/17114

Change-Id: I7647d17b3d03f8e193ef6e793a2d3c1967744eef
Fixes: CID#208181, CID#208179
2020-02-10 14:12:24 +07:00
Vadim Yanitskiy c74e217799 tbf: cosmetic: fix spacing in gprs_rlcmac_tbf::create_ul_ass()
Change-Id: Ice4c4db20551753fa4219e7a216309229f7a2ab5
2020-02-09 05:40:51 +07:00
Pau Espin ac2b866426 Fix trailing newline mess with LOGP(C) in rlcmac/csn1
Output was incorrect before this patch. LOPC was being called without
having any initial LOGP, and trailing newline was usually missing at the
end.

Since csnDecoder/encoder functions are recursive, it's difficult to
handle logging state in a coherent way inside them. Let's better simply
control start/end of logging related topics in the callers of those
functions, and simply use LOGPC everywhere in csn1.cpp.

Change-Id: I50da7560939fac360b7545e2a6bfaf45ed0c4832
2020-02-08 11:03:13 +00:00
Vadim Yanitskiy 3ff1a3c6d5 pcu_sock: cosmetic: fix typo in a comment message
Change-Id: Ia7e91d803152ac3f2af88f4552fced27f59d8270
2020-02-08 14:36:01 +07:00
Vadim Yanitskiy 8832c2e5d4 pcu_sock: fix memleak, allocate pcu_sock_state on stack
It was noticed that OsmoPCU leaks memory when trying to reconnect
to the BTS. It could be easily fixed, but we don't really need to
allocate the PCU socket state on heap as we never have more than
one connection.

Change-Id: Iea8930f443caa16f522f7c5375e0004e4e2315cb
2020-02-08 14:36:01 +07:00
Vadim Yanitskiy d83c8ffb6b VTY: install talloc context introspection commands
Change-Id: I2e1e26be1162b0fb695969e5ac265704adaf9d5c
2020-02-08 14:36:01 +07:00
Vadim Yanitskiy 1ec29c7324 VTY: get rid of pcu_vty_go_parent() / pcu_vty_is_config_node()
Since I2b32b4fe20732728db6e9cdac7e484d96ab86dc5, go_parent_cb()
is completely optional. It no longer has the task to determine
the correct parent node. The is_config_node() callback is no
longer needed too. Get rid of them.

Since Ic5e69a396df659933fd4d50298b9925e837a6861 we depend on 1.3.0.

Change-Id: Id7ce8c4e1ac43747ad40a06d01433c366da07b42
2020-02-08 14:36:01 +07:00
Vadim Yanitskiy 28b4d27209 csn1: fix csnStreamDecoder(): avoid conditional calls to bitvec_read_field()
As was discovered by pespin, changing logging level of DCSN1 makes
the CSN.1 decoder behave differently (see OS#4375). In particular,
this makes RLCMACTest (encode / decode test) fail.

I did a quick investigation and noticed that some of the logging
statements call bitvec_read_field(). By definition this function
moves the internal pointer (current bit position) of a given
vector and increments readIndex by a given amount of bits.

The problem is that LOGPC would not evaluate its format string if
the logging message is not going to be printed, e.g. if a given
logging level is lower than the current one, or in case if
logging is not enabled at all.

The first two conditional calls to bitvec_read_field() are related
to CSN_PADDING_BITS, so that's not critical because padding is
always in the end of messages. The later two are related to
CSN_RECURSIVE_ARRAY and CSN_RECURSIVE_TARRAY respectively.

Let's use bitvec_get_uint() instead to keep readIndex unchanged.

Change-Id: Ia331048db9f790ca407fd341ced01df12d10a233
Fixes: OS#4375
2020-02-06 16:19:47 +00:00
Pau Espin ea9de4ae25 rlcmac: Transform a few LOGPC messages to LOGP
Those messages are self contained and don't need LOGPC.

Change-Id: Iea79e030563cd29bfc9750ff5c3e398c590a7307
2020-02-05 17:27:48 +01:00
Pau Espin 5e300ce565 Check return code of rlcmac decode/encode functions
Change-Id: Iabcb768bd714680aa768b35c786dea2015d1e451
2020-02-05 17:26:02 +01:00
Pau Espin 47de23266d rlcmac: Return error code from csn1 encoder/decoder
Change-Id: I0c5e1b870608b0622b239791effd5c5878e230bc
2020-02-05 17:25:59 +01:00
Pau Espin d636f74923 csn1.cpp: Rework ProcessError() function to print errors
Same API is kept to more easily keep code compatibility with wireshark's
packet-csn1.c implementation.

Change-Id: I1ce2c52e2357841aa1f31babfdce9011435f866b
2020-02-05 11:44:46 +01:00
Pau Espin f960d5bcf4 cosmetic: csn1.cpp: Fix whitespace
Change-Id: I663c5c20a878b3643db6a8ddd58e29bc9fe93d80
2020-02-03 14:39:38 +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
Vadim Yanitskiy f6b83a24a3 encoding: fix log_alert_exit(): do not treat error as format string
This is rather a cosmetic change aimed to make ASAN / Coverity happy.
In general, we never pass any input from an untrusted source.

Change-Id: I26d654da4c3bf5fd86a298c3027fd9820c932308
2020-01-29 06:17:49 +07:00
Vadim Yanitskiy 4590b91728 gsm_timer: fix comparison of constant LONG_MAX with an integer
It does not make sense since INT_MAX is always less than LONG_MAX.
Found by Clang [-Wtautological-constant-out-of-range-compare].

Change-Id: I9934e05aa050bf93b3c795376f5dca3a848a7e11
2020-01-29 06:14:54 +07:00
Vincent Helfre e525bf94ba gsm_rlcmac: add dissection of NAS container
Port from wireshark.git 575e4df4aa3392ffd09ca372859573f09f0a5c57

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: I2a05a057b6f441364502a96f9f34872c7e251a36
2020-01-28 18:16:24 +01:00
Pascal Quantin e4a243c02b gsm_rlcmac.cpp: fix an out of bounds access
Port from wireshark.git a4a5adb68b898f770e2addf9168d796979ebe237.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: I23fb2199fc8f9cc3e5bd475e2558ee8d482df1e1
2020-01-28 18:08:29 +01:00
Pascal Quantin 463746917f gsm_rlcmac.cpp: Do not skip too many lines of the CSN_DESCR when the field is missing
Port from wireshark.git c4ead251da7199cfd746d378c51eb8c30d09a6ba.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: Ib9b8eafd69d3b45b0d631ba9635689807b472b73
2020-01-28 18:03:59 +01:00
Anders Broman 8ea3cbe6b2 gsm_rlcmac.cpp: hanged all M_BIT macros to M_UINT, as M_BIT does not use the referenced hf.
Port from wireshark.git e97273a35d101516decbc7d98fcc6c6b3f193962.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: Id20d31e9ebd851b45d5f3280f3e229d8d7ae2cea
2020-01-28 17:42:34 +01:00
Pau Espin 034e32f0eb gsm_rlcmac.cpp: Fix trailing whitespace
Change-Id: I3b50cf386d417ba73b97f48b3000f69d9a54c8c9
2020-01-28 17:14:26 +01:00
Pascal Quantin 29248d6941 gsm_rlcmac: Enhance dissection of PSI1
Port of wireshark.git 7e9411fee3a101b53693210f7a38789fd4c70ba2.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: I89d488c1f349c556e40a9d13895b1309d5140212
2020-01-28 17:13:39 +01:00
Pascal Quantin cc76d412fd gsm_rlcmac.h: Remove Uplink messages from the RlcMacDownlink_t structure
(as they are part of the RlcMacUplink_t structure that is also used to call csnStreamDissector function).

Port from wireshark.git commit 9f8b638cfa8a660fb64c54dcadb83e6747db0a15.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: If46f8cc3f21f527f911dcac6ff1b78f182104a00
2020-01-28 16:46:51 +01:00
Gerald Combs bc4f3930a9 gsm_rlcmac.h: Make sure we have a corresponding 'u' member to RlcMacDownlink_t for every call
Port from wireshark.git commit 6c32ba5ff1a5f5ec2426d1d2c4f4f37fd136bab0.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: I989befc56fa37b8f982301f4f9aa4f4533e3e87a
2020-01-28 16:38:39 +01:00
Bill Meier bcc6408cd1 gsm_rlcmac.h: #if 0 unused stuff
Port of wireshark.git 2ef0c615946cd290aa9463c637169da0a1ca7972.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: Ia2e80664d293a2a95372213b4164c3e72259e0bb
2020-01-28 16:17:41 +01:00
Alexis La Goutte e36fb5b802 csn1: fix this statement may fall through [-Werror=implicit-fallthrough=] found by gcc7
Port of wireshark.git commit fd68c7dfc7d06ce7babe914f2575d9e4f35988ad.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: Ibaf47d7c4fdff326ac1dccf6fff77e2357e6a2bd
2020-01-28 13:45:03 +01:00
Pau Espin 900c2e277a csn1: Drop format_p union from CSN_DESCR
Port of wireshark.git 8626bb4cbb4d9926f7b56663585d9ef66252f93f.
We don't really need the other fields added there, let's keep only the
value out of the union.

Change-Id: Ia8889252ee7518a919a15d749815c2803b4b23cd
2020-01-28 13:43:45 +01:00
Anders Broman 771da85a11 csn1: Try to fix cast discards '__attribute__((const))' qualifier from pointer target type
Port of wireshark.git 1ff6213c949b373bcb7de5c48a5a4f805093066f.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: Ie14c335a904a17333e98ef58bf5e40245444e956
2020-01-28 13:43:24 +01:00
Guy Harris e26467c4ed csn1: Don't cast away constness
Port of wireshark.git commit 8e22ded7f8537e37e89ba558c83702d127443ae8.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: I100d5c43d8878e660035bf4a64718771f41a38a8
2020-01-28 13:42:29 +01:00
Anders Broman 60bf845f25 csn1: Fix warning with -Wmissing-prototypes
Port of wireshark.git 2e52e2ac997ca58caabee3270b5a6c3f96159ff0.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: Ic69a75ce3f01cea326139f678b963110e895c356
2020-01-28 13:41:21 +01:00
Pascal Quantin c515551625 csn1: Fix an infinite loop in CSN.1 dissector when having more than 255 padding bits
Port of wireshark.git 8b5aa913711b32b1e1bc707919d2a98c1875d443.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: I7f6aecc2c0f300c1a77cd683652969d3f1aa5794
2020-01-28 13:40:14 +01:00
Pau Espin 5b71697618 csn1: Fix pedantic compiler warnings in csn.1 dissectors
Port of wireshark.git commit 6aca10831f86c562970b13efa811f46e25ee3091.

    From Mike Morrin:
    Fix pedantic compiler warnings in csn.1 dissectors.

    There is some tricky casting going on in csn.1 structures.  To eliminate all
    the warnings, the function pointers needed to be moved out of the object
    pointer unions.  Fortunately macros (mostly) hide these changes from the
    protocol dissector tables.

    https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7686

    svn path=/trunk/; revision=44899

Change-Id: Ia1a8c50c4b024ca6df4e3fbbf891cd33591ccc9b
2020-01-28 13:38:42 +01:00
Pau Espin 7cce825fa4 csn1: Allow CHOICE elements to re-process the bits used for the choice
This is a port of wireshark.git commit
2f024256bf337400ef3a82fa75e6d48d5707e059.

From 78516187d821b8d19d16987b1d6bc855ee7cbe10 Mon Sep 17 00:00:00 2001
From: Sylvain Munaut <tnt@246tNt.com>
Date: Sat, 4 Feb 2012 10:00:22 +0100
Subject: [PATCH 4/6] packet-csn1: Allow CHOICE elements to re-process the bits used for the choice

We may want to display more detail, or the sub-element should be
displayed with its headers or whatever ...

Change-Id: I3a5a95d5f918b8f17a2400a6d0c4d855ecacea7e
2020-01-28 13:38:42 +01:00
Pau Espin 98e4c53cad csn1: Extend CSN_SERIALIZE to allow 0 bit of length
Port of wireshark.git 2f024256bf337400ef3a82fa75e6d48d5707e059.

From c6ee558d3bb00bfd25cca7c534448bf60df3c7cf Mon Sep 17 00:00:00 2001
From: Sylvain Munaut <tnt@246tNt.com>
Date: Sat, 4 Feb 2012 10:24:01 +0100
Subject: [PATCH 6/6] packet-csn: Extend CSN_SERIALIZE to allow 0 bit of length

In some coding there is no 'length' field at the top of a serialized
block, or it's more complex than a single field, in which case we
have to rely on the serialize decoder to consume the correct number
of bits.

We extend the CSN_SERIALIZE processing so that if a '0 bit' length
field is specified, then the length is not displayed and the
consumed bits by the serialize function is taken as the length
at posteriori.

The processing keeps the same behavior for any length > 0.

Change-Id: I9fadc99218594447001f7bb9943f4514b9877799
2020-01-28 13:38:42 +01:00
Jeff Morriss c0b4f4a633 csn1: shuffle decrements of remaining_bits_len
So that they always occur next to an increment of bit_offset.

Port from wireshark.git 1c81971d4292438ffdf83e9f9b9ab96c133c785b.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: I7474e9d632e068d6e33b0a502b81d4fff1f48802
2020-01-28 13:37:50 +01:00
Anders Broman c0190c8a5a csn1: packet-csn1.c:179: warning: 'pui8' may be used uninitialized in this function
Port from wireshark.git commit fd9f182f4b13a3d81b1b5c797a6e4b9d6d327fdd.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: I37f5f3732f92cd7340af8ac1e04383f3e45e7636
2020-01-28 13:34:36 +01:00
Anders Broman 72c102acf8 csn1: Update M_NULL CSN_DESCR to match wireshark
Port from iwireshark.git commit cc6d4341e65ef2e8d8488fe0ac0f236ece0dd844.
It looks like it makes no difference to us now, but other EGPRS messages
may use it in the future.

Ported-by: Pau Espin Pedrol <pespin@sysmocom.de>
Change-Id: I34039370c292e62790a38abb59f55c69fffa88e8
2020-01-28 13:34:08 +01:00
Pau Espin cdbc5dbd1c tests/rlcmac: Add test to showcase that decode_gsm_ra_cap() fails
Currently code using that function in osmo-pcu is disabled, allegadly
because SGSN was sending incorrect values, but it looks more like a CSN1
issue.

Related: OS#1525, OS#3499
Change-Id: I92c86397f988afaa791871d823a45fa85054f3bb
2020-01-28 13:29:42 +01:00
Vadim Yanitskiy bd0b0b3242 pcu_l1_if.cpp: fix NULL-pointer dereference in imsi2paging_group()
Passing NULL to strlen() would lead to a segmentation fault.

Change-Id: I838e3a21a3b25c2bc8260f67d156c6cc284f4456
Fixes: CID#207484
2020-01-16 00:25:54 +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 fbfab297ee Split identity_lv param into mi+mi_len
It's not really needed to have those together in some function calls,
and makes it more difficult to follow the code. Furthermore, new callers
not having content already aligned (len+value) will be using these
functions in forthcoming commits.

Change-Id: Ifb9d3997bfb74b35366c3d1bc51ce458f19abf16
2020-01-01 16:10:15 +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 506eb23dc5 fix typo in log message
Change-Id: Ib6fc4625242d855193b62b561624b23b265648b9
2019-12-31 17:01:34 +00:00
Pau Espin 585cfb28b8 Fix trailing whitespace
Change-Id: I0515b5c8f6744fa501de88fa7808b7fc91981f0e
2019-12-10 20:02:21 +01: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
Pau Espin 32499b614b pcu_l1_if: Check pag_req id_lv len fits buffer
Related: OS#4316
Change-Id: I803e1d2577a0d210e74feb5ca4c216375a5024ea
2019-12-09 13:55:14 +01:00
Pau Espin 30f6617c79 tbf_dl.cpp: Fix typo in log line
Change-Id: I9fdea4246c95897f3e72604981597db828a219a3
2019-12-04 18:11:52 +01:00
Pau Espin d0fc9e80fe Remove dash from name used in VTY cmd prompt
Others projects don't contain a dash in there, and it seems to cause
problems with TTCN3 VTY expectations.

Change-Id: I3430abb5fc622dec293457466e760de95fa3a05c
2019-12-02 11:14:26 +00:00
Vadim Yanitskiy 657a4c0ccd VTY: cosmetic: use osmo_talloc_replace_string()
Change-Id: Id09c7d24b48ddecfa96404c3e75330465a11f830
2019-11-30 20:17:25 +07:00
Vadim Yanitskiy fc75cc0ecf VTY: add warning about changing PCU socket path at run-time
Change-Id: I7cee2d782bd3dfc2cc8d2febc16dca905dcc294e
2019-11-30 20:17:21 +07:00
Pau Espin 1e6eb30f51 Clarify (M)CS related VTY attributes
Some are used to control (M)CS values for downlink while some do it for
uplink. Let's make clear which one is used for what. Take the chance to
document the fields a bit better than they were.

Some more information about the origin of cs_downgrade_threshold can be
found in the commit introducing it: 70b96aa232.

Related: OS#4286
Change-Id: I4e890e924b094a1937fbd3794de96704cf0421a8
2019-11-28 17:11:56 +01:00
Vadim Yanitskiy ffebd24456 PTCCH: properly handle RACH.ind for PCU_IF_SAPI_PTCCH
Change-Id: I482d60a46b9d253dfe0b16140eac9fea6420b30c
Related: OS#1545
2019-11-23 17:42:45 +07:00
Vadim Yanitskiy 78f58618f3 PTCCH: properly handle RTS.req for PCU_IF_SAPI_PTCCH
Change-Id: Ib204acce1a7e33f6651b9da2a7b4a9b9ae461093
Related: OS#1545
2019-11-17 02:58:31 +07:00
Vadim Yanitskiy bd0dac3783 PTCCH: implement basic message codec and API
Change-Id: Id79e95aafdde4a71977c64385fce48b729a51ca9
Related: OS#1545
2019-11-17 02:35:18 +07: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 fd734de4d1 GprsMs::update_cs_ul(): clarify the meaning of old_link_qual
Change-Id: Iad703a573621c64613b9b8c229079dc63fcaeb9e
2019-11-08 06:20:55 +07: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 05bca3524a Fix assertion hit upon CCCH Paging Request
Recent commit added an assertion to check for buffer boundaries and it
actually gets hit.
One of the 2 code paths calling pcu_l1if_tx_pch() was passing a buffer
of 23 bytes while one of maximum 22 is expected (because plen is not set
in the buffer but set inside pcu_l1if_tx_pch()).
So it seems before the assert, that code path was actually writing 1
byte outside the boundaries of data buffer, since bitvec_pack() uses
data_len field of bitvec.

Related: OS#4228
Fixes: 8dc09e73d0
Change-Id: I84c5dfd4d5580e9d4c00ed21887cb51bd9abbd2e
2019-10-16 14:36:28 +02:00
Alexander Couzens b3b0c49d1c encoding: fix space, tabs
Change-Id: I80ac88f50bfedfd2b86d548883313b5a187b1e8f
2019-10-09 17:14:17 +00:00
Vadim Yanitskiy cef2f843b4 VTY: fix command 'show tbf all': properly filter TBFs
For a long time the VTY command to show all active TBFs was broken.
The TBF filtering (by allocation origin) logic allows one to show
TBFs allocated on CCCH, PACCH, or on both of them. In the latter
case we have been checking whether a TBF was allocated on both
logical channels at the same time.

Let's fix this by passing a flag-mask instead of boolean arguments.
To be able to use GPRS_RLCMAC_FLAG_* definitions from "tbf.h", let's
exclude them from "#ifdef __cplusplus ... #endif" block.

Change-Id: I1c9f401368af880a97d32905c4cce0da481ffc21
2019-10-09 22:00:54 +07:00
Vadim Yanitskiy afbf189ef2 VTY: refactor pcu_vty_show_ms_all(): use show_ms()
Change-Id: I72aa1a1de22602a3ad2a4d19604ae0935c88c750
2019-10-09 20:26:47 +07:00
Pau Espin d752d7cebe pcu_l1_if.cpp: Replace value 23 with libosmocore's GSM_MACBLOCK_LEN
Change-Id: Ieec3dd028fffa1a735afaaf3f93da0a1202d122a
2019-10-07 21:04:19 +02:00
Pau Espin 8dc09e73d0 pcu_l1_if.cpp: Imm Assign PCH: clarify size of different items
Change-Id: I32876858e3e93951e965b0fc7875c95c1f36f3ac
2019-10-07 21:04:19 +02:00
Pau Espin f681f07cd0 pcu_l1_if.cpp: Drop unneeded byte in Imm Ass PCH buffer
paging group is 3 bytes and imm assign with plen prepended is 23 bytes,
so there's 1 extra byte not needed and makes code confusing.

Change-Id: Id7835e5aa1506505ff54e019b38f30111f79b5dc
2019-10-07 21:04:19 +02:00
Pau Espin 2ccb6aef89 pcu_l1_if.cpp: Fix GSMTAP Imm Assign PCH wrong encoding
Wireshark expects to receive the plen in order to decode it.

Fixes: 58543709e4
Change-Id: I91d1354689300b949760cdbaee03294eab958e12
2019-10-07 18:26:10 +02:00
Pau Espin 58543709e4 Log AGCH and PCH blocks using GSMTAP
Change-Id: I4d62f98801af1b0a290d3dd35bd213ccf3151035
2019-10-01 10:38:55 +02:00
Pau Espin 1ec211f57f Log RACH Requests using GSMTAP
Change-Id: Ib686a49e8c630808c30bede5810cd65fc045954a
2019-09-30 20:15:54 +02:00
Pau Espin 1879442443 vty: Fix osmo_tdef timers not listed in write config
Change-Id: I5c7ae18919e4b016505aa01eea6694d8a3f5df5f
2019-09-26 18:25:35 +02:00
Pau Espin f4c77e686a tbf_dl.cpp: Remove dup call to tbf_update_ms_class() in state GPRS_RLCMAC_WAIT_RELEASE
tbf_update_ms_class() is already called two lines above in the common
path.

Fixes: 409efa1ec8
Change-Id: Icbe3805c72a5c77366215be55128b586e5a00fb7
2019-09-26 14:43:22 +02:00
Pau Espin ad586a9fe4 tbf_dl: Setup m_llc_timer in constructor using osmocom API
Change-Id: I3e761b319326e33ab1d56c4fb30cafe3b0f96c29
2019-09-26 14:43:22 +02:00
Pau Espin bddf1ad7f6 Move tbf_{dl,ul} child constructors to respective .cpp files
Fixes: 9d1cdb1f69
Change-Id: Id258589d46de42ad4e27889bc396f930b7f94b79
2019-09-26 14:43:22 +02:00
Pau Espin 9d1cdb1f69 Move out tbf subclasses from tbf.h to their own headers
It's a good start towards clearing current mess between parent and the 2
children classes.

Change-Id: Ibc22ea2e02609af7ee058b8bc15df2115d4c6f60
2019-09-25 17:50:06 +02:00
Pau Espin 488aa29083 cosmetic: fix whitespace
Change-Id: I45bbe4d3c69d573aaff010d16f338c7ec3eaf08a
2019-09-25 17:50:06 +02:00
Pau Espin e13cdc503e pdch.cpp: Use pcu_l1_meas previously filled by lower layers
Otherwise, a new meas object is allocated in the stack in upper layers
which doesn't contain the link_qual information (have_link_qual=0),
outputting following error:

osmo-pcu/src/gprs_ms.cpp:644 Unable to update UL (M)CS CS-2 because we don't have link quality measurements.

Change-Id: I1980ca325c8d65f3f6310fa697dd810eec7ab077
2019-09-25 13:52:31 +02:00
Pau Espin 812d466bbd pdch.cpp: Refactor bitvec param passing in rcv_control_block
Move code in rcv_block_gprs() only needed for rcv_control_block() into
the later. This way rcv_block_gprs() is simplified and shows similar
code paths with regards to rcv_data_block().
It can now be seen that the main difference between both is the meas
param no being passed in the control case.

Change-Id: I2a0133463edced93c72ccc743a0cf00d1d6922cf
2019-09-25 13:35:13 +02:00
Pau Espin 2b5c629055 Use osmo_tdef to implement dl-tbf-idle-time
Change-Id: I5e4f0d2f90e643600b7752525d6c2830856c9d3b
2019-09-17 11:11:04 +02:00
Pau Espin 63700ead34 Use osmo_tdef to implement ms-idle-time
This commit would also remove the option from config_write_pcu() since
it's automatically filled in by osmo_tdef, but there was actually a bug
because that param was never printed when saving the config...

Change-Id: Id8e70b0f44ef2f7e20ecdb3fd8ca93ae2a05b9a3
2019-09-17 11:05:45 +02:00
Pau Espin 38cfa734f4 Use osmo_tdef to implement T3190
Change-Id: I0c767c526398d98ca47ef98fdaccfc23af11fb0d
2019-09-16 14:21:21 +00:00
Pau Espin 5211d9deca Use osmo_tdef for BSSGP T1 and T2
Change-Id: I477e5b702c8b956136d93fc1cee01991233e381f
2019-09-16 14:21:21 +00:00
Oliver Smith cfb6321b88 Forward ETWS Primary Notification to MS
Receive an Application Information Request from the BTS via PCU
interface. Construct a Packet Application Information message from it
(3GPP TS 44.060 11.2.47) and send it to all MS with active TBF.

The TTCN-3 test infrastructure to test this feature is not quite ready
yet, so I've added C unit tests instead.

Related: OS#4048
Change-Id: Ie35959f833f46bde5f2126314b6f96763f863b36
2019-09-14 15:28:43 +00:00
Pau Espin 5360ef5447 bts.cpp: Fix osmo_tdef initialization on older g++ compilers
Fixing errrors spotted:
bts.cpp:78:1: error: uninitialized const member 'osmo_tdef::T'
 };
 ^
bts.cpp:78:1: error: uninitialized const member 'osmo_tdef::default_val'
bts.cpp:78:1: error: uninitialized const member 'osmo_tdef::unit'
bts.cpp:84:1: error: uninitialized const member 'osmo_tdef::T'
 };
 ^
bts.cpp:84:1: error: uninitialized const member 'osmo_tdef::default_val'
bts.cpp:84:1: error: uninitialized const member 'osmo_tdef::unit'

Change-Id: I2dfecf22516f52cc19e0a0442e70dbc4dbc61336
2019-09-13 12:42:38 +02:00
Alexander Couzens e46d8dcaab tbf_dl: add comments to the scheduler
Change-Id: Ib037f9fda30472313c7a82effb1e925c6abebbe5
2019-09-12 16:49:21 +00:00
Pau Espin 28f160e76c Introduce osmo_tdef infra and timer VTY commands
This will allow for configuration of some of the timers by the user,
and allow him to inspect current values being used.
It will be also useful for TTCN3 tests which may want to test some of
the timers without having to wait for lots of time.

Timers are splitted into 2 groups: BTS controlled ones and PCU controlled
ones. The BTS controlled ones are read-only by the user (hence no
"timer" VTY command is provided to change them).

TbfTest.err output changes due to timers being set up correctly as a
consequence of changes. Other application such as pcu_emu.cpp and
pcu_main.cpp had to previosuly set the initial values by hand (and did
so), but apparently TbfTest.c was missing that part, which is now fixed
for free.

Depends: libosmocore.git Id56a1226d724a374f04231df85fe5b49ffd2c43c
Change-Id: I5cfb9ef01706124be262d4536617b9edb4601dd5
2019-09-12 14:17:07 +02:00
Oliver Smith 45fdc44d68 tbf_dl: make preemptive retransmission optional
Since [1], OsmoPCU already starts to retransmit downlink blocks before
the MS has had a chance to receive them and/or send the related
acknowledgement in uplink. Make this optional with the new VTY option
"no dl-tbf-preemptive-retransmission".

[1] e25b5b91f6 ("tbf: Only create dummy frames if necessary")
Related: OS#2408
Change-Id: Id08aed513d4033aa0d4324c6ce07cbb2852f2f92
2019-09-11 06:16:29 +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
Pau Espin ef1fe58e19 cosmetic: tbf: Rename T and N arrays
Those namings my collide with usual osmocom "T" variable name associated
to a timer number, which will be added in following patches.

Change-Id: Ic2b5068a4882e4a043bf81496be30a378fdb9a09
2019-09-05 14:40:26 +02:00
Vadim Yanitskiy df0fd8ba27 osmobts_sock.cpp: do not print the same debug message twice
The following message is printed by the pcu_tx_txt_ind():

  DL1IF INFO pcu_l1_if.cpp:113 Sending XXX TXT as PCU_VERSION to BTS

There is no need to print it twice:

  DL1IF INFO osmobts_sock.cpp:74 Sending version XXX to BTS.
  DL1IF INFO pcu_l1_if.cpp:113 Sending XXX TXT as PCU_VERSION to BTS

Change-Id: Ic2793f20cf9df2fa08c45070a8f81ef1c08b925a
2019-08-27 11:06:11 +02:00
Vadim Yanitskiy 9e5ef54594 osmobts_sock.cpp: pcu_sock_read(): further simplify the code
Change-Id: Ie7c0ca8baf0ae5beadda60bda0bc76a44664d439
2019-08-27 11:06:00 +02:00
Vadim Yanitskiy c7849c2dfe osmobts_sock.cpp: pcu_sock_read(): use stack buffer, not heap
We don't really need to use the message buffer (on heap), because
it's never getting passed to pcu_rx(). Let's use a buffer on stack.

Change-Id: I4cb8ca80513df7b71e1438da2e82799be6be1fa0
2019-08-23 18:03:37 +02:00
Vadim Yanitskiy aef6bf43e5 osmobts_sock.cpp: pcu_sock_cb(): use libosmocore's socket API
Change-Id: I7f5c7f5744ab14f36f46cf7941e91352eca8d2b9
2019-08-23 18:03:37 +02:00
Pau Espin cd2ac56bd4 Remove undefined param passed to {logging,osmo_stats}_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.
API osmo_stats_vty_add_cmds never had a param list but has seem problem
(no "void"), so some users decided to pass a parameter to it.

Related: OS#4138
Change-Id: Ic1ac815eafab49577ff883a5d700ecca5936d216
2019-08-05 14:30:47 +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
Eric Wild ab8b01effd ubsan: fix shift
Ubsan complains about shifts into the sign bit due to automatic int
promotion, so cast explicitly.

Change-Id: I6387c7313832f6c7c920e1016b74562b66d6b68e
Related: OS#4029
2019-07-24 19:28:38 +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
Thorsten Alteholz 8bb7904458 fix spelling errors detected by lintian
Change-Id: I381618eb55cc513cfa9c2e384c27cead0935c8bf
2019-07-17 10:56:19 +00:00
Max f3038e7b2a Use libosmocore for IMSI parsing
Change-Id: Iec5c65776fc54b2f9e5dd55c711ace2471662db1
2019-07-16 04:19:21 +00:00
Vadim Yanitskiy f17dfc062a src/pcu_l1_if.cpp: fix: properly pass measurements from PCUIF
The recent versions of OsmoBTS do provide the following measurements:

  - RSSI (Received Signal Strength Indication),
  - ToA (Timing of Arrival),
  - BER (Bit Error Rate),

as well as C/I (Carrier-to-Interference ratio) since [1] (OS#4006).

[1] https://gerrit.osmocom.org/r/Ia58043bd2381a4d34d604522e02899ae64ee0d26

Change-Id: I0fd6c35e8cf0b1314f4e3c336b233b5f7e42dfc6
Related: OS#1855
2019-07-16 04:11:20 +00:00
Alexander Couzens 210ccf4a1d Encoding: ACK/NACK: always encode with length field present
In most cases the length field was present and this field takes 7
bits of the maximum available 110 rest bits.
The length field was only removed when encoding huge bitmaps usually
only happen on lossy connections with packet lost.
However the cases without length field were encoded incorrect,
because all remaining bits must be used by the uncompressed bitmaps,
but the PCU violates this by encoding always the "release 5" bit.
Rather than fixing the encoding without length field, simply remove it
and always encode with length field. This also reduces the code
complexity.

Change-Id: I7bc2e18d647b72b8f17ba7a5c9c5e421d88275fb
2019-07-11 18:38:45 +02:00
Alexander Couzens e4e70d052e Encoding: use uint16_t when interacting with the window object
The ESN, SSN and uncompress bitmap len are uint16_t. The Window is using uint16_t in
function arguments and return values. Don't do so many integer conversions.

Change-Id: If62fa09d7bfa8e91ce707824f7019edb1b83da9e
2019-07-11 03:23:52 +00:00
Alexander Couzens fba931bab6 bts.cpp: ensure left-shift operation does not exceed uint32_t
Found by Asan
Relates: OS#4029
Change-Id: I21640e40e689016d6fb80a8db4257b22e85b303b
2019-07-11 03:22:15 +00:00
Alexander Couzens 243a204021 Encoding: write_packet_ack_nack_desc_egprs: don't use a reference for rest_bits
The rest_bits are never read after calling this function nor are rest_bits
updated properly.

Change-Id: Ic350b0365b125638a6c752f692bef981ad6b9d89
2019-07-11 00:27:15 +02:00
Alexander Couzens 2d24eba903 decompress_crbb: add length argument for search_runlen
search_runlen() must know the exact size in bits when parsing
the bits otherwise it read over the buffer.
Fixes testcase #7 which was wrongly decoded.

Change-Id: Ie34a0651e7e7efea4e9ecff1e3a467588113cf47
2019-06-24 13:51:06 +00:00
Alexander Couzens 3a499f3cb2 Encoding: drop struct gprs_rlcmac_bts* from all functions
The bts is not used at all.

Change-Id: Ia07755e825913a16352ab13f6cf55f2918de8681
2019-06-24 13:48:43 +00:00
Alexander Couzens 0d482c5c97 rlc: replace int with uint16_t
The i value will only count forward and is limited to 11 bit. The integer is also
converted when returning to uint16_t

Change-Id: Ib8a9081bbcb8b4344498254c58941002d17f9381
2019-06-24 13:48:09 +00:00
Alexander Couzens 6d73205280 egprs_rlc_compression: fix white spaces
Change-Id: I43a5acc2dda4ba567ada9846880e31c85bc98394
2019-06-17 02:04:09 +02:00
Alexander Couzens b7439f28a1 encoding: use `/* */` for comments instead of `#if 0 #endif`
Change-Id: Ifff9526b15bfda7a0f85c92bcb0d3fabab61ca32
2019-06-17 02:03:18 +02:00
Alexander Couzens 3f640773f3 encoding: correct encoding of CRBB in ACK/NACK when not byte aligned
The last bits of the CRBB (compressed receive block bitmap) was incorrect
encoded when the CRBB is not byte aligned.

Related: OS#3728
Change-Id: I7261aa71b37d7ead52992f8db462f72a3804988e
2019-06-13 21:26:12 +00:00
Alexander Couzens 5c3783b7e8 gprs_bssgp_pcu: explicit allocate & initialize bssgp_nsi instance
The instance bssgp_nsi is a global instance to be used by all
NS related functions. Previous the PCU allocated and initialized
the bssgp_nsi instance when (re-)connecting and freeing on disconnect.
The problem of the implicit initialisation is gprs_ns_vty_init(bssgp_nsi).
All vty init functions must be called before the configuration is read,
otherwise a previous vty written configuration is invalid.
Furthermore the vty modifications to the `ns` object were lost when the PCU has to
reconnect to the SGSN.

Fixes: OS#4024
Change-Id: I2aa53ea54e9352577f6280ad7b9d1d9da9f57eaf
2019-06-07 01:17:53 +02:00
Alexander Couzens eb64d43922 gprs_bssgp_pcu: make gprs_bssgp_ns_cb public
rename the function sgsn_ns_cb -> gprs_bssgp_ns_cb.
To allow writing and reading the same configuration, the pcu needs to register
all vty commands before reading the configuration. This callback
is required to register NS based vty commands

Related: OS#4024
Change-Id: I440c0df2e32fe22bf43288c00bb4aa3a0c6a3a51
2019-05-25 05:56:32 +02:00
Rafael Diniz 0e6e45a65f Fix help message formatting of osmo-pcu.
Change-Id: If4ecf9be5a0739bb54aedb077eda51ad091b4c3f
2019-04-08 19:28:02 +00:00
Max 34513feff9 cosmetic: use const pointer for bts_data
It's used several time for logging so let's call it once to make code
easier to follow.

Change-Id: Icfd9e5603a5d8701f487f17e9c0335d458e9e80b
2019-04-08 07:36:11 +00:00
Max 902e3e58db Update MCS selection for retransmission
In 3GPP TS 44.060 the selection of MCS for retransmissions is defined as
separate tables (8.1.1.1 and 8.1.1.2) depending on the value of
resegmentation bit (which is opposite to the way EGPRS_ARQ are defined
in the source code). Let's follow the same idea and explicitly check for
resegmentation bit value and use separate tables. This also makes it
easier to add proper support for special cases (MCS-6-9 and MCS-5-7) and
padding in future independently for different ARQ types. The code is
also moved to c to avoid unnecessary conversions to and from cpp class.

Change-Id: Ia73baeefee7a58834f0fc50e3b8bf8d5e3eb7815
2019-04-08 07:35:19 +00:00
Max 12a0987b36 vty: add commands to show TBF of a certain kind
Add vty commands to show only TBFs allocated via PACCH or CCCH.

Change-Id: I80f8df4fe663a0346f4289a4220b761e39726312
Related: OS#1759
2019-04-08 07:35:00 +00:00
Max 0e6ac799f7 TS alloc: expand tests log
* restructure code for easier reading
* use consistent formatting for output
* log essential allocation parameters on failure

Change-Id: I4b78951a79ddbc0745b39d091080a4e0e247d3c5
Related: OS#2282
2019-03-28 08:58:41 +00:00
Daniel Willmann 32518cce5a oc2g: Change log type (Litecell15->Oc2g)
Change-Id: I95ced5da1c89dae5a16963b10b005747277f320b
2019-03-27 14:23:17 +01:00
Daniel Willmann f57dccbbfb oc2g: Remove custom alarms
Don't try to send custom alarms that weren't included in upstream.

Change-Id: I51de826aa732a3875d75396b46b7d2821ef7417c
2019-03-27 14:21:15 +01:00
Minh-Quang Nguyen ba66ea4406 OC-2G: Always use positive TA information provided in PH-RA-IND
From-Commit: 960aa3d1b0b1
From-Remote: https://gitlab.com/nrw_noa/osmo-pcu
Change-Id: Ia526f712b95eb7bba99252f2a348d9fb5d2f3838
2019-03-27 14:20:21 +01:00
Minh-Quang Nguyen 2ba608415b OC-2G: Fix TA adjustment
Problem:
 TA provided from L1 PH-DATA-IND is a relative amount of TA adjustment to actual TA
 being used for given TBF. The current TA update algorithm in PCU simply applies the relative
 amount of TA to given TBF but does not take into account of current TA.
 As a result, the PCU will request wrong TA jump for given TBF if the MS is moving away from
 BTS more than 2 km.

 Related issue: http://osmocom.org/issues/2611

Fixes:
- The PCU needs increase or decrease current TA of given TBF on receiving of relative
  amount of TA adjustment provided by PH-DATA-IND from L1.
- The PCU needs to set absolute TA of given TBF on receiving absolute TA provided by
  PH-RA-IND from L1.

From-Commit: 139ad3f42193
From-Remote: https://gitlab.com/nrw_noa/osmo-pcu
Change-Id: I7665586dd5722bbe04632ee5673d3033bc082324
2019-03-27 14:19:40 +01:00
Minh-Quang Nguyen 4a1796fe76 OC-2G: Fix missing header
From-Commit: a9eefb54c62a
From-Remote: https://gitlab.com/nrw_noa/osmo-pcu
Change-Id: Ida0592c9da74588a57d9d2d5be40fcf79edcb596
2019-03-27 14:18:30 +01:00
Jean-Francois Dionne c1e44908fe Initial commit for OC-2G support.
From-Commit: b77fd00608dd
From-Remote: https://gitlab.com/nrw_noa/osmo-pcu
Change-Id: I7cd89a549c9463e81893ca7dd925299f728e4453
2019-03-27 14:16:41 +01:00
Max 3fa235fe01 Update IA Rest Octets encoding
Write initial bits of 3GPP TS 44.018 §10.5.2.16 IA Rest Octets the same
way as  write_ia_rest_*() routines do.

This should also fix the issue addressed in
I75dd5bebc74eea85edf9582607c774d0bba0d2a6 initially by properly encoding
L/H bits.

Change-Id: I7ed5270bf95c3f6e9e026ff447eef8539f6f0314
2019-03-27 12:32:04 +00:00
Max d4a39291e0 TBF-DL: cosmetic update for helper routines
* use enum values where appropriate
* reformat to proper code style to improve readability

Change-Id: If1d2bc69b0d43fc520e579457007704b7975117e
2019-03-27 12:32:04 +00:00
Max fb59a93425 TBF: update MCS counters
* use enum CodingScheme directly instead of converting it to class and
  back
* drop useless mode check
* log errorneous update attempt

Change-Id: I763136c2f356d63aa3d28d09c57fd5faf5336258
2019-03-27 12:32:04 +00:00
Max e742cc0997 Use Timing Advance Index in UL assignments
Write TAI (if available) when generating Rest Octets for UL
Assignment. This should not affect actual PCU behavior because TAI is
not yet supported by upper layers but we have to adjust corresponding
tests anyway.

That's updated version of reverted commit.

Change-Id: I69407793bdb863be5fc42adadf75842d22f27335
Related: OS#3014
2019-03-27 12:32:04 +00:00
Max 3eb47363ad Rewrite Packet Uplink IA Rest Octets for SBA
Use bitvec_set_*() directly without external write pointer tracking to
simplify the code. This is part of IA Rest Octets (3GPP TS 44.018
§10.5.2.16) which is the last part of the message so it should not
interfere with the rest of encoding functions.

The difference in the expected test output is due to proper handling of
TAI which should not be transmitted for SBA according to the Note in
Table 10.5.2.16.1 in 3GPP TS 44.018.

The change was manually tested against real mobile phone using options
'gprs mode gprs' in osmo-bsc.cfg and 'two-phase-access' in osmo-pcu.cfg
to make sure appropriate code path is actually triggered.

That's partially based on reverted commit 93d947f5e8.

Change-Id: I97d53c27c1ca9e032d431b3aa7f915027d63ddc0
Related: OS#3014
2019-03-27 12:32:04 +00:00
Max 0367ddd62b Rewrite Packet Uplink IA Rest Octets for MBA
Use bitvec_set_*() directly without external write pointer tracking to
simplify the code. This is part of IA Rest Octets (3GPP TS 44.018
§10.5.2.16) which is the last part of the message so it should not
interfere with the rest of encoding functions.

That's partially based on reverted commit 93d947f5e8.

Change-Id: Ibe294b26ac374b9264a734db9663cacc105a4474
Related: OS#3014
2019-03-27 12:32:04 +00:00
Max 6e96dd4665 Fix Channel Coding Command for MCS
Previously result of ".to_num() - 1" was used without any checks which
means that in case of to_num() returning zero we would effectively try
to encode (uint8_t)(-1).

Let's fix this by using proper mcs_chan_code() function which returns
Channel Coding Command for MCS without the need to further correct it
and adjust expected tests output accordingly.

Change-Id: I868062a81fffe6714a811c032215f25a79259905
2019-03-27 12:32:04 +00:00
Max 898dddb1d1 MCS: add Channel Coding Command encoder
Add function to encode MCS value as proper EDGE or GPRS Channel Coding
value according to 3GPP TS 44.060 and corresponding helpers.

Use it for everything except IA Rest Octet encoding which is done in a
follow-up patches to make sure that we distinguish between
encoding-related changes to test output and unrelated changes.

Change-Id: I127fb29f5aaf77a7f6c4c565dfeb3b711af9845d
2019-03-27 12:32:04 +00:00
Harald Welte 48b1e7a86f gprs_debug: Use named initializers and explicit array indicies
This is a much safe way, it allows for modifications of the debug
subsystem enum member values without breakage.  Also, the syntax
introduced here is what we do in all other Osmocom CNI projects.

Change-Id: I2be88586ca44b0b8361f96cf3c034c8459244c2c
2019-03-27 07:39:02 +00:00
Harald Welte 3447c4a8a4 Forward GPRS SUSPEND REQ from BTS to SGSN using BSSGP
As specified in 3GPP TS 03.60 Section 16.2.1 and 44.018 Section 3.4.15,
a Class B MS is sending a "RR GPRS SUSPEND REQ" via a DCCH to the BTS if
it wants to suspend GPRS services.  As of
Change-Id I3c1af662c8f0d3d22da200638480f6ef05c3ed1f, OsmoBTS forwards
this via the PCU socket, so we need to pick it up and send it via BSSGP
to the SGSN.

Change-Id: I7b4beb413a6f974373a404b5a11c44d86ba695d3
Closes: OS#2249
2019-03-27 07:39:02 +00:00
Harald Welte 1473b377c2 pcu_l1_if: Fix erroneous endian-swapping of the CellID
In Change-Id I787fed84a7b613158a5618dd5cffafe4e4927234 in February 2018
we accidentially introduced a change that would erroneously swap
the endianness of the CellID on the way between PCUIF socket and
BSGSP.  This meant that all OsmoPCU based BTSs would report the
wrong CellId to the SGSN.

Closes: OS#3854
Change-Id: I2f6cc930c5dbf8dac386b24b0756df2efe8199e4
2019-03-27 07:39:02 +00:00
Max 8a8e0fb267 MCS: add mcs_is_*() helpers
In preparation for Channel Coding Command encoder in follow-up patches
let's add necessary helpers. Those are similar to previously used
helpers from GprsCodingScheme class but without CamelCase and with less
typo chances between Gprs and Egprs cases.

Change-Id: I6699cbc8d7ae766fa4d2b3d37e5f9ff1cf158b7e
2019-03-26 11:19:30 +01:00
Daniel Willmann fb3fd09353 Include pdch.h in bts.h even if we're not compiling C++
bts.h needs pdch.h whether we're compiling C or C++ code so move it out
of the #ifdef.

make[1]: Entering directory '/home/daniel/scm/osmo/oc2g/osmo-pcu-oc2g/src'
  CC       osmo-bts-oc2g/oc2g_l1_if.o
In file included from osmo-bts-oc2g/oc2g_l1_if.c:39:
./bts.h:74:26: error: array type has incomplete element type ‘struct gprs_rlcmac_pdch’
  struct gprs_rlcmac_pdch pdch[8];
                          ^~~~

Change-Id: Ib39e4424f73c677b34f921917440f211e400e14f
2019-03-26 09:29:17 +00:00
Max a4de02db5d MCS: move Mode enum outside of class definition
Move Mode (EDGE/GPRS) definition and related functions outside of
GprsCodingScheme class. This allows us to use standard libosmocore
value_string functions.

Change-Id: I3baaac7f1ca3f5b88917a23c1679d63847455f47
2019-03-24 18:54:52 +01:00
Max 02fbfc15c7 Fix TA index encoder
The TAI is described as { 0 | 1 < TIMING_ADVANCE_INDEX : bit (4) > } in
3GPP TS 44.018 §10.5.2.16.1 so it should be encoded with if-else.

Change-Id: I54482790e1cf3cb13a635a99a481250576deabaf
2019-03-19 18:27:49 +01:00
Max a0353547b1 TBF-DL: log MCS as string
Log MCS name instead of numeric value.

Change-Id: I3e1925a010a6def5fd14da63b73e0b75feddfafc
2019-03-19 18:27:49 +01:00
Max 136ebccc5e MCS: use value_string for conversion
Change-Id: I212ebb892ab162821633974d5a6c7e315d308370
2019-03-19 18:27:49 +01:00
Max 51754b6f35 MCS: move HeaderType enum outside of class definition
Move functions which compute number of blocks or bits depending on
header type and corresponding enum outside of GprsCodingScheme
class. This will allows us to use standard libosmocore value_sting
functions in upcoming patches for IA Rest Octet encoding/decoding.

Change-Id: Id0873f85e1f16a72e17e7fbc4ad76b194917067f
2019-03-19 18:27:06 +01:00
Max d5ffeb5e63 Explicitly clean up BTS singleton
Add method to explicitly cleanup BTS singleton similar to GprsMsStorage
class and use it from main(). The destructor becomes trivial wrapper
around cleanup() method.

This prevents annoying SIGABRT on exit of OsmoPCU caused by
rate_ctr_group_free() being called after talloc_free() which removes the
context in which counter group is allocated.

Change-Id: I796d56a7de3f3a1f9d59708995c8e3e9b05a2747
2019-03-19 15:42:10 +00:00
Max f4d3973688 MS store: move test helper to unit test
It's confusing to have test-specific helper with the same name as tested
function directly inside the GprsMsStorage class. Let's convert it into
static function and move to the unit test.

Change-Id: Ia2a5b90779051af894fe15d957c1d26f0a142f33
2019-03-19 15:05:51 +00:00
Max 0620656288 MCS: remove unused function
Change-Id: I32ab5ac36a0db90f2bea670b7684784b83a90b6b
2019-03-13 17:11:01 +01:00
Max e43ef21d35 Make get_retx_mcs() into regular function
Moving from header-defined inline function allows us to hide
egprs_mcs_retx_tbl definition and simplify further changes.

Change-Id: I95258d1558a3b918ae83f1a69e7c3de2b97e5627
2019-03-12 15:35:40 +01:00
Max bea2edbc46 MCS: move Coding Scheme enum outside of class definition
Move generic MCS enum to C header file to simplify further modifications
to GprsCodingScheme class in follow-up patches. This also allows us
to use standard libosmocore value_sting functions in upcoming patches
for IA Rest Octet encoding/decoding.

Related: OS#3014
Change-Id: I993b49d9a82b8c7ad677d52d11003794aeabe117
2019-03-12 15:35:40 +01:00
JF Dionne 1beed38b54 encoding: Fixes TMSI vs MI bit selection in repeated page info
Change-Id: Iddb00b9133f523f4ba09c8f1fc5694e62dc46fbf
2019-03-11 13:36:44 +00:00
Max fa3085b45e Log (M)CS UL update errors
Previously some of the errors in update_cs_ul() call were silently
ignored. Let's log all those as errors with appropriate message.

Note: test output needs updating because we do not (yet) set proper meas
struct in TBF tests. That's likely wrong but it's better to update tests
in a separate commit.

Change-Id: I4084fb281dd9dad04a2a3a68cac2a8f7b462548e
2019-03-07 17:05:19 +00:00
Max 8119ecd2db Tighten lqual table limits check
Previously MAX_GPRS_CS was used for both EDGE and GPRS which means that
we waste extra memory in GPRS case. It also leads to misleading
name. Let's fix this by introducing separate definitions for GPRS and
EDGE cases and use them as appropriate in limit checks.

Change-Id: I3ae1ee64ec8e80247b8fe669cc79505b4dadf58f
2019-03-06 20:52:15 +00:00
Max 01f9bc7bf1 EDGE tests: remove no-op check
The headerTypeControl() function always return constant and is only used
inside OSMO_ASSERT() which compares it to the very same constant which
makes it no-op. Let's remove this clutter.

Change-Id: Ie0f81fe05a2b3f432de7d1f3446e8115d7524ff4
2019-03-05 12:10:52 +01:00
Max 9feaddc390 MCS: remove dead code
As a preparation for (M)CS fixes in follow-up patches, remove unused
operators from GprsCodingScheme class.

Change-Id: Ieef3b095a6732300e5efa395b989843112b9ca78
2019-03-04 16:25:12 +00:00
Max 807dde070f MCS: internalize 'family' parameter
There's no need to expose it in header file as it's only used internally
for consistency checks.

Change-Id: Ic705615cd2a8ca077efef9ea62a2a676f70b4aed
2019-02-26 19:59:46 +01:00
Harald Welte 57d3515abd Optionally Use the NS Sub-Network-Service (SNS) on Gb
This change add support for the recently-introduced GPRS Gb interface
auto-configuration using the NS IP Sub-Network Service (SNS) procedures.

It requires a Change-Id I84786c3b43a8ae34ef3b3ba84b33c90042d234ea of
libosmocore.

Related: OS#3372
Depends: I84786c3b43a8ae34ef3b3ba84b33c90042d234ea (libosmcore)
Change-Id: I256b40ac592d3b6e75dd581bf7b9512f69b11e83
2019-02-26 13:23:24 +01:00
Max 2a47c73217 Rewrite EGPRS Packet Uplink IA Rest Octets for SBA
Use bitvec_set_*() directly without external write pointer tracking to
simplify the code. This is part of IA Rest Octets (3GPP TS 44.018
§10.5.2.16) which is the last part of the message so it should not
interfere with the rest of encoding functions.

That's partially based on reverted commit 529ce88545.

Change-Id: I143b3dd02aa54b9ce206d9e780a5554f6d9fd118
Related: OS#3014
2019-02-26 11:20:15 +00:00
Harald Welte b26854c276 Mark gprs_ns_reconnect() as static (not used outside of C file)
Change-Id: I95138adedacdc2d953284cff57f79ecb33616f0f
2019-02-26 11:11:51 +00:00
Max bd5647ee92 Rewrite EGPRS Packet Uplink IA Rest Octets for MBA
Use bitvec_set_*() directly without external write pointer tracking to
simplify the code. This is part of IA Rest Octets (3GPP TS 44.018
§10.5.2.16) which is the last part of the message so it should not
interfere with the rest of encoding functions.

That's partially based on reverted commit 529ce88545.

Change-Id: I19cc4226e7e831e7d7f70212b2078f5589a87ff0
Related: OS#3014
2019-02-19 18:58:04 +01:00
Max 23c0e018e4 Rewrite Packet Downlink Assignment
Use bitvec_set_*() directly without external write pointer tracking to
simplify the code. This is part of IA Rest Octets (3GPP TS 44.018
§10.5.2.16) which is the last part of the message so it should not
interfere with the rest of encoding functions.

That's updated version of commit with the same topic reverted earlier.

Change-Id: Ie180733d2584ebb16fb80b84526d0dbc70e3d441
Related: OS#3014
2019-02-19 18:58:04 +01:00
Max 0160a29b6c Restructure IA Rest Octets encoders
In preparation for upcoming patches with 11 bit RACH and TA support,
let's restructure existing encoders to simplify further modifications:

* move consistency checks to top-level Imm. Ass. encoder
* use consistent formatting
* constify pointers where appropriate
* split SBA and MBA encoders into separate functions

Those changes also make it obvious which parameters are necessary for
Rest Octets in each specific case (DL, UL-SBA, UL-MBA, UL-SBA-EGPRS,
UL-MBA-EGPRS).

There're no functional code changes so there's no need to adjust tests.

Change-Id: I0ad1bc786c3a8055ea9666f64ae82c512bd01603
Related: OS#1548
2019-02-19 18:58:04 +01:00
Max fc8afc2f33 Clarify write_immediate_assignment() signature
* remove unused variable
* use bool for boolean types
* add clarification comments

Change-Id: I363445063e2d873d9194b2a5924b9e59b8b7ea53
2019-02-19 18:58:04 +01:00
Max 7426c5f957 Add define for dummy burst string
Change-Id: I464920b3d6d47bb1c797a4ce06230f005a2e06a0
2019-02-19 18:58:04 +01:00
Max 0c55bf19a5 Move C include to proper place
Change-Id: Id58d1820b94d54ce73ed40edb7747ef975890a7b
2019-02-19 18:58:04 +01:00
Max 1f2e69fd35 Don't install pcuif_proto.h header
Both OsmoBTS and OsmoBSC use their own copies of this header nowadays so
we can simplify our installation slightly by making it local only.

Change-Id: I4a87395d4ab7212fe2fc055dae0a737e10d20c69
2019-02-14 16:35:36 +01:00
Rafael Diniz f0af1b051a Added support for daemonize to osmo-pcu.
Change-Id: Ia889544e0a350b6bab55da4e4201a617e0241ea2
2019-01-29 12:32:58 -02:00
Harald Welte 099f4f2169 gprs_rlcmac_received_lost(): Fix regression / uninitialized now_tv
In Change-Id I7d22e7b5902c230efeae66eb20c17026a4037887 we
introduced the use of timespecsub(). Unfortuantely, we also
accidentially removed the call to osmo_clock_gettime() along
with it, leaving now_tv completely uninitialized.

Change-Id: Ieced0c62700b2fe4ab0208258183154cc701490b
Related: OS#3225
Fixes: Coverity CID#188872
2018-10-21 11:50:10 +02:00
Stefan Sperling 173d7fdbb9 check for overlong unix socket paths
In pcu_l1if_open(), use osmo_strlcpy() instead of strncpy() and check for
overflow. This catches overlong and non-NUL-terminated socket paths.

Change-Id: I825190cbb34d052b797e9fb5208884d6f5992839
Related: OS#2673
2018-09-20 18:31:36 +02:00
Pau Espin 218ee98de0 tbf: Replace '.' in counter names with ':'
The '.' is illegal character in counter names, as they are exported
via CTRL interface, where '.' has a special meaning that cannot be
used by strings comprising the variable name.

Change-Id: Ieb7496e1a30ab4f2bfe36c7b664dcdc034010a15
2018-07-11 22:20:31 +02:00
Pau Espin 09269017d3 tbf: Use incrementing id for rate_ctr_group_alloc
Wrap-around of var handling next id will luckly happen
long after initially assigned TBFs are already released.

Change-Id: I90ef64133986c556c1a529f5b966e847e6cabbad
2018-07-11 22:20:31 +02:00
Stefan Sperling 3df1532e97 check bssgp_tlv_parse() return code in gprs_bssgp_pcu_rcvmsg()
The return code from bssgp_tlv_parse() was not checked for a parsing
error. In case of a parsing error the stored return code could have
been overwritten later in this function.

Explicitly check for a parsing error, log corresponding packets,
and return an "invalid mandatory information" error status to
the sender. To avoid loops, do not respond with an error status
to STATUS PDUs.

Change-Id: I56e10a97cda7fd2d40bc7b4b2e6202f97772e1b3
Related: OS#3178
2018-06-25 13:02:06 +02:00
Stefan Sperling 082443d2c7 change log level of "DL packet loss" log messages
The TBF tests are failing on some machines due to unexpected
log output: "DL packet loss of IMSI= / TLLI=0xffeeddcc: 0%"
These messages are printed if >= 1 second has passed between
loss reports. This timing is machine-dependent so the test
is unstable as a result. Only print these messages at log
level debug to (hopefully) make TBF tests pass consistently.
Update expected test output accordingly.

Change-Id: Ie43f0e3a8740f0fc132809a09a153886c51fadf9
2018-06-05 11:42:12 +02:00
Stefan Sperling 78ab624c2a fix time-delta calculations for measurement reports
The previous implementation unconditionally subtracted nanosecond
values from different time measurements, causing overflow if the
current measurement was taken in less of a fraction of a second
than the past measurement. Use timespecsub() instead, which
accounts for nanoseconds correctly.

Also, fix calculations of KBit/s throughtput. It was not being
calculated correctly, since it was actually accounting for one
KB per 128th-part-of-a-second.

Change-Id: I7d22e7b5902c230efeae66eb20c17026a4037887
Related: OS#3225
2018-05-31 14:12:58 +02:00
Stefan Sperling f0f7df1b87 read monotonic clock with clock_gettime() instead of gettimeofday()
There have been test failures on the osmo-pcu Jenkins builders due
to apparent clock drift. Switch relevant code from gettimeofday()
to clock_gettime() with CLOCK_MONOTONIC to prevent time from going
backwards and causing negative time deltas in calculations.

Change-Id: I775d85d0d3ac740330879e588bdab6fce7f0b46c
Related: OS#3225
2018-05-25 17:33:06 +00:00
Stefan Sperling 143b2da4f8 fix a one-byte stack buffer overrun in osmo-pcu
Address sanitizer uncovered a one-byte stack overrun due to an
off-by-one in the size of the 'data' buffer in pcu_l1if_tx_pch().
Fix the problem and add an assertion which triggers before the
overrun can occur.

Change-Id: I08a879d72fcb916f78f175612fd90467d7bdd57c
Related: OS#3289
2018-05-25 15:19:50 +02:00
Pau Espin 7a9c1660cc rlc: Fix memset(0) on object with no trivial copy-assignment
As warned by gcc 8.1.0, the cs field is a class (GprsCodingScheme) and
should not be memset.

Change-Id: Id742f82aa856e696b5fb414991dfd0883d0ac7fe
2018-05-16 15:22:27 +02:00
Pau Espin 0b0748a4be tbf: Fix memset(0) on object with no trivial copy-assignment
As warned by gcc 8.1.0:
osmo-pcu/src/tbf.cpp: In constructor ‘gprs_rlcmac_tbf::gprs_rlcmac_tbf(BTS*, gprs_rlcmac_tbf_direction)’:
osmo-pcu/src/tbf.cpp:222:33: error: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct gprs_rlc’ with no trivial copy-assignment; use assignment or value-initialization instead [-Werror=class-memaccess]
  memset(&m_rlc, 0, sizeof(m_rlc));
                                 ^
In file included from osmo-pcu/src/tbf.h:24,
                 from osmo-pcu/src/bts.h:37,
                 from osmo-pcu/src/tbf.cpp:22:
osmo-pcu/src/rlc.h:234:8: note: ‘struct gprs_rlc’ declared here
 struct gprs_rlc {
        ^~~~~~~~

Change-Id: Ifb0529b9ae6cd4300e5cbbd9151054792edbfe06
2018-05-16 15:20:43 +02:00
Harald Welte 45143d270c Don't register SIGHUP handler without actually handling SIGHUP
In libosmocore, we normally register a SIGHUP handler for log file
rotation.

However, the osmo-pcu code so far installed its own signal handler,
which did exactly nothing in the SIGHUP case.

Let's fix this by removing SIGHUP handling here, letting libosmocore
take care about this.

Change-Id: Ifa20d79770bc4d88d40601b008a3a2a79d083c04
Closes: OS#3265
2018-05-15 16:23:04 +02:00
Stefan Sperling 513c9bca17 improve documentation of Encoding::write_paging_request()
Add pointers to relevant parts of the spec. Tweak comments to be
more specific about the values being written and abbreviations used.

Change-Id: Ia5bf3f7f8846198b7b4e25ff1accf6206764be74
2018-05-02 14:53:16 +02:00
Philipp Maier 33c52b6271 tbf: add frame number to log output
Currently, the TBF timer log messages lack the frame number in
the logoutput

- Add frame number to TBF timer related log-statements

Change-Id: I5a744dc5cd7c1de1baea13fffac026c83d091429
Related: SYS#4139
Patch-by: Octasic inc.
2018-04-12 12:46:44 +02:00
Philipp Maier 7e8e3978fe pcu_l1_if: add frame number to log output
Currently, the log output lacks the frame number.

 - make get_current_fn() public
 - add frame number to the log statements in pcu_l1_if.cpp

Change-Id: Idce994dbf86a2bbf861907d75418a2a3867244db
Related: SYS#4139
Patch-by: Octasic inc.
2018-04-10 13:35:24 +02:00
Philipp Maier 8ccf704608 cosmetic: remove runaway semicolon
Change-Id: I33c335dc8d564a8357ffb5b1163c2c4b1a578b49
Related: SYS#4139
Patch-by: Octasic inc.
2018-04-10 13:35:18 +02:00
Neels Hofmeyr 42f2d61ac9 use osmo_init_logging2() with proper talloc ctx
There is a duality of initialization: early_init() in bts.cpp wants to init
logging even before static instances get initialized. Make sure that
tall_pcu_ctx is initialized during early_init() as well. There is a build
context that does not seem to include bts.cpp (osmo-pcu-remote), so to be sure,
init tall_pcu_ctx as NULL and both in early_init() as well as pcu_main.cpp,
init both tall_pcu_ctx and logging if it is still NULL.

Change-Id: I2199b62d0270bd35dec2283e8f5b364b7c63915b
2018-04-01 16:57:42 +02:00
Neels Hofmeyr e6e4898027 Revert "Rewrite EGPRS Packet Uplink Assignment"
This reverts commit 529ce88545,
I2139fb347b3290621bbc3f6a031f7f213d372e65.

Commit I52ec9b07413daabba8cd5f1fba5c7b3af6a33389 /
896574e92b was found (empirically) to be a
regression, rendering GPRS service fatally unreliable.

This reverted commit seems to be related to the regression and is reverted
along with it.

Related: OS#3013
Change-Id: I3e8cc0e8ba3ba5bd444124fd4cb95ef92a71fdfb
2018-03-30 14:30:13 +00:00
Neels Hofmeyr 39f845848c Revert "Rewrite Packet Downlink Assignment"
This reverts commit 896574e92b,
I52ec9b07413daabba8cd5f1fba5c7b3af6a33389.

This commit was found (empirically) to be a regression, rendering GPRS service
fatally unreliable.

Related: OS#3013
Change-Id: Idcba0381f70eb7f7c9aefdee9dfeafd5de96a9be
2018-03-28 14:34:55 +00:00
Neels Hofmeyr 782da2cf95 Revert "Rewrite Packet Uplink Assignment"
This reverts commit 93d947f5e8,
I44db2eeea7448ff67e688ae716487bc6dbfc96a3.

Commit I52ec9b07413daabba8cd5f1fba5c7b3af6a33389 /
896574e92b was found (empirically) to be a
regression, rendering GPRS service fatally unreliable.

This reverted commit seems to follow after the regression and is reverted along
with it.

Related: OS#3013
Change-Id: If7038127e9a663c93006475b3add961adc0b1922
2018-03-28 14:34:55 +00:00
Neels Hofmeyr 89b85e078e Revert "Use Timing Advance Index in UL assignments"
This reverts commit 6298fbb7b2,
I8b17be78a46c0bc17516b7c90f35aa4768010ae4.

Commit I52ec9b07413daabba8cd5f1fba5c7b3af6a33389 /
896574e92b was found (empirically) to be a
regression, rendering GPRS service fatally unreliable.

This reverted commit seems to follow after the regression and is reverted along
with it.

Related: OS#3013
Change-Id: I5e0fd8c9c3b89e519e7382e3d0bb24e0aeddeff6
2018-03-28 14:34:55 +00:00
Neels Hofmeyr f75381498c mslot_class: two more: use uint32_t to shift 1 << 31
Avoid runtime error seen on jenkins admin-deb9build slave, when building
osmo-pcu with_dsp=None,with_vty=False, during ts_alloc and tbf regression
tests:

+../../../src/mslot_class.c:271:36: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
+../../../src/mslot_class.c:272:22: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

This time it seems that these are all.

The master-osmo-pcu breaks on this since moving to a debian9 build slave.

Change-Id: I976a1dca9da19a05afc85a17b7ba60545b7bc1e5
2018-03-28 14:44:47 +02:00
Neels Hofmeyr 8b4bd46b95 mslot_class: find_free_tfi(): use uint32_t to shift 1 << 31
Avoid runtime error seen on jenkins admin-deb9build slave, when building
osmo-pcu with_dsp=None,with_vty=False, during ts_alloc and tbf regression
tests:

+../../../src/mslot_class.c:242:22: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

The master-osmo-pcu breaks on this since moving to a debian9 build slave.

Change-Id: I0cdf10e5fbc1173a7a09bd4fed8a66d06f80aeb1
2018-03-26 23:24:16 +02:00
Pau Espin 74906224ca gprs_bssgp_pcu.cpp: Comment unused function parse_ra_cap
Commit 741d25cb6f commented the only user
of the function but forgot to comment too the function itself.

Change-Id: I8b291b45aaedfb0421cd28c0d9e24cefa5547b09
2018-03-17 01:43:14 +01:00
Neels Hofmeyr bdc55fad62 implement support for 3-digit MNC with leading zeros
Receive the mnc_3_digits flag from the PCU interface.

Bump the PCU interface to 9.
This is one part of the three identical pcuif_proto.h patches:
- I49cd762c3c9d7ee6a82451bdf3ffa2a060767947 (osmo-bts)
- I787fed84a7b613158a5618dd5cffafe4e4927234 (osmo-pcu)
- I78f30aef7aa224b2e9db54c3a844d8f520b3aee0 (osmo-bsc)

Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout
the code base to be able to handle an MNC < 100 that has three digits (leading
zeros).

Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore),
         Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore)

Change-Id: I787fed84a7b613158a5618dd5cffafe4e4927234
2018-03-11 00:47:14 +01:00
Max 731e2bb328 Simplify TS alloc: move slot check into functions
Move timeslot applicability check outside of nested for loop into
separate functions and document them. Add corresponding tests.

This allows us to clarify types used in TS-related computations.

Change-Id: Ic39e848da47dc11357782362fdf6206d2c1457c2
Related: OS#2282
2018-02-21 12:08:40 +00:00
Max 77988d469d Simplify TS alloc: move slot assignment
Move into separate functions:
* move timeslot reservation
* move UL timeslot assignment
* move DL timeslot assignment

Change-Id: I64cf78c5cfc78664766f9769dd5cde632dab92b0
Related: OS#2282
2018-02-21 12:08:38 +00:00
Max 847ed9f8cd TBF: make network counters internal
* store N310* counters in shared array similar to corresponding timers
* add functions to increment/reset counters

This avoids direct access to TBF counters from PDCH.

Change-Id: I8ffff9c7186f74bde7e6ac5f6e98f0b3e4c35274
Related: OS#1539
2018-02-20 18:16:11 +01:00