summaryrefslogtreecommitdiffstats
path: root/include/osmocom/core
Commit message (Collapse)AuthorAgeFilesLines
* fix logging talloc ctx: add osmo_init_logging2()Neels Hofmeyr2018-03-281-1/+5
| | | | | | | | | | | | | | | Deprecate osmo_init_logging() for the benefit of adding an explicit talloc context argument to new function osmo_init_logging2(). Pass a ctx to log_init() instead of hardcoded NULL. Before now, *all* of our code uses a NULL ctx for logging, which amounts to talloc "leaks" hit by address sanitizer builds on newer gcc (e.g. gcc 7.3.0 on debian 9). This commit helps fixing "leaks" detected in e.g. osmo-bsc unit tests by a sanitize build with gcc (Debian 7.3.0-12) 7.3.0. Change-Id: I216837780e9405fdaec8059c63d10699c695b360
* timer: Introduce osmo_clock_gettime to override clock_gettimePau Espin Pedrol2018-03-011-0/+6
| | | | Change-Id: I5bebc6e01fc9d238065bc2517058f0ba85620349
* core/logging.h: Add logging category for jitter bufferPau Espin Pedrol2018-02-271-1/+2
| | | | | | Forthcoming jitter buffer code in libosmo-netif will make use of it. Change-Id: I2434f9dfa401f736bc62a2ddce920e587cd8c517
* core: Add timespec helper macros and make timer_compat.h publicPau Espin Pedrol2018-02-271-0/+44
| | | | | | | | | | | If a monotonic clock must be used, then the clock_gettime API is used which uses timespec structures. Linux systems by default don't provide helpers to calculate time using timespecs, so let's add them here. Let's also make this header public so these helpers can be used in other projects using libosmocore (expected user: libosmo-netif). Change-Id: I45fc993b9bb0a343763238bf463c8640f47b00f1
* rate_ctr: Add rate_ctr_inc2() as convenience wrapperHarald Welte2018-02-241-0/+9
| | | | | | | rate_ctr_inc2() is slightly easier to use than the old rate_ctr_inc() variant. Change-Id: Ie00706be201c32ec2981ea38b70354ed85e1aefd
* fsm: allow graceful exit on FSM terminationPhilipp Maier2018-02-191-0/+2
| | | | | | | | | | | | | | | | The function _osmo_fsm_inst_term() terminates all child FSMs befor it calls fi->fsm_cleanup(). This prevents the cleanup callback to perform last actions on the child FSMs (e.g. osmo_fsm_inst_unlink_parent()). - Since moving the cleanup callack to the beginning of the function would alter the termination behavior and possibly cause malfunction in already existing implementation that use OSMO fsm, a new optional callback that is called immediately at the beginning of the terminatopn process is added. Change-Id: I0fdda9fe994753f975a658c0f3fb3615949cc8bb Closes: OS#2915
* fsm: Add a function to change the FSM instance ID laterDaniel Willmann2018-02-151-0/+2
| | | | | | | Sometimes we want to create an FSM instance before we know its name. In that case we should be able to update the id later. Change-Id: Ic216e5b11d4440f8e106a297714f4f06c1152945
* gsmtap.h: define TETRA DMO mode channelsallesklar22018-02-141-0/+5
| | | | Change-Id: I98976c0ff16a69b2508a79259ed1aeaec51e7549
* osmo_msgbdump_{l2,l3}(): Proper typecastHarald Welte2018-02-091-2/+2
| | | | | | | | | | | | This avoids compiler warnings like /tmp/work/sysmobts_v2-poky-linux-gnueabi/osmo-pcu/0.4+gitAUTOINC+4c112dc5a6-r1.18/recipe-sysroot/usr/include/osmocom/core/msgb.h: In function 'const char* msgb_hexdump_l2(const msgb*)': error: invalid conversion from 'void*' to 'const unsigned char*' [-fpermissive] return osmo_hexdump(msgb_l2(msg), msgb_l2len(msg)); which we've been getting in osmo-pcu builds on some platforms. Change-Id: I0ec652a1a569ec1507d8411cf1ef87afabcca799
* msgb: Add msgb_hexdump_{l2,l3}() to dump l2 or l3 part of message bufferHarald Welte2018-02-091-0/+14
| | | | Change-Id: I98e85397fb541ee0fd711f2e1852f63f3bb87359
* utils: add helper wrapper for osmo_strlcpy()Max2018-02-051-0/+3
| | | | | | | | | | Add wrapper for osmo_strlcpy() which uses sizeof() to automatically determine buffer's size and use it for GSMTAP logging. This is pretty common use case for osmo_strlcpy() so it's a good idea to save some typing by using generic define. Related: OS#2864 Change-Id: I03d0d3d32a8d572ad573d03c603e14cdc27a3f7b
* fsm: add functions for unlinking and changing parentsPhilipp Maier2018-01-241-0/+4
| | | | | | | | | | | | | | At the moment it is not possible to unlink a child from from its parent, nor is it possible to assign a new parent to a child FSM. - osmo_fsm_inst_unlink_parent(): Make it possible to unlink childs from a parent. - osmo_fsm_inst_change_parent(): Make it possible to change the parent of a child. Change-Id: I6d18cbd4ada903cf3720b3ad2a89fc643085beef
* logging: allow to log only the basename of each sourceNeels Hofmeyr2018-01-191-0/+1
| | | | | | | | | | | In the C API, add another enum log_file_type value, and when set print only the basename of the source file path. Rationale: especially when not building directly in the source dir, the paths to the source files can become rather long. Usually, just the basename of the file is sufficient to identify the source line. Change-Id: If3e4d5fb2066f8bf86e59c82d1752b1a843cf58e
* logging: separate the '<000b>' subsys from filename loggingNeels Hofmeyr2018-01-191-1/+13
| | | | | | | | | | | | | | | | | | | Add a separate flag and API to switch the category-in-hex output: log_set_print_category_hex(). Add log_set_print_filename2() to modify only the print_filename flag. The old log_set_print_filename() function still affects both flags. Explain the rationale in the comment for log_set_print_filename(). There is no need to deprecate log_set_print_filename(); it might cause compiler warnings and break strict builds unnecessarily. Add VTY command 'logging print category-hex (0|1)'. Since there is no VTY command to switch filename output, nothing needs to be adjusted there (a command will be added in a subsequent patch). Change-Id: Iba03a2b7915853c6dccaf6c393c31405320538b4
* logging: add ability to log the log-level with API and vtyNeels Hofmeyr2018-01-171-0/+4
| | | | | | | | Log the log level string after the category name, if enabled. The default behavior remains unchanged. Change-Id: Ie6be365cfa6aeabdf115bff19bac198440c9adf1
* utils: add osmo_escape_str()Neels Hofmeyr2017-12-181-0/+3
| | | | | | | | | | | | | 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
* 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
* 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
* msgb: add inline msgb_queue_free()Neels Hofmeyr2017-11-201-0/+9
| | | | | Related: Iaad35f03e3bdfabf3ba82b16e563c0a5d1f03639 (libosmo-netif) Change-Id: Ia291832ca445d4071f0ed9a01730d945ff691cf7
* Fix/Update copyright notices; Add SPDX annotationHarald Welte2017-11-133-4/+6
| | | | | | | | 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
* 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
* add osmo_talloc_asprintf() and ctrl_cmd_reply_printf()Neels Hofmeyr2017-10-241-0/+18
| | | | | | | | | | | | | | | | 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
* 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
* 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-171-1/+1
| | | | Change-Id: I6c1f47d13c5b7a9cb2281de9f017df4f1ed88ba7
* [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
* 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
* Expand bit pretty-printerMax2017-09-181-9/+11
| | | | | | | | | | Add OSMO_BIT_PRINT_EX() which is like OSMO_BIT_PRINT() but allows to specify character to be printed for set bits. It's useful to print bytes used as mask where set bit has particular semantics - for example TS mask in OsmoPCU. Change-Id: I72528bc1e376134c5a7b6e7a50c48e38c3f48b0a Related: OS#2282
* add osmo_fd_setup() convenience function to fill-in osmo_fdHarald Welte2017-08-121-0/+4
| | | | | | | | This basically follows the concept of osmo_timer_setup() and allows the caller to fill-in all configurable fields of osmo_fd in one line of code, rather than open-coding it in 5 lines everywhere. Change-Id: I6dbf19ea22fd65302bfc5424c10418d1b7939094
* Rename GSMTAP_CHANNEL_PDCH to GSMTAP_CHANNEL_PDTCHHarald Welte2017-07-291-1/+3
| | | | | | | PDCH is the physical channel, while actually we want to talk about PDTCH the logical channel. Introduce backwards compatibility define. Change-Id: Id6782d2247846e2db29fc58d98684970a66db948
* add DLMGCP logging category for libosmo-mgcpNeels Hofmeyr2017-07-181-1/+2
| | | | | | | In the course of splitting up the openbsc.git repository, we will create libosmo-mgcp and need a library logging category for that purpose. Change-Id: I09c587e2d59472cbde852d467d457254746d9e67
* socket: Add new OSMO_SOCK_F_NO_MCAST_ALL optionHarald Welte2017-07-131-0/+2
| | | | | | | Using this option at socket creation, the caller can request disabling the IP_MULTICAST_ALL socket option. Change-Id: I5ab5de45c0b64ceb3636ea98245a23defa24ffd4
* socket: Allow disabling multicast loop on socket creationHarald Welte2017-07-131-0/+2
| | | | | | | | | | | This introduces a new flag OSMO_SOCK_F_NO_MCAST_LOOP, which can be used to disable the looping back of multicast packets transmitted throug this socket to other local sockets on the machine. As this looping-back is active by default, a single option to deviate from the default is deemed sufficient. Change-Id: I24a5b1ebc3f84d2d5d4734e54df50efaea26490b
* socket.c: Add multicast related convenience functionsHarald Welte2017-07-131-0/+6
| | | | Change-Id: Id703e7a7a1e065181a4c76c088b8dcc1b7fe15a2
* select: Add new osmo_fd_close() functionHarald Welte2017-07-131-0/+1
| | | | | | | | | This is a convenience helper that will both close a fd, mark it as closed and unregister it from the event loop abstraction. In most cases, you probably actually want to use it instead of manually closing and calling osmo_fd_unregister(). Change-Id: Icd0933eed6a24edde7cdcb378e138897ecc5332c
* gsmtap: Add value_strings for GSMTAP_TYPE and GSMTAP_CHANNELHarald Welte2017-07-131-0/+3
| | | | Change-Id: Iaf8a99912f42a56ef785a1642e18238c0b67cf68
* gsmtap_util: Add chantype_gsmtap2rsl() as inverse of chantype_rsl2gsmtap()Harald Welte2017-07-131-0/+1
| | | | Change-Id: Ie1bc00670887064da0fea61c3dab036c23ceea25