Commit Graph

63 Commits

Author SHA1 Message Date
Alexander Chemeris 22630e6827 gsm0808: Implement helper functions for CONFUSION BSSMAP message decoding.
Also add a test for an actual CONFUSION message parsing.

Change-Id: If8afd2d096fb66c6c2f255a08fc1129de3d09cec
2020-05-17 07:32:32 +00:00
Alexander Chemeris fdfe25b105 gsm0808: Make a function to extract Cause IE publicly available.
Function gsm0808_get_cipher_reject_cause() was previously available
in private gsm0808_utils.h. In practice, the exact same code is useful
to extract Cause IE value from any of the many other BSSMAP messages
which use it.

So let's rename it to gsm0808_get_cause() and make it avilable
to everyone to use.

Change-Id: Idf2b99e9ef014eba26e3d4f0f38c2714d3a0520a
2020-05-13 00:46:00 +03:00
Alexander Chemeris a5b1b86a33 gsm0808: Fix encoding of the SAPI_N_REJECT BSSMAP message.
See TS 08.08 section 3.2.1.34 SAPI "n" REJECT:
1) DLCI is a TV element, not V.
2) Cause is a TLV element and we have a special function to encode it.

Change-Id: I033afe556c06427d06ac55c4f78854a45e41aae6
2020-05-12 01:14:03 +03:00
Pau Espin 2605ffc3d7 gsm0808_test: Fix wrong use of memcp
After recent system upgrade, gcc 9.1.0, I started getting gsm0808_test
failing locally:
Assert failed memcmp(&enc_ct, &dec_ct, sizeof(enc_ct)) == 0 libosmocore/tests/gsm0808/gsm0808_test.c:992

During investigation with gdb, fields of both structures seem to contain
same values. However, closer lookup gives some hints on why it fails:
(gdb) print memcmp(&enc_ct, &dec_ct, sizeof(enc_ct))
$1 = 85
(gdb) print memcmp(&enc_ct, &dec_ct, 12)
$14 = 85
(gdb) print ((uint8_t*)&enc_ct)[11]
$15 = 85 'U'
(gdb) print ((uint8_t*)&dec_ct)[11]
$16 = 0 '\000'

So the 12th byte in struct gsm0808_channel_type is basically an
alignment padding byte added by the compiler (to align perm_spch_len to
4-byte alignment). Since both compared structs are initialized without
memset(0) but using compiler's designated initializers, it seems the compiler
decided it's no longer needed to zero the padding byte, making memcp fail in
this case.

In order to avoid the failure, let's properly check every field instead
of using memcp here.

Change-Id: I17fe7a0a5dc650f050bba1f47d071be749550729
2019-07-30 12:51:29 +00:00
Philipp Maier 94d79fdeef gsm0808_utils: fix gsm48 multirate to S-bit converter
The function gsm0808_sc_cfg_from_gsm48_mr_cfg() is used to convert a
gsm48 multirate struct into a set of S-bits (S0 to S15). However, the
conversion function currently does not take into account that bit S1
actually stands for four rates at once (Config-NB-Code = 1). Lets make
sure that S1 is only set when the multirate configuration permits all
four required rates.

Change-Id: I6ad531d4e70c2252e32e2bbaca8e14a7ec6d9840
Related: SYS#4470
2019-03-11 09:08:31 +01:00
Philipp Maier 3713af8655 gsm0808_utils: fix gsm48 multirate configuration generator
The function gsm0808_sc_cfg_from_gsm48_mr_cfg() takes an S15 to S0
bitmask and converts that bitmask into an AMR multirate configuration
struct.

Unfortunately the current implementation implements 3GPP TS 28.062,
Table 7.11.3.1.3-2 wrongly in some aspects. Lets fix this.

- Fix wrong interpretation of the bitpatterns
- 5,15K is invalid and must never be selected
- Make sure that no more than 4 rates are selected in the active set
- Extend unit-test

Change-Id: I6fd7f4073b84093742c322752f2fd878d1071e15
Related: SYS#4470
2019-03-11 09:08:31 +01:00
Neels Hofmeyr 3a5045302f add gsm0808_cell_id_from_cgi(), gsm0808_cell_id_to_cgi()
CGI to Cell ID: for example, for Paging, osmo-msc has a CGI for a subscriber
and needs to send out a Cell Identifier IE. Makes sense to add this conversion
here.

Cell ID to CGI: for a Layer 3 Complete, a subscriber sends the current cell in
the form of a Cell Identifier, which we store as a CGI, if necessary enriched
with the local PLMN.

Add enum with bitmask values to identify parts of a CGI, for the return value
of gsm0808_cell_id_to_cgi(). Can't use enum CELL_IDENT for that, because it
doesn't have a value for just a PLMN (and is not a bitmask).

Change-Id: Ib9af67b100c4583342a2103669732dab2e577b04
2019-03-08 05:25:07 +01:00
Max 5ec0cf5475 LCLS: add string dump helpers
Add functions to dump LCLS (without GCR) and GCR. Dumping entire struct
results in inconveniently long string hence the separate functions. Both
use talloc functions so they expect caller to take care of providing
proper allocation context and freeing memory.

Change-Id: Ic3609224c8f3282d667e75f68bc20327e36eb9e6
2019-02-26 09:16:38 +00:00
Harald Welte cf665fc6bc gsm0808: Add unit tests for test_create_clear_command2()
Change-Id: Ie3f34b78edc91a013152742bebbd839586a787fe
Related: OS#3805
2019-02-18 13:34:02 +00:00
Neels Hofmeyr d01ef75ab8 gsm0808: add BSSMAP Cell Identifier matching API
Add
* osmo_lai_cmp() (to use in gsm0808_cell_id_u_matches())
* osmo_cgi_cmp() (to use in gsm0808_cell_id_u_matches())
* gsm0808_cell_id_u_match() (to re-use for single IDs and lists)
* gsm0808_cell_ids_match()
* gsm0808_cell_id_matches_list()
* Unit tests in gsm0808_test.c

Rationale:

For inter-BSC handover, it is interesting to find matches between *differing*
Cell Identity kinds. For example, if a cell as CGI 23-42-3-5, and a HO for
LAC-CI 3-5 should be handled, we need to see the match.

This is most interesting for osmo-msc, i.e. to direct the BSSMAP Handover
Request towards the correct BSC or MSC.

It is also interesting for osmo-bsc's VTY interface, to be able to manage
cells' neighbors and to trigger manual handovers by various Cell Identity
handles, as the user would expect them.

Change-Id: I5535f0d149c2173294538df75764dd181b023312
2019-01-28 23:58:53 +00:00
Max 3b90125346 LCLS: make GCR into static member of osmo_lcls
Most of the time we'll have GCR filled anyway so it make sense to have
it as static parameter instead of a pointer to separately allocated
structure. Update tests to cover both static and dynamic osmo_lcls
allocation variants.

Change-Id: I905c36d8455911c68c30bc429379b7313dd46aea
2019-01-19 21:06:03 +00:00
Max 414c8f565b LCLS: add status parameter to Assignment Completed message
* add gsm0808_create_ass_compl2() with additional gsm0808_lcls_status
  parameter and make gsm0808_create_ass_compl() into trivial wrapper
  around it
* update tests accordingly

Change-Id: I547c6b8707123aa8c1ef636db88908df112d90a4
Related: OS#2487
2019-01-19 21:03:56 +00:00
Max 1bec3908c6 LCLS: add GCR comparison helper
Change-Id: I9e3b5560a058b976638d03cb819415d237ae9984
2019-01-14 23:46:34 +00:00
Max 4fd64e5d93 LCLS: expand enc/dec tests
Change-Id: I8ed87f26216104d34c7bd11c1527b203843760a2
2019-01-14 23:46:34 +00:00
Max 470221575d LCLS: enc/dec entire parameter set instead of GCR
In 3GPP TS 48.008 the Global Call Reference IE is only used in HANDOVER
REQUEST (§3.2.1.8) and ASSIGNMENT REQUEST (§3.2.1.1) messages which
also include LCLS Config and CSC parameters. Hence, there's no point in
using GCR encode/decode functions alone.

Introduce gsm0808_dec_lcls() and gsm0808_enc_lcls() as trivial wrappers
on top of GCR enc/dec routines which are made static. Adjust tests
accordingly. Test output intentionally left unchanged.

Change-Id: Icfbb2404e1a1d500243e2071173299b557369335
2018-12-23 10:20:05 +00:00
Vadim Yanitskiy cf6ee64423 tests/gsm0808: use new msgb comparison API
Since I3bc95f2f5ab6e3f4b502647fb3e0aaaf1f7c4cf5, we have some
helpers to compare certain msgb layer to a given buffer. Let's
change 'VERIFY' macro to use msgb_eq_l3_data_print().

Change-Id: Ib6be778236eff8f2153f3113f9379ecfbec9052b
2018-12-21 18:22:52 +00:00
Max 5207432780 LCLS: add gsm0808_create_ass2()
It allows setting additional assignment parameters explicitly.

Change-Id: Id89765df3f8c12f55f73f1d7a9d90c8883eb3bba
Related: OS#2487
2018-12-14 13:15:39 +00:00
Max 969fb2ed84 LCLS, TS 48.008: add GCR IE encoding/decoding
* add functions to encode Global Call. Ref. from TS 29.205 as 3GPP TS
  48.008 §3.2.2.115 information element
* add corresponding tests

Change-Id: I82ce0207dc8de50689a8806c6471ad7fbae6219d
2018-12-14 13:15:39 +00:00
Philipp Maier 4f4905fac5 gsm0808: add encoder for cause codes and use it
At the moment the all gsm0808 cause codes are encoded directly using the
tlv API directly to put a one byte TLV field. This works ok for most
situations where the cause code consists of a single byte. However,
gsm0808 specifies a two byte cause code model where cause codes may be
extended up to two bytes. Instead of implementing the encoding over and
over and again, let's rather have an encoder function we can call.

- Add an encoder function that can generate single byte and extended
  cause codeds and makes the length decision automatically.

- Use only this function to append cause codes

Change-Id: I71d58fad89502a43532f60717ca022c15c73f8bb
2018-12-08 19:29:34 +00:00
Max ed651d2485 Support cipher mode reject with extended cause
* add function to generate cipher mode reject with extended (2-byte)
  Cause IE
* add function to get (extended) Cause value
* add corresponding (extended cause) test
* update existing (non-extended cause) test
* use enum as a parameter for existing non-extended version to make
  interface more unified

Change-Id: Id5509b94a18180a44f45300caaa02b843c166fa3
Related: OS#3187
2018-11-19 05:52:28 +00:00
Max fa3b482277 Fix deprecation warning in gsm0808_test
Use gsm0808_create_layer3_2() directly instead of deprecated wrapper.

Change-Id: I44772666c929dfd94d25953379cf51b371ce202c
2018-11-06 17:25:57 +00:00
Max 2b4a67a412 Update cipher reject function
* add note about (yet) unsupported standard feature
* use enum constant instead of hex value

Change-Id: I5cc5fc1ae8d5474dbc8d3385a493adf6420a3c98
Related: OS#3187
2018-11-02 16:12:03 +01:00
Philipp Maier f6c369fb8c gsm0808: allow decoding of zero length speech codec lists.
3GPP_TS_48.008, 3.2.2.103 Speech Codec List states the following:

"The length indicator (octet 2) is a binary number indicating the
absolute length of the contents after the length indicator.
The length depends on the number and type of Speech Codec Elements
to be included. The minimum length of one Speech Codec Element is 1
octet and the maximum length is 3 octets. The maximum number of
Speech Codec Elements within the Speech Codec List is not defined."

This clearly refers only to the length of a single speech codec
element but not on the overall list. So speech codec lists with
length 0 are indeed permitted by the spec.

- Remove the assertion that checks on zero length speech codec
  lists.

Change-Id: I1eb1f4466b98bdd26d765b0e4cc690b5e89e9dd6
Related: OS#3657
2018-10-16 16:41:45 +02:00
Philipp Maier 8515d035ae gsm0808: add function to convert AMR S15-S0 to gsm0408 settings
Add a function to convert S0-S15 bits to struct gsm48_multi_rate_conf,
which hold the codec settings for AMR.

Change-Id: I973736273c236eee84decf15868190e339c3fed4
Related: OS#3548
2018-09-25 15:32:29 +00:00
Philipp Maier 5f2eb15074 gsm0808: add function to convert amr gsm0408 setings to gsm0808
Add a function to convert struct gsm48_multi_rate_conf, which holds the
codec settings for AMR, to S0-S15 bit representation as defined in
3GPP TS 48.008 3.2.2.49

This resurrects change-id I4e656731b16621736c7a2f4e64d9ce63b1064e98
which was reverted in I9e0d405e303ed86d23703ca6362e958dddb2f861
due to gsm0808_test failing.

The test failure is fixed by properly clearing the struct
gsm48_multirate_cfg prior to running tests (add memset(0)).

Change-Id: Ia782e21c206c15e840226d79b4209d13658ee916
Related: OS#3548
2018-09-19 14:01:10 +00:00
Neels Hofmeyr dd8c73cc6d Revert "gsm0808: add function to convert amr gsm0408 setings to gsm0808"
This reverts commit 2fd4fe6aa1.

As shown in https://jenkins.osmocom.org/jenkins/view/master/job/master-libosmocore/475/a2=default,a3=default,arch=amd64,label=osmocom-master-debian9/console

This commit breaks gsm0808_test with:

stderr:
--- expout	2018-09-16 22:37:31.382280438 +0200
+++ /n/s/dev/make/libosmocore/tests/testsuite.dir/at-groups/21/stdout	2018-09-16 22:37:31.426281372 +0200
@@ -78,9 +78,9 @@
 Input:
  m4_75= 0   smod=  0
  m5_15= 0   spare= 0
- m5_90= 0   icmi=  0
+ m5_90= 0   icmi=  1
  m6_70= 0   nscb=  0
- m7_40= 0   ver=   0
+ m7_40= 0   ver=   6
  m7_95= 0
  m10_2= 0
  m12_2= 0
@@ -92,9 +92,9 @@
 Input:
  m4_75= 1   smod=  0
  m5_15= 0   spare= 0
- m5_90= 0   icmi=  0
+ m5_90= 0   icmi=  1
  m6_70= 0   nscb=  0
- m7_40= 0   ver=   0
+ m7_40= 0   ver=   6
  m7_95= 0
  m10_2= 0
  m12_2= 0
@@ -106,9 +106,9 @@
 Input:
  m4_75= 0   smod=  0
  m5_15= 1   spare= 0
- m5_90= 0   icmi=  0
+ m5_90= 0   icmi=  1
[...]

Change-Id: I9e0d405e303ed86d23703ca6362e958dddb2f861
2018-09-16 21:02:25 +00:00
Philipp Maier 2fd4fe6aa1 gsm0808: add function to convert amr gsm0408 setings to gsm0808
Add a function to convert struct gsm48_multi_rate_conf, which holds the
codec settings for AMR, to S0-S15 bit representation as defined in
3GPP TS 48.008 3.2.2.49

Change-Id: I4e656731b16621736c7a2f4e64d9ce63b1064e98
Related: OS#3548
2018-09-14 16:24:10 +02:00
Neels Hofmeyr 178bf7a409 gsm0808_test: silence deprecation: use gsm0808_create_layer3_2()
Change-Id: Ia0afecafa8862ffbe2af3c86e5552673f0935eb0
2018-04-23 08:42:00 +00:00
Neels Hofmeyr 9a4286b709 gsm0808_test: fix more missing inits (address sanitizer issues)
In recent Iaa20c59f624fbdc69a018cabd0f7e9c5a1389519 I fixed one missing init
issue and didn't notice the N other similar ones right next to it. Also fix the
remaining missing inits.

Fixes:
    ../../../../src/libosmocore/src/gsm/gsm0808_utils.c:187:8: runtime error: load of value 13, which is not a valid value for type '_Bool'
    ../../../../src/libosmocore/src/gsm/gsm0808_utils.c:191:8: runtime error: load of value 119, which is not a valid value for type '_Bool'

Related: OS#3148
Change-Id: Ie8a1a9b3132024135ca70390eae4d21c907b2edc
2018-04-23 08:40:55 +00:00
Neels Hofmeyr a4399c8891 add gsm0808_cell_{id,id_list}_name() and friends
Provide comprehensive API to obtain string representations of Cell Identifiers
and -Lists.

Change gsm0808_test.c to use the new functions (which simplifies the output a
bit), so that we don't duplicate printing code in gsm0808_test.c, and so that
the not-so-trivial printing code is also tested.

In gsm0808_test, also test gsm0808_cell_id_list_name_buf()'s return value and
truncation behavior.

The rationale for gsm0808_cell_id_list_name(), i.e. printing an entire list of
cell identifiers, is that even though the maximum is 127 elements, a list of
more than a few elements is hardly ever expected in practice (even more than
one element isn't actually expected: either "entire BSS" or a single LAC). It
is thus useful to log the entire list when it shows up in Paging and Handover.

Change-Id: I9b2106805422f96c5cc96ebb9178451355582df3
2018-04-18 02:38:37 +02:00
Neels Hofmeyr c62c934647 test_gsm0808_enc_dec_speech_codec_with_cfg: initialize properly
The uninitialized members of enc_sc sporadically hit address sanitizer failure
during gsm0808_test, like:
../../../../src/libosmocore/src/gsm/gsm0808_utils.c:187:8: runtime error: load of value 13, which is not a valid value for type '_Bool'
../../../../src/libosmocore/src/gsm/gsm0808_utils.c:191:8: runtime error: load of value 119, which is not a valid value for type '_Bool'

How the test survived so long is a mystery to me; as soon as some uninitialized
members would by coincidence not be zero, the test should always have failed at
OSMO_ASSERT(memcmp(&enc_sc, &dec_sc, sizeof(enc_sc)) == 0).

Related: OS#3148
Change-Id: Iaa20c59f624fbdc69a018cabd0f7e9c5a1389519
2018-04-15 23:40:19 +02:00
Neels Hofmeyr db2fa4e0d5 test_gsm0808_enc_dec_cell_id_list_lac(): populate all LACs
Change-Id: I7535166a2827c03a954fe72d5d99217e4f25868f
2018-04-13 05:38:48 +02:00
Neels Hofmeyr 066473fe36 test_gsm0808_enc_dec_cell_id_list_lac(): validate encoded bytes
Change-Id: I81b1ffbe6a5ec566c112492c2cbaf99c018c45bb
2018-04-13 05:38:48 +02:00
Neels Hofmeyr 250e7f7d30 add gsm0808_{enc,dec}_cell_id
Clarify semantics and micro-optimise for the case of single Cell Identifer IEs.
Test in gsm0808_test.c

So far we have gsm0808_enc_cell_id_list2(), but there also exist instances of
single Cell Identifiers (3GPP TS 48.008 3.2.2.17).

It is possible to decode the same using the cell identifier list API, but this
forces the caller to also keep a full struct gsm0808_cell_id_list2 with all its
127 entries around.

E.g. for handover, there are two Cell Identifiers (Serving and Target); I'd
need two full cell id lists for each, and these would be dynamically allocated
for each handover operation, whether it uses them or not.

Related: OS#2283 (inter-BSC HO, BSC side)
Change-Id: I9f9c528965775698ab62ac386af0516192c4b0cc
2018-04-13 05:38:47 +02:00
Neels Hofmeyr 74663d97c6 add gsm0808_cell_id_list_add() to combine two cell identifier lists
This will be used by the upcoming neighbor_ident API in osmo-bsc, where the vty
interface allows composing neihbor BSS cell identifier lists, and we want to
allow adding individual items from individual user commands.

It will also be useful to accumulate cell identifiers in case a subscriber sees
multiple alternative cells from a neighboring BSS, and we want to pass these on
to the MSC in a Handover Required.

Related: OS#2283 (inter-BSC HO, BSC side)
Change-Id: I5781f5fa5339c92ab2e2620489b002829d206925
2018-04-13 05:28:09 +02:00
Neels Hofmeyr 21946e8f5d cosmetic: gsm0808_test: drop extraneous assertion
Recent commit I77cd4b9142510c6914298b720d9c19ab68f9ebef left an obsolete
assertion around. It is already done in the if-body now.

Change-Id: I1bb2ea363e8a9d86b24338df3584abc93ebc6dd4
2018-03-24 20:10:41 +01:00
Neels Hofmeyr 8b8cd93817 fix gsm0808_enc_cell_id_list2 for leading-zero MNC
Use non-deprecated API to decode encode in gsm0808_enc_cell_id_list2().

Adjust gsm0808_test.c to now expect the correct results instead of previous
failure.

Change-Id: I1ce78883995e0d484368046b69db5afb2b4adc97
2018-03-23 12:47:05 +00:00
Neels Hofmeyr c44fc23fee show failure in gsm0808_enc_cell_id_list2() in gsm0808_test
Change-Id: I763b18d2922701ad97382269747ff0cbb7bd657b
2018-03-23 12:31:29 +00:00
Neels Hofmeyr 473485c903 gsm0808_test: cosmetic: test non-hex MCC
The test currently sets the MCC by a hex value, which is a weird choice. The
MCC gets BCD'd and hence we will see the decimal values 1:1 in the encoded
octets as hex digits. Using hex as input obscures that:

Right now it sets mcc = 0x123, which is actually 291 in decimal, and we hence
see "92 .1" in the expected BCD result. Using 0x124 in the test source actually
makes it hard to see where the 0x123 went.

Change the MCC to decimal notation (123, 124, 125) and adjust the expected
encoded output.

Change-Id: I973835c54a90fefe50d2b3581324d12556715f58
2018-03-23 12:25:13 +00:00
Neels Hofmeyr c1991df2c4 gsm0808_test: cosmetic: re-arrange struct init; print hexdump on failure
I am going to ehance the test to actually include leading-zero MNC, but first I
would like to simplify how the test source struct is initialized, before I edit
around in it.

Also, when the memcmp() fails, print hexdumps of expected and actual result for
comparison. I needed it to figure out a test failure, might as well keep it.

Change-Id: I77cd4b9142510c6914298b720d9c19ab68f9ebef
2018-03-23 12:25:04 +00:00
Philipp Maier 7e27b14ef2 gsm_08_08: correct speech codec defaults
The speech codec defaults are not correct. The defaults recommended
in 3GPP TS 28.062, Table 7.11.3.1.3-2 are limited by 3GPP TS 48.008,
Section 3.2.2.103. Some defaults are actually reserved for future
use. Also the endianess of the 16 bit values is reversed.

- correct values so that they match the specification
- transmit bytes in the correct endianess

Change-Id: I6c3a34d39a375d71c4128fd38f06629e8b98b100
2018-03-23 11:59:29 +00:00
Stefan Sperling 483f386fd4 add a test for CELL_IDENT_WHOLE_GLOBAL cell identifier lists
Add a regression test which encodes and decodes a cell identifier
list of type CELL_IDENT_WHOLE_GLOBAL.

Change-Id: Ie633d9e55c6a30555c0153d35aaf9f982d6e0088
Depends: If0fafbc7171da2a3044bfa9a167208a1afa1c07b
Related: OS#2847
2018-03-16 12:23:42 +01:00
Stefan Sperling ed4327c470 fix parse_cell_id_lac_and_ci_list()
The implementation was entirely broken, reading data from wrong offsets
and always writing to the first element of the decoded list.

Also, add a new test for this function which found the problems.

Change-Id: If0fafbc7171da2a3044bfa9a167208a1afa1c07b
Related: OS#2847
Depends: Ife4e485e2b86c6f3321c9700611700115ad247b2
2018-03-16 11:02:59 +01:00
Stefan Sperling 9c62fc69a8 fix bug in parse_cell_id_ci_list()
Cell ID lists with CI were misparsed because parse_cell_id_ci_list()
failed to report the amount of consumed bytes to its caller.

Also add a regression test which uncovered the bug.

Change-Id: Ife4e485e2b86c6f3321c9700611700115ad247b2
Depends: If6b941720de33dca66b6b1aa2cb95a3275708b7f
Related: OS#2847
2018-03-16 10:35:08 +01:00
Stefan Sperling 2338145d5b use gsm48_decode_lai2() in gsm0808_dec_cell_id_list()
This makes gsm0808_dec_cell_id_list() properly decode 3-digit MNCs.
Add a test which encodes/decodes a LAI_AND_LAC list with 3-digit MNCs.

Change-Id: If6b941720de33dca66b6b1aa2cb95a3275708b7f
Related: OS#2847
2018-03-15 19:44:37 +01:00
Stefan Sperling e1a86748a2 fix cell identifier decoding in libosmocore
The cell ID list decoder merged in 11a4d9dd91
has a bug which was introduced part-way through the review process in
gerrit at https://gerrit.osmocom.org/#/c/6509/

When Neels suggested "why not just {...}id_list[MAXLEN] once?" I changed
the cell identifier list from a union of arrays to an array of unions.

After this change, elements smaller than the largest type in the union
were not laid out consecutively in memory anymore. E.g. uint16_t lac
values now occur at offsets of sizeof(id_list[0]) instead of offsets
of sizeof(uint16_t).

The problem is that I forgot to adjust the decoder accordingly, so the
decoder writes to the wrong offsets and returns cell identifier lists
which appear to contain uninitialized values when read back by API
consumers.

I found this problem while adding new regression tests to libosmocore to
test encoding and decoding. This commit adds one such tests for LAC list
decoding, which failed due to the above bug. I plan to write more tests,
however because this first test already uncovered a severe issue I chose
to submit a fix now and work on additional tests in later commits.

Change-Id: Ie1a5a9d858226be578cf11a03cf996d509bd51fb
Related: OS#2847
2018-03-15 18:27:30 +01:00
Stefan Sperling 11a4d9dd91 support for more cell ID list types in libosmocore
Introduce gsm0808_dec_cell_id_list2() with supports additional types of
cell identifier lists. The new parsing routines are based on similar
routines used by the paging code in osmo-bsc's osmo_bsc_bssap.c.

Likewise, introduce gsm0808_enc_cell_id_list2() with support for the
same additional types of cell identifier lists.

The old API using struct gsm0808_cell_id_list is deprecated.
The previous definition was insufficient because it assumed that all
decoded cell ID types could be represented with a single uint16_t.
It was declared in a GSM protocol header (gsm/protocol/gsm_08_08.h)
despite being a host-side representation of data in an IE.
The only user I am aware of is in osmo-msc, where this struct is used
for one local variable. osmo-msc releases >= 1.1.0 make use of this API.

While here, fix a small bug in a test:
test_gsm0808_enc_dec_cell_id_list_bss() set the cell ID type to 'LAC'
but obviously wants to use type 'BSS'.

Change-Id: Ib7e754f538df0c83298a3c958b4e15a32fcb8abb
Related: OS#2847
2018-03-13 14:28:15 +01:00
Harald Welte 62e40855c2 gsm0808_create_cipher_reject: Fix encoding of Cause IE
The Cause IE in the 08.08 CIPHER MODE REJECT is a normal TLV IE,
and not just a value.  Let's make sure we encode the cause value
properly.

Change-Id: I4f5b231edf6dcb0a9c2bbafb2a59f301f3b2402b
Closes: OS#2766
2017-12-17 20:51:48 +01:00
Neels Hofmeyr 9a938ae882 gsm0808_test: sanitize: fix msgb memleak
Helps fix sanitizer build on debian 9.

Change-Id: I0097d63bbb4e7ee20eb4a8474f4fef32d39e625f
2017-11-18 10:30:58 +00:00
Philipp Maier bb8396690e gsm0808: fix AoIP speech codec element parser/generator
The implementation of the parser/generator for the speech codec
information element slightly wrong, making it impossible to use
it properly.

(See also: 3GPP TS 48.008, 3.2.2.103)

Change-Id: Idabb0f9620659557672e1c6b90c75481192e5c89
2017-06-22 17:08:14 +00:00