Commit Graph

920 Commits

Author SHA1 Message Date
Vadim Yanitskiy 061b7ec434 gsm0808: remove unneeded assignment in enc_speech_codec()
Change-Id: Ifc6d109e27cdada0d08d2a8fc1c354f3de04f15c
2022-12-14 02:06:06 +07:00
Vadim Yanitskiy 8e962451fc gsm0808: cosmetic: switch is not a function
Change-Id: I2f58711675c5c9511c4f4fe4bf0d6e6f7dd093b1
2022-12-14 01:13:19 +07:00
Max 2b283b1a1a LAPD: move tx_hist code into static functions
Related: OS#4074
Change-Id: Ibf3b08c8d874416796b94ba3a672a02d614313b1
2022-11-26 13:59:09 +00:00
Pau Espin 6ca0a43294 gsm: constify several readonly params
Change-Id: Ib11bfe57f546a5618f70152b9b75115808e54bf6
2022-11-24 17:09:03 +01:00
Vadim Yanitskiy 8fbaad6903 */Makefile.am: do not mix up AM_CFLAGS with AM_CPPFLAGS
Change-Id: I2c1d5f9c61714f487fbbe60603b2682f2c0a4c6b
2022-11-10 16:07:03 +00:00
Harald Welte e61d459cef Support building with -Werror=strict-prototypes / -Werror=old-style-definition
Unfortunately "-std=c99" is not sufficient to make gcc ignore code that
uses constructs of earlier C standards, which were abandoned in C99.

See https://lwn.net/ml/fedora-devel/Y1kvF35WozzGBpc8@redhat.com/ for
some related discussion.

Change-Id: I84fd99442d0cc400fa562fa33623c142649230e2
2022-11-03 12:44:28 +01:00
Vadim Yanitskiy 19bd12e919 gsm0502: gsm0502_fn_remap(): use GSM_TDMA_FN_SUB() macro
Change-Id: Id77644d945ad195733d4bf68c0d1c5b450b16e58
2022-10-26 18:13:22 +07:00
Vadim Yanitskiy 73aa0e5219 {gsm,gb}/Makefile.am: drop undefined $GCC_FVISIBILITY_HIDDEN
Change-Id: I142cf38e8954720ed66b0c242a5527c96626dcaa
2022-10-20 04:51:40 +00:00
Max 327e5e990d LAPD: use bool for T200 reset flags
Related: OS#4074
Change-Id: I2d1a3dd7938b079a3525c84647f82b7bc6cdfdd6
2022-10-11 20:01:59 +03:00
Max c569526379 LAPD: log unknown format value
Change-Id: I9efd433ed128ae1d9df45591b1a93e10f8a3372c
2022-10-11 19:47:49 +03:00
Max 68588c57ef cosmetic: make linter happy with LAPD code
The weird formatting not only makes it hard to read but caused linter to fail in the follow-up patch.

Change-Id: Ie4e56b4796c1b8f270a692453faccf102c963db5
2022-10-11 19:34:43 +03:00
Keith Whyte 486d98404d Fix Typo in gsm0808_msgt_names[]
Change-Id: I91585d81efd6e18f4b8f9eaeaaaa50412253d93b
2022-10-06 03:16:15 +01:00
Keith Whyte e852544f6c Fix LCLS-CONNECT-CONTROL generation
gsm0808_create_lcls_conn_ctrl() was adding the LCLS-Configuration IE twice.

Correct is LCLS-Configuration followed by LCLS-Connection-Status-Control
(TS 48.008 3.2.1.91)

Change-Id: I455ac7695ad33ef9073bea7d1711508717732607
2022-10-06 01:12:15 +01:00
Pau Espin 18c6a8183f gsm: bts_features: Add missing entries to osmo_bts_features_names
Those features were present in osmo_bts_features_descs but not in
osmo_bts_features_names.

Change-Id: Ic8162e7ab6b657de694e3825e694e9b18c540271
2022-08-09 17:53:17 +02:00
Pau Espin 83287ba41c gsm: rsl: Define new osmocom extension TLV IE to pass Osmux CID
This is similar to what we already do between BSC<->MSC to pass Osmux
CID (GSM0808_IE_OSMO_OSMUX_CID).
We now want to support Osmux between BSC and Osmocom BTS, hence add an
extension IE which will be used in ipaccess CRCX messages to tell the
BTS to use Osmux.

Change-Id: I580fe99c01bc0a844d877994ec6cd954310e265d
2022-08-09 08:35:55 +00:00
Pau Espin 306400786d gsm: Add BTS feature for Osmux
This feature is used by the BTS to signal to the BSC that it supports
using Osmux instead of RTP on the BTS<->BSC(MGW) data plane.

Related: SYS#5987
Change-Id: Ie79bfb6d0a7a8fe2842d2596b3244e7b74a0d5b6
2022-08-09 08:35:55 +00:00
Pau Espin 9eb698a030 cbsp: Fix decoding of Fail List
The decoding pointer was not increased correctly, ending up in reading
by 1 byte offset  for each item in the list.

Change-Id: I16ed9bd65109a7ce32ff43c5789b4544479838e7
2022-08-06 17:00:48 +00:00
Pau Espin 5563bc998f cbsp: Guard against malformed msgb without l1h,l2h being passed
Change-Id: Ie8854c780cfd96e67df10c1fc38c6b99ec07422f
2022-08-06 17:00:48 +00:00
Pau Espin fdb8f81922 cbsp: Return error if decoding any of the cell id lists fail
Change-Id: I5934167f927df0547cb57687e2717489fd1f3719
2022-08-06 17:00:48 +00:00
Oliver Smith c66b35b616 gsm0808_enc_aoip_trasp_addr: add length check
Instead of running into OSMO_ASSERT in msgb_put(), return early if the
msgb is too small. As suggested by Pau in [1].

I would have returned -EMSGSIZE, but the function returns uint8_t.

[1]: https://gerrit.osmocom.org/c/osmo-bsc-nat/+/28582/2#message-a183c463ea20a8d958465ce45a83e62c46214cf6

Change-Id: I632986b99d841abff0f14c6da65f030175f5c4a1
2022-08-05 14:07:55 +00:00
Mychaela Falconia 605c9e63bb gsm48_ie: fix parsing of Bearer capability IE without octet 3a
The testcase in gsm0408_test is still failing because the encoder
produces a different result (with octet 3a present).  There is no
way to tell the encoder to use the implicit coding, and in general
this is not that critical, so we can live with that.

Change-Id: I722c168f01bffa915cb155eac234a796549d3762
2022-07-03 07:01:15 +07:00
Vadim Yanitskiy 384e6a340c gsm48_ie: fix coding style: while is not a function
Change-Id: Id28bf61c5e1dfb6da1c89a5502eb869b67fed6c6
2022-07-03 06:48:56 +07:00
Pau Espin 8f577fbb5c cbsp: avoid potential msgb write overflow in osmo_cbsp_recv_buffered
>>>     CID 273001:  Insecure data handling  (TAINTED_SCALAR)
>>>     Passing tainted expression "needed" to "recv", which uses it as an offset.
1444                    rc = recv(fd, msg->tail, needed, 0);

Fixes: Coverity CID#273001
Change-Id: I17c558254f9c7907b56d61c53c2f597e8e4566cf
2022-07-01 14:22:09 +00:00
Pau Espin 09e5409cef iuup: Explicitly mark default case as unexpected with assert
That code path should not happen since this function is only called for
data frames coming with IUUP_FSM_EVT_IUUP_DATA_IND.
Control frames should come with specific events like
IUUP_FSM_EVT_IUUP_CONFIG_REQ.
Hence, let's add an assert to make sure we early exit if that ever
happens (it shouldn't), instead of carrying on reading uninitialized var
"dt".

Fixes: Coverity CID#272996
Change-Id: Iaeba59bc9ebfe817dbb7528572dc669c010ef14d
2022-06-29 18:19:38 +02:00
Pau Espin a1584d237b Bump version: 1.6.0.132-0239-dirty → 1.7.0
Change-Id: Idb0d20aa4336a69cb100e140fb1fa9e7ac25b984
2022-06-28 17:00:51 +02:00
Pau Espin 3278f0fb3c iuup: Fix Handling of subsequent Initialization msgs
Once the IuUP FSM moved away from Init state, it stopped handling
Initialization messages received from peers and simply ignored them
starting from that point. As a result, if the first IuUP Init ACK it
sent to the peer was lost, the peer would keep retrying with more IuUP
Init and getting no answer.
In any case, it seems possible and desirable that a peer may send an
IuUP Init at a later point, as pointed out vaguely in 3GPP TS 25.415.

sec 6.5.2.1:
"""
Upon reception of a frame indicating that an Initialisation procedure is
active in the peer Iu UP entity, the Iu UP protocol layer forwards the whole
protocol information contained in the INITIALISATION control frame to the
upper layers. It also stores the RAB sub-Flow Combination set (and thus
replaces a possible previous set) in order to control during the transfer of
user data, that the Iu UP payload is correctly formatted (e.g. RFCI matches
the expected Iu UP frame payload total length). The peer Iu UP entity
receiving the INITIALISATION control frame shall choose a version that it
supports among the proposed versions indicated by the sender for which it
has enough initialisation information.
"""

sec B.2.2 "Initialisation State":
"""
After sending a positive acknowledgement of the last INITIALISATION control
frame, the Iu UP instance enters SMpSDU data transfer ready state. Note that
CN does not know if the initialisation ACK was correctly received by the RNC
(and Initialisation procedure successfully completed) until it receives RAB
assignment response, or use data from the RNC. The CN must therefore be able
to continue receiving INITIALISATION control frames by re-entering the
Initialisation state (from Support Mode Data Transfer Ready State), if the CN
has started to send user data before receiving the indication that
Initialisation was successfully completed
"""

sec B.2.3 "Support Mode Data Transfer Ready State":
"""
In case of handover or relocation, Initialisation procedures may have to be
performed and Iu UP instance may have to enter the initialisation state.
"""

Related: SYS#5995
Change-Id: I5cb740702805693cc7f0a550e2e093f9bfdd507c
2022-06-13 13:51:55 +02:00
Pau Espin 8d7bf4b053 iuup: Drop unused events
Those events are not realy used there and they are not even present in
the FSM definition. Let's drop them.

Change-Id: I4beec96ac4bdf047ebf144a8b009b297b47cacdc
2022-06-13 13:13:59 +02:00
Pau Espin 0664a3e60f iuup: Add missing state to bitmask for st SMpSDU_Data_Transfer_Ready
The event is expected since the user of the IuUP stack can send a
CONFIGURE.req to transition to state null. The handling was already
there in the function, but the bit was missing in the FSM definition.

Change-Id: I830835a5b8b98f8b91b866f5280f508098c9ae7e
2022-06-13 13:12:31 +02:00
Pau Espin 0cdd0abd53 cbsp: Add enum and value string for Cause
Change-Id: I35592bb4fff2e7b442d0e0cd537b66687862baf2
2022-06-09 18:17:43 +02:00
Pau Espin 6d6d22ea34 iuup: Fix IPTIs_present not set to 0 if no IPTIs received
Related: SYS#5969
Change-Id: I503dc509ad8619f13cd83ae03261a2297e2b9fc7
2022-05-27 14:30:30 +02:00
Pau Espin 510f4c9d63 iuup: Rework API to support RFCI IDs != RFCI index
The initially merged IuUP API and implementation assumed that RFCI with
ID was always in the position of its ID inside the list of RFCIs. This
was the case for messages sent by ip.access nano3g as well as our own
osmocom implementation. However it was noticed that other nodes from
other vendors actually use other order, as allowed by the IuUP message
format.
Hence, we need to break the assumption and provide explicit ID
information in the list.

NOTICE: This commit breaks API and ABI compatibility with older versions
of libosmogsm, but not with any previous release of libosmocore since
the API is only available in master so far (it was added in
9fe1f9fb0b).
Similary, it's only user (osmo-mgw) only uses the API in master, so
there's no API breakage with older releases.

Related: SYS#5969
Change-Id: Ib21cee2e30bf83dff4e167f79541796007af9845
2022-05-25 14:10:17 +00:00
Vadim Yanitskiy be5e838dbb Use internal <osmocom/core/talloc.h> everywhere
Change-Id: If40e1eefcfa88a2b376becfe057836acdd3a1cc2
2022-04-27 12:42:15 +00:00
Pau Espin b0c2f75665 jenkins: Validate gsm 08.58 IEs are added to tlv_definition
It was recently found that several IEs which were added in the header
file were not actually added to the tlv_definition, and hence the tlv
parser failed to decode them. Let's make sure we don't foget to add new
IEs in the future.

Related: SYS#5915

Change-Id: Id8a679ca43eb0fcc4882780e9a95ec21c7f51972
2022-04-05 17:38:25 +02:00
Pau Espin 388a53a8d7 rsl: Fix tlv_parse of IPAC_DLCX_IND message
The IE was missing in rsl_att_tlvdef.

Related: SYS#5915
Change-Id: Ib637197ef3508ec94aec05d08d4e6aa15ddea055
2022-04-05 17:32:41 +02:00
Vadim Yanitskiy be1338789a bssmap_le: support additional IEs in Perform Location Request
Change-Id: I8775a93cf4089b1752d040e43d2cba6b8997f955
Related: SYS#5891
2022-03-22 18:38:19 +03:00
Pau Espin 3cf475917e gsm0808: Add missing IEs in bss_att_tlvdef
Change-Id: I8660640ce50a6dc20e718c4165ccf779c5f553a4
2022-03-18 17:36:46 +01:00
Pau Espin fffd7c345b gsm0808: Fix decoding of IE GSM0808_IE_LCS_CLIENT_TYPE
Change-Id: I7acafdefd105e330c466df2e17e884327651e348
2022-03-18 17:36:46 +01:00
Pau Espin 28b404fb71 gsm: lapd_core: Change log line NOTICE->INFO
Change-Id: I71f014645b4b487bf91499a1da9ed2d3032d7e40
2022-03-02 19:03:32 +01:00
Neels Hofmeyr a25a6dca25 BSSAP: HO Request Ack: add missing Codec List (BSS Supported)
Related: SYS#5839
Related: I3c0576505a3ceb3cd5cc31dc69c5bc4a86a4ea08 (osmo-bsc)
Change-Id: Iab0a7b4d81592157fc111d1adb9e9f4cb53a94e9
2022-02-28 11:04:08 +00:00
Pau Espin b5551eec33 gsm: [ABI BREAK] Support CellId SAI, change CellId CGI-PS id number
Those are available in 3GPP TS 48.008 version 16.0.0 Release 16, section
3.2.2.17 Cell Identifier. It can be seen that we have a collision
between the osmocom non-standard format and the SAI standard one.

This is because CGI-PS is not really a TS 48.008 Cell Identifier, but only
specified in TS 48.018 and has no ID number assigned. The CGI-PS was
added there because the whole osmo-bsc neighbour configuration works
with CellIds to manage neighbours, so it felt natural to extend the APIs
to also provide means to use CGI-PS format (TS 48.018 even refers 48.008
existance and mentions there's no explicit ID).

At the time this Cell Identifier was added, the firstly available number
(11) was taken, which was of course a really bad idea since newer
versions of the spec can at some point use it, which is the case if one
checks for instance TS 48.008 Release 16 SAI Cell Id.

There no perfect way to fix this bad decision at the time, but the
CGI-PS is only used in osmo-bsc and only for RIM related purposes, so by
changing the ID of CELL_IDENT_WHOLE_GLOBAL_PS, we only break RIM under
some specific CIs being used, and when an osmo-bsc is built against
older libosmocore and then used at runtime against a newer libosmocore
(which should be rare).
Hence, the downside is acceptable, and by moving the new ID number to be
ouside of the spec proto TS 48.008 range (4 bits), we make sure we don't
have the same problem again in the future.

Related: SYS#5838
Fixes: ca33a71ca8
Change-Id: Id25e563febdb7640174540136225f399515a0089
2022-02-16 17:59:23 +01:00
Vadim Yanitskiy 846db1b3c3 gsm_7bit_encode_n(): use regular malloc() instead of calloc()
In general, it's safe not to use talloc API here because those are
internal allocations, and there are no 'return' statements between
calloc() and free().  However, we don't really need to initialize
the heap memory with 0, so let's use the 'normal' malloc().

Change-Id: I6956cbd83b2999dbcf8e2d210134b0a166c33efb
2022-01-29 01:02:32 +06:00
Philipp Maier bdd7df3c83 iuup: do not use illegal characters in state/event names.
The event names contain '.', and there are spaces ' ' in the state
names. This is a problem since states and events can also be monitored
via the CTRL interface. Unfortunately the CTRL interface does not allow
certain reserved characters. So lets rename the states and event names
to make them compatible with the CTRL interface.

Change-Id: Id19973b56f9d7b1e3d0b0d7c7d0be7beba5428fc
Related OS#4149

Change-Id: I5ebc9ab5b1456fee29aa4e254fae862dc053f0aa
2022-01-18 12:04:47 +01:00
Philipp Maier c7c1ff573b gsm23003: fix docstring for osmo_plmn_from_bcd()
The parameters described in the docstrings for osmo_plmn_from_bcd() do not match the actual parameter list.

Change-Id: Ic0999dbe096a98418db7482bd110e20497d8e4a5
2022-01-14 17:14:15 +01:00
Pau Espin 1322755922 iuup: Improve CRC checksum error logging
Change-Id: I14f2ff14af24f20b788d123c0bfb47aeb0333d19
2022-01-10 13:58:45 +00:00
Pau Espin 604eaba2c3 iuup: Submit RNL-STATUS-Initialization.ind upon rx of Init
This allows init-passive users to get the configured sizes for the RFCIs
and other similar information once engotiated with the peer.

Realted: OS#1937
Change-Id: I63ee780b4aa162ea097410b234e73984000c0965
2022-01-07 13:02:56 +00:00
Pau Espin d3b016fec5 iuup: Fix decoding of 1byte-length subflow size fields
Change-Id: I78ae9e7d46d0725ddec05e004ae22ee5da738162
2022-01-05 23:09:17 +00:00
Harald Welte 29814a5374 iuup: Fix signed/unsigned loop counter control flow issue
The use of an unsinged integer as for loop counter variable doesn't
work when counting down and comparing with >= 0.  The existing code
would be an infinite loop if it wasn't for the (data dependent) break
condition:

>>>     CID 243259:  Control flow issues  (NO_EFFECT)
>>>     This greater-than-or-equal-to-zero comparison of an unsigned value is always true. "i >= 0U".
572             for (i = 15; i >= 0; i--) {
573                     if (match_mask & (1<<i)) {
574                             iui->mode_version = i;
575                             break;
576                     }

Change-Id: I019d0f0d8f2b167575a2883a13cca692c96961cf
Closes: CID#243259
2021-12-24 11:35:57 +01:00
Harald Welte 9fe1f9fb0b Introduce CRC and FSM for IuUP (user plane) as used in 3G RTP data
Only support for SMpSDU mode is introduced in this commit.

Not supported explicit list:
- Transparent mode
- ATM/AAL2 based Transport layer
- GTP-U based Transport Layer
- Iu Rate Control procedure
- Time Alignment procedure

APIs are provided to allocate the primitives properly inside the related
msgb. This way primitives can be placed in the headroom, leaving the
data part of the msgb for the IuUP payload, hence allowing re-use of the
msgb and 0 copy of IuUP payload when forwarding data over RNL<->TNL.
Since RNL and TNL primitives relu struct osmo_prim_header, which is not
packed, they cannot be set to packed, and hence proper memory alignment
in the msgb must be done to avoid misaligned accesses (Asan errors about
it otherwise).

Related: SYS#5516
Change-Id: Ibe356fa7b1abaca0091e368db8478e79c09c6cb0
2021-12-22 14:58:31 +01:00
Oliver Smith 04bfb7165b treewide: remove FSF address
Remove the paragraph about writing to the Free Software Foundation's
mailing address. The FSF has changed addresses in the past, and may do
so again. In 2021 this is not useful, let's rather have a bit less
boilerplate at the start of source files.

Change-Id: I5050285e75cf120407a1d883e99b3c4bcae8ffd7
2021-12-14 12:44:03 +01:00
Pau Espin c7deaf28aa Bump version: 1.5.1.282-ab5e-dirty → 1.6.0
Change-Id: Ia3ac0a36b9e898996f596c6d2787e03cd59bfc11
2021-11-16 13:08:23 +01:00
Neels Hofmeyr 34907fe6e1 revisit some calls of strtol(), stroul(), strtoull()
Replace some with atoi(), where the VTY has already validated correct
range of the argument.

Replace others with the new osmo_str_to_int() or osmo_str_to_int64()
functions, possibly covering more detection of invalid number strings.

Leave those strtol() callers that depend on endptr to provide the next
string token.

Related: SYS#5542
Change-Id: I0ebb06e751c28f7d1cdf328de29cd227a2449391
2021-10-04 11:24:59 +00:00
Vadim Yanitskiy 6b60d52abf fix rsl_chan_nr_str_{buf,c}(): enlarge the buffer size
20 bytes is not enough for some VAMOS specific channel number values,
so the resulting string representation gets truncated by snprintf():

  expected: "VAMOS TCH/H(0) on TS4\0"
  actual:   "VAMOS TCH/H(0) on T\0"

Let's enlarge the buffers to 32 bytes.

Change-Id: I68d839f4ab742cf56de34e7e22572a1163aec2da
2021-10-01 15:47:05 +06:00
Pau Espin 50e6f06658 gsm: Mark gsm0858_rsl_ul_meas_enc() pointer param const
Change-Id: I9b2704250d8a3f6c6fc6cd2a5136b1408c8ed965
2021-09-28 11:32:00 +02:00
Pau Espin 51933840ff gsm_08_58.h: Extend IPA Power Control Params IEs to pass C/I params
This commit adds new Osmocom specific IEs required to pass C/I related
Power Control Parameters osmo-bsc => osmo-bts to be used by the MS Power
Control Loop being implemented.

Related: SYS#4917
Change-Id: Iffef0611430ad6c90606149c398d80158633bbca
2021-09-03 15:32:50 +00:00
Philipp Maier 58f76d8b90 bts_features: Add new feature to indicate support for temporary overpower
To indicate to the BSC that a BTS supports temporary overpower of
SACCH/FACCH channels a new feature BTS_FEAT_ACCH_TOP is added.

Change-Id: I62fbfc30acd5d67b20727b75a8f256e6b5d31e06
Related: SYS#5319
2021-08-31 19:54:28 +00:00
Philipp Maier 0e44a7203c rsl: add new RSL IE to signal temporary overpower
To transfer the temporary overpower value from the BSC to the BTS, a new
RSL IE (RSL_IE_OSMO_TOP_ACCH_CAP) is added.

Change-Id: I31c5be4bceb9140d63ab8e2f197f0acc68699426
Related: SYS#5319
2021-08-31 19:54:28 +00:00
Pau Espin 6fe865daae Make gcc 11.1.0 false positivies happy
After my system's gcc was upgraded, I get false positivies in a couple
places. Let's initialize those to make gcc happy.

"""
/git/libosmocore/src/socket.c: In function ‘osmo_sock_init’:
/git/libosmocore/src/socket.c:958:25: error: ‘sfd’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  958 |                         close(sfd);
      |                         ^~~~~~~~~~

/git/libosmocore/src/gsm/gsm48.c: In function ‘osmo_mobile_identity_decode’:
/git/libosmocore/src/gsm/gsm48.c:690:20: error: ‘str_size’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  690 |         if (rc < 1 || rc >= str_size) {
      |             ~~~~~~~^~~~~~~~~~~~~~~~~
/git/libosmocore/src/gsm/gsm48.c:679:22: error: ‘str’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  679 |                 rc = osmo_bcd2str(str, str_size, mi_data, 1, 1 + nibbles_len, allow_hex);
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"""

Change-Id: I8aacfbc21e23f63a65e8baee3fd536a1fe1bdd8a
2021-07-16 16:01:30 +00:00
Pau Espin d9825c0a2c bts_feature: Introduce feature to confiure dyn ts as sdcch8
This feature signals support to configure Osmocom Dynamic Timeslot type
as SDCCH8, on top of historically supported TCH/H and TCH/F.
The idea is that when unneeded, the TS is configured as PDCH, and as
soon as there's need for an SDCCH and there's none available, the TS is
dynamically reconfigured to SDCCH8. Once all logical channels in the
dynamic TS are released and hence becomes free, the BSC will reconfigure
it to PDCH.

Related: SYS#5309
Change-Id: Ifc0ca8916bd3e93e5a60a7dd7391d2588fdb5532
2021-06-30 13:15:02 +02:00
Pau Espin 45dc9d00fe Rename osmo dyn ts enums
They will gain support to be activated as SDCCH/8 soon too. Since new
name would start to be too large, use a more generic naming for it.

Related: OS#5309
Change-Id: I56dcfe4d17899630b17f80145c3ced72f1e91e68
2021-06-30 13:14:08 +02:00
Neels Hofmeyr 26e53b181c add fixme: enforce 8 byte length of Kc
Change-Id: I57efb0a24cb71b365189eccb5088b130fad15093
2021-06-29 22:35:03 +02:00
Vadim Yanitskiy 1c2a329f85 bts_features: add feature for BCCH carrier power reduction mode
Change-Id: I69283b3f35988fc7a1a1dcf1a1ad3b67f08ec716
Related: SYS#4919
2021-06-25 19:34:52 +02:00
Neels Hofmeyr e4378b7e38 gsm0808: add Kc128 to Handover Request
Change-Id: Ieb6e43eef9e57281d54d4b7c63664668df5aef3e
2021-06-25 08:19:04 +00:00
Neels Hofmeyr 4a9756c17a add Kc128 to gsm0808 Create Ciphering Command
Prepare for A5/4 support in osmo-msc.

Add new function gsm0808_create_cipher2() which takes a struct as
argument instead of individual fields. This is akin to e.g.
gsm0808_create_handover_request() below in the file, and allows
backwards compatibly extending the argument list without needing a new
function signature every time.

Add struct gsm0808_cipher_mode_command, as argument list for
gsm0808_create_cipher2(), with kc128 included.

Encode the Kc128 IE in gsm0808_create_cipher2().

Implement gsm0808_create_cipher() by calling gsm0808_create_cipher2().

Change-Id: Ib3906085e0c6e5a496a9f755f0f786238a86ca34
2021-06-21 00:36:46 +02:00
Pau Espin 42bb125df1 bts_feature: Introduce feature to speak to PCU
This feature provides the BSC with information on whether the BTS talks
the IPAC_PROTO_EXT_PCU osmocom extension over the underlying IPA
multiplex of the OML link.

Related: SYS#5303
Change-Id: Id62421f7f5540875ac877a187757f2cf0556bd02
2021-06-11 16:36:29 +00:00
Eric Wild c3fa007610 kdf: add key derivation functions
generic sha code from git://w1.fi/hostap.git commit
5ea93947ca67ba83529798b806a15b247cdb2e93 which also happens
to be the source of our milenage code.

Related: SYS#5324
Change-Id: Ibf2e49edada944d91ceba62bd0d6b6ce69261fcd
2021-06-08 02:38:15 +02:00
Pau Espin 6c7ac6abcd range_enc_determine_range(): Don't dereference array on size=0
cherry-picked from osmo-bsc.git d4c391eab03ce768d7eaf483368d9cda4f9668df

Change-Id: Iae058c35506bc25c9f4790889b89ac46aea664b6
Fixes: Coverity CID#182710 (osmo-bsc.git)
2021-06-01 14:04:20 +02:00
Neels Hofmeyr 208c5b643f fixup for gsm48_chan_mode_to_non_vamos()
When modifying chan modes, I first thought rather always fail if there
is no equivalent mode.

That is true for gsm48_chan_mode_to_vamos(), but for a change to
non-VAMOS, rather return the unchanged mode for non-VAMOS modes, so that
gsm48_chan_mode_to_non_vamos(GSM_CMODE_SIGN) works without failure.

This makes more convenient checking, e.g. in osmo-bsc's lchan_fsm.c
making sure that a non-VAMOS lchan has a non-VAMOS chan_mode, for all
types of lchans.

Change-Id: Ibf20f04d167e0e0599012ff530bc17ba8c8ab562
2021-05-29 23:45:22 +00:00
Vadim Yanitskiy fc02ff459a gsm_08_58.h: add Osmocom specific Bm/Lm CBITs for VAMOS
Change-Id: If33c1695922d110c0d2c60d5c0136caf2587194e
Related: SYS#4895, OS#4941, SYS#5315, OS#4940
2021-05-26 21:18:11 +02:00
Vadim Yanitskiy 57850ae188 rsl: make rsl_dec_chan_nr() more readable, use RSL_CHAN_NR_MASK
Change-Id: I1650e3b02e79461e42499268fa8ed30bff667489
2021-05-26 21:02:06 +02:00
Neels Hofmeyr dd6f13636e add RSL_IE_OSMO_TRAINING_SEQUENCE
This IE is explained in the Abis manual in osmo-bts commit
Ie583bd5969fdb45f772af198033e58d7c4077306
http://git.osmocom.org/osmo-bts/commit/?id=823cd529649b667af20bfa4e383255a8ed5931f1

Change-Id: I573c26b1431ee789e42f6fa620947b003c384dc0
2021-05-19 18:34:33 +02:00
Vadim Yanitskiy f466a1592f gsm/abis_nm: add missing NM_OC_IPAC_* value-string entries
Change-Id: I2181af229e8e7da12d716c176ab9230f09e29eef
2021-05-06 16:32:29 +00:00
Harald Welte a545842609 ipa_ccm_make_id_resp: Make it work at all
This could never possibly have worked.  When iterating over the
different IEs to encode, we must of course use the tag of the current
iterator item, and not the hard-coded value of the second tag in the
list.

Change-Id: I148799c5bdb95f70118691c1150330ebac4fdf21
2021-04-29 19:59:12 +02:00
Harald Welte b189b5f29c Fix ipa_ccm_make_id_resp_from_req to work at all
The parser was so horribly broken, it could not ever have possibly
worked.

Change-Id: Ibed0ff7f8d36504ef783f2653c9982d4e25e874f
2021-04-29 19:59:09 +02:00
Harald Welte 539272dd8e Fix ipa_ccm_make_id_resp_from_req
In 2018, I4723361e1094b358310541a7dc4c5c921c778a15 introuced a
check against an integer unterflow.  However, the fheck got the
logic wrong, with the result of breaking the function completely:
It would always only detect the first tag within the IPA request
and then take the branch that assumes an integer underflow.

Change-Id: I344975d0bda565ff196a1c0c69305cd349b98a19
2021-04-29 19:55:43 +02:00
Neels Hofmeyr a0f2b21c6d gsm48_mr_cfg_from_gsm0808_sc_cfg(): drop bitmask without effect
GSM0808_SC_CFG_AMR_4_75_5_90_7_40_12_20 has value 0x0002, so the
'& 0xff' had exactly no effect.

Change-Id: Ia25ac20539e8ac70fb5f70c1191bd58825151c68
2021-04-22 18:49:44 +00:00
Pau Espin cde47795d1 gsm0808: Introduce gsm0808_old_bss_to_new_bss_info_att_tlvdef
Introduce TLV attribute definition for "Old BSS to New BSS Information"
container.

Related: SYS#5337
Change-Id: I0e55e947b6fef6dad0cf1a6c16b781bef4cc76c5
2021-04-21 19:02:31 +02:00
Neels Hofmeyr 4b44ac4012 RR: add missing Extended TSC Set IE
Defined in 48.018 10.5.2.82.
This will be used by Channel Mode Modify for VAMOS.

Related: SYS#4895 SYS#5315
Change-Id: I9bad6e7121af43dfa9706635e58279ce672a4e14
2021-04-20 02:43:40 +02:00
Neels Hofmeyr a9da9f7640 RR: add VAMOS channel modes
Also add functions to convert between VAMOS and non-VAMOS speech modes.

Related: SYS#4895 SYS#5315
Change-Id: Ie0ea592da5610ae70290106d004e549cf3212a89
2021-04-20 02:42:42 +02:00
Pau Espin 49766ab1b6 cosmetic: fix typo in comment
Change-Id: I43cb7b88a4e867836a67928e361253ce0f02a329
2021-04-19 12:14:36 +02:00
Pau Espin 1b625cb134 gsm: Support Sending Last EUTRAN PLMN Id in Handover Required
Related: SYS#5337
Change-Id: I6280ce1abc283f1491bc6f391b2dd952df33a16b
2021-04-19 10:55:43 +02:00
Pau Espin d110529972 cosmetic: tlv_parser: fix typo in func description
Change-Id: I27f28376a88f00d86a0f65595f61f6026f7e0fd4
2021-04-14 17:21:02 +02:00
Neels Hofmeyr 47c7b4fc24 add osmo_bts_features_names: short BTS feature strings
This will be used by osmo-bts-omldummy to parse features strings from
the cmdline.

Note that osmo_bts_feature_name() already exists to return the longer
descriptive value_strings from osmo_bts_features_descs (_descs!).
Luckily that misses the plural 'features' in the name, so that I can
still add a properly named osmo_bts_features_name() function that only
returns the name, matching the common pattern used in osmocom code.

Related: SYS#4895
Change-Id: I699cd27512887d64d824be680303e70fff3677c1
2021-04-09 00:10:44 +02:00
Neels Hofmeyr 158bc795e5 add BTS_FEAT_VAMOS
Change-Id: Ic3bd1b8075f76d1f35499faa68fad70698ee9a00
2021-03-27 17:14:57 +01:00
Pau Espin Pedrol f286fdc87e Bump version: 1.4.0.535-e387-dirty → 1.5.0
Change-Id: I3bc0826c0000be4d76235ed6b5be86d216ea2e4d
2021-02-23 14:03:31 +01:00
Harald Welte fcbf3470b9 CBSP: Fix encoding of warning period
The warning period encoding was wrong, resulting in way too short
warning periods being encoded than intended/specified by the caller.

Change-Id: Idf3cae48a6ab45550d7bbd937bb49a0e1a4e8aed
2021-02-22 10:06:12 +01:00
Harald Welte 48f22b0e87 CBSP: fix encoding/decoding of keep-alive repetition period
Even though the value is only between 0..120s, they didn't encode
it 1:1 in the uint8_t, but 3GPP chose to use the same encoding
as for the warning period (which has a much larger range).

Let's fix this in our implementation.

Before this patch, osmo-cbc wanted to send 30s keep-alive repetition
period, but a spec-compliant receiver actually decoded this as 80s.

Change-Id: I04baa6b6b99b092fa0512b3b6138a363c7f3a13d
2021-02-22 09:58:00 +01:00
Pau Espin Pedrol d7a209bce9 gsm: Introduce API osmo_gsm48_rest_octets_si13_decode
Related: SYS#5358
Change-Id: I74fb0a3afc1ac4aadbfc609b882d929401f790eb
2021-02-18 00:54:33 +00:00
Pau Espin 524898504a gsm: Fix encoding of gsm0808_cell_id_list2 with CGI-PS types
CGI-PS type doesn't exist in GSM 08.08 Cell Id lists. That type of cell
id is osmocom-specific and used internally. In here CGI-PS is
automatically converted to CGI (since the later is an extension of this
one).

The encode/decode_cell_id_u are left intact (comment added) since those
can still be used (and are used by RIM code) to encode/decode TS 48.018
Cell Identifiers.

Related: SYS#4909
Change-Id: Id74f4577c397c1ba696f00395858311bd82cb2c8
2021-02-15 16:42:46 +01:00
Pau Espin 85a0f1143d gsm0808_utils: Move static function further up in file
It's a static internal function, so it makes sense to have it at start
of its related section.
It will be used by other functions in follow up patches.

Change-Id: I60f61f8f7bb6543feb068bdcee76d3b752565c95
2021-02-15 16:25:35 +01:00
Pau Espin 20b763d0af gsm: Support converting to cgi-ps in gsm0808_cell_id_from_cgi()
This is not really used nowadays, but added for completeness in case
someone wants to use it.

Change-Id: I1361b044bd897d04133cda6fd62c16852700b17a
2021-02-15 16:18:26 +01:00
Pau Espin Pedrol c31809faf3 cosmetic: Move comment one line below in append_gprs_cell_opt
Move it above the place where the bit is set, since the bit represents
whether Extension Information is available, not whether R99 is
available.

Change-Id: Ice592acc50a24efd7fe4cf1a91f1d48fd74f38d8
2021-02-10 15:04:22 +00:00
Vadim Yanitskiy 1c4fc227d9 gsm0808: use msgb_tv16_put() and osmo_store32be()
This API makes the code simpler and easier to read.

Change-Id: Ibe9eaaa2a9344ba798631b8f115ad248f0a2f76b
2021-02-05 20:10:16 +01:00
Philipp Maier d11a5d5b9a gsm48: add compare function for struct gprs_ra_id
Comparing struct gprs_ra_id using memcmp can be error prone, so lets add
a compare function to compare two struct gprs_ra_id values reliably.

Change-Id: I4d7558c04d9d01761516526086be5104bb2eeada
Related: SYS#5103
2021-02-04 15:17:41 +01:00
Vadim Yanitskiy 943133cad8 gsm_7bit_encode_n(): fix integer overflow in gsm_septets2octets()
Using 'uint8_t' for the length argument is definitely a bad idea.
Because of this, packing more than 255 septets would not work as
expected.  Deprecate the old function and use 'size_t' instead.

Change-Id: Ib1aac538afeb0a5c76a1df472d555139a496e12e
2021-02-01 17:47:54 +00:00
Pau Espin 3e3f377749 gsm: bts_features: Introduce BTS_FEAT_CCN
This feature is used by BSC to gain knowledge on whether a given BTS
supports GPRS Cell Change Notification (CCN) related procedures on PDCH,
and as a result enable or not by default the CCN_ACTIVE bit in SI13 to
announce the support it is allowed to use the feature.

Related: SYS#4909
Change-Id: I61991266b95d0c13d51b47906cc07846e9cf1390
2021-01-29 18:01:14 +01:00
Pau Espin 5b6f1d7d7a gsm: Fix wrong length in SI13 GPRS Cell Options IE
Older commit adding the 2 bits for Rel-4 extension forgot to increase
the length field (see TS 44.060 Table 12.24.1)

Fixes: 946bb95af1
Change-Id: I20efb4403cdf6c5bc717502a7075630044142f17
2021-01-29 18:01:14 +01:00
Pau Espin d426ba6730 gsm: Introduce osmo_{rai,cgi_ps}_cmp() APIs
Similar to what we already have for other data types, such as
osmo_lai_cmp or osmo_cgi_cmp.

Change-Id: I00e329bc5be8674b30267dec238e7656ddfc21db
2021-01-22 20:32:45 +01:00
Pau Espin cc885fb0b6 gsm: Add missing osmo_*_cmp symbols to libosmogsm.map
Change-Id: I8ff677aa381118466d065abee7db20b15880352f
2021-01-22 17:44:04 +01:00
Harald Welte efdd641c29 tlv_parser: Fix various out-of-bounds accesses
The libosmocore TLV parser had a number of insufficient bounds checks
leading to reads beyond the end of the respective input buffer.

This patch
* adds proper out-of-bounds checks to all TLV types
* simplifies some of the existing checks
* introduces test cases to test all the corner cases
  where either TAG, or length, or value are not fully contained
  in the input buffer.

Thanks to Ilja Van Sprundel for reporting these problems.

Change-Id: I98b02c914c9e3ecf56050af846292aa6979d7508
2021-01-12 21:11:20 +01:00
Pau Espin ca33a71ca8 Intoduce Packet Switch CGI
This structure is needed in order to identify a given cell within the
BSS during RIM transactions.
The naming was made up by myself since I couldn't find any naming
reference for this kind of data (RAI + CI).
Since LAI + CI = CGI, then RAI + CI = CGI-PS

osmo_rai_name2 family of functions get a "2" suffix due to already
existing functions handling struct struct gprs_ra_id in gsm48.h

Change-Id: If48f412c32e8e5a3e604a78d12b74787a4786374
2021-01-11 14:22:21 +00:00
Vadim Yanitskiy 7e104d96ba bts_features: s/Repeation/Repetition/ in osmo_bts_features_descs[]
Change-Id: Ia8c77766842ce80eae969774959cbf46e86f97b9
2021-01-07 14:22:56 +01:00
Harald Welte 886e742935 cbsp: Fix parsing DCS in decode of WRITE-REPLACE
The encoder generates the DCS IE, but the decoder forgot to parse it :/

Change-Id: I05d489f91a2cc5df372e8e695126659eedac9485
2021-01-03 14:18:58 +01:00
Harald Welte fdd71c822a cbsp: Fix osmo_cbsp_recv_buffered() for KEEP-ALIVE-COMPLETE
We used to suppress/drop any "zero length" messages, but we didn't
include the header when computing the length.  However, in CBSP there
are messages (at least KEEP-ALIVE-COMPLETE) which only consist of the
header without any information elements.  We cannot simply drop such
messages.

This also fixes the return value of osmo_cbsp_recv_buffered() to be
the total number of received octets (including the header).

Change-Id: Ib620128a167cb77f061ee57e8f8ad707b96b1c0d
2021-01-03 14:18:58 +01:00
Harald Welte 64b9407c4e cbsp: Fix encoding of "ETWS Warning Security Info" IE
This is a fixed-length Tag-Value IE.  Our decoder already parsed
it correctly, but the encoder encoded it as TLV, which is wrong.

Change-Id: I7e1d7eab8b8e51acd9a24c38e2d3d30bbf00847a
2021-01-03 14:18:58 +01:00
Pau Espin Pedrol d01163a977 rest_octets: Fix decoding of SI3 3G Early Classmark Sending Restriction
Restriction is applied if the value is L, so fix it.

Fixes: f85b33f68f
Change-Id: Idd170bc0f12e8b215a624e0632a106bde076179b
2020-12-23 12:39:17 +00:00
Pau Espin Pedrol 3f6a282a14 Revert "rest_octets: fix encoding of 3G Early Classmark Sending Restriction"
This reverts commit c9eab828ea.

The initial code was correct, which has also been used in osmo-bsc until
recently, where it moved to use this function from libosmocore and
errors started to show up in TTCN3 tests.

See 3GPP TS 44.018 Section 10.5.2.34 / Table 10.5.2.34.1: "SI 3 Rest
Octets information element":

"""
<SI3 Rest Octet> ::=
...
<3G Early Classmark Sending Restriction>
...

<3G Early Classmark Sending Restriction>::= L | H;
"""

Change-Id: I0ee48d3240c62c4d2e15063b26da7a2a617f383e
Related: OS#3075
Related: SYS#4021
2020-12-23 12:39:17 +00:00
Harald Welte d2a61179a3 lapd_core: Don't dereference data link after sending PRIM_DL_REL
We must always send the RELEASE.{indication,confirm} last before
returning from a function.  We cannot rely on the datalink to
still be around after the call, as the SAP user might have destroyed
the data link meanwhile.

This fixes a heap use-after-free (at least) with RBS2000 when the BTS
is fully brought up and the OML data link is lost, see OS#1762

Change-Id: I8ccca8d5e5d07b666557afe12ab8ac4910ddfb00
Related: OS#1761
Related: OS#1762
2020-12-21 17:43:54 +01:00
Pau Espin Pedrol 946bb95af1 GPRS Cell Options (SI13): Add REL-4 CCN_ACTIVE bit
This is required in order to tell MS that osmo-pcu now supports
Network Assisted Cell Change (NACC).

Related: SYS#4909
Change-Id: I2aaa8c1107c977f711c2d7530034f57e36e3a237
2020-12-17 15:22:09 +00:00
Pau Espin Pedrol 0f619de715 gsm: append_eutran_neib_cell: Fix SI2quater EARFCN list
Commit bd6e7a9f2d did the initial porting
of rest_octet APIs from osmo-bsc, but introduced a bug when moving
bts->e_offset to a generic pointer independent of bts structure.
As a result, using this API from osmo-bsc makes gsm0408 unit test fail
due to bad encoding of several EARFCNs in si2quater.

Fixes: bd6e7a9f2d
Change-Id: I2bf5635b8536b11d69774d17ac1908019633e3af
2020-12-14 17:58:23 +01:00
Pau Espin Pedrol c4286ad056 si2quater: fix budget calculation for multiple EARFCNs
In rest_octets.c append_earfcn(), the unconditional bits added are 40, not 25.
Removing only 25 bits from the budget resulted in malformed SI2quater starting
with 4 configured EARFCNs, by adding more EARFCNs than fit in 20 bits.

These malformed SI2quater were also expected in gsm0408_test.c. Update the
expected SI2quater to what is being generated now. This patch passes the ttcn3
testing added in I45382f88686ca60e68569e93569fc4cfb63a0e0d, which provides some
confidence that the coding expected in gsm0408_test.c is now correct.

This commit is a cherry-pick of osmo-bsc.git 6589f7c3a8dfdaaf66dda3afa6bbb1118ec825f9

Change-Id: Icc1ece39ad162d09720e104c5cbc12b07d6771a8
Related: OS#4652
2020-12-14 17:19:30 +01:00
Pau Espin Pedrol 30bf0e6745 gsm: si13: Fix encode of EGPRS_PACKET_CHANNEL_REQUEST
Cherry-pick from osmo-bsc.git e981f17200bf3a5d5114f46d9f7515fd10b96dbb

Change-Id: I0aae385a427205cc73f60feca161e38608e608d8
2020-12-14 17:13:47 +01:00
Pau Espin Pedrol 908224c1a4 rest_octets: add Serving Cell Priority Parameters
When we add an EARFCN to to the SI2quater struct we do not add Serving
Cell Priority Parameters. This essentially causes to MS to ignore the
EARFCN because it is still undefined under which conditions the MS
should change to LTE.

This is a cherry-pick from osmo-bsc.git 295c965c063a8c431507191f6aef1ef78b720685

Related: SYS#4510
Change-Id: If9134759e9bc4ae0920800972632fd8c5dc9c2d9
2020-12-14 17:11:21 +01:00
Harald Welte 30a9294306 tlv: Introduce enum with error codes for TLV parser functions
Change-Id: I0b352792089c5c0c714712d2ea237beb92e1d73f
2020-12-08 12:27:38 +00:00
Harald Welte 9510992c53 Introduce 'osmo_tlv_prot' abstraction for validation of TLV protocols
This extends our existing TLV parser with the ability to
* validate that mandatory IEs of a given message are present
* validate that all present IEs are of required minimum length

Introducing this generic layer will help us to reduce open-coded
imperative verification across virtually all the protocols we
implement, as well as add validation to those protocols where we
don't properly perform related input validation yet.

Change-Id: If1e1d9adfa141ca86001dbd62a6a339f9bf9a912
2020-12-08 12:27:38 +00:00
Vadim Yanitskiy c1c420ce3d bts_features: add missing description for BTS_FEAT_ACCH_REP
Change-Id: Ie1d7f00b1bed43c41274bba4ce767a61cd71bb61
Fixes: Ib4d1d8d8a1a1d58bc320a1c0eff2d52100267f09
2020-11-20 01:41:15 +07:00
Philipp Maier e36be56fc8 gsm_04_08: add parser for Mobile Station Classmark 3
3GPP TS 24.008 section 10.5.1.7 describes a Mobile Station Classmark 3
IE, which is encoded as CSN.1 struct. This means that it can not be
parsed by just casting a memory location to a struct pointer, so lets
add a parser to parse the CM3 IE.

This is fixed version of Ic8b2bfd00330235f5bed00771e421588abfaac1f,
which got reverted because it used the keyword "class" as struct member,
which lead into problems with c++ builds. This is now fixed.

Change-Id: Id8732551b33616227609cd6fcf6c3133751a89eb
Related: OS#4796 SYS#5114
2020-11-12 15:55:31 +00:00
Harald Welte c2118940aa Revert "gsm_04_08: add parser for Mobile Station Classmark 3"
This reverts commit a4939dc846,
which caused massive build failures in C++ programs like osmo-pcu
- unsurprisingly, as it calls a struct member "class", which is a
reserved keyword in C++.

Change-Id: Ia43e56385e7b580f492c560aee8ff8b1e8a0e1d8
2020-11-11 23:11:15 +01:00
Philipp Maier a4939dc846 gsm_04_08: add parser for Mobile Station Classmark 3
3GPP TS 24.008 section 10.5.1.7 describes a Mobile Station Classmark 3
IE, which is encoded as CSN.1 struct. This means that it can not be
parsed by just casting a memory location to a struct pointer, so lets
add a parser to parse the CM3 IE.

Change-Id: Ic8b2bfd00330235f5bed00771e421588abfaac1f
Related: OS#4796 SYS#5114
2020-11-10 16:36:54 +01:00
Philipp Maier a15967ba98 gsm_08_58: add proprietary IE to signal Repeated ACCH Capability
3GPP TS 24.008, section 10.5.1.7 specifies a Repeated ACCH Capability
bit in the Classmark 3 IE. Unfortunately, there is no way specified how
the Repeated ACCH feature should be controlled on RSL level. Since it is
not unusual that BTS/BSC vendors occassionally add proprietary IEs to
different RSL messages we may pick this as a solution as well and add a
propritary RSL_IE_OSMO_REP_ACCH_CAP IE, so that we can enable repeated
FACCH/SACCH on the BTS side when we send RSL CHAN ACT or RSL CHAN MODE MODIFY
messages.

Change-Id: I61ea6bf54ea90bd69b73ea0f0f3dc19a4214207b
Related: OS#4796 SYS#5114
2020-11-09 23:41:10 +01:00
Vadim Yanitskiy f5f0d4304a gsm48: add missing RR cause value definitions
3GPP TS 44.018 version 15.4.0 Release 15 (2019-04).

Change-Id: If7187e005d65fd2bf067d258148281c5df0526ff
2020-10-29 18:23:06 +07:00
Vadim Yanitskiy 65954bac13 fix spelling in 'value_string' arrays: existAnt -> existEnt
It could be that this spelling variant was originally used in the
specs., but now at least in 3GPP TS 44.018 they use 'existEnt'.

Change-Id: I847de910411f2edf7cc45b8c296b43e65fed5447
2020-10-29 18:09:36 +07:00
Pau Espin 76190d308d lapdm: Allow SABM L=0 in Timer Recovery State
3GPP TS 44.006 8.6.3 "Procedures for re-establishment" is quite
explicit:
"""
When the data link layer receives in the multiple frame established state
or !!!timer recovery state!!! a DL-ESTABLISH- REQUEST primitive from layer
3 or an SABM (with L=0), the normal establishment procedure of sub-clause
8.4.1.2 shall be initiated.
"""

If L>0 in that state, send a DM as stated in 8.4.1.2:
"""
If the data link layer entity is unable to enter the multiple-frame-established
state, it shall respond to the SABM command with a DM response with the F bit
set to the same binary value as the P bit in the received SABM command.
"""

Related: OS#4549
Related: OS#4819
Change-Id: I7959dc39f883cd5c56c36a21176a2401838d7b62
2020-10-21 13:03:30 +00:00
Pau Espin d5f7147419 lapdm: Split lapd_rx_u() spaghetti into one function per message type
Change-Id: Ia1a49f7ae1d133174fad7a396db72867612fa619
2020-10-21 13:03:30 +00:00
Pau Espin 16333bb58c lapdm: Drop log lines printing fmt=B
Change-Id: Ic8794ee66ddeb45ebcc7b9834f4d5e8321fd91f1
2020-10-21 11:54:23 +00:00
Vadim Yanitskiy fdaec8e706 rsl: rsl_chan_nr_str_buf(): use ABIS_RSL_CHAN_NR_CBITS_* macros
Change-Id: I3cd745e180787ea5c22f2a13441d599e0220d81f
2020-10-17 00:27:12 +07:00
Harald Welte 65aabd437c [cosmetic] rest_octets: Follow coding style regarding {}
As pespin point out, the kernel coding style says:

Do not unnecessarily use braces where a single statement will do.
[...]
This does not apply if only one branch of a conditional statement is a single
statement; in the latter case use braces in both branches:

Change-Id: Ia23c4bd018db141ff0afe77fe25678a9b2a395f0
2020-10-15 08:06:08 +02:00
Harald Welte 5e1cd5e411 gsm48_rest_octets: Add parser for SI4 rest octets
Introduces osmo_gsm48_rest_octets_si4_decode()

Change-Id: I9d6ed06731ae15fdcef1a1f397d6ac2b7b1ca980
Related: OS#3075
2020-10-15 08:01:43 +02:00
Neels Hofmeyr b85c87aec6 gad.c: fix rc for osmo_gad_enc_ell_point_unc_circle()
Related: CID#214889
Change-Id: If9bb6ab22280e0dc66ca21bba9409d817603dd4f
2020-10-15 01:02:04 +00:00
Neels Hofmeyr 9faeacd6a1 gad.c: try to workaround warning for "h.type >= 0"
The DEC_ERR() macro has a check for a missing type, but when used on the uint
h.type variable, emits a warning about an always-true statement. Try to work
around that warning with a cast to (int).

Related: CID#214888 CID#214890 CID#214891
Change-Id: Ic5fa87d23a6f0ce872de9c1dcfe36023981f70de
2020-10-15 01:02:04 +00:00
Pau Espin 86160ace73 gsm: Fix make distcheck with parallel make
Change-Id: I0bab4cfbc82d2b0aa7bd07769000ab8e4968a00b
2020-10-13 08:24:03 +00:00
Neels Hofmeyr 5b214e2847 add BSSMAP coding for Location Services
BSSMAP: add A-interface messages between MSC and BSC:
- Perform Location Request
- Perform Location Response
- Perform Location Abort

Change-Id: I4d7302a4853518916b6b425e710c10568eb2ffe5
2020-10-07 15:37:50 +02:00
Neels Hofmeyr 02de87bd5c add BSSMAP-LE coding for Location Services
BSSMAP-LE: add Lb-interface messages between BSC and SMLC:
- Reset
- Reset Acknowledge
- Perform Location Request, possibly containing BSSLAP TA Layer3
- Perform Location Response
- Perform Location Abort
- Connection Oriented Information containing any BSSLAP APDU

Add encoding and decoding tests.

Change-Id: I271e59b794bafc0a7ae0eabbf58918f6d7df431d
2020-10-07 15:37:50 +02:00
Neels Hofmeyr c6848f4145 add BSSLAP coding for Location Services
BSSLAP: there are APDUs transferred in BSSMAP-LE Connection Oriented
Information messages on Lb between BSC and SMLC.
Add BSSLAP coding for these APDU messages:
- TA Layer3
- TA Request
- TA Response, possibly containing Location Estimate coded in GAD
- Reject
- Reset (for intra-BSS handover during TA Request)
- Abort (for inter-BSS handover)

Add encoding and decoding tests.

Change-Id: I6409c4bcac402dc7626a3afce9081c59cd715fe8
2020-10-07 15:19:43 +02:00
Neels Hofmeyr 086bd33f18 add GAD coding for Location Services
GAD, Universal Geographical Area Description:
- raw coding for all GAD elements.
- SI-units encoding and decoding for Ellipsoid point with uncertainty circle,
  which I presume is the typical "at most N meters away from cell tower located
  at X,Y", which corresponds to the TA positioning currently being implemented.
- other SI-units GAD element encodings are so far not implemented.

Add encoding and decoding tests.

In gsm/protocol/gsm_23_032.h are the raw coding structs as defined in 3GPP TS
23.032.

In gsm/gad.h are structs carrying consistent units based on meters and degrees,
for convenient / less error prone handling of GAD data, and for human readable
representations of the GAD data.

The separation of the two is desirable because OsmoBSC will receive GAD data
from OsmoSMLC on the Lb interface, and pass on this data to the MSC via the A
interface. It is better to pass the GAD data as-is without de/encoding.

Change-Id: I7a9dd805a91b1ebb6353bde0cd169218acbf223c
2020-10-07 11:39:46 +00:00
Vadim Yanitskiy ecaf5faa79 gsm0808: fix: do not encode invalid encryption algorithm
According to 3GPP TS 48.008, section 3.2.2.44, the Chosen Encryption
Algorithm IE, which may be included in the following messages:

  - 3.2.1.2   ASSIGNMENT COMPLETE
  - 3.2.1.8   HANDOVER REQUEST
  - 3.2.1.10  HANDOVER REQUEST ACKNOWLEDGE
  - 3.2.1.12  HANDOVER COMPLETE
  - 3.2.1.25  HANDOVER PERFORMED
  - 3.2.1.31  CIPHER MODE COMPLETE

is coded as follows:

  0000 0001   No encryption used
  0000 0010   GSM A5/1
  0000 0011   GSM A5/2
  0000 0100   GSM A5/3
  0000 0101   GSM A5/4
  0000 0110   GSM A5/5
  0000 0111   GSM A5/6
  0000 1000   GSM A5/7

basically A5/X => X + 1.  All other values are Reserved for future
international use.  As can be seen, value 0x00 is RFU.  Passing
this value to some encoding functions would result in a PDU with
this IE omitted.  Although, some functions would still encode
Chosen Encryption Algorithm IE with this RFU value.

Let's ensure that all functions behave consistently.

Change-Id: If10e433a8174eabe6aa6d2c2937bf9cf5d14d7c9
2020-09-18 08:41:57 +00:00
Vadim Yanitskiy 776c5b16ea lapdm: fix SAPI-0/SAPI-3 frame prioritization on DCCH
According to 3GPP TS 44.005, section 4.2.2 "Priority":

  a) on DCCH, a SAPI=0 frame always has higher priority than SAPI=3;
  b) on ACCH, the priority arrangement is more complex:
    b1) if a SAPI = 3 frame is awaiting transmission, two SAPI=0
        frames shall not be sent in consecutive SACCH frames;
    b2) on the network side (LAPDM_MODE_BTS), it must also be ensured
        that any SAPI=3 frame is followed by at least one SAPI=0 frame;
    b3) a SAPI = 0 frame may be repeated in the next SACCH period
        if the Repeated SACCH is supported (see 3GPP TS 44.006, section 11).

We definitely need to extend our testing coverage to ensure that
we implement b) correctly, but for now let's focus on DCCH:

  a) for DCCH, ensure that SAPI=0 frames preceed SAPI=3 ones;
  b) for ACCH, re-use the existing round-robin implementation.

Change-Id: Ia3780bce1222b312ae2fd2d21496a4d6c5ccb6e0
Related: SYS#5047, OS#4731
2020-08-27 22:10:54 +07:00
Vadim Yanitskiy 29ecabe7a2 lapdm_pad_msgb(): cosmetic: use GSM_MACBLOCK_PADDING
Change-Id: Ic2ff931ea4272903c440c7c5ea996dd84c2e470b
2020-08-27 19:35:13 +07:00
Pau Espin 9cc661b0e8 ipa: Fix wrong output log formatting
Change-Id: I1862465e9f9a1d9f06a189641360ae7b9e03b1fc
2020-08-27 10:45:30 +00:00
Vadim Yanitskiy fa6cd88ee5 gsm0808: add gsm0808_create_sapi_reject_cause()
This is basically a successor of gsm0808_create_sapi_reject(), but
instead of hard-coding GSM0808_CAUSE_BSS_NOT_EQUIPPED, it allows
the caller to specify a cause value to be used.  The old function
is now deprecated and should not be used.

Change-Id: Iefe5484d0fa02d5722b628b1dc237d51d3fb1a9b
Related: OS#4728
2020-08-26 18:30:19 +07:00
Neels Hofmeyr b19b533e36 comment: mention spec reference in cbsp.[ch]
Change-Id: I1217883a85b4ddd20e9646c7e80ba18950e09713
2020-08-25 13:34:04 +02:00
Harald Welte 5c5713e869 Bump version: 1.3.0.173-51974 → 1.4.0
Change-Id: I4fc6dd4f727c8ff5a64865bbb87e1d9feb7c5174
2020-08-13 11:06:36 +02:00
Alexander Couzens 6300aff3b2 gsm 12.21: add osmocom specific NM_ATT_OSMO_NS_LINK_CFG
The sysmobts uses the same OML attributes as IP.access. Because the IP.access
attribute only supports IPv4 as NSVC configuration, add an own attribute.

Change-Id: Ic261bc43a07fa741b97a9c6ec5a9ed6f5ecae588
2020-08-06 16:41:20 +00:00
Harald Welte 44964981c2 i460: Fix bit- and subslots ordering of I.460 mux + demux
When I wrote the new I.460 mux + demux code, I failed to realize that
* bit numbers in relevant ITU specs start with 1 as MSB ... 8 as LSB
* sub-slot 0 is bits 1+2, i.e. the two MSBs of a byte
* bit-ordering within each sub-slot is also MSB first

As a result, the code and test data was broken.

Change-Id: I6df7dbf411efbdeaf516e72ac552432bf5a569d0
2020-08-02 21:57:05 +02:00
Harald Welte b3b474d8ad i460: pass more context to call-back functions
When calling a user-provided call-back function for the i460 mux
or demux, always pass a pointer to the osmo_i460_subchan the callback
relates to.  This way, the user can walk the i460 data structures
to obtain information about which mux/demux instances is calling.

Change-Id: Id842c72ce371a67fe5df6694e195c281aaf607ab
2020-08-02 11:57:55 +02:00
Harald Welte eb8240d564 i460: Add back-pointer from sub-channel to timeslot
A user may want to walk back from a sub-channel to the timeslot
to which it belongs.

Change-Id: Id6e5e208c5daa63fd23ac719d62314622b5d0ed9
2020-08-02 11:57:55 +02:00
Philipp Maier b5518a8f1f i460_mux: add callback to notify empty tx queue
There is no way for the API user to know if the TX queue of the
multiplexer runs empty. However, this is criticil since an empty TX
queue will cause dropout of a TRAU frame, which can have quite severe
effects to the receiving end. Lets add a callback that allows the APU
user to insert appropiate idle frames or silent frames into the queue
before it runs empty.

Change-Id: I88a87724235fe50d55ce6215bb385c044072226e
Related: OS#2547
2020-08-02 11:57:55 +02:00
Philipp Maier 6d21448911 gsm_08_58: add missing RSL error cause codes
The define constants for the cause codes "BTS not equipped",
"remote transcoder failure" and "notification overflow" are missing.
Lets add them including value strings.

Change-Id: Ic3e936da00bd256bae03867887851f1a4e30e218
2020-07-31 21:23:49 +00:00
Harald Welte 701968f286 gsm0411_{smc,smr}.c: Work around newlib bug
At least on Debian unstable, newlib is [currently?] buggy in that
we need to include sys/types.h before including inttypes.h, otherwise
PRIu64 is not defined.

Change-Id: Ic1c9cdf66cfd5b82bd7e20eaaf05b10e6bdb675e
Closes: OS#4686
2020-07-30 21:35:10 +02:00
Philipp Maier 6509d202d9 i460_mux: correctly reset subchannels
When a subchannel is deleted or created the initalization mainly
consists of a memset over the wohle subchannel struct a message buffer
initailization.

However, when we delete a subchannel we also must take of the resetting
of the related struct. Currently this is done with a memest.
Unfortunately this creates not only a memory leak (there might be still
items in the multiplexer tx queue) but also it makes the application
crash when the message buffer is used the next time since the llist_head
of the tx queue looses its initialization.

Lets fix the memory leak problem and the message buffer problem and put
the reset functionality in a single place.

Change-Id: I937a9d4db95f44a860cd2c5dbb660dc1970b9a49
2020-07-30 10:39:43 +02:00
Alexander Couzens 03a421359d bts_features: add feature BTS_FEAT_IPV6_NSVC
Previous both the IPA nanobts and the sysmobts has been using the IPv4 only OML
attribute NM_ATT_IPACC_NS_LINK_CFG.
A bts with BTS_FEAT_IPV6_NSVC supports IPv6 for NSVC (PCU<Gb>SGSN) using
the new OML attribute NM_ATT_OSMO_NS_LINK_CFG.

Change-Id: I9ef7949f66764b3c639e45eb440122e318da44a0
2020-07-28 13:58:46 +02:00