summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* utils: add osmo_escape_str()Neels Hofmeyr2017-12-181-0/+87
| | | | | | | | | | | | | To report invalid characters in identifiers, it is desirable to escape any weird characters. Otherwise we might print stray newlines or control characters in the log output. ctrl_test.c already uses a print_escaped() function, which will be replaced by osmo_escape_str() in a subsequent patch. control_cmd.c will use osmo_escape_str() to log invalid identifiers. Change-Id: Ic685eb63dead3967d01aaa4f1e9899e5461ca49a
* add osmo_auth_c3() (separate from gsm_milenage())Neels Hofmeyr2017-12-183-3/+16
| | | | | | | | | | | | | | | To send a Ciphering Mode Command, we may need to derive a Kc from UMTS AKA tokens. gsm_milenage() derives Kc from 3G tokens, but also derives an SRES. For SRES, it requires an OPC, which may need to be derived from OP first. All we need is a Kc, so we could feed a zero OPC ... but to simplify the function call for cases where just a Kc is required, separate the c3 function out from gsm_milenage(), as osmo_auth_c3(). Obviously call osmo_auth_c3() from gsm_milenage() (meaning that osmo-hlr's 55.205 derived auc tests still cover exactly that implementation). Prepares: If04e405426c55a81341747a9b450a69188525d5c (osmo-msc) Related: OS#2745 Change-Id: I85a1d6ae95ad9e5ce9524ef7fc06414848afc2aa
* rate_ctr: print proper error message if rate_ctr already existsHarald Welte2017-12-181-1/+4
| | | | Change-Id: I86b7ccb0931f5a2a489bb8c7c6aee0894a126eb8
* utils: add osmo_separated_identifiers_valid()Neels Hofmeyr2017-12-171-4/+17
| | | | | | | | For validating CTRL input, we want to verify that an input variable is a series of valid osmo_identifier_valid() separated by dots. Allow validating any additional chars with identifiers, for CTRL vars will be just ".". Change-Id: I13dfd02c8c870620f937d789873ad84c6b1c45de
* fix osmo_identifier_valid(): only allow printable charactersNeels Hofmeyr2017-12-171-0/+2
| | | | | | In particular disallow ASCII 0..31 (control characters) and 127 (DEL). Change-Id: I04469988495af03c881fe81d7786ca7f71636299
* Do not allocate already existing counter groupMax2017-12-171-0/+3
| | | | | | | | Check that no group with the given name and index already exist before allocating it. Add corresponding test case. Change-Id: I563764af1d28043e909234ebb048239125ce6ecd Related: OS#2757
* gsm0808_create_cipher_reject: Fix encoding of Cause IEHarald Welte2017-12-171-1/+2
| | | | | | | | | 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
* logging vty: describe 'logging set-log-mask' command, add OSMO_STRINGIFY_VAL()Neels Hofmeyr2017-12-121-2/+11
| | | | Change-Id: I73ac5873ede858da44e1486d8a5c81da1ed5b19f
* Add functions for extended RACH codingMax2017-12-113-17/+66
| | | | | | | | | | | Add support for extended RACH (11 bit) according 3GPP TS 45.003 §5.3.2: * convolutional code with puncturing * encoding/decoding routines * corresponding tests Change-Id: I85a34a82d5cd39a594ee89d91a2338226066ab5d Related: OS#1548
* Fix malformed Abis/RSL messages with extra L3 Information fieldPau Espin Pedrol2017-12-102-8/+1
| | | | | | | | | | | | | | | | | Some Abis/RSL messages such as "Release Indication" contained 3 extra bytes from an L3 Information header which should not be there according to specs in GSM 08.58 (section 8.3 "Radio link layer management messages"). Other RSL messages were affected by the same issue, except for "Establish Indication", which had already a workaround in send_rslms_dlsap. This commit fixes the issue in a generic way, removes the "Establish Indication" and fixes the test accounting for the bug, as it otherwise fails after applying the changes. Fixes: OS#1635, OS#2336 Change-Id: Ibb116214e8b1798d65a8b0917150496a3c14f344
* Fix LAPD UA msgb memory leak.Jean-Francois Dionne2017-12-101-0/+3
| | | | Change-Id: Ia4f0606810e00aa6f1779d11893e4acc01976f9a
* cosmetic: Fix trailing whitespacePau Espin Pedrol2017-12-102-8/+8
| | | | Change-Id: I0c7a414789f8ce6516369327430f71164e2cbd94
* vty: set name for VIEW+ENABLE nodes, for VTY referenceNeels Hofmeyr2017-12-101-0/+4
| | | | | | This leaves no unnamed chapters in future VTY reference documents. Change-Id: Iefb8b78094208a1a4c5d70bd6c69a3deca8da54f
* VTY reference: use node names as section namesNeels Hofmeyr2017-12-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 'show online-help' output, add the node names (currently all derived from the prompt) as <node><name> entry, so that in the osmo-gsm-manuals, each section of node commands gets a title. So far, each section of commands has no name at all, and it is entirely up for guessing which part of the VTY the commands are about. Node section names, e.g. for OsmoHLR, will be like 1 VTY reference 1.4 config 1.5 config-log 1.6 config-line 1.7 config-ctrl 1.8 config-hlr 1.9 config-hlr-gsup Before this patch, all but '1 VTY reference' were plain empty. A better solution would be to list the actual command name that enters the node, and to nest the commands identically to VTY node nesting, but since this information is currently hidden in node command implementations, it is impossible to derive it. So we should actually make the VTY reflect the node nesting structure in its data model, which would resolve both the accurate node name problem as well as produce well-structured output to generate the VTY references from. This patch is a workaround for lack of a more profound fix of the VTY data model. At least it makes the VTY references' sections even remotely useful. Change-Id: Iaf745b2ab3d9b02fc47025a0eba3beb711068bfe
* VTY reference: do not list empty nodesNeels Hofmeyr2017-12-101-0/+2
| | | | | | | In 'show online-help' output, don't list nodes that have no commands (the 'Password' node). Change-Id: I3bd6883a87b8b893e560ceadfffbf41bc380109c
* vty XML export: avoid repeating common node commands for each nodeNeels Hofmeyr2017-12-101-0/+45
| | | | | | | | | | | We use 'show online-help' to generate VTY reference manuals. It is not helpful to include the common node commands on each and every node level, it clutters the actual useful help. Have a separate first section called 'Common Commands', but omit them elsewhere. Change-Id: Ie802eccad80887968b10269ff9c0e9797268e0d4
* vty: show asciidoc counters: don't create an empty table for osmo_countersAlexander Couzens2017-12-051-0/+7
| | | | | | When creating asciidocs for osmo_counter an empty is not useful. If there aren't any counter, output a hidden comment Change-Id: Ie2768100e69dcd7d8d77533688585dd9b43c4a5e
* counters: add osmo_counters_count() returns the amount of countersAlexander Couzens2017-12-051-0/+7
| | | | Change-Id: I9068231d71876e06d27ee67a688d7fb611ac3a1b
* Fix embedded buildMax2017-12-042-0/+10
| | | | | | | Do not attempt to load auth plugins - this does not make sense on embedded target anyway. Change-Id: Ie92d2eea21e19e499b3f3bb4d5a82e31fbbea3f0
* ctrl: make response easier to parseMax2017-11-271-32/+9
| | | | | | | | | | | | | | | | | | | | Previously ctrl request for all counters in group (e. g. 'rate_ctr.abs.msc.0') will result in human-readable description which is not regular enough and is hard to both parse and generate. The ctrl interface is intended for m2m, not for human interaction. Let's simplify things by making response similar to counter group request ('rate_ctr.*'). Reply now looks as follows: GET_REPLY 9084354783926137287 rate_ctr.abs.msc.0 loc_update_type:attach 0;loc_update_type:normal 0; Previously it was: GET_REPLY 9084354783926137287 rate_ctr.abs.msc.0 All counters in msc.0 loc_update_type:attach 0 loc_update_type:normal 0 Change-Id: I7a24cc307450efdcd28168fffe477320c59fcd36 Related: OS#2550
* fsm_tmr_cb: don't set T=0, the fi may no longer existNeels Hofmeyr2017-11-251-4/+5
| | | | | | | | | | | | | | | | | | | | | When calling the timer_cb, that may have effected an fi termination and deallocation, e.g. from dispatching events and/or complex choices made. Current timer_cb implementations expect T to reflect the fired timer number, so we can't actually set T=0 before calling the timer_cb. Instead, never reset T to zero, let it always reflect the timer that last fired. When a new timer starts, T will be set to its new value. Adding a T arg to the timer_cb() would have been the cleanest solution, so that fi->T can be set to zero before dispatching the timer_cb. But since we've already rolled out this FSM API, we should stay backwards compatible. In the case where the timer returned 1 to request termination, we can assume that the fi still exists, but to be consistent, don't set T = 0 in that code path either. Change-Id: I18626b55a1491098b3ed602df1b331f08d25625a
* Improve get_rate_ctr() error handlingMax2017-11-241-1/+1
| | | | | | | Report back expected interval values. Change-Id: I05ca7f716342af4f7424b28216ed6c1bf2bd589f Related: OS#2550
* ctrl: log incorrect interval valuesMax2017-11-241-4/+7
| | | | | | | | This should never happen with the current code, but if it ever does, we should log the error instead of silently returning 0. Change-Id: I544001d3072e5f12a96a67e4178f9b945c5f6b6c Related: OS#2550
* Ctrl: add rate counter group introspectionMax2017-11-241-0/+18
| | | | | | | | | | | | Before user have to know group name and index in advance to request rate counter value. Introduce introspection function which allows user to obtain all the groups and their indexes by requesting 'rate_ctr.*' variable. This simplifies KPI dumping over ctrl interface. Change-Id: Ifad8b4f0360c8bcd123a838676516476e84c246a Related: OS#2550
* osmo_strlcpy: sanitize: don't memcpy from NULL src even if len is 0Neels Hofmeyr2017-11-211-1/+2
| | | | | | | | Some callers pass NULL and len == 0. The semantics are that we then nul-terminate an emtpy string. Avoid a sanitizer warning by not calling memcpy() for the NULL case. Change-Id: I883048cf2807e606c6481634dbd569fc12aed889
* gprs_bssgp: bssgp_fc_in(): fix mem leak on queue overflowNeels Hofmeyr2017-11-201-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All successful and all error code paths of bssgp_fc_in() free the msgb, except the code path calling fc_enqueue() when the msg is dropped (due to queue being full, or failure to allocate). Callers could theoretically catch the -ENOSPC return value and discard the msgb. However, in other code paths, a callback's return value is returned, which is expected to free the msgb, so such callback would have to never return -ENOSPC when it freed the msgb. Much simpler semantics would be to free the msgb in every code path, no matter which kind of error occurred. Who is currently calling bssgp_fc_in and how do they handle the return value? - bssgp_fc_test.c ignores the return value (and hits a mem leak aka sanitizer build failure if the queue is full). - fc_timer_cb() ignores the return value. - bssgp_tx_dl_ud() returns the bssgp_fc_in() rc. - which is returned by a cascade of functions leading up to being returned, for example, by gprs_llgmm_reset(), which is usually called with ignored return code. At this point it is already fairly clear that bssgp_fc_in() should always free the msgb, since the callers don't seem to distinguish even between error or success, let alone between -ENOSPC or other errors. bssgp_fc_test: assert that no msgbs remain unfreed after the tests. Adjust expected results. Helps fix sanitizer build on debian 9. Change-Id: I00c62a104baeaad6a85883c380259c469aebf0df
* rate_ctr: fix mem leak for mangled descNeels Hofmeyr2017-11-201-9/+9
| | | | | | | | | | | | Using the NULL context creates mem leaks that bother sanitizer builds. Allocate as talloc "child" of the rate_ctr_group, so that the mangled desc (if any) gets freed when the rate_ctr group is freed. Remove the comment concerning osmo-msc: the way to fix the unexpected talloc state in osmo-msc tests is to have no invalid rate counter names in osmo-msc. See Ib1db8e3dc6c833174f1b0b1ca051b0861f477408 (osmo-msc). Change-Id: Ief9abfeb78b7706200bcc6aaa5dcb04fbeaa9b5b
* memleak: osmo_config_list_parse: getline() needs free also on errorNeels Hofmeyr2017-11-181-2/+3
| | | | | | Helps fix sanitizer build on debian 9. Change-Id: Iddf0a6cc733cd81d5f6c1eb62fc079ad319db119
* conv_acc: Our code requires SSSE3, not just SSE3Harald Welte2017-11-174-19/+19
| | | | | | | | | | | | | | | The accelerated convolutional decoder uses SSSE3 instructions such as PSIGNW (via _mm_sign_epi16) which go beyond what SSE3 offers. So let's make sure we use the right compiler flag (-mssse3) and also the right runtime check. Without this patch, we would use illegal instructions e.g. on Opteron Gen3 such as Opteron 2427, which are also used as build.opensuse.org build hosts (build31 through build36) where we wouldn't pass "make check" as a result. Change-Id: I2754164384109f2821fd98ffb48f625893f2923d Fixes: OS#2386
* gsm: Use correct include for getrandomPau Espin Pedrol2017-11-161-1/+1
| | | | | | | | | | | "man getrandom" states sys/random.h is required. Fixes warning below: warning: implicit declaration of function ‘getrandom’; did you mean ‘srandom’? [-Wimplicit-function-declaration] rc = getrandom(out, len, GRND_NONBLOCK); ^~~~~~~~~ Change-Id: I2e73fd018e887893dc5527d6d73644d627eb963a
* Fix/Update copyright notices; Add SPDX annotationHarald Welte2017-11-13128-46/+372
| | | | | | | | Let's fix some erroneous/accidential references to wrong license, update copyright information where applicable and introduce a SPDX-License-Identifier to all files. Change-Id: I39af26c6aaaf5c926966391f6565fc5936be21af
* vty: Fix bad use of vector_slot()Pau Espin Pedrol2017-11-101-1/+1
| | | | | | | | | | | | | | | | | | Commit in e9e9e427b78271941a25a63567fc2ec2bb9e4433 attempted to fix a compilation warning but introduced a regression documented in OS#2613. The commit was reverted in 4aa0258269296f078e685e21fb08b115567e814. After closer lookup and testing, it seems vector_slot(vline, index) is expected to be NULL in this case as set by vty_complete_command: /* In case of 'help \t'. */ if (isspace((int)vty->buf[vty->length - 1])) vector_set(vline, NULL); As a result, the correct fix for the compilation warning is to test against NULL instead of testing for empty string. Change-Id: Id9e02bbf89e0a94e1766b1efd236538712415c8a
* gsm0503_coding.c: Use majority vote in tch_efr_unreorder()Niro Mahasinghe2017-11-031-3/+3
| | | | | | | | | | | | The EFR coding contains some repeated bits. In case there are transmission errors, some bits may of course get corrupted. It looks like there's an improvement can be made by taking a majority vote on those "repetition bits", i.e. if 2 out of 3 bits are the same, then use that instead of expecting to match all 3 bits. See 3GPP TS 45.003 Section 3.1.1.3 for reference. Change-Id: I2a28a4d7fb82aed4d39fe8efeea702effdba3858
* gsm0503_coding.c: Fix tch_efr_unreorder() of one bitNiro Mahasinghe2017-11-031-1/+1
| | | | | | | | | | | | There's an error in tch_efr_unreorder() function in gsm0503_coding.c that results in increased RBER. One of the indices used by repetition bit recombining in this function doesn't match 3GPP TS 45.003 section 3.1.1.3, specifically "w(k) = s(223) for k = 231 and 232". This bug resulted in RBER even under ideal conditions, with no fading or AWGN present. Change-Id: I153da7bbc1bb3e01ed31eb5a7417e90841cfcde3
* Enable GnuTLS fallbackMax2017-11-022-5/+19
| | | | | | | | | | | | | | | | On systems with GNU/Linux kernel older than 3.17 (Debian 8 "jessie" for example) the osmo_get_rand_id() would always return failure due to missing getrandom() syscall. To support such systems, let's add fallback code which uses GnuTLS library. It can be disabled explicitly via '--disable-gnutls' option at compile-time, otherwise ./configure will fail if both getrandom() and GnuTLS are not available. When building with '--enable-embedded' the fallback is disabled automatically. Related: OS#1694 Change-Id: Ic77866ce65acf524b768882c751a4f9c0635740b
* Revert "vty: Fix bad use of vector_slot()"Neels Hofmeyr2017-11-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | The patch seemed sensible, but introduces a segfault when hitting tab on the interactive VTY. Reproduction example: osmo-msc telnet 127.0.0.1 4254 OsmoMSC> enable <TAB> So we need to understand what that line of code actually intends to do. Until then, revert this to avoid the segfault. The segfault happens at: Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7bc0894 in cmd_complete_command_real (vline=0x5555558d59e0, vty=0x5555558d57b0, status=0x7fffffffe024) at ../../../../src/libosmocore/src/vty/command.c:1953 1953 if (*(char *)vector_slot(vline, index) == '\0') This reverts commit e9e9e427b78271941a25a63567fc2ec2bb9e4433. Change-Id: I3fe213bdfb96de9469aae64e67000dafee59302e
* Move additional libraries to appropriate placeMax2017-10-306-12/+12
| | | | | | | | | | | | | According to https://www.gnu.org/software/automake/manual/automake.html#Libtool-Flags the libraries supposed to be added to *_LDADD or *_LIBADD while *_LDFLAGS should contain additional libtool linking flags. Previously we used both. Let's unify this and move all the libraries into proper automake variable. While at it - also add libosmocore.la for tests to LDADD since all the tests link against it anyway. Change-Id: Ia657a66db75df831421af5df1175a992da5ba80f
* Catch repeated calls to osmo_init_logging()Harald Welte2017-10-291-0/+6
| | | | | | | | If an application calls osmo_init_logging() multiple times, let's bail out in a safe way without corrupting the state + returning an error. Change-Id: Icf337a430fb367bbca48a1b02822a2cb3b644e5f
* Tag/Release version 0.10.0Harald Welte2017-10-276-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's been way too long since the last release. Almost one year and 468 commits. A brief summary of the changes below: * Doxygen for libosmo{coding,gb} * pseudotalloc for embedded builds, jenkins for arm-none-gnueabi * --disable-doxygen, --disable-ctrl, --disable-simd * update debian packaging * gsm0503 coding routines * osmo_hton[sl] * statistics.h -> counter.h * QCDIAG in gsmtap * llist_{first,last}_entry() * llist_count() * LOGPSRC() macro * msgb_pull_to_l2() * msgb_printf() * prbs * osmo_sock_init2() * osmo_sock_mcast_{name,loop_set,ttl_set,all_set,subscribe,ip}() * OSMO_STRINGIFY() * OSMO_VALUE_STRING() * OSMO_BYTES_FOR_BITS() * osmo_talloc_asprintf() * osmo_sub_auth_type_name() * osmo_sub_auth_data support for IND/SQN_MS * osmo_fsm ctrl interface * ctrl_handle_alloc2() * ctrl_interface_setup_dynip2() * OSMO_CTRL_PORT_HLR * bssgp_tx_bvc_ptp_reset() * gprs_ns_inst connect/remote_{ip,port} * osmo_gprs_{ul,dl}_block_size_{bits,bytes}() * osmo_gprs_{dl,ul}_cs_by_block_bytes() * gprs_ns_pdu_strings[] * more BSSGP cause values * abis_nm_admin_name() * AoIP support in gsm0808 * gsm_fn_as_gsmtime_str() * osmo_dump_gsmtime() * gsup charging support * ipa_ccm_make_id_resp() * ipa_ccm_make_id_resp_from_req() * struct gsm48_gprs_susp_req * gsm_04_14.h * rsl measurement preprocessing related IEs * abis_nm_event_cause_names[] * abis_nm_sw_desc and friends * more SYSINFO_TYPE_ values * osmo_earfcn_bit_size_ext() * t16lv_put() * msgb_t16lv_put() * tlvp_val16be() * tlvp_val32be() * osmo_tlvp_copy() * osmo_tlvp_merge() * many additional VTY nodes * cmd_node.name member * bitvec_set_u64() * bitvec_rl_curbit * ctrl_lookup_register() * osmo_fsm_find_by_name() * osmo_fsm_inst_find_by_name() * osmo_fsm_inst_find_by_id() Change-Id: Ieb5db2e910a90db780ea058b3280f2facbd68d76
* osmo_char2bcd(): Implment hex digits a-f and A-FHarald Welte2017-10-271-1/+8
| | | | | | | | | | | | | | osmo_bcd2char() has always supported both decimal and hex. However, osmo_char2bcd() use to only implement decimal digits. With this patch, it also suppots conversion of hex characters from ASCII to BCD. This would be relevant in cases where somebdoy would want to use 'code 11', 'code 12' or 'ST' signals in any addresses (SCCP GT e.g.) Change-Id: I7bbcc6de08024567ab64765c12d7de71df787a7a
* utils: avoid segfault when calling osmo_strlcpy(src=NULL)Neels Hofmeyr2017-10-251-1/+1
| | | | Change-Id: Ieba7ba262ace2e370a4b9a550b3131fb13f07413
* rate_ctr: Fix null pointer dereference in error pathHarald Welte2017-10-241-1/+2
| | | | | | | | | | In Change-Id Ifc6ac824f5dae9a848bb4a5d067c64a69eb40b56 we introduced a variable de-reference before we check if it's NULL. Let's reorder the statements to avoid this. Fixes: Coverity CID#178219 Change-Id: I99265a7ee76f85c479543c19ce8c05ce5d43ae69
* GPRS: constify NS printing routine parametersMax2017-10-242-3/+3
| | | | Change-Id: I549ab7c26ac1489e01f281594bafe44b0681dc83
* GPRS: add vty command to show only persistent NSMax2017-10-241-8/+23
| | | | | | | | | | | The regular 'sh ns' lists all available NS. Sometimes it's handy to know which of those are persistent. * add "show ns persistent" command * adjust parameters of dump-ns*() functions to use bool where appropriate Change-Id: Ib812864bae3ea414cc107a7b4f49bea4e6161795
* Convert lib-internal rate_ctr from '.' separator to ':' separatorHarald Welte2017-10-242-12/+12
| | | | | | | | The rate_ctr.c code would do this mangling automatically, but let's avoid using this from new versions of our code for simplicity/explicitness. Change-Id: I24a556f447cfac25efb6e83cac2d0c2972d98fe3
* rate_ctr: Enforce counter (and ctr_group) names are valid identifiersHarald Welte2017-10-241-1/+117
| | | | | | | | | | | | | | As rate counters are automatically exposed on the CTRL interface, we need to make sure they don't contain special characters such as '.' which are not permitted/supported by CTRL. In order to be able to run old versions of osmocom programs with libosmocore versions after this commit, we introduce some special name mangling: Any '.' in the names are replaced with ':' during counter group registration, if valid identifiers can be obtained this way. Change-Id: Ifc6ac824f5dae9a848bb4a5d067c64a69eb40b56
* fsm: Enforce FSM and FSM instance names are valid osmocom identifiersHarald Welte2017-10-241-1/+12
| | | | | | | | | Let's enforce that the names of FSMs and their instances are valid osmocom identifiers. This is important as the FSMs are automatically exported via those names on the CTRL inteface, and we have to make sure CTRL syntax actually permits them. Change-Id: I9ef59432f43a3cdb94e4cbb0c44ac3f9b2aac0f2
* Introduce osmo_identifier_valid() function to check validity of identifierHarald Welte2017-10-241-0/+28
| | | | | | | | | We define the notion of an 'osmocom identifier' which is basically a 7-bit US-ASCII without any special characters beyond "-_:@". We introduce a function to verify if an identifier consists only of the permitted characters. Change-Id: I96a8d345c5a69238a12d040f39b70c485a5c421c
* GPRS: check and report local address used for NSEMax2017-10-241-7/+13
| | | | | | | | | | When dumping NSE via