summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* lapd_core: Perform N200 retransmissions, not N200-1Harald Welte2019-06-051-4/+4
| | | | | | | | | | | | | | | During testing with BTS_Tests_LAPDm.TC_t200_n200() it was discovered that the existing LAPD[m] implementation always gave up at N200-1 retransmissions, rather than N200 retransmissions. The first transmission doesn't count, and hence we must have N200 actual re-transmissions. The Error message is then described as "T200 expired N200+1 times", i.e. we start T200 one more time after the last re-transmission and only give up if it expires again (i.e. no ACK received) Change-Id: Ic33854ee61311f73b7db55eeef10280349151097 Related: OS4037
* lapdm: Allow user to specify T200 values; Use correct N200 valuesHarald Welte2019-06-053-15/+85
| | | | | | | | | | | | | | | | | | TS 04.06 specifies a N200 re-transmission counter that depends on the channel type, which we didn't care about at all so far. Let's have the caller tell us the channel type so we can internally look up the correct N200 value for it. At the same time, permit the user to specify T200 re-transmission timer values for each SAPI on both DCCH and ACCH, which is required at least in the BTS as per GSM TS 12.21. Also, extend the timer resolution of the API from seconds to milli-seconds, which is more applicable as particularly on the FACCH the recommended values are in the 200ms range. Change-Id: I90fdc4dd4720d4e02213197c894eb0a55a39158c Related: OS#3906 Related: OS#2294 Related: OS#4037
* gsm0808_utils: Add gsm0808_decode_cell_id_u()Harald Welte2019-06-043-11/+60
| | | | | | | | | This function parses a single Cell ID list element into a 'union gsm0808_cell_id_u'. This function is going to be used by the upcoming CBSP support. Related: OS#3537 Change-Id: I08b33881667aa32f01e53ccb70d44d5b79c7c986
* make all library-internal static buffers thread-localHarald Welte2019-06-0413-33/+32
| | | | | | | | | | | | | | | We have a number of library-internal static global buffers which are mainly used for various stringification functions. This worked as all of the related Osmocom programs were strictly single-threaded. Let's make those buffers at least thread-local. This way every thread gets their own set of buffers, and it's safe for multiple threads to execute the same functions once. They're of course still not re-entrant. If you need re-entrancy, you will need to use the _c() or _buf() suffix version of those functions and work with your own (stack or heap) buffers. Change-Id: I50eb2436a7c1261d79a9d2955584dce92780ca07
* utils: add gsmtap_logread.py a gsmtap log readerAlexander Couzens2019-06-042-0/+167
| | | | | | | | Receive gsmtap logs and feeds it into the python logging framework. Allows to use generic logging features and further utilities. Change-Id: I24478d8e16066c6118e867bdba54c6418c15e170
* lapdm: Don't truncate L3 payload at 200 bytes lengthHarald Welte2019-06-021-1/+1
| | | | | | | | | 3GPP TS 04.06 is quite clear that the [segmented] L3 payload can be as long as 251 bytes. Our libosmocore lapdm implementation truncated already at 200 bytes :( Change-Id: I6769986f27dda1d429ed7b2e32c36d34663acba9 Closes: OS#4035
* socket.c: fix Doxygen doc for osmo_sock_unix_init_ofd()Vadim Yanitskiy2019-06-011-2/+2
| | | | | | One typo s/optionall/optionally/, and a few incorrect references. Change-Id: Iab42aa376b5cf4cf36413fede46e001c6b2d1525
* vty/command.c: cosmetic: add missing curly bracketsVadim Yanitskiy2019-06-011-2/+4
| | | | | | Otherwise it's a bit hard to read the code. Change-Id: I807ec71cfb67976251be844cdb2d2776b1837438
* gsm48_encode_bcd_number(): clarify optional LHV header initializationVadim Yanitskiy2019-05-293-6/+16
| | | | Change-Id: Iafd911dd55691b3715391e3899cd6971245c8d7f
* rest_octets: Remove SI2ter + SI2bis encoders that don't do anythingHarald Welte2019-05-283-35/+0
| | | | | | | | The library should either provide functions that implement encoding of those rest octets, or it shouldn't. Providing a function that doesn't do anything but pad the buffer is useless. Change-Id: Ie10684de6a6b2663e2a871fcdb2b275b6ad7a1e7
* rest_octets: Implement actual SI6 rest octets encodingHarald Welte2019-05-282-12/+73
| | | | | | | | | There's very little sense behind introducing a function into libosmogsm which doesn't implement 90% of the spec. Let's allow the caller to provide the various optional bits of information to the encoder, rather than generating mostly static SI6 rest octets. Change-Id: Id75005a0c4a02ce7f809692d58b3bd226bc582b2
* rest_octets: Add function to parse SI3 rest octetsHarald Welte2019-05-283-0/+82
| | | | | | Change-Id: I690cf308311f910005a325d50f5d5d825678d2b2 Related: OS#3075 Related: OS#4023
* rest_octets: Suffix encoder functiosn with _encodeHarald Welte2019-05-283-28/+32
| | | | | | ... otherwise it's not really clear what they do. Change-Id: I08e0ca9a8d13c7aa40b9d90f34f0e13adb87d4e0
* rest_octets: Fix export of osmo_gsm48_rest_octetsHarald Welte2019-05-281-8/+8
| | | | | | | | the symbols had an omso_ prefix, while the entry in the .map file didn't. As a result, all related symbols were never exported and hence not usable by any users of the dynamic library. Change-Id: I8b1ee2405f6338507e9dfb5f1f437c4c2db2e330
* rest_octets: Actually include gsm48_rest_octets.c in Makefile.amHarald Welte2019-05-281-1/+1
| | | | | | | | | The gsm48_rest_octets.c file was added in Change-Id I47888965ab11bba1186c21987f1365c9270abeab, but it never actually ended up being compiled as it wasn't listed in the makefile :/ Change-Id: I0355115c2645f236c9e32cf7a563cf51a857e8a3 Relsted: OS#3075
* rest_octets: Use correct symbols names for range encoderHarald Welte2019-05-281-4/+4
| | | | | | | | | As gsm48_rest_octets.c is not listed in the Makefile.am, it's never actually compiled and we never noticed that it's calling functions by symbol names that don't exist :/ Change-Id: I7b1e436f70e0c60979261db87606f38271ec47d3 Related: OS#3075
* gsm48_rest_octets: Fix license: GPLv2+ instead of AGPLv3+Harald Welte2019-05-281-4/+6
| | | | | | | | | | | | | | libosmo{core,gsm,vty} code is GPLv2+. The rest octet code originated in osmo-bsc.git and was moved here without changing the license. That was a mistake, it always was meant to be under GPLv2-or-later after moving to libosmocore.git. Original copyright is mine. For contributions by sysmocom, I as the managing director can approve the license change. This means only Holger needs to ACK this. Change-Id: Ief3009dc28dd83e1e26a7101af2eed2341684a87
* gsm48_decode_bcd_number2(): return -EINVAL if LV has too big lengthVadim Yanitskiy2019-05-283-5/+5
| | | | Change-Id: Ie07b2e8bc2f9628904e88448b4ee63b359655123
* gsm48_decode_bcd_number2(): fix: return -ENOSPC on truncationVadim Yanitskiy2019-05-283-7/+17
| | | | | | | | The documentation of gsm48_decode_bcd_number2() clearly states that the output truncation is a erroneous case, so it should actually return negative in such cases. Let's return -ENOSPC. Change-Id: I75680f232001ba419a587fed4c24f32c70c3ad2b
* gsm48_decode_bcd_number2(): fix output truncationVadim Yanitskiy2019-05-282-4/+4
| | | | | | | | | | | | | | | | | Thanks to the new unit test for BCD number encoding / decoding, it was discovered that gsm48_decode_bcd_number2() does not properly handle encoded LV if the output buffer size is equal to the original MSISDN length + 1 (\0-terminator): one digit is lost. For example, decoding of 15-digit long MSISDN to a buffer of size 16 (15 digits + 1 for \0) would give us only 14 digits. The problem was that 'output_len' was being decremented before checking the remaining buffer length and writing a digit to it. As a result, the maximum length was always one byte shorter. Change-Id: I61d49387fedbf7b238e21540a5eff22f6861e27a Fixes: OS#4025
* gsm0408/gsm0408_test.c: introduce BCD number encoding / decoding testVadim Yanitskiy2019-05-282-0/+224
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far, both gsm48_encode_bcd_number() and gsm48_decode_bcd_number2() did not have any unit test coverage. Let's fill this gap by testing the following scenarios: - encoding / decoding of a regular 9-digit MSISDN; - encoding / decoding of a MSISDN with optional LHV; - encoding / decoding of a long 15-digit MSISDN; - encoding / decoding of a MSISDN to a buffer: - with exactly matching size, - with lower size (truncation); - decoding LV buffer with incorrect length, - encoding / decoding an empty input buffer. As it turns out, gsm48_decode_bcd_number2() does not properly handle encoded LV if the output buffer size is equal to the original MSISDN length + 1 (\0-terminator): one digit is lost. For example, decoding of 15-digit long MSISDN to a buffer of size 16 (15 digits + 1 for \0) would give us only 14 digits. This is reflected in the unit test output: Decoding HEX (buffer limit=16) '0821436587092143f5'... Expected: (rc=0) '123456789012345' Actual: (rc=0) '12345678901234' Moreover, if the output buffer is shorter than decoded number, gsm48_decode_bcd_number2() silently truncates it and returns 0, while its description states, that the rc should reflect this. To be fixed in the follow-up patches. Change-Id: I4b2c330cf8ffe4427c0bee7d5f3b74be56ecd85d Related: OS#4025
* tdef: Fix license: GPLv2+ instead of AGPLv3+Harald Welte2019-05-273-12/+15
| | | | | | | | | | | | libosmo{core,gsm,vty} code is GPLv2+. The tdef code originated in osmo-msc.git and was moved here without changing the license. That was a mistake, it always was meant to be under GPLv2-or-later after moving to libosmocore.git. Copyright is with sysmocom, so I as the managing director can approve the license change. Change-Id: Ie483ff6f6ea0a56c477649677b4b163c49df11d7
* oap_client: Fix license: GPLv2+ instead of AGPLv3+Harald Welte2019-05-273-12/+16
| | | | | | | | | | | | libosmo{core,gsm,vty} code is GPLv2+. The OAP code originated in osmo-msc.git and was moved here without changing the license. That was a mistake, it always was meant to be under GPLv2-or-later after moving to libosmocore.git. Copyright is with sysmocom, so I as the managing director can approve the license change. Change-Id: I08311fa8214c15f8df8945b9894226608cf96f15
* rsl: Add osmocom-specific extensions to RSL channel numbers for CBCHHarald Welte2019-05-272-0/+14
| | | | | | | | | | | We don't really *need* it in libosmocore as such, but the lack of having all osmocom extensions listed here lead to using overlapping definitions: 0x18 was used for dynamic PDCH on the Abis side, but also for CBCH on the L1SAP side. Let's list them all here to increase visibility in case anyone wants to extend this further... Related: OS#4027 Change-Id: I93e557358cf1c1b622f77f906959df7ca6d5cb12
* protocol/gsm_12_21.h: fix copy-pasted struct descriptionVadim Yanitskiy2019-05-241-1/+1
| | | | Change-Id: Ic6d32c886f6f8f859e382d48f9e1b509000db9ba
* lapdm_rslms_recvmsg: Fix memory leak in error pathHarald Welte2019-05-191-1/+3
| | | | | | | | | | | | The caller of lapdm_rslms_recvmsg() (e.g. osmo-bts/src/common/rsl.c) assumes the message ownership is transferred. However, in one of the two error paths, msgb_free() was not called and hence we had a memory leak. Also clarify the msgb ownership transfer in a comment. Related: OS#3750 Change-Id: Id60cb45e50bfc89224d97df6c68fcd2949751895
* TLV: Add one-shot TLV encoderHarald Welte2019-05-195-0/+155
| | | | | | | | | | | | | | | | | So far, the TLV code contained two types of functions * tlp_parse() to parse all TLVs according to definition into tlvp_parsed * various helper functions to encode individual TLVs during message generation This patch implements the inverse of tlv_parse(): tlv_encode(), which takes a full 'struct tlv_pared' and encodes all IEs found in it. The order of IEs is in numerically ascending order of the tag. As many protocols have different IE/TLV ordering requirements, let's add a tlv_encode_ordered() function where the caller can specify the TLV ordering during the one-shot encode. Change-Id: I761a30bf20355a9f80a4a8e0c60b0b0f78515efe
* Cosmetic: GSUP: fix too long comment lineOliver Smith2019-05-191-2/+2
| | | | Change-Id: I60ba8fef8924e58bc73cff5c7ff77ebb76d8bfaa
* Deprecate usage of osmo_counter_*Daniel Willmann2019-05-191-2/+10
| | | | | | | There's not many of those around any more, let's try to move them to osmo_stat_items Change-Id: If67f64c6ec7a3f3114c962df9db50107d9ea86e2
* pseudotalloc: turn talloc_steal() into #defineHarald Welte2019-05-182-2/+3
| | | | | | | | | | | | | Any non-anciant version of talloc implements talloc_steal() as a #define using the _talloc_steal_loc() symbol. Let's be more compatible. This fix is relevant to using osmo_fsm inside the osmo-ccid-firmware builds for Cortex-M4. In this situation, for some strange reason, libosmcoore is compiled using src/pseudotalloc/talloc.h, but later then linked against the real libtalloc. Change-Id: I1ee7f5e9b1002cff37bb8341ad870e1da5f1f9ff
* Revert "Change GSM48_PDISC_* to enum type"Harald Welte2019-05-181-20/+18
| | | | | | | This reverts commit ece1d8509d5c5af7a60ab5e1a5dddade1b181dc9 which causes build failures due to compile warnings everywhere. Change-Id: Ic131439ea206a0b0f57968ef701667da73711b51
* Change GSM48_PDISC_* to enum typeMax2019-05-171-18/+20
| | | | | | | | An enum is more clear than an int and #defines for passing around, also in case you have a switch () statement, the compiler will issue warnings for unhandled cases. Change-Id: Icbbe8786a776081d7643193f154e6270224399e6
* codec/ecu: Add a bit of precision about the actual frame format usedSylvain Munaut2019-05-151-2/+7
| | | | | Change-Id: I9620088e449c31e966ecb9ec5ddf283b949c5a4a Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
* gsm_23_003: add GSM23003_MSISDN_{MIN,MAX}_DIGITSOliver Smith2019-05-152-1/+4
| | | | | | | | | | | Add the constant, so it can be used in create-subscriber-on-demand related patches. ITU-T Rec. E.164 6.1 states that maximum international number length should be 15. I did not find a source for a minimum length, but I've added the constant and set it to 1 for consistency (based on the existing osmo_msisdn_str_valid() function). Related: OS#2542 Change-Id: Idc74f4d94ad44b9fc1b6d43178f5f33d551ebfb1
* gsm0808: Introduce Osmocom extensions to announce Osmux supportPau Espin Pedrol2019-05-135-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | IE GSM0808_IE_OSMO_OSMUX_SUPPORT (T, 1 byte) is sent in AoIP appended to BSSMAP RESET in order to announce the peer that its MGW supports handling Osmux streams upon call set up. IE GSM0808_IE_OSMO_OSMUX_CID (TV, T 1 byte & V 1 byte) is sent in AoIP during call set up: * MSC->BSC Assignment Request * BSC->MSC Assignemnt Complete The 1 byte value contains the local Osmux CID, aka the recvCID aka CID where the peer sending the Assign Req/Compl will look for Osmux frames on that call. Hence, the peer receiving this CID value must use it to send Osmux frames for that call. As a result, a given call leg BSC<->MSC can have one different Osmux CID per direction. For example: * MS => MGW_BSC ==CID 0==> MGW_MSC * MS <= MGW_BSC <=CID 1=== MGW_MSC This allows for setups with 256 call legs per BSC on scenarios where NAT is not a problem, where MSC can have a pool of 256 CID per MGW_BSC (or remote peer). Related: OS#2551 Change-Id: I28f83e2e32b9533c99e65ccc1562900ac2aec74e
* NS: log address:port on errorMax2019-05-101-2/+2
| | | | Change-Id: If2dc533a6dc150254f5d44b672f04bb728e7e927
* osmo_sock_get_name_*: Ensure string is returned in error caseHarald Welte2019-05-101-1/+3
| | | | | | | | | | | | | | osmo_sock_get_name_buf(): In case the getsockname() call is failing for some weird reason, we shouldn't return an uninitialized, non-zero-terminated string buffer to the caller, as most callers will be too lazy to test the return value. This holds even more true for users of the internal osmo_sock_get_name2() and osmo_sock_get_name2_c() functions which indeed very much ignore the return value of osmo_sock_get_name_buf(). Change-Id: I2d56327e96b7a6783cca38b828c5ee74aed776ae
* Revert "Print error message if application fails to call rate_ctr_init()"Harald Welte2019-05-101-5/+2
| | | | | | | This reverts commit 9685a48c7bc83b1f5ee9b51e29419164b387ade2 which has caused massive fall-out among (particularly) unit tests in osmo-{msc,bts,pcu}. Change-Id: Iede72e86451d94cf678045992cb71f6b1bf16896
* gsm0808_utils: Introduce gsm0808_msgb_put_cell_id_u()Harald Welte2019-05-103-41/+44
| | | | | | | | | | | | This function is doing the bulk work of encoding a given Cell ID List item. gsm0808_enc_cell_id_list2() is modified to be a wrapper / loop around the new function. The purpose of this is to expose Cell ID List Entry encoding so that the upcoming CBSP protocol encoder can re-use this code. Related: OS#3537 Change-Id: I6cc567798e20365e6587e6b2988e834306d8c80c
* Print error message if application fails to call rate_ctr_init()Harald Welte2019-05-101-2/+5
| | | | | Change-Id: Ie8093b66b7e27cf863d2558fe21b2c6e0f3fcdfd Closes: OS#3580
* Fix osmo_quote_str_c() for strings larger than 32 bytesHarald Welte2019-05-101-2/+13
| | | | | | | As Neels pointed out, we shouldn't pass a constant value of 32 to osmo_quote_str_buf2(). Change-Id: Id9bde14166d6674ce4dda36fa9f4ae9217ce5cc2
* Add MO-FALLBACK-VALUE SGsAP IEOmar Ramadan2019-05-102-0/+3
| | | | | | | In testing against a particular EPC, the SGsAP-SERVICE-REQUEST can contain a MO fallback value TLV with T 0xF1 Change-Id: Ia2460af9673818d375e28c67f1631b5f7eacdaeb
* fix typo in FSM descriptionKévin Redon2019-05-091-4/+4
| | | | Change-Id: I3559e9c0769b708cee0d1b221b60960c62f15bd4
* Add expect script: 'vty' for easy access to all vtysKeith2019-05-081-0/+87
| | | | | | | | | | | This expect script can be run as: ./vty bsc ./vty msc ./vty sip ... etc (no need to remember ports) Change-Id: Ice4532be7cb3139da29cb9d84dd4769e8d826dfa
* deal with rate_ctr_group_alloc() returning NULLHarald Welte2019-05-082-0/+8
| | | | | Change-Id: I47d6623b9eca704e3c2537cfb5799a4c0749a7bc Related: #3701
* Add VTY and CTRL port numbers for OsmoCBC (Cell Broadcast Centre)Harald Welte2019-05-082-0/+3
| | | | Change-Id: I2075420048b43973c800ba0fc389f4b559437233
* Bump version: 1.0.1.143-cc72c → 1.1.0Pau Espin Pedrol2019-05-0710-25/+177
| | | | Change-Id: I351411ca5913c8b40f23287ec7c9ebfe11bd2bb0
* add osmo_stat_item_inc/osmo_stat_item_dec to set it relativeAlexander Couzens2019-05-073-0/+42
| | | | Change-Id: Id2462c4866bd22bc2338c9c8f69b775f88ae7511
* Re-introduce declaration of gsm0808_create_handover_request_ack()Harald Welte2019-05-061-0/+4
| | | | | | | | | | | | | In Change-Id Ia71542ea37d4fd2c9fb9b40357db7aeb111ec576, the old declaration of gsm0808_create_handover_request_ack() was accidentially removed from the gsm0808.h header file. The actual function itself (and the exported symbol) remained for backwards compatibility at runtime, but removing the declaration from the header file resulted in build failures across the board of all automatic tests. Let's re-introduce the old declaration. Change-Id: I9e96fa675fccca9ee9631caad7559dea3794d490
* add gsm0808_create_handover_request_ack2 to add AoIP RTP addrNeels Hofmeyr2019-05-053-12/+60
| | | | | | | | | | | | | | | | | | | osmo-bsc so far omits the AoIP Transport Layer Address from its Handover Request Acknowledge message, which breaks inter-BSC Handover for AoIP. Allow fixing that. One quirk I really don't like about this: I would prefer to directly use struct sockaddr_storage as a member of the struct gsm0808_handover_request_ack. Even though struct sockaddr_storage appears in various function signatures, the gsm0808.c actually also gets built on embedded systems that lack arpa/inet.h (for me indicated by the ARM build job on jenkins). Compiling gsm0808.c works only because the actual coding of struct sockaddr_storage is implemented in gsm0808_util.c, which (apparently) does not get built on embedded and hence, even though there are undefined references to e.g. gsm0808_enc_aoip_trasp_addr() it works. Related: I4a5acdb2d4a0b947cc0c62067a67be88a3d467ff (osmo-bsc) Change-Id: Ia71542ea37d4fd2c9fb9b40357db7aeb111ec576