path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2016-12-02logging: Extend log_target with call-back for un-formatted log lineHarald Welte1-1/+4
Some targets might not want to receive only an opaque, pre-formatted string, but rather the unformatted arguments with metadata like sub-system/level/file/line. We solve this by introducing a log_target->output_raw() function pointer. If a target specifies this function, it takes precedence over the regular log_target->output() function. Change-Id: I9dc9205d70dce9581458e7e9dc2d8a92991897bd
2016-12-01gsm0480: add gsm0480_create_ussd_notify() and *_release_complete()Neels Hofmeyr2-0/+31
Add two functions to create USSD messages. Moves and generalizes code from openbsc. Pending: use the new functions in openbsc. It looks like _release_complete() should also set trans_id and direction flag; but since this is moving code from openbsc that is apparently working, just place a fixme comment and don't change the functionality. Change-Id: Ia80e32c7105359915bfad3cc5621a1c09caf20f0
2016-12-01gsm0480: code dup: introduce and use gsm0480_l3hdr_push()Neels Hofmeyr2-13/+16
Add function gsm0480_l3hdr_push() to push a struct gsm48_hdr to the start of a msgb. Use in gsm0480.c and gsm0411_utils.c. Further callers of the new function will follow in openbsc as well as another libosmocore patch for ussd. Change-Id: I54fce6053ab8362015686fe22dbcd38bf1366700
2016-11-28timer: only call the callback if not NULLAlexander Couzens1-1/+2
Fix a crash in osmo-sgsn. Change-Id: I04d58d9580708cc0f6d0f4aa17d3e9f2c6235c8e
2016-11-26ctrl_cmd_parse: Make coverity FORWARD_NULL happyHarald Welte1-0/+1
The 'strtok_r' function requires passing a NULL as the first parameter on subsequent calls in order to ensure the code picks up where it left off on a previous call. However, Coverity doesn't quite realize this and points out that if a NULL was passed in as the third argument it would result in a possible NULL deref because the strtok_r function will assign the third argument to the first in the call is NULL. Change-Id: I7a9d08d0d4eae76a5207d285e32a25d1b384a57f Fixes: Coverity CID 135186
2016-11-26Introduce osmo_strlcpy() function so we can stop using strncpy()Harald Welte1-0/+22
I'm aware of the existing criticism on stlrcpy(), but I think it is still better than what we have now: stnrcpy(), sometimes with Coverity warnings and sometimes with a manual setting of the termination byte. The implementation follows the linux kernel strlcpy() which is claimed to be BSD compatible. We could of course link against libbsd on Linux instead, but I think it's reasonably small and simple to provide our own implementation. Future versions of libosmocore could use some autoconf magic and preprocessor macros to use the system-provided strlcpy() if it exists. Change-Id: Ifdc99b0e3b8631f1e771e58acaf9efb00a9cd493
2016-11-26osmo_gsup_encode(): Make coverity happy by invariant checkingHarald Welte1-0/+1
gsm48_encode_bcd_number() can theoretically return a length in excess of the size of the bcd_buf, but only in case an overly-long IMSI is passed into the function (which would be illegal in the first place). Change-Id: If3dc68ee13ff784b487bbc686b777cec9057d537 Fixes: Coverity CID 135216
2016-11-26telnet_interface: Handle osmo_fd_register() eror return codeHarald Welte1-1/+6
Change-Id: I5bc1c2cbb04e363d868355b5ed866b4840f16c61 Fixes: Coverity 57637
2016-11-26osmo_sock_init(): Fix memory leak in error pathHarald Welte1-0/+1
We forgot to call freeaddrinfo() in an error path. Change-Id: Iccbd3beef4c4a70dc443131b909c45e650d8c6a2 Fixes: Coverity CID 135217
2016-11-26Fix unchecked return valueof osmo_fd_register()Harald Welte1-4/+12
Change-Id: Ib040a7f94eb1bbec8270b66fd4c2aedef9d5346a Fixes: Coverity CID 57636
2016-11-16Extend IPA error loggingMax1-2/+2
Output more information in case of IPA protocol errors to make debugging easier. Change-Id: I7632d6e679e076bfbec9abc12da4a46cc27ccea1 Related: SYS#3028
2016-11-15vty: Skip printing non-initialized log categoriesDaniel Willmann1-0/+3
Without this patch the vty command show logging vty will cause a segfault if not all elements of the log_categories array are defined. Ticket: OW#3053 Sponsored-by: On-Waves ehf Change-Id: Ieeba649c3bde6c9376d8e32b00b92beb37c08ef2
2016-11-11bssgp_rx_paging(): Fix parsing of P-TMSI IE in Paging messageHarald Welte1-1/+2
This was actually discovered by the following compiler warning in gcc-6.2.0: CC gprs_bssgp_bss.lo gprs_bssgp_bss.c: In function ‘bssgp_rx_paging’: gprs_bssgp_bss.c:544:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] if (TLVP_PRESENT(&tp, BSSGP_IE_TMSI) && ^~ gprs_bssgp_bss.c:548:3: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’ *(pinfo->ptmsi) = ntohl(*(uint32_t *) ^ This is an actual bug. If we recevied a BSSGP Paging Request without P-TMSI, we might crash or report some random memory as P-TMSI to the caller in the output data structure. Change-Id: Ib4f307827cd7cccc91c1415a6fb5428d7cf8416d
2016-11-11gan: Mark gan_pdisc_vals[] as public / non-static symbolHarald Welte1-1/+1
It is actually listed in libosmogsm.map, but still used to be a static symbol. That couldn't have worked. Change-Id: I6f3f04b683d906674ee7da9bab5762bb00cea916
2016-11-11bssgp_vty: Remove dead code and compiler warningHarald Welte1-7/+0
gprs_bssgp_vty.c:48:34: warning: ‘gprs_bssgp_timer_strs’ defined but not used [-Wunused-const-variable=] static const struct value_string gprs_bssgp_timer_strs[] = { ^~~~~~~~~~~~~~~~~~~~~ Change-Id: Ia41ccb7b227c41996cdef51dc6779bfc5b5a8d48
2016-11-11statsd: Fix compiler warning (int32_t vs. int64_t)Harald Welte2-2/+3
Fixes the following compiler warning: stats_statsd.c: In function ‘osmo_stats_reporter_create_statsd’: stats_statsd.c:54:18: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types] srep->send_item = osmo_stats_reporter_statsd_send_item; Change-Id: Id36914906e0982f6ac092a311210727de66b343a
2016-11-10bitcomp: Remove the t4 decoding from libosmocoreHolger Hans Peter Freyther1-128/+0
As outlined by mail on the 13th of July the tree based approach to decoding in the PCU is faster by order of magnitude. Instead of having a slow implementation in the library and a quick one in the PCU, let's only have a quick one in the PCU and at some point in the future move it to libosmocore. Execute the plan and remove t4_decode. Change-Id: I021424444625a097560d086c217c81eac4a5ee44
2016-11-08Add logging and testing for FSM deallocationMax1-0/+1
osmo_fsm_inst_alloc() logs allocation but osmo_fsm_inst_free() is silent. Fix this by adding log message for deallocation to make FSM lifecycle tracking easier. Also make sure it's covered by test suite. Change-Id: I7e5b55a1fff8e36cf61c7fb61d3e79c1f00e29d2
2016-11-07Add null-pointer check to osmo_amr_rtp_dec()Max1-3/+3
Check that RTP payload we're about to decode is not NULL and return proper error code instead of segfaulting. Add corresponding test case. Change-Id: Ib6cda9900a41ed16bbfbde9df3de9d38e0a7469b
2016-11-01Fix typo in osmo_fsm_log_addr()Max1-1/+1
Previously function parameter was ignored, fsm_log_addr was always set to false. Change-Id: I74f06eab2dfa81dbb95e01f0b4b26448fd1b98f8
2016-10-27gsm0408: Completing GSM 04.08 RR message typesPhilipp2-0/+109
- Add missing message types to be up to date with the latest specification release (3GPP TS 04.18) - Add value strings to translate RR message type identifiers into human readable strings. (see gsm48_rr_msg_name() in gsm48.h Change-Id: I3ceb070bf4dc8f5a071a5d43c6aa2d4e84c2dec6
2016-10-27COSMETIC: moving rr_cause_name() in gsm48.cPhilipp1-5/+5
rr_cause_name() is located a far of from value_string rr_cause_names[] while other value string functions are located right below their related value string definitions. This commit moves rr_cause_name() below rr_cause_names[] as it should be Change-Id: Ie6c03a6ea02c370d8733db5ba2a709610cd70ce7
2016-10-23utils/conv_gen.py: add EDGE MCS 1-9 definitionsVadim Yanitskiy1-0/+15
Change-Id: Ie1452342f524a8b60f2babc07398a1d9c9e06aa3
2016-10-23utils/conv_gen.py: add RACH, SCH and TCH/AHS definitionsVadim Yanitskiy1-0/+10
Change-Id: I0ea7151f4e8119a8798a9e129b951559e56b0d93
2016-10-23utils/conv_gen.py: generate a single fileVadim Yanitskiy1-7/+5
Instead of generating every convolutional code into a separate file (such as conv_xcch_gen.c, conv_cs3_gen.c), it is better to have a single file, containing all definitions, because as many convolutional codes we add, as many entries we will have to add into 'src/gsm/Makefile.am'. This approach increases readability of the Makefile.am, and also makes us able to share some data between some convolutional code definitions. For example: xCCH, RACH, SCH, TCH/F, both CS2 and CS3 may use the same *_state[][2] and *_output[][2] arrays within a single file. This optimization is currently WIP. Change-Id: Ib4e4ee5fdde38429e68e3b2fa50ec03a18f59daa
2016-10-18vty/show asciidoc: counters: improve table headersAlexander Couzens1-5/+8
add [options=header] to every table header vty/show asciidoc: rename reference field into "Reference" vty/show asciidoc: capilize table header field names Change-Id: Ie991f4db77a60afb86a2a0b35c137586527f6228
2016-10-18vty/show asciidoc: add user readable description of the versionAlexander Couzens1-0/+10
Change-Id: Ie0f1b3894361c58386da9defb225979fa0ee6a18
2016-10-18stats_statsd: use int64_t instead of int for value and delta.Alexander Couzens1-3/+3
The stats infrastructure use int64_t for values and delta. So the statsd reporter get call with int64_t. Change-Id: I33df86de60007a64fa853d6d3af9b609877a8fc6
2016-10-13vty/osmo_counter: use name if description is NULLAlexander Couzens1-1/+5
`show stats` shows (null) for osmocom_counters when description is null. OpenBSC> show stats Ungrouped counters: (null): 4 Change-Id: I553b88a6fca688924b1f2b49e8cb17e90f057bb1
2016-10-12gsm/Makefile.am: use proper top_builddir/top_srcdir pathsNeels Hofmeyr1-3/+3
This fixes the conv*gen.c targets when building in a different directory than the source tree. Notably, building in a different dir worked when the generated sources were already present from a previous build inside the source directory. Change-Id: I5a9b780ad4ba607ea39854dcf7207ed05f5447bc
2016-10-12Add function to send TRAP over Control InterfaceMax1-0/+21
Change-Id: Ic0b8d88c4f5c4d42c3f8fb754f8eabf049c9e388 Related: OS#1646
2016-10-12fix USSD: SS message type mask should be 0x3f, not 0xbfNeels Hofmeyr1-1/+1
See 04.80[1], section 3.4: the highest two bits are used as counter or ignored and do not contribute to the SS "Miscellaneous message group". Previous mask of 0xbf included the highest bit, fix to 0x3f. Observed a value of 0xbb that should mean 0x3b="Register" during testing of 3G USSD requests, which seem to be the first to send a nonzero highest bit to our code. The erratic mask of 0xbf lead to an unhandled message type of 0xbb. [1] 3GPP TS 24.080 version 7.2.0 Release 7 / ETSI TS 124 080 V7.2.0 (2006-09) Change-Id: I299001a9e36c16f55622a0acd5d4a55ca49d0055
2016-09-28osmo_select_main(): drop useless call to osmo_timers_check()3G_2016_09Neels Hofmeyr1-2/+0
osmo_timers_check() does nothing more than counting the active timers. It is of no use to count them when not using the return value in any way. Change-Id: I8d35ca90a4c16d6f1c7f9793d663e5479783efed
2016-09-27msgb: add msgb_talloc_ctx_init(), deprecate msgb_set_talloc_ctx()Neels Hofmeyr1-1/+20
So far each and every main() scope creates a msgb talloc context and either passes it to msgb_set_talloc_ctx() or sets tall_msgb_ctx directly (by defining it extern first). Remove some code duplication: add one central function that creates the "msgb" talloc context for all. Most users of msgb employ a talloc_named_const(), but osmo-bts uses a talloc_pool() instead. Offer both ways by means of the pool_size argument, and for both ways make sure the context is called "msgb". Suggest that msgb users should move to this new function: deprecate msgb_set_talloc_ctx(). To be able to do so, include core/defs.h in msgb.h. There's a tradeoff between hiding the msgb talloc context behind API that tries to guess all use cases versus avoiding code dup. This patch opts against code dup and boldly assumes that all future use is covered. Also, the new function suggests to not access tall_msgb_ctx directly, which can be considered a style improvement. It seems that not all main scopes that use msgb actually initialize the msgb ctx. As a fallback for these, explicitly initialize tall_msgb_ctx to NULL. Change-Id: I747fbbf977c4d2c868c8dead64cfc5fd86eb8d4c
2016-09-23log CTRL bind address and portNeels Hofmeyr1-0/+3
Log 'CTRL at 5678' from ctrl_interface_setup*. All callers can now drop any extra 'CTRL at 5678' logging. Change-Id: If449d0514e3d0cc1b346d7452194d931aa090166
2016-09-23log telnet bind address and portNeels Hofmeyr1-1/+8
Log 'telnet at 5678' from telnet_init*. All callers can now drop any extra 'VTY at 5678' logging. Change-Id: I1da7b9076311d9458caea732fc0daace6533a3fd
2016-09-22add osmo_gettimeofday as a shim around gettimeofdayNeels Hofmeyr7-13/+72
This allows feeding a custom time for unit tests by overriding osmo_gettimeofday. Change-Id: Ic7a81a6eb51f27fe452962b91f2eae2070d87089
2016-09-19remove unused local variable in get_rate_ctr()Neels Hofmeyr1-1/+1
Unused after 22886d9e320ecf734d2827d825a191b977f70d2c "Fix retrieving rate_ctr over control interface" Change-Id: Ib5411da80c4eb4f905a5ed87c60477eca2cdff42
2016-09-19remove unused function get_rate_ctr_group()Neels Hofmeyr1-37/+0
Unused after 22886d9e320ecf734d2827d825a191b977f70d2c "Fix retrieving rate_ctr over control interface" Change-Id: I405367ef6ba5833957778a79dd398ce5ea29307e
2016-09-09libosmocodec link fix on MacOSXAnatoly Orlov1-0/+1
Fixes the following bug: CCLD libosmocodec.la Undefined symbols for architecture x86_64: "_bitvec_get_bit_pos", referenced from: _osmo_fr_check_sid in gsm610.o "_bitvec_get_uint", referenced from: _osmo_hr_check_sid in gsm620.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [libosmocodec.la] Error 1 Change-Id: Id7358b94e274b529a8da38a0b2ef8c892b6dd7a5
2016-08-29IuPS: add GMM Service Request related constants and value_strNeels Hofmeyr2-0/+12
Change-Id: Ie023fc78099932f95cc8f1b3a04fe25dfd14bc35
2016-08-29fix printf format for commit 'osmo_sock_init(): include host and port in ↵Neels Hofmeyr1-1/+1
error messages' Related: CID#143566 Change-Id: I75c542089749a0875d3d1913151fe838d7722ff2
2016-08-27osmo_sock_init(): include host and port in error messagesNeels Hofmeyr1-5/+16
For programs like osmo-hnbgw with numerous sockets, the message that some unspecified connection was refused is not very helpful. Also output the host and port where an error occured. Instead of perror, use fprintf(stderr, ..., strerror()) to be able to include a format string and print host and port as passed to osmo_sock_init(). Change-Id: I8d0343f51310699b78fcb83fd76fd93764acf3dc
2016-08-20vty: use VTY_BIND_ADDR_DEFAULT instead of ""Neels Hofmeyr1-1/+1
Change-Id: Ice0688ac9847524cb546f6d41547090b6a3cb3d8
2016-08-01fsm: Make sure we call 'onenter' of new state, not old stateHarald Welte1-0/+1
Change-Id: I1a0181c25d9debe935e86d97ddffc24675e56a5f
2016-08-01lapd_core: Fix crash in lapd_dl_flush_hist()Harald Welte1-1/+1
When lapd_dl_flush_hist() was called before we actually had started a transmit history from lapd_dl_init(), we woul segfault before this patch. Change-Id: Ifa677c9b335dd2884b4f3e44699d901957a0500b
2016-07-25egprs: Add CPS tables from TS 04.60Tom Tsou3-1/+109
Includes EGPRS coding and puncturing scheme (CPS) tables from 3GPP TS 04.60. Currently osmo-bts-trx is the only user of CPS table values, but this may change with gprsdecode and other utilities. Change-Id: I09fe6514a0e2e51bb3206f8387633f7e0255345f
2016-07-23rsl: add rsl_act_type_name()Neels Hofmeyr2-0/+14
Change-Id: Ie90c76d8aef42d5e2c9be94f4b206d4994e305f8
2016-07-23dyn TS: add definitions for dynamic TCH/F_TCH/H_PDCHNeels Hofmeyr1-0/+1
Add: * GSM_PCHAN_TCH_F_TCH_H_PDCH * NM_CHANC_OSMO_TCHFull_TCHHalf_PDCH * RSL_CHAN_OSMO_PDCH * RSL_ACT_OSMO_PDCH Related: OS#1776 Change-Id: Ib1a8b11f37af4686d00ac88beba38557aa29edc2
2016-07-17fix compiler warning: gsup.c: missing bracesNeels Hofmeyr1-1/+1
osmo_auth_vector's first member is an array, so for a zero initializer, we should add a second set of array braces. Change-Id: Iace448caca8152e46244f26c3af250f2035c99eb