summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* CTRL: Ensure peer/connection info is always printed the same wayHarald Welte2017-12-221-6/+6
| | | | | | | | | Now that we use osmo_sock_get_name() to print connection information at disconnect, let's use the same also at accept() time. Furthermore, let's call it CTRL connection everywhere for consistency. Change-Id: I33ee7d0ed853c5b2a4ae4e8ef945f8f27753cdea
* control_if: Log the disconnect of a CTRL clientHarald Welte2017-12-221-1/+4
| | | | | | | We are logging new CTRL connections at LOGL_INFO, so we should also log disconnects for symmetry. Change-Id: Id30aa76a5a3dab32d6b4121ce6fdf56d71dfc2ba
* control_if: Close control connection socket/fd on read/write == 0Harald Welte2017-12-221-1/+9
| | | | | | | | | | | When read() or write() system calls return '0' on a stream socket, it means that the connection has been closed ("EOF"). We must accordingly close this socket and remove all related state. Before this patch, every new CTRL connection would introduce a leak of both some memory/state, as well as a file descriptor :( Change-Id: I4fb70e5f123b37dece29f156c5f430c875e7cbaf
* timer: fixup whitespace issuesHarald Welte2017-12-221-3/+3
| | | | Change-Id: Ic0c8fc407a45ff4b0d3da1d3e4fdf8885b5bca9b
* logging vty: tweak general 'logging' command docNeels Hofmeyr2017-12-201-1/+1
| | | | | | 'logging' is not only for terminals, also for stderr and other log targets. Change-Id: If1ee59c7d1073502259b7d60008206ac3d8e87a3
* jenkins: add 'make V=1' for more verbose build logsNeels Hofmeyr2017-12-201-1/+1
| | | | | | | | In the logs, it is nice to see whether e.g. sanitize or -Werror args actually made it to the gcc command line. With V=1 we see the complete command invocations that would be hidden otherwise. Change-Id: Ie89b1c39489ba80fb47716f4c747f2c85960e32e
* ctrl: separate handling of GET_REPLY, SET_REPLY and TRAPNeels Hofmeyr2017-12-201-25/+28
| | | | | | | So far, error reporting just says "Trap/Reply", more accurately report 'GET REPLY', 'SET REPLY' and 'TRAP' as appropriate. Change-Id: Ic25a251502499aeda4e2952ec4190a1fa0bebb01
* ctrl: tighten CTRL input parsingNeels Hofmeyr2017-12-204-121/+144
| | | | | | | | | | | | | | | | Validate that incoming CTRL commands... - have decimal IDs, - return error on trailing characters, - have invalid characters in variable identifiers, - send detailed error messages as reply to the requestor. Adjust ctrl_test.{c,ok}, which best show the change in behavior. Message handling causes log messages on stderr; previously, stderr was empty. Add '[ignore]' in testsuite.at so that the nonempty stderr doesn't cause test failures. Change-Id: I96a9b6b6a3a5e0b80513aa9eaa727ae8c9c7d7a1
* libosmocodec: add FR bit offset definitionsPhilipp Maier2017-12-202-0/+273
| | | | | | | | This change defines the GSM FR bit positions as described in RFC 3551, which will be used by further ECU (Error Correction Unit) implementation. Change-Id: I1d0a198af0f8dd1f690b5a81f5c9eb92c43aefed
* libosmocodec: add FR/HR/EFR frame length definitionsVadim Yanitskiy2017-12-201-0/+7
| | | | | | | | | There are some projects, such as OsmoBTS and OsmocomBB, which are dealing with raw TCH payloads, so they need to have the FR/HR/EFR frame length defined. At the moment, each project defines them itself. Let's share these definitions. Change-Id: Ib19dd1bf81712d034157f9ce061008be0000ef38
* ports: define proper VTY and CTRL ports for OsmoHNBGWNeels Hofmeyr2017-12-202-0/+3
| | | | | | | | | So far it uses 2323, a development default. Instead, assign new ports, appending to the common range of VTY and CTRL ports: 4261 and 4262. Related: https://osmocom.org/projects/cellular-infrastructure/wiki/Port_Numbers Related: I28bd7a97d24455f88fadc6724d45c3264ba2fce4 (osmo-gsm-manuals) Change-Id: Ife52a968a41cb286f640006587877971ff66c1a4
* rate_ctr: fix osmo-sgsn DoS: don't return NULL on already used indexNeels Hofmeyr2017-12-202-8/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recent patch I563764af1d28043e909234ebb048239125ce6ecd introduced returning NULL from rate_ctr_group_alloc() when the index passed already exists. Instead of returning NULL, find an unused group index and use that, adjust the error message. In stats_test.c, adjust, and also assert allocated counter group indexes everywhere. Rationale: The original patch causes osmo-sgsn to crash as soon as the second subscriber attempts to establish an MM context. Of course osmo-sgsn is wrong to a) fail to check a NULL return value and crash and b) to fail to allocate an MM context just because the rate counter group could not be allocated (it still rejects the MM context completely if rate_ctr_group_alloc() fails). Nevertheless, the price we pay for rate counter correctness is, at least in this instance, way too high: osmo-sgsn becomes completely unusable for more than one subscriber. Numerous other places exist where rate_ctr_group_alloc() is called with a constant index number; from a quick grep magic I found these possible breaking points: osmo-sgsn/src/gprs/gb_proxy.c:1431: cfg->ctrg = rate_ctr_group_alloc(tall_bsc_ctx, &global_ctrg_desc, 0); osmo-sgsn/src/gprs/gprs_sgsn.c:139: sgsn->rate_ctrs = rate_ctr_group_alloc(tall_bsc_ctx, &sgsn_ctrg_desc, 0); osmo-sgsn/src/gprs/gprs_sgsn.c:270: ctx->ctrg = rate_ctr_group_alloc(ctx, &mmctx_ctrg_desc, 0); osmo-sgsn/src/gprs/gtphub.c:888: b->counters_io = rate_ctr_group_alloc(osmo_gtphub_ctx, &gtphub_ctrg_io_desc, 0); osmo-bsc/src/libfilter/bsc_msg_acc.c:87: lst->stats = rate_ctr_group_alloc(lst, &bsc_cfg_acc_list_desc, 0); osmo-pcu/src/bts.cpp:228: m_ratectrs = rate_ctr_group_alloc(tall_pcu_ctx, &bts_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:793: tbf->m_ctrs = rate_ctr_group_alloc(tbf, &tbf_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:879: tbf->m_ul_egprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_ul_egprs_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:880: tbf->m_ul_gprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_ul_gprs_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:970: tbf->m_dl_egprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_dl_egprs_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:977: tbf->m_dl_gprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_dl_gprs_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:1475: ul_tbf->m_ctrs = rate_ctr_group_alloc(ul_tbf, &tbf_ctrg_desc, 0); osmo-pcu/src/bts.cpp:226: m_ratectrs = rate_ctr_group_alloc(tall_pcu_ctx, &bts_ctrg_desc, 1); We can fix all of these callers and then reconsider returning NULL, but IMO even into the future, rate counter group indexes are not something worth failing to provide service for. For future bugs we should keep the automatic index picking in case of index collisions. We will get an error message barfed and can fix the issue in our own time, while the application remains completely usable, and even the rate counters can still be queried (at wrong indexes, but life is tough). Related: I49aa95b610f2faec52dede2e4816da47ca1dfb14 (osmo-sgsn's segfault) Change-Id: Iba6e41b8eeaea5ff6ed862bab3f34a62ab976914
* ctrl: on parse errors, return a detailed message to senderNeels Hofmeyr2017-12-182-12/+24
| | | | | | | | | | | The recently added ctrl_cmd_parse2() returns non-NULL cmd with error messages upon parsing errors. In handle_control_read(), use ctrl_cmd_parse2() and send those back to the CTRL command sender as reply. Retain the previous "Command parser error" reply only in case ctrl_cmd_parse2() should return NULL, which shouldn't actually happen at all. Change-Id: Ie35a02555b76913bb12734a76fc40fde7ffb244d
* add ctrl_cmd_parse2() to return parsing errorsNeels Hofmeyr2017-12-182-2/+17
| | | | | | | | | | | | | | | | | | | | | If a control command fails to parse, we so far discard specific error messages and instead send just "Command parser error". In ctrl_cmd_parse() we actually compose detailed error replies, but in the end simply talloc_free() them and return NULL. A first step to report these errors to the ctrl command issuer is to not return NULL and instead return the cmd with type = CTRL_TYPE_ERROR. Add ctrl_cmd_parse2() to return such instead of NULL. To stay API compatible, provide ctrl_cmd_parse2() to return a cmd on errors. ctrl_cmd_parse() retains identical behavior but becomes just a simple wrapper around ctrl_cmd_parse2() which discards the cmd on error. No need really to deprecate ctrl_cmd_parse() yet; especially as long as compiler warnings might break jenkins builds. Change-Id: I5047c9f977d70b03eea77cbcfd2b96d43ea46880
* ctrl_test: add two more current parsing bugs to prep for fixNeels Hofmeyr2017-12-182-0/+34
| | | | Change-Id: Id11bc326be2f0bc2746a928354e416495a18baf7
* ctrl: fix mem leak when handling GET_REPLY and SET_REPLYNeels Hofmeyr2017-12-183-7/+3
| | | | | | | | | | | | In ctrl_handle_msg() (code recently propagated from handle_control_read()), talloc_free() the parsed ctrl_cmd in all code paths. In particular, a free was missing in case ctrl_cmd_handle() returns CTRL_CMD_HANDLED. CTRL_CMD_HANDLED is triggered by GET_REPLY / SET_REPLY parsing, as show by ctrl_test.c. With the memleak fixed, adjust expected test output and make a detected mem leak abort the test immediately. Change-Id: Id583b413f8b8bd16e5cf92a8a9e8663903646381
* ctrl_test: show memleak when receiving GET_REPLY and SET_REPLY commandsNeels Hofmeyr2017-12-182-2/+40
| | | | | | | The "memleak!" output shows messages that lack a talloc_free() of the parsed ctrl command buffer. The leak shall be fixed in a subsequent patch. Change-Id: I2c3e4d08b769b9cd77593362ea36a28d681cd042
* ctrl_test: expand to test message handling and detect mem leaksNeels Hofmeyr2017-12-182-57/+197
| | | | | | | Subsequent patches that tighten CTRL input validation will make the results more interesting. Change-Id: Idd4cc7d193db1a7d761f72ed33ed46eea450a78f
* ctrl: prep test: separate new ctrl_handle_msg() from handle_control_read()Neels Hofmeyr2017-12-182-17/+28
| | | | | | | | | | In order to allow unit testing the ctrl iface msgb handling, have a separate msgb entry point function from the actual fd read function. An upcoming patch will prove a memory leak in CTRL msgb handling by a unit test that needs this separation. Change-Id: Ie09e39db668b866eeb80399b82e7b04b8f5ad7c3
* ctrl_test.c: replace print_escaped() with new osmo_escape_str()Neels Hofmeyr2017-12-182-60/+28
| | | | Change-Id: I12d3828dcc925f97fde11c360f1d60f3bd8cad8b
* utils: add osmo_escape_str()Neels Hofmeyr2017-12-184-0/+167
| | | | | | | | | | | | | 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-184-3/+18
| | | | | | | | | | | | | | | 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-172-4/+18
| | | | | | | | 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-172-1/+9
| | | | | | | | 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-172-2/+3
| | | | | | | | | 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-122-2/+13
| | | | Change-Id: I73ac5873ede858da44e1486d8a5c81da1ed5b19f
* Add functions for extended RACH codingMax2017-12-119-21/+30850
| | | | | | | | | | | 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-104-16/+3
| | | | | | | | | | | | | | | | | 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
* comment: utils: more accurately describe OSMO_STRINGIFY macroNeels Hofmeyr2017-12-101-1/+3
| | | | Change-Id: I7b057c026f9df90608b7cbd12481ab9e7a41d88c
* vty reference: merge_doc.xsl: do not omit description tagNeels Hofmeyr2017-12-101-3/+1
| | | | | | | | | | vty_additions.xml files provide <description>s for <node> tags, but for unknown reasons, merge_doc.xsl explicitly omits description tags. Do not omit <description>s so that they show up in the merged document. This will take effect when next building the osmo-gsm-manuals using this file. Change-Id: I418e61705043d4df047d8038c5d61623ba64f2e0
* 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
* license: Fix the license to GPLHolger Hans Peter Freyther2017-12-094-27/+16
| | | | | | | | This was always intended to be GPL and not AGPL. "kat" did the development as part of an internship paid by me and we agreed to shared copyright. Change-Id: Ied2041ba20c5737bd967dfaa3017edf72a95b31c
* Embedded: fix sercomm testMax2017-12-051-0/+4
| | | | | | | | | | | The external sercomm_drv_[un]lock() functions are defined as stubs in case of non-embedded build only which causes linking issue with sercomm_test. Let's define the same stubs in sercomm_test unconditionally - the implementation details of the locking are irrelevant for the test anyway. Related: OS#2708 Change-Id: I3dab4f3348871b66b5d6c9fd10b2e448c61f9e73
* 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-052-0/+9
| | | | Change-Id: I9068231d71876e06d27ee67a688d7fb611ac3a1b
* embedded: fix testsMax2017-12-041-5/+5
| | | | | | | | | | | In case of embedded build some tests are failing to link properly. Fix it: * do not run fsm_test unless CTRL is enabled * do not run fr_test unless GB is enabled * do not link loggingrb_test with libosmovty Change-Id: Icedad5ba3ed311ccdb97fa3ccd3002f5fda8be68
* 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
* logging: Extend the LOGPSRC macro to put cont in it as wellHolger Hans Peter Freyther2017-12-011-2/+18
| | | | | | | | For the lua console printing I need to print several values with continuation but also specify the filename. Add a "C" for continue and forward arguments. Change-Id: I1d6dcb2567b9ed2c8767f661737b979bc3d1377e
* coding test: use OSMO_ASSERTMax2017-11-301-17/+10
| | | | Change-Id: I896d6aaae3c36b87243b7dc270267090dcb44afe
* coding test: move bit dump into functionsMax2017-11-281-123/+48
| | | | Change-Id: I65c75e56831420d3daf386ea280c13ae9cb64d1b
* coding test: enable debug outputMax2017-11-282-125/+4293
| | | | Change-Id: I1ec23ca3cf0d973c77b8c4e7e23e0e75a4f0a7a3
* coding test: cosmetic cleanupMax2017-11-282-102/+55
| | | | | | | | | * remove duplicate code: use function from libosmocore * use utility function to dump ubits * reformat for easier reading * link against libosmocore Change-Id: I8c31b0954176a2c53305936a025c92a793b6d9b6
* 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