aboutsummaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2016-12-21fsm: log tweak: upon free, say 'Freeing instance'Neels Hofmeyr1-1/+1
Logging 'Release' is a bit ambiguous. At first I tought a subscriber connection was being released, IMHO 'Freeing instance' better describes that we are freeing an osmo_fsm_inst. Change-Id: I5cf99707d2ba5620b2988f777fa39cc806ec0212
2016-12-21doc: fix typo for osmo_hexparseNeels Hofmeyr1-1/+1
Change-Id: Ifc2b499792fda378c807c678b8e06630cb64d273
2016-12-21utils.h: add OSMO_STRINGIFY and OSMO_VALUE_STRING macrosNeels Hofmeyr1-7/+5
OSMO_STRINGIFY particularly allows putting port numbers from a #define into VTY doc strings, like: #define FOO_PORT 2342 DEFUN(..., "Foo UDP port (default: " OSMO_STRINGIFY(FOO_PORT) ")\n") OSMO_VALUE_STRING creates value_string items with the string being exactly the enum value's name. Replaces a similar macro def in fsm.c Change-Id: I857af45ae602bb9a647ba26cf8b0d1b23403b54c
2016-12-21Catch-up with git version tagsMax6-8/+14
* update debian/changelog * update TODO-RELEASE * add comments to Makefile.am and TODO-RELEASE to simplify the process in future * add link to libtool docs to Makefile.am to simplify LIBVERSION maintenance Related: OS#1861 Change-Id: I22c257e357f597519120232d742d6a61289db021
2016-12-20fsm: term: safer iteration to remove all child FSMsNeels Hofmeyr1-4/+20
When terminating child FSMs, restart iteration after every child, to make sure that we don't terminate a child twice. Terminating one child may emit events that in turn terminates other children. I created this patch because at first it looked like the cause of a bug, which turned out not to be the case. So I have no actual use case of this situation, but it does generally make sense to me, so submitting this. Change-Id: I00990b47e42eeb43707a9a42abcd9df52fe5f483
2016-12-16fsm: explicitly log removal from parent fsmNeels Hofmeyr1-0/+3
Since removing an FSM from its parent twice causes a segfault, it is very interesting to see when that is attempted. Removing could be made more robust, but logging is interesting for investigating why an FSM is being removed twice in the first place (currently the case in openbsc's vlr_lu_fsm). Change-Id: Idec6b7aa5344f1e903c9d2aa2a3640cab0d70fb0
2016-12-15add value strings for enum osmo_fsm_term_cause and use for loggingNeels Hofmeyr1-1/+13
Change-Id: Iaf63d3cadb0d46bf454e3314ebb439240cafd834
2016-12-14typo in comment for osmo_fsm_log_addr()Neels Hofmeyr1-1/+1
Change-Id: I6f683ed0c864a87bf1232994eb2deaf9b313a244
2016-12-14fsm: log caller's source for events and state changes, not fsm.c linesNeels Hofmeyr1-17/+45
When looking at log output, it is not interesting to see that a state transition's petty details are implemented in fsm.c. Rather log the *caller's* source file and line that caused an event, state change and cascading events. To that end, introduce LOGPSRC() absorbing the guts of LOGP(), to be able to explicitly pass the source file and line information. Prepend an underscore to the function names of osmo_fsm_inst_state_chg(), osmo_fsm_inst_dispatch() and osmo_fsm_inst_term(), and add file and line arguments to them. Provide the previous names as macros that insert the caller's __BASE_FILE__ and __LINE__ constants for the new arguments. Hence no calling code needs to be changed. In fsm.c, add LOGPFSMSRC to call LOGPSRC, and add LOGPFSMLSRC, and use them in above _osmo_fsm_inst_* functions. In addition, in _osmo_fsm_inst_term(), pass the caller's source file and line on to nested event dispatches, so showing where a cascade originated from. Change-Id: Iae72aba7bbf99e19dd584ccabea5867210650dcd
2016-12-14fsm: add LOGPFSML to pass explicit logging levelNeels Hofmeyr1-9/+6
Provide one central LOGPFSML to print FSM information, take the FSM logging subsystem from the FSM instance but use an explicitly provided log level instead of the FSM's default level. Use to replace some, essentially, duplications of the LOGPFSM macro. In effect, the fsm_test's expected error changes, since the previous code dup for logging events used round braces to indicate the fi's state, while the central macro uses curly braces. Change-Id: If295fdabb3f31a0fd9490d1e0df57794c75ae547
2016-12-12fix logging: log_set_category_filter() for internal DL* logging catsNeels Hofmeyr1-1/+2
In log_set_category_filter(), passing a negative index lead to memory corruption. Particularly dangerous since the internal logging categories have negative values. Fix: apply map_subsys() to interpret negative values as internal logging categories. As a side effect, out-of-bounds logging categories will be mapped to DLGLOBAL instead of being dropped. Fix the expectations in logging_test to match the fixed bug. While at it also guard against a NULL logging target. Change-Id: Ib0725b22bc39498c6b3970a61eb3339cf56d19f1
2016-12-12fix logging: out-of-bounds check should end with user categoriesNeels Hofmeyr1-0/+5
To check category bounds, rather use num_cat_user, to redirect all semantically unknown categories to DLGLOBAL. Adjust logging_test expectations accordingly: "(d)" is now also shown. Note: subsys is and needs to be signed, while num_cat* are unsigned. Thus for a negative subsys, 'subsys >= num_cat_user' practically always yields true. Pay close attention to signedness and check upper bound only for positive values. Change-Id: I4a952b759f30d90fbfb81fedcfc56a8092ea18c1
2016-12-12fix logging: also catch first out-of-bounds logging catNeels Hofmeyr1-1/+3
In map_subsys(), fix the '>' condition to '>=' for array bounds checking. Also make the bounds checking more strict: after both invocations of subsys_lib2index(), re-check validity of the array index. If the final index is still wrong, which should never happen, exit by assertion. Change-Id: I7ca1a1d47724e40350f1c4dfebe90bad01c965f9
2016-12-12fix logging: redirection to DLGLOBAL for invalid categoriesNeels Hofmeyr1-1/+8
For out-of-bounds logging categories, redirect to the proper DLGLOBAL array index instead of returning -1. Adjust test expectation which shows that the bugs tested for are fixed. Note: there are separate bounds checking problems, left for another patch. Change-Id: I6ea9a59e005a22e0305454291714fdb9531c346b
2016-12-11gsm/oap: more robust: decode presence as clearly either 1 or 0Neels Hofmeyr1-4/+4
Prepares for the unit test, which can now simply check for encode/decode identity. Change-Id: I410ff120d868e8d55df9cb19ba6eefd99749cdf0
2016-12-11import oap message parsing / encoding from openbsc.git; AGPL->GPLHarald Welte4-1/+193
In the process, also: * Change the license from AGPLv3 to GPLv2-or-later; * correct spelling of 'sysmocom' to lowercase; * add '2016' to the copyright; * rename to osmo_*; * add API docs; * add logging category DLOAP: define id and add to internal_cat; * redirect all oap.c logging to DLOAP. A unit test will follow in a subsequent patch, since it needs a minor tweak for decoding of boolean values. The related openbsc change-id is I2f06aaa6eb54eafa860cfed8e72e41d82ff1c4cf. Tweaked-by: Neels Hofmeyr Change-Id: If5099e60681a215e798b6675f21813f26769c253
2016-12-11fix: DLGSUP logging category "unusable"0.9.5Neels Hofmeyr1-0/+5
All DL* categories are typically negative, but DLGSUP isn't, and it's also not in libosmocore's internal_cat array. See: 3b6fb0880c3ab1e23a3d7d738d073b00c2a794c2 This means that a program using DLGSUP has to include DLGSUP in its own logging cat array (typically not needed for DL* categories), which means for osmo-nitb that DLGSUP (11) replaces DMGCP (also 11), and DMGCP becomes unusable. Fix this: make DLGSUP -11 and include in internal_cat. In gsup_test.c, no longer add DLGSUP to the logging categories array. External follow-ups are otherwise needed only in osmo-hlr.git and some pending patches for openbsc (Id3938267fa062e1a997d3704cd678874306f86ee). Change-Id: Id974c7be158e4d60421a98110f5c807aefd31119
2016-12-11Fix VTY: add missing doc for 'log gsmtap [HOSTNAME]'Neels Hofmeyr1-1/+2
Add missing doc string for the HOSTNAME arg. Added in commit aa00f99be2e4cc64ede20d8c9548b83054696581, this breaks the VTY tests for openbsc and hence breaks our jenkins build jobs. Change-Id: I734b22c950242541322e902887bf779c14ba10fd
2016-12-09Implement GSMTAP log targetHarald Welte4-3/+169
This target wraps the to-be-logged string (With metadata) into a GSMTAP packet and sends it to the configured destination address. Change-Id: I9a7e72b8c9c6f6f2d76d1ea2332dcdee12394625
2016-12-09cosmetic: gsup comments: write 'Generic' for the G in GSUPNeels Hofmeyr1-1/+1
The G used to mean GPRS, but the scope is larger now. To satisfy the curious reader, give the G a name in gsup files' header comments. BTW, logging.h and gsup_test.c already mentioned "Generic" before this. Change-Id: I6ac5cf94c215e156ceff6a58da3d9e520ca942d9
2016-12-09license: gsup: libosmogsm requires GPL, not AGPL; say 'sysmocom'Neels Hofmeyr1-5/+5
The copyright in gsup.h differed from the one in gsup.c: gsup.c names the GNU Affero GPL, gsup.h only the GNU GPL. Change both to GPL-v2-or-later. In gsup.c/h's copyright notice, 'sysmocom' should be spelled lower case. Change-Id: Ia5748c275501889b9086aef7d20ccb5c9edb8031
2016-12-09wqueue: Reject messges if queue is considered fullHolger Hans Peter Freyther1-3/+8
The write queue was always meant to not queue more than the max_length messages but the implementation never rejected a message. Begin to log and enforce the queue size limit, add a testcase to verify the code and initialize except_cb as part of a fix for that new test case. Real applications might now run into the queue limit and drop messages where they just queued them before. It is unfortunate but I still think it is good to implement the routine as it was intended. We need to review osmo_wqueue_enqueue once more to see that no msgb is leaked. Change-Id: I1e6aef30f3e73d4bcf2967bc49f0783aa65395ae
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