summaryrefslogtreecommitdiffstats
path: root/include/osmocom/core
Commit message (Collapse)AuthorAgeFilesLines
* core/counter: add osmo_counter_dec()Alexander Couzens2016-08-301-0/+6
| | | | Change-Id: I030140a45afa295c3ebc4d3ccaffd437b984f515
* Mark input string to osmo_talloc_replace_string() as constHarald Welte2016-07-281-1/+1
| | | | | | | This allows us to pass in strings that are 'const', which for the source of a copy should be the normal/regular case anyway. Change-Id: Icee6a5f88babd3a4e30bf0886f0f8d3b865d80ce
* Mark input parameter to bitvec_set_bits() as 'const'Harald Welte2016-06-271-1/+1
| | | | | | | The input data is accessed in a read-only manner, so it should be marked with the const qualifier. Change-Id: I0d6b86289fa647594f3da1f1c0e0168685307a37
* fsm: Introduce default time-out handlingHarald Welte2016-06-271-1/+3
| | | | | | | | | | | If a FSM doesn't specify any timer_cb, simply terminate the FSM by default on time-out. This is a reasonable default for most cases, and avoids copy+pasting a one-line timer_cb function in every FSM. Also, even if there is a timer_cb, let it have a return value to decide if the core should terminate after return from timer_cb or not. Change-Id: I0461a9593bfb729c82b7d1d1cf9f30b1079d0212
* Add octet-aligned/unaligned shift functionsMax2016-06-201-0/+5
| | | | | | | | | The actual code is from OsmoBTS' tch.c by Harald Welte. Add unit tests, doxygen annotation and extra memory safety check. Those functions are used in several BTS implementations but seems generic enough to be generally useful. Change-Id: I2b1901c4161e8035f059585901dca593b661556d
* Add Finite State Machine abstraction codeHarald Welte2016-06-161-0/+135
| | | | | | | | | | This code is supposed to formalize some of the state machine handling in Osmocom code. Change-Id: I0b0965a912598c1f6b84042a99fea9d522642466 Reviewed-on: https://gerrit.osmocom.org/163 Tested-by: Jenkins Builder Reviewed-by: Harald Welte <laforge@gnumonks.org>
* add get_value_string_or_null() to handle unknown itemsNeels Hofmeyr2016-06-131-0/+2
| | | | | | | | | | | | | | | | | Add get_value_string_or_null() to return NULL in case the given value is not found in the list of strings, to be able to cleanly fall back to another list of strings. Absorb the lookup loop from get_value_string(). Context: in osmo-bts, I want to look up an RSL message name in rsl_msgt_names and fall back to rsl_ipac_msgt_names if not found, because the IPAC PDCH ACT and DEACT messages are sent in a standard ABIS_RSL_MDISC_DED_CHAN. In a subsequent commit, get_value_string_or_null() will be used by new rsl_or_ipac_msg_name(). Change-Id: I1fa3907e28d528d2758bc3eae9d19e6c1168f5e5 Reviewed-on: https://gerrit.osmocom.org/230 Reviewed-by: Harald Welte <laforge@gnumonks.org> Tested-by: Jenkins Builder
* Fixing build on Mac OSXBeshr Al Nahas2016-05-281-1/+1
| | | | | | | | | Fix minor syntax error Change-Id: I67f9a1e41fa5b1da3a4b10fc76138e153b767241 Reviewed-on: https://gerrit.osmocom.org/125 Tested-by: Jenkins Builder Reviewed-by: Holger Freyther <holger@freyther.de>
* Fix build for OSXArran Cudbard-Bell2016-05-201-0/+11
| | | | | | | Change-Id: I580a500edcf4812e570be586890abef746083a8c Reviewed-on: https://gerrit.osmocom.org/74 Tested-by: Jenkins Builder Reviewed-by: Holger Freyther <holger@freyther.de>
* logging: Use __BASE_FILE__ instead of __FILE__Harald Welte2016-05-122-5/+5
| | | | | | | | | | | | | | Apparently __FILE__ expands to nasty '../../..' paths when BUILDDIR != SRCDIR. This in turn leads to ugly log lines like: <0000> ../../../../osmo-bts/src/common/rsl.c:1642 (bts=0,trx=0,ts=0,ss=0) Handing RLL msg UNIT_DATA_IND from LAPDm to MEAS REP Where we certainly wouldn't want the "../../../../osmo-bts" part. Change-Id: If6d2de33c3b6bb2943954bbd81eff261dc279d58 Reviewed-on: https://gerrit.osmocom.org/38 Tested-by: Jenkins Builder Reviewed-by: Harald Welte <laforge@gnumonks.org>
* import gprs_gsup_message.[ch] from openbsc as gsup.[ch]Harald Welte2016-05-061-1/+2
| | | | | | | Move those routines from OpenBSC to libosmogsm, so they can be re-used from other programs. I think it was a mistake to add them only inside the openbsc repository in the first place. We need to pay more attention to this in the future.
* Import osmo_{encode,decode}_big_endian() from openbscHarald Welte2016-05-051-0/+4
|
* Update doxygen annotations in libosmocoreHarald Welte2016-05-059-139/+162
| | | | | This adds and improves doxygen API descriptions all over libosmocore, reducing the 'white spots' that don't have any documentation.
* Add log_fini() function to release all memory allocated by logging frameworkHarald Welte2016-05-051-0/+1
| | | | | This is e.g. quite useful to call at the end of test code, in order to show that all memory allocated actually is released before exit().
* Add ubit <-> sbit convertorsMax2016-04-121-0/+3
| | | | | Move functions for conversion between soft and unpacked bits to main library as they are generally useful.
* select: Externalize fd_set filling and dispatchHolger Hans Peter Freyther2016-03-311-0/+6
| | | | | | | | | | | | | | | | To integrate with an external event loop (in this case glib) we need to allow an application to get a filled out fd_set and then dispatch it. osmo_fds and maxfds are static and I decided to keep it that way and instead create two routines to fill the fdset and then one to dispatch the result. The public header file does not include sys/select.h and we can compile the library without select, so I didn't want to require having to include this file, and used void * for the parameter. Mark the routines as inline to avoid a call from the select function. I have confirmed that inlining has an effect on x86 using Debian's gcc-4.9.2-10 compiler
* Add new osmo_fd_get_by_fd() functionHarald Welte2016-03-191-0/+2
| | | | | | This function can be used to obtain the osmo_fd corresponding to a given fd. The latter can be useful when integrating libosmocore main loop with other libraries.
* Add function to add bits from array to bitvecMax2016-03-171-0/+3
| | | | | | | | | Add function which adds specified number of bits from each element of array to the bit vector prefixing each addition with one and finishing entire sequence with adding 0. This is very common patter for various repetitive data structures described with CSN.1 in 3GPP standards. Corresponding test vectors and doxygen headers are added too.
* log: Add conditional logging based on log_check_levelJacob Erlbeck2016-02-291-4/+20
| | | | | | | | | | | | | | Currently the LOGP/DEBUGP arguments are always evaluated even if no logging will happen at all. This can be expensive, for instance if hexdumps or pretty printed object names are generated. This causes high base load especially on embedded devices and is a major part of CPU usage e.g. of the osmo-pcu. This commit uses the log_check_level function to avoid the evaluation of the parameters if it is known in advance, that no logging entry will be generated. Sponsored-by: On-Waves ehf
* log: Add log_check_level functionJacob Erlbeck2016-02-291-0/+1
| | | | | | | | | | | | | | | | | | This commit adds this predicate function which can be used to avoid the execution of code if a certain log level is not enabled. The function will only return 0 (false), if it is sure that a logging call for the same facility and level will not produce any output. This safety criterion shall ensure, that no logging output is lost due to the use of this predicate as a guard. On the other hand, even if the predicate returns != 0 (true), no logging output might get generated by a similar logging command. Note that the current implementation is not focussed on performance, which could be improved by using a lookup table instead of iterating through every target. Sponsored-by: On-Waves ehf
* Add byte printing macrosMax2016-02-251-0/+21
| | | | | | It's sometimes handy for debugging to be able to immediately see which bits are set in a given byte. Generalize macro used for that in bitvec tests and make it available for the rest of the library.
* Add T4 bit map compression routinesMax2016-02-181-0/+42
| | | | | | | | | | | | | | | Add bit map encoder and decoder functions: decoder is fully functional while encoder is good enough for testing - no backtracking to find the best possible compression is implemented. If somebody is willing to implement MS side of EDGE than this has to be expanded. Add corresponding tests. N. B: the encoding is implemented according to ETSI TS 44.060 which is slightly different from T4 used for fax according to CCITT G31D (RFC 804). Ticket: OW#2407 Sponsored-by: On-Waves ehf Signed-off-by: Max <msuraev@sysmocom.de>
* Expand bitvec interfaceMax2016-02-181-0/+9
| | | | | Add bit filling, shifting and other functions necessary for bit compression implementation. Add corresponding tests.
* bitvec: Test and fix regression for C++->C conversionHolger Hans Peter Freyther2016-01-301-2/+2
| | | | | | | | | | | | | bitvec_read_field/bitvec_write_field in the PCU used a C++ reference and when porting to C it was decided to pass the parameter by value and this lost the "back propagation" of the new index. Change the parameter to be an in/out parameter and this way do not have a silent semantic break in the osmo-pcu (where we copy the reference in csn.1 by value) and have a true compile failure. Add Max's simple test for bitvec_unhex function leaving the checking of bitvec_read_field and the side effect in the datastructure about the number of bits still open.
* Add bitvec-related functions from Osmo-PCUMax2016-01-261-0/+9
| | | | | | Allocation, pack/unpack, field access and helper routines used extensively by Osmo-PCU. Whenever memory allocation happens, alocator context is passed explicitly by caller.
* bitvec: Fix interface to consistently use unsigned intMax2016-01-221-5/+5
| | | | | | | Use unsigned int for the length throughout the interface. We will never have a a negative length. Sponsored-by: On-Waves ehf
* comment typoNeels Hofmeyr2016-01-181-1/+1
|
* msgb: Assert len >= 0 in msgb_trimJacob Erlbeck2016-01-151-0/+2
| | | | | | | | | | | Currently msgb_trim only checks for len > data_len and returns -1 in that case, allowing the caller to fix it somehow. Using a negative length will always lead to a corrupt msgb, but this is not being checked. This commit adds a check for len < 0 and a conditional call to MSGB_ABORT. Sponsored-by: On-Waves ehf
* bitvec: Add get/set byte sequencesJacob Erlbeck2016-01-151-0/+10
| | | | | | | | | | | | | | | The new functions bitvec_get_bytes and bitvec_set_bytes copy byte sequences from bitvecs to uint8_t arrays and vice versa. While the bytes in the bitvecs do not need to be aligned, the uint8_t arrays always are. In case the bytes in the bitvec are aligned, the implementation uses memcpy. Note that the implementation like the other existing functions assume MSB first encoding. [hfreyther: Squash the comment fix into this commit as well] Sponsored-by: On-Waves ehf
* osmo_prim_op_names should be externHarald Welte2015-12-251-1/+1
|
* Add osmo_prim_op_names[] symbol and _SAP_SS7_BASE defineHarald Welte2015-12-231-0/+3
|
* msgb: Add msgb_test_invariant functionJacob Erlbeck2015-12-211-0/+40
| | | | | | This adds a function that verifies whether a mgsb is consistent. Sponsored-by: On-Waves ehf
* msgb: Add msgb_resize_area and msgb_copyJacob Erlbeck2015-12-211-0/+3
| | | | | | | | | | | | | | | These functions originate from openbsc/src/gprs but are generic msgb helper functions. msgb_copy: This function allocates a new msgb, copies the data buffer of msg, and adjusts the pointers (incl. l1h-l4h) accordingly. msgb_resize_area: This resizes a sub area of the msgb data and adjusts the pointers (incl. l1h-l4h) accordingly. Sponsored-by: On-Waves ehf
* some comments / fixed typosNeels Hofmeyr2015-12-211-0/+1
|
* stats: Add OSMO prefix to STAT_ITEM_NOVALUE_IDJacob Erlbeck2015-12-081-1/+1
| | | | | | | This symbol is globally visible and therefore should have an OSMO prefix like the other identifiers exported by stat_item.h. Sponsored-by: On-Waves ehf
* stat: Explicitly support stat_items without unitJacob Erlbeck2015-12-081-0/+1
| | | | | | | Add OSMO_STAT_ITEM_NO_UNIT for stat items without an unit. The statsd reporter uses gauges ("g") to report them. Sponsored-by: On-Waves ehf
* remove our internal copy of talloc, use system libtallocHarald Welte2015-12-052-189/+4
| | | | | | | Shipping our own private copy of talloc was a good idea in 2008, when it was not readily available on most target platforms. Today, the situation is quite different, as it is a standard library on major Linux distributions.
* stats: Move statsd related code into a separate fileJacob Erlbeck2015-11-261-4/+12
| | | | | | | | | | | This commit moves the stats specific code parts into stats_statsd.c while keeping the generic parts in stats.c. The code in stats.c no longer contains references to statsd symbols. Note that the VTY code still needs to know about every stats reporter backend. Sponsored-by: On-Waves ehf
* use system-wide libtalloc with --enable-system-tallocHarald Welte2015-11-211-0/+0
| | | | | | | | | This introduces a new configure flag by which the libosmocore-internal talloc code is not compiled, but rather a system-wide libtalloc is used. When we started openbsc/libosmocore in 2008, libtalloc was not widely present on systems yet. This has changed meanwhile, and we should simply use the system-wide library
* fix FSF address in sources/headersJaroslav Škarvada2015-11-121-1/+2
| | | | Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
* stats: Send all values on reporter updateJacob Erlbeck2015-11-091-0/+1
| | | | | | | | | | | | | | | | | | | | | Currently only counter changes and new item values are being reported. This makes it cumbersome to configure reporting clients, since there is nothing like a list of all parameters. This commit changes this behaviour such that all currently existing counters and items that would be reported eventually, are passed to the reporter when it has been reconfigured or enabled. If a counter has not been incremented, 0 is sent. If a stat item value has not been added, the last item value (or the default value if there is none) is resent again. Note that this will not catch transient counters/items that will be created later on, e.g. triggered by new peers or subscribers. To just force this kind of dump on a running reporter, it is sufficient to invoke the 'enable' command in its configuration node. Sponsored-by: On-Waves ehf
* gprs-ns/stats: When the NSVCI is updated, update the stats counterHolger Hans Peter Freyther2015-11-042-0/+11
| | | | | | | | | | | The NS object is created with an unknown identity and only after the reset procedure has progressed (completed?) we know the real ID for this peer. Before nobody has looked at the idx values (this could have been seen with the CTRL interface) but with statsd the wrong NSVCI becomes obvious. Add routines to update the idx and I don't know if the change of idx is causing any issues but we will find that out soon.
* stats: Fix build on FreeBSDHolger Hans Peter Freyther2015-08-211-0/+2
| | | | | include stdint.h for int64_t and use netinet/in.h and not netinet/ip.h for getting sockaddr_in and such.
* fix some typosNeels Hofmeyr2015-11-021-4/+4
| | | | Sponsored-by: On-Waves ehi
* log: Add new DLSTATS log levelJacob Erlbeck2015-11-021-1/+2
| | | | | | | | This log level is used by the stats subsystem log reporter to report statistics to level INFO. Note that the default level of DLSTATS is NOTICE. Sponsored-by: On-Waves ehf
* stats: Limit reporting by class idJacob Erlbeck2015-11-023-0/+14
| | | | | | | | | | | | | | | This commit adds class_id fields to the rate_ctr and stat_item group descriptions. The stats reporter code is extended to only process groups whose class_id does not exceed a per reporter max_class level. If the class_id is not set, the code assumes 'global' for groups with idx == 0 and 'subscriber' otherwise. The following vty command is added to config-stats: level (global|peer|subscriber) Set the maximum group level Sponsored-by: On-Waves ehf
* stats: Add osmo_ name prefix to identifiersJacob Erlbeck2015-11-022-64/+64
| | | | | | | | | | Since the the stat_item and stats functions and data types are meant to be exported, they get an osmo_ prefix. Sponsored-by: On-Waves ehf [hfreyther: Prepended the enum values too. This was requested by Jacob]
* stats: Add log reporterJacob Erlbeck2015-10-291-0/+3
| | | | | | | This reporter passes the measurement values to the logging subsystem as DSTATS (which is currently DLGLOBAL) level INFO messages. Sponsored-by: On-Waves ehf
* stats: Use function pointers in reporter objectsJacob Erlbeck2015-10-291-0/+14
| | | | | | | | | | | | Currently case statements are used to select the right reporter functions. This makes it difficult to add new reporter types, especially if they are not going to reside in the same file. This commit introduces per reporter function pointer for open, close, send_count, and send_item. They are checked for non-NULL before being called or skipped. Sponsored-by: On-Waves ehf
* stats: Make net config optionalJacob Erlbeck2015-10-291-0/+2
| | | | | | | | To support reporters without network configuration, this commit introduces the have_net_config flag to provide corresponding error messages. Sponsored-by: On-Waves ehf