summaryrefslogtreecommitdiffstats
path: root/tests/gsm0808/gsm0808_test.c
Commit message (Collapse)AuthorAgeFilesLines
* add gsm0808_{enc,dec}_cell_idNeels Hofmeyr2018-04-131-0/+199
| | | | | | | | | | | | | | | | | | | 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
* add gsm0808_cell_id_list_add() to combine two cell identifier listsNeels Hofmeyr2018-04-131-0/+195
| | | | | | | | | | | | | 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
* cosmetic: gsm0808_test: drop extraneous assertionNeels Hofmeyr2018-03-241-1/+0
| | | | | | | Recent commit I77cd4b9142510c6914298b720d9c19ab68f9ebef left an obsolete assertion around. It is already done in the if-body now. Change-Id: I1bb2ea363e8a9d86b24338df3584abc93ebc6dd4
* fix gsm0808_enc_cell_id_list2 for leading-zero MNCNeels Hofmeyr2018-03-231-4/+1
| | | | | | | | | 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
* show failure in gsm0808_enc_cell_id_list2() in gsm0808_testNeels Hofmeyr2018-03-231-4/+8
| | | | Change-Id: I763b18d2922701ad97382269747ff0cbb7bd657b
* gsm0808_test: cosmetic: test non-hex MCCNeels Hofmeyr2018-03-231-6/+6
| | | | | | | | | | | | | | | 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
* gsm0808_test: cosmetic: re-arrange struct init; print hexdump on failureNeels Hofmeyr2018-03-231-24/+32
| | | | | | | | | | | 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
* gsm_08_08: correct speech codec defaultsPhilipp Maier2018-03-231-7/+7
| | | | | | | | | | | | 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
* add a test for CELL_IDENT_WHOLE_GLOBAL cell identifier listsStefan Sperling2018-03-161-0/+61
| | | | | | | | | 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
* fix parse_cell_id_lac_and_ci_list()Stefan Sperling2018-03-161-0/+42
| | | | | | | | | | | 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
* fix bug in parse_cell_id_ci_list()Stefan Sperling2018-03-161-0/+35
| | | | | | | | | | | 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
* use gsm48_decode_lai2() in gsm0808_dec_cell_id_list()Stefan Sperling2018-03-151-0/+57
| | | | | | | | 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
* fix cell identifier decoding in libosmocoreStefan Sperling2018-03-151-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The cell ID list decoder merged in 11a4d9dd91216fe353e94bfdbbab53bc4f891c0d 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
* support for more cell ID list types in libosmocoreStefan Sperling2018-03-131-25/+22
| | | | | | | | | | | | | | | | | | | | | | | | 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
* gsm0808_create_cipher_reject: Fix encoding of Cause IEHarald Welte2017-12-171-1/+1
| | | | | | | | | 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
* gsm0808_test: sanitize: fix msgb memleakNeels Hofmeyr2017-11-181-0/+2
| | | | | | Helps fix sanitizer build on debian 9. Change-Id: I0097d63bbb4e7ee20eb4a8474f4fef32d39e625f
* gsm0808: fix AoIP speech codec element parser/generatorPhilipp Maier2017-06-221-41/+36
| | | | | | | | | | 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
* gsm0808: make gsm0808_create_reset_ack() accessiblePhilipp Maier2017-04-081-0/+13
| | | | | | | | | | | The create function to generate the RESET ACKNOWLEDGE message is not accessible from outside, as it does not appear in limosmogsm.map. It also has not testcase. This commit adds gsm0808_create_reset_ack() to the map file and also adds a testcase. Change-Id: I82d3411484f82b4a9205d407fa0442244678f183
* gsm0808: Add create functions for BSS_MAP_MSG_ASSIGMENT_RQSTPhilipp Maier2017-04-081-0/+50
| | | | | | | | | | gsm0808.h/c lacks functionality to generate BSS_MAP_MSG_ASSIGMENT_RQST messages. These messages are required if the code is used in an MSC implementation. This commit adds a gsm0808_create_assignment() function, that generates an A/AoiP BSS_MAP_MSG_PAGING message. Change-Id: I4d1d455a1e1cf95407e23ded7b7defbcf2dd6ff0
* gsm0808: Add create functions for BSS_MAP_MSG_PAGINGPhilipp Maier2017-04-081-0/+42
| | | | | | | | | | gsm0808.h/c lacks functionality to generate BSS_MAP_MSG_PAGING messages. These messages are required if the code is used in an MSC implementation. This commit adds a gsm0808_create_paging() function, that generates an A/AoiP BSS_MAP_MSG_PAGING message. Change-Id: I9afecf0109305ca5153bf081bb29cd94071dd2b7
* gsm0808: Add create functions for CIPHER MODE COMMANDPhilipp Maier2017-04-081-0/+41
| | | | | | | | | | gsm0808.h/c lacks functionality to generate CIPHER MODE COMMAND messages. These messages are required if the code is used in an MSC implementation. This commit adds a gsm0808_create_cipher() function, that generates an A/AoiP CIPHER MODE COMMAND message. Change-Id: I8eb1c357860c3e740b0f5d17e1c256bc87920958
* gsm0808: Add utils for Cell Identifier ListPhilipp Maier2017-04-081-0/+85
| | | | | | | | | | The planned support for true A over IP requires the encoding of the a Cell Identifier List element (see also BSS_MAP_MSG_PAGING). This commt adds encoding/decoding functionality and tests for the element mentioned above, however, it is not yet actively used. Change-Id: I625245dd1dd396fc2bc189e8cd2c444a33042528
* gsm0808: Add utils for Encryption InformationPhilipp Maier2017-04-081-0/+40
| | | | | | | | | | The planned support for true A over IP requires the encoding of the an Encryption Information element (see also BSS_MAP_MSG_CIPHER_MODE_CMD). This commt adds encoding/decoding functionality and tests for the element mentioned above, however, it is not yet actively used. Change-Id: I8262050a9d9fd3f17462cfbb046c6e034dccc6fb
* gsm0808: Add utils for Channel TypePhilipp Maier2017-04-081-0/+31
| | | | | | | | | | The planned support for true A over IP requires the encoding of the a Channel Type element (see also ASSIGNMENT REQUEST). This commt adds encoding/decoding functionality and tests for the element mentioned above, however, it is not yet actively used. Change-Id: Id0e2164d84b8cbcc6fe6a090fc7f40a1251421d7
* gsm0808: Add AoIP specific elements to gsm0808_create_... functionsPhilipp Maier2017-04-081-0/+115
| | | | | | | | | the classic A implementation in libosmocore lacks support for AoIP message elements. This patch adds support for AoIP by adding a set of new gsm0808_create_..., which support the missing AoIP message elements Change-Id: I77f866abec1822d19871052f3c647ad782785b34
* gsm0808: Add utils for Speech Codec List and Speech CodecPhilipp Maier2017-04-081-0/+124
| | | | | | | | | | The planned support for true A over IP requires the encoding and decoding of a so called "Speech Codec Element" element. This commt adds parsing functionality and tests for the element mentioned above, however, it is not yet actively used. Change-Id: I0e1e2edf47adaa45b22d4b0bcae3640dba7ca200
* gsm0808: Add utils for AoIP Transport Layer AddressPhilipp Maier2017-04-081-0/+64
| | | | | | | | | | The planned support for true A over IP requires the encoding and decoding of a so called "AoIP Transport Layer Address" element. This commt adds parsing functionality and tests for the element mentioned above, however, it is not yet actively used. Change-Id: I57933b0a06a3f54ec2a41e6ecb6ced9fbbc89332
* test: Fix compiler warnings on 64bit systemsHolger Hans Peter Freyther2015-11-091-1/+1
| | | | | | Use %td to print ptrdiff_t use %zu to print size_t, include time.h on FreeBSD. Some more compiler warnings are left but they require more thinking.
* GSM 08.08: change gsm0808_create_classmark_update() prototypeHarald Welte2012-01-261-3/+11
| | | | | The caller explicitly specifies CM2 and CM3, rather than one blob containing both.
* tests: Introduce a very basic gsm0808 testHolger Hans Peter Freyther2012-01-221-0/+261
This tests verifies the content of the GSM 08.08 messages, it does not verify the remaining headroom (which the SCCP/IPA code relies on being plenty to prepend the header). More to come in the future.