summaryrefslogtreecommitdiffstats
path: root/include/osmocom
Commit message (Collapse)AuthorAgeFilesLines
* add osmo_auth_c3() (separate from gsm_milenage())Neels Hofmeyr2017-12-181-0/+2
| | | | | | | | | | | | | | | 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
* utils: add osmo_separated_identifiers_valid()Neels Hofmeyr2017-12-171-0/+1
| | | | | | | | 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
* logging vty: describe 'logging set-log-mask' command, add OSMO_STRINGIFY_VAL()Neels Hofmeyr2017-12-121-0/+2
| | | | Change-Id: I73ac5873ede858da44e1486d8a5c81da1ed5b19f
* Add functions for extended RACH codingMax2017-12-111-1/+6
| | | | | | | | | | | 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
* comment: utils: more accurately describe OSMO_STRINGIFY macroNeels Hofmeyr2017-12-101-1/+3
| | | | Change-Id: I7b057c026f9df90608b7cbd12481ab9e7a41d88c
* counters: add osmo_counters_count() returns the amount of countersAlexander Couzens2017-12-051-0/+2
| | | | Change-Id: I9068231d71876e06d27ee67a688d7fb611ac3a1b
* 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
* gsmtap.h: Introduce new GSMTAP type for LTE NAS messagesHarald Welte2017-11-231-0/+1
| | | | Change-Id: I6e1274f17e2d9d2eee16481940642216ca96e3e3
* tlv_put: guard against NULL val and 0 lenNeels Hofmeyr2017-11-201-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | For example encode_auth_info() from gsup.c calls msgb_tlv_put(msg, iei, 0, NULL) to put a tag and len with content data following later. However, this would cause a memcpy() from a NULL pointer, in tlv_put(). Allow passing NULL and len = 0 for cases like the above: If val is NULL, use memset(0) instead of memcpy(). If len is zero, do not copy nor memset anything. Hence make tlv_put() behave in a well-defined and valid way for any and all input args; no negative fallout is possible from this patch. Add proper API doc comment. Fixes a sanitizer build failure in gsup_test: ../../../../src/libosmocore/include/osmocom/gsm/tlv.h:99:2: runtime error: null pointer passed as argument 2, which is declared to never be null Helps fix sanitizer build on debian 9. Change-Id: I13dce9cd1228817890d3e81edeeb660c893c1d64
* msgb: add inline msgb_queue_free()Neels Hofmeyr2017-11-201-0/+9
| | | | | Related: Iaad35f03e3bdfabf3ba82b16e563c0a5d1f03639 (libosmo-netif) Change-Id: Ia291832ca445d4071f0ed9a01730d945ff691cf7
* ports.h: Use same VTY port number for osmo-mgw and osmo-bsc_mgcpHarald Welte2017-11-201-1/+1
| | | | | | | | It was decided that osmo-mgw as direct successor of osmo-bsc_mgcp will use the same VTY port number (similar to osmo-nitb, osmo-bsc and osmo-bsc-sccplite all using the same VTY port number) Change-Id: Iec1da9f3b4d170416279f05876d9e1ae2970c577
* Fix/Update copyright notices; Add SPDX annotationHarald Welte2017-11-136-13/+18
| | | | | | | | 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: add port number for osmo-mgwPhilipp Maier2017-11-101-0/+1
| | | | Change-Id: Ied224fe94b5152fd19e259396fbc0eaf69be4b96
* vty: deprecate now empty node commandsNeels Hofmeyr2017-11-081-2/+2
| | | | | | | | | | | Following I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b a deprecation of vty_install_default() and install_default() commands is indicated. However, compiler warnings may clutter build output or even fail strict builds, hence I am submitting the deprecation in a separate patch. Depends: I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b Change-Id: Icf5d83f641e838cebcccc635a043e94ba352abff
* GPRS: constify NS printing routine parametersMax2017-10-241-1/+1
| | | | Change-Id: I549ab7c26ac1489e01f281594bafe44b0681dc83
* rate_ctr: Enforce counter (and ctr_group) names are valid identifiersHarald Welte2017-10-241-1/+1
| | | | | | | | | | | | | | 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
* Introduce osmo_identifier_valid() function to check validity of identifierHarald Welte2017-10-241-0/+3
| | | | | | | | | 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: clarify ip/frgre union useMax2017-10-241-0/+2
| | | | | | | | | * add comment about underlying assumption that structs in ip/frgre union members in gprs_nsvc struct have the same memory layout * remove such assumption from gprs_ns_ll_str() * use gprs_ns_ll_str() for NSE dump Change-Id: Idcb912b7b3f7460fd2b058e16650c0bde8f757ee
* GPRS: unify NS state printingMax2017-10-241-0/+4
| | | | | | | | | * introduce defines with NS state names * use them for vty and tests * expand test output to print complete NS state Change-Id: I69f8d536135ae76dbca623c2f1ffba625adcb1e9 Related: SYS#3610
* add osmo_talloc_asprintf() and ctrl_cmd_reply_printf()Neels Hofmeyr2017-10-242-0/+21
| | | | | | | | | | | | | | | | Add macro to append to a CTRL commands' reply string, ctrl_cmd_reply_printf(). The talloc_asprintf() part of it is generic enough to qualify for a separate macro, osmo_talloc_asprintf(). The idea is to not have to decide for each bit added to a string whether the string is already allocated or not, but simply be able to issue printf commands and let the macro worry about initial allocation or reallocation. This originally came from osmo-hlr change I1bd62ae0d4eefde7e1517db15a2155640a1bab58, where it was requested to move this bit to libosmocore. Change-Id: Ic9dba0e4a1eb5a7dc3cee2f181b9024ed4fc7005
* gb: optionally allow nsip packets only from a specific hostPhilipp Maier2017-10-241-0/+2
| | | | | | | | | | | | | | When listening for nsip connections is enabled, then every remote host may send packets. This is useful for an SGSN that serves multiple PCUs, but contraproductive for a PCU that awaits packets from a single SGSN. Add struct members remote_ip, and remote_port to struct gprs_ns_inst, when set, then the listening end uses connect() to ensure that only the expected host may send packets. Related: OS#2401 Change-Id: Ifeb201d9006eec275a46708007ff342cdfc14e45
* Replace bitvec_set_uint() with bitvec_set_u64()Max2017-10-241-0/+2
| | | | | | | | | | | | | | | | | | | Old bitvec_set_uint() uses "unsigned int" as input parameter which length is not guaranteed. It does not allow to specify which bit_value to set and does not check for incorrect length. Overall this makes it harder to re-use and more error-prone. Let's replace it with extended implementation which uses fixed type length parameters and extra checks. The additional parameter allows caller to explicitly indicate the need to use L/H instead of 0/1 for bit vector elements. It's necessary to properly encode some of the messages from 3GPP TS 44.018, for example §10.5.2.16 IA Rest Octets. The old function is left for backward compatibility as a tiny wrapper around new function and will be deprecated in follow-up patches. Change-Id: I1b670dacb55fb3063271d045f9faa10fccba10a6 Related: OS#1526
* ctrl: allow more nodes than those in enum ctrl_node_typeNeels Hofmeyr2017-10-231-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Add ctrl_interface_setup_dynip2() to add a node_count parameter, which can be used to define more ctrl nodes without having to merge a patch to libosmocore. In consequence, also add ctrl_handle_alloc2(), since ctrl_interface_setup_dynip() uses ctrl_handle_alloc() to allocate the node slots, and add node_count param to static ctrl_init(). Passing zero as node_count indicates to use the default of _LAST_CTRL_NODE as before, i.e. to not define more ctrl nodes. Assert that we never allocate less than _LAST_CTRL_NODE slots. The current ctrl_interface_setup_dynip() and ctrl_handle_alloc() become simple wrappers that pass zero as node_count. Their use is still valid and they do not need to be deprecated. The API comment to ctrl_interface_setup_dynip2() explains how to define more node IDs. This patch was verified to work by osmo-hlr.git change I98ee6a06b3aa6a67adb868e0b63b0e04eb42eb50 which adds two node IDs for use by osmo-hlr only. Change-Id: I1bd62ae0d4eefde7e1517db15a2155640a1bab58
* abis_nm: Add abis_nm_admin_name() APIPau Espin Pedrol2017-10-231-0/+7
| | | | | | | | | Similar APIs exist for opstate and availability status. This patch does not break backward compatibility because osmo-bsc still requires direct use of the structure in get_string_value(). Change-Id: Ieace734aaff3f07606113feddde65b75202d96d6
* socket: add function osmo_sock_local_ip() to query local ipPhilipp Maier2017-10-231-0/+2
| | | | | | | | | | In some cases it is required to know the ip-address of the interface through that a given remote IP-Address can be reached. Add function osmo_sock_local_ip() to determine the local ip-address for a given remote ip-address Change-Id: I2988cc52b196fc8476703d1287e24cb4a48491c2
* add function msgb_printf() to print formatted text into msg bufPhilipp Maier2017-10-221-0/+1
| | | | | | | | | | | In ASCII string based protocols it a printf() version that prints directly to the message buffer may be useful. Add function msgb_printf(), make sure that msg buffer bounderies are not exceeded. If the end of the tail buffer is hit, return with an error code. Change-Id: I15e1af68616309555d0ed9ac5da027c9833d42e3
* api doc: fix two doxygen group closing bracesNeels Hofmeyr2017-10-172-2/+2
| | | | Change-Id: I6c1f47d13c5b7a9cb2281de9f017df4f1ed88ba7
* [doc] Properly define gsm0800 group and move all related files into itHarald Welte2017-10-172-2/+10
| | | | Change-Id: I91920c69c86d6a1932172becacb76faff2d3eb1e
* [doc] Properly define 'oap' group and add introductory textHarald Welte2017-10-171-2/+11
| | | | Change-Id: I1e875991ae1dd93862f850f85d40b3dac61ece72
* [doc] Define 'gsup' group with proper name, add intro textHarald Welte2017-10-171-2/+19
| | | | Change-Id: Ieee6213dc5aad082a2d439c7418b51f281b80b1a
* [doc] make sure all SMS related code is part of the 'sms' groupHarald Welte2017-10-174-4/+20
| | | | Change-Id: I24c56ccb56d5b39cfb887808f91b715da54c0f8b
* [doc] gea has separate group; A5 is not part of crypto but a5 groupHarald Welte2017-10-172-4/+7
| | | | Change-Id: I2fd24c86f9b52244073ec800a3287e3d38e660d9
* [doc] Provide proper name for 'auth' groupHarald Welte2017-10-171-1/+1
| | | | Change-Id: I5fb1c34475ea9db36c2ec5cddc988074a72a35f7
* [doc] TLV parser has far grown beyond GSM L3Harald Welte2017-10-161-1/+1
| | | | | | Let's hence not call the group "GSM L3 compatible TLV parser" Change-Id: Ic53f9c0d5ee787f994f42cf2aff313c6e131fbe6
* [doc] Rename "RSL" to "A-bis RSL" in documentation.Harald Welte2017-10-161-1/+1
| | | | | | | We also have "A-bis OML" and it's a bit odd to have one with prefix and the other without. Change-Id: Ida325f8a9c40b40c1aeaa4edfd1123ced7cc92b8
* [doc] Expand Doxuygen documentation for osmo_primHarald Welte2017-10-161-4/+23
| | | | | | Also, make sure prim.c is actually part of the 'prim' module. Change-Id: I4363e46a5f606eb2114a9cc1d2086007eaa58d31
* [doc] Put CRC-16 and generic CRC code in one Doxygen moduleHarald Welte2017-10-163-8/+14
| | | | | | .. and add missing API documentation bits Change-Id: I67119894bcbf8c779426a0272bae4c5ce1fbd1ed
* [doc] bits.c: Better / more Doxygen documentationHarald Welte2017-10-161-10/+12
| | | | Change-Id: If824a5c8d8ee6e3dc96a3fddeb105786c0c027c1
* [doc] Add Doxygen API documentation for stats.c and stats_statsd.cHarald Welte2017-10-161-21/+33
| | | | Change-Id: I8e49505f5c19beac90290fdba8821714e8eecd97
* [doc] counter.[ch] Add Doxygen API documentationHarald Welte2017-10-161-16/+5
| | | | | | | This adds a more complete set of API documentation for all osmo_counter relatedd functions and definitions. Change-Id: I24283c05620ee86a8beb165af98a85d754549efb
* [doc] stat_item: Complete doxygen documentation for APIHarald Welte2017-10-161-33/+13
| | | | | | | | The stat_item code base had some incomplete doxygen documentation so far. Let's complete it, and at the same time fix some cosmetic as well as copy+paste issues in the existing documentation bits. Change-Id: Ib514c137b40bf7b9791bd74be99af0b65575f2b6
* Rename 'statistics.c' to 'counter.c'Harald Welte2017-10-152-60/+62
| | | | | | | | | With stat_item, stats.c and stats_statsd.c, it is becoming a bit difficult to understand file naming. Also, the 'statistics.c' file actually only contained osmo_counter handling, so let's rename it to counter.c altogether. Change-Id: I2cfb2310543902b7da46cb15a76e2da317eaed7d
* utils: add osmo_is_hexstr(), add unit testNeels Hofmeyr2017-10-091-0/+5
| | | | | | Will be used by OsmoHLR to validate VTY and CTRL input. Change-Id: Idf75946eb0a84e145adad13fc7c78bb7a267aa0a
* auth: add OSMO_MILENAGE_IND_BITLEN_MAXNeels Hofmeyr2017-10-091-0/+1
| | | | | | Will be used by OsmoHLR to validate VTY and CTRL input. Change-Id: Ic39f3404d1a49ffd06070aa9897b36f219eacf4d
* auth: add value_strings for osmo_sub_auth_type, comment on osmo_auth_alg_name()Neels Hofmeyr2017-10-091-1/+7
| | | | | | | | | Add osmo_sub_auth_type_names[] and osmo_sub_auth_type_name(). Also add a hint to enum osmo_auth_algo's API doc that osmo_auth_alg_name() already exists (it is defined further below). Change-Id: I652a929bcd11c694d86812fb03d0a1cbd985efda
* Add function to generate random identifierMax2017-10-091-0/+5
| | | | | | | | | | | | | | | | | The function is a wrapper on top of getrandom() (if available via glibc) or corresponding syscall. If neither is available than failure is always returned. It's intended to generate small random data good enough for session identifiers and keys. To generate long-term cryptographic keys it's better to use special crypto libraries (like GnuTLS for example) instead. As an example it's used to replace old insecure random number generator in osmo-auc-gen utility. Change-Id: I0241b814ea4c4ce1458f7ad76e31d390383c2048 Related: OS#1694
* add osmo_imsi_str_valid() and osmo_msisdn_str_valid()Neels Hofmeyr2017-10-052-0/+5
| | | | | | | | | Add GSM23003_IMSI_MIN_DIGITS definition. Add regression test gsm23003_test.c to test the two new functions. Will be used by OsmoHLR to validate VTY and CTRL input. Change-Id: I1e94f5b0717b947d2a7a7d36bacdf04a75cb3522
* vty: install 'exit', 'end',... commands on *all* nodesNeels Hofmeyr2017-09-271-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In many callers of the VTY API, we are lacking the vty_install_default() step at certain node levels. This creates nodes that lack the 'exit' command, and hence the only way to exit such a node is to restart the telnet session. Historically, the VTY looked for missing commands on the immediate parent node, and hence possibly found the parent's 'exit' command when the local node was missing it. That is why we so far did not notice the missing default commands. Furthermore, some callers call install_default() instead of vty_install_default(). Only vty_install_default() also includes the 'exit' and 'end' commands. There is no reason why there are two sets of default commands. To end this confusion, to catch all missing 'exit' commands and to prevent this from re-appearing in the future, simply *always* install all default commands implicitly when calling install_node(). In cmd_init(), there are some top-level nodes that apparently do not want the default commands installed. Keep those the way they are, by changing the invocation to new install_node_bare() ({VIEW,AUTH,AUTH_ENABLE}_NODE). Make both install_default() and vty_install_default() no-ops so that users of the API may still call them without harm. Do not yet deprecate yet, which follows in Icf5d83f641e838cebcccc635a043e94ba352abff. Drop all invocations to these two functions found in libosmocore. Change-Id: I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b
* VTY: implement talloc context introspection commandVadim Yanitskiy2017-09-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change introduces a new command, which could be used to inspect the application's talloc context directly from VTY. To enable this feature, an application need to provide it's context via the 'vty_app_info' struct, and register the VTY command by calling the osmo_talloc_vty_add_cmds(). The new command is a sub-command of 'show': show talloc-context <context> <depth> [filter] Currently the following contexts may be inspected: - application - a context provided by an application; - null - all contexts, if NULL-context tracking is enabled. A report depth is defined by the next parameter, and could be: - full - full tree report, as the talloc_report_full() does; - brief - brief tree report, as the talloc_report() does; - DEPTH - user defined maximal report depth. Also, there are two optional report filters: - regexp - print only contexts, matching a regular expression; - tree - print a specific context, pointed by specified address. The command output is formatted the same way as in case of calling the talloc_report() or talloc_report_full(). Change-Id: I43fc42880b22294d83c565ae600ac65e4f38b30d
* Add time conversion helpersMax2017-09-251-0/+5
| | | | | | | Add macros to break down absolute time in seconds into days/hours/minutes passed. Change-Id: I46b9a405c18ed9da8f31b7d5b6dcece5468bafbf