aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2018-04-13add gsm0808_cell_id_list_add() to combine two cell identifier listsNeels Hofmeyr5-0/+361
This will be used by the upcoming neighbor_ident API in osmo-bsc, where the vty interface allows composing neihbor BSS cell identifier lists, and we want to allow adding individual items from individual user commands. It will also be useful to accumulate cell identifiers in case a subscriber sees multiple alternative cells from a neighboring BSS, and we want to pass these on to the MSC in a Handover Required. Related: OS#2283 (inter-BSC HO, BSC side) Change-Id: I5781f5fa5339c92ab2e2620489b002829d206925
2018-04-13add osmo_cgi_name()Neels Hofmeyr3-0/+31
This will be used by cell idenitifier list code, like upcoming neighbor_ident VTY in osmo-bsc and regression tests. Change-Id: Iebc5cdf61b697b1603900993fc265af3eca0cedf
2018-04-11msgb: msgb_pull: Abort when pulling more than avail sizePau Espin Pedrol1-0/+3
Change-Id: I512ff2035ae7a929e6c96df82938cc1ddbcc4e2a
2018-04-11msgb: msgb_get: Drop unneeded tmp varPau Espin Pedrol1-2/+1
Change-Id: I27bb2ab59408c9cd1363b3b5acb2263128c55732
2018-04-10avoid warning in gsm0808_create_layer3Neels Hofmeyr1-1/+11
Change-Id: Ie098af4fc9640240196eda10fd61edcb3a872455
2018-04-10deprecate PLMN de-/coding functions incapable of 3-digit MNC with leading zerosNeels Hofmeyr2-7/+12
All our projects have seen patches to move to 3-digit MNC handling. Furthermore, since our builds no longer break from deprecation warnings, I shall no longer refrain from deprecating old API. Change-Id: I55dfaf7ce74870de44120b26c42d45bb7b184341
2018-04-09fix issue on big endian architectureThorsten Alteholz1-1/+1
OSMO_IS_LITTLE_ENDIAN is always defined and has a value of either 0 or 1 as a result in byteswap.h the corresponding swap functions will be always called, independent of the endianess Signed-off-by: Thorsten Alteholz <osmocom@alteholz.de> Change-Id: I4a09d2d8ccf155e70a3977ae1747758b6bc5125e
2018-04-09add gsm48_reject_value_namesNeels Hofmeyr3-0/+38
There seems to be quite some confusion / overlap between enum gsm48_reject_value, gsm48_gsm_cause and gsm48_gmm_cause. I tried to go with gsm48_gsm_cause_names[], but e.g. GSM48_REJECT_CONGESTION is not represented. Instead of attempting to mix/merge those enums, provide a separate value string array for enum gsm48_reject_value. This will be used by osmo-msc's libvlr (refactoring of FSM result handling), I27bf8d68737ff1f8dc6d11fb1eac3d391aab0cb1. Change-Id: I6661f139e68a498fb1bef10c266c2f064b72774a
2018-04-09add osmo_fsm_inst_update_id_f()Neels Hofmeyr4-22/+97
In the osmo-msc, I would like to set the subscr conn FSM identifier by a string format, to include the type of Complete Layer 3 that is taking place. I could each time talloc a string and free it again. This API is more convenient. From osmo_fsm_inst_update_id(), call osmo_fsm_inst_update_id_f() with "%s" (or pass NULL). Put the name updating into separate static update_name() function to clarify. Adjust the error message for erratic ID: don't say "allocate", it might be from an update. Adjust test expectation. Change-Id: I76743a7642f2449fd33350691ac8ebbf4400371d
2018-04-09cosmetic: osmo_fsm_inst_update_id(): don't log "allocate"Neels Hofmeyr2-4/+5
On erratic id in osmo_fsm_inst_update_id(), don't say "Attempting to allocate FSM instance". Escape the invalid id using osmo_quote_str(). Change-Id: I770fc460de21faa42b403f694e853e8da01c4bef
2018-04-09fsm: id: properly set name in case of NULL idNeels Hofmeyr3-19/+4
Since alloc relies on osmo_fsm_inst_update_id() to set the name, never skip that. In osmo_fsm_inst_alloc(), we allow passing a NULL id, and in osmo_fsm_inst_update_id(), we set the name without id if id is NULL. Change-Id: I6d6b09a811b82770818f19b189a57d9fc4a8133b
2018-04-09fsm_test: more thoroughly test FSM inst ids and namesNeels Hofmeyr2-7/+138
Place id and name testing in its separate section, test_id_api(). Add a test that actually allocates an FSM instance with a NULL id, which is allowed, but uncovers a bug of an unset FSM instance name. osmo_fsm_inst_name() falls back to the fsm struct's name on NULL, but osmo_fsm_inst_find_by_name() fails to match if the instance's name is NULL (and until recently even crashed). Show this in fsm_test.c with loud comments. Add test to clear the id by passing NULL. Add test for setting an empty id. Add test for setting an invalid identifier (osmo_identifier_valid() == false). Change-Id: I646ed918576ce196c395dc5f42a1507c52ace2c5
2018-04-09osmo_fsm_inst_find_by_name(): guard against strcmp(NULL)Neels Hofmeyr1-0/+5
strcmp() *must not* be passed NULL pointers, or we hit: ../../../src/libosmocore/src/fsm.c:123:8: runtime error: null pointer passed as argument 2, which is declared to never be null ASAN:DEADLYSIGNAL (Or, alternatively, a segfault.) If any of the search string or an FSM instance's name string should be NULL, simply never match. Technically, an FSM should never have a NULL name, but a current bug actually allows this (pass NULL id to alloc), which will be addressed by an upcoming patch. To test for it, we need to first make sure this here doesn't segfault. Change-Id: I2e5f82c06d1a4727bd93e955366e3b62b2df1b32
2018-04-09fsm_test: terminate the main loop instead of exit on timeoutNeels Hofmeyr2-2/+7
In fsm_test.c, we have FSM instance cleanup after the select main loop, but we exit(0) in the timer cb; hence the final code is never called. Rather clean up the instance and hence also test that, by using a global flag to exit the main loop upon timeout. Adjust expected stderr output. BTW, in a subsequent commit, I want to move the fsm instance id testing to below the main loop, to more clearly group the tested bits. Change-Id: Ia47811ffcc1bd68d2630c86be7ab98fc1f338773
2018-04-09add osmo_quote_str(),osmo_quote_str_buf() and testNeels Hofmeyr4-0/+128
Rationale: with osmo_escape_str(), you get the escaped contents of the string, but not so graceful handling of NULL strings. The caller needs to quote it, and for NULL strings not quote it. osmo_quote_str() is like osmo_escape_str() but always quotes a non-NULL string, and for a NULL string returns a literal NULL, i.e. it should (tm) give the exact C representation of a string. That's useful in testing, to show exactly what char* situation we have, without jumping through hoops like if (str) printf("\"%s\"", osmo_escape_str(str, -1)); else printf("NULL"); Copy the unit test for osmo_escape_str() and adjust. To indicate that the double quotes are returned by osmo_quote_str(), use single quotes in the test printf()s. I considered allowing to pick the quoting characters by further arguments, but that complicates things: we'd need to escape the quoting characters. Just hardcode double quotes like C. Change-Id: I6f1b3709b32c23fc52f70ad9ecc9439c62b02a12
2018-04-08fix spellingThorsten Alteholz3-3/+3
fix for some spelling issues found by lintian Signed-off-by: Thorsten Alteholz <osmocom@alteholz.de> Change-Id: I69976ecae6939d9ff51bfe4ce7374890c6563b82
2018-04-06use osmo_init_logging2() with proper talloc ctxNeels Hofmeyr14-21/+47
Ironically, when deprecating osmo_init_logging() in I216837780e9405fdaec8059c63d10699c695b360, I forgot to change the callers within libosmocore itself, i.e. in the various regression tests. Change-Id: Ia36c248f99353d5baaa2533f46a2f60a8579bdf8
2018-04-05socket.c: osmo_sock_init: Several logic fixes and log improvementsPau Espin Pedrol1-8/+16
See explanations in previous commit. Change-Id: I4889e777d8627fdfb52c97ab3ab353b6ed34aab2
2018-04-05socket.c: osmo_sock_init2: connect: Several logic fixes and log improvementsPau Espin Pedrol1-8/+17
See explanations in previous commits. Change-Id: Ib2f7577b9f498ae9d388ed1f79f6ca0ec6f09664
2018-04-05socket.c: osmo_sock_init2: bind: Several logic fixes and log improvementsPau Espin Pedrol1-7/+19
After investigating osmo-msc showing this log message and looking at the code, it's a bit difficult to find out what's going on in the code: socket.c:224 unable to bind socket: (null):0: Protocol not supported The root cause was not yet found, but probably SCTP is not enabled in the kernel of the host running it. The cod eis most probably failing during socket() and not due to bind error as the log says, so let's print an error if socket() fails. Then, if setsockopt fails, we want to still keep trying in case an extra addr was offered by addrinfo_helper. It is definetly wrong to continue if setsockopt fails, because then we are skipping the bind(), which is a fundamental part of what osmo_sock_init2 does. Then, let's print the bind error when it really happens, and re-write the extra log at the end if we reach the point at which no suitable addr is found. Change-Id: I1854422ad92dadf33ed4d849e15c0380c3bf1626
2018-04-05fix ctrl_test sanitizer issuesNeels Hofmeyr1-1/+12
Add logging to root ctx, add msgb ctx to root ctx, free wqueue to simulate the msgb being sent, and assert final talloc size. Change-Id: Ief3d5e7b6c4d781b3854e230e45a67d5281b94cd
2018-04-05cosmetic: flatten ctrl_handle_msg()Neels Hofmeyr1-17/+19
Change-Id: I3a711f5c974b7f56e27b333d390d1a706fb57007
2018-04-05ctrl: fix deferred commands (and hence fix osmo-bts-sysmo 'clock-info' cmd)Neels Hofmeyr5-5/+13
The CTRL interface has a ctrl_cmd_def_* API that allows deferring a CTRL command reply until later. However, the command handling currently fails to acknowledge this and deallocates the struct ctrl_cmd anyway. Fix: in struct ctrl_cmd, add a defer pointer to be populated by ctrl_cmd_def_make(). A cmd thus marked as deferred is not deallocated at the end of command handling. This fix needs no change in calling code. (Another idea was to return a different code than CTRL_CMD_HANDLED when the command is to be deferred, but that would require adjusting each user of ctrl_cmd_def_make(). The implicit marking is safer and easier.) Show that handling deferred commands is fixed by adjusting the expectations of ctrl_test.c's test_deferred_cmd() and removing the now obsolete exit_early label. One symptom of the breakage is that osmo-bts-sysmo crashes when asked to report a trx's clock-info, which is aggravated by the fact that the sysmobts-mgr does ask osmo-bts-sysmo for a clock-info. The crash appears since Id583b413f8b8bd16e5cf92a8a9e8663903646381 -- it looked like just fixing an obvious memory leak, which it did as shown by the unit test, but deferred ctrl commands actually relied on that leak. Both fixed now. Related: OS#3120 Change-Id: I24232be7dcf7be79f4def91ddc8b8f8005b56318
2018-04-05ctrl: test deferred cmd, show current failureNeels Hofmeyr2-0/+108
Handling a deferred command currently deallocates the struct ctrl_cmd upon exiting the initial command handling, while it should actually stay around for the asynchronous/deferred handling of the ctrl command. Show the current bug by means of a ctrl test. The test will be adjusted to expect the correct result when the bug is fixed in a subsequent commit (I24232be7dcf7be79f4def91ddc8b8f8005b56318). Change-Id: Ibbc847fc583bdd8e5e53a008258805e634ea12b4
2018-04-04gsm0480: drop messages with incorrect data lengthVadim Yanitskiy1-9/+12
If either an INVOKE, either a RETURN_RESULT component has the data with incorrect length (see Annex A, 3GPP TS 04.80), the whole message is probably incorrect. Let's drop such messages instead of silent truncation. Change-Id: I2a169b0b84aa26ea2521edd55ff005c27ae6d808
2018-04-04gsm0480: copy the raw USSD data, its DCS and lengthVadim Yanitskiy3-10/+32
As it was already documented before, the 'ss_request' struct has a rudiment of deprecated 'ussd_request' struct - the 'ussd_text' field. It represents the data either of an INVOKE component, either of a RETURN_RESULT component, encoded as ASCII in case if DCS is 0x0f (i.e. decoded by the code itself), otherwise raw bytes 'as is'. Previously, there was no possibility to distinguish between ASCII and raw bytes with different DCS. Moreover, the payload decoding is not desired in some cases. Let's introduce the new fields, which will carry the raw unmodified payload, its length and DCS (Data Coding Scheme). Change-Id: Ia193d175021e145bb3b131290231f307dbefc64a
2018-04-04gsm0480: document the 'ss_request' structureVadim Yanitskiy1-0/+31
Change-Id: I22144dd759e0c1bb1965574b7ddd676606e5d6b7
2018-03-29gsm0808: Add value strings for BSSMAP cause codesPhilipp Maier3-0/+75
libosmocore has no value strings for BSSMAP cause codes yet. - Add value strings for BSSMAP cause codes and a function to retrieve them Change-Id: I313dd8d7b06374e1e35ddc18b7a42562d9e25d45 Related: OS#1609
2018-03-28fix logging talloc ctx: add osmo_init_logging2()Neels Hofmeyr2-2/+11
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
2018-03-28vty/command.c: write_config_file(): sanely compose temp pathNeels Hofmeyr1-1/+11
Fix GCC version 7.3.0 (Debian 7.3.0-12) compiler warning: ../../../../src/libosmocore/src/vty/command.c: In function ‘write_config_file’: ../../../../src/libosmocore/src/vty/command.c:2741:2: error: null destination pointer [-Werror=format-overflow=] sprintf(config_file_tmp, "%s.XXXXXX", config_file); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Check agains NULL after each _talloc_zero() in write_config_file(). While at it, add a comment explaining why we don't use talloc_asprintf() instead. Change-Id: I7bdc52afe724c1d21f419fe49a6e2ebca9420969
2018-03-27VTY: Don't welcome the user to the "control" interface, if it's VTYHarald Welte1-1/+1
This is quite confusing, I'm surprised that it has not been flagged before... Change-Id: I3dc07290579949891e481675d493e5a2ea6d0aed
2018-03-26contrib/fsm-to-dot: warn about identically named FSMsNeels Hofmeyr1-2/+19
FSMs with identical names confuse the script, so at least warn about them. IMHO we should also have different names for each FSM, so not bothering to make the script safe against identical naming. Change-Id: I4fe7e85d2fdf23e2ba964f3b47be1954edc63cef
2018-03-26contrib/fsm-to-dot: mark illegal states in redNeels Hofmeyr1-5/+29
If an FSM transitions to a state that actually belongs to a different FSM, print an error and mark it red, instead of exiting with exception. Change-Id: I73d95a0c65ca1ea586ad55234610671a53d6220f
2018-03-26contrib/fsm-to-dot: less false positives on event parsingNeels Hofmeyr1-8/+29
Do some more mad hacking to only detect event triggers if event names actually appear in if() or case: statements. Also combine events in consecutive 'case' statements. When will this madness stop? Change-Id: Iabaaab57f0d1687607eaaa4e09c7c2439fbd7a25
2018-03-26contrib/fsm-to-dot: mark arrows that feed eventsNeels Hofmeyr1-7/+12
Most arrows draw state transitions, but some want to show that an event is delivered to a state. Mark those with a "halfopen" arrow head. Change-Id: Ib07380894a6d513896c9135f175ecbf653a23eec
2018-03-26contrib/fsm-to-dot: add default edge label '-'Neels Hofmeyr1-1/+4
When some edges have no label, it is sometimes hard to interpret which label belongs to which edge. Adding a '-' default label clarifies the edge labeling. Change-Id: I3a10b615288107e8fc12ffdbbe0099cf51abe94f
2018-03-26contrib/fsm-to-dot: warn and draw unallowed state transitionsNeels Hofmeyr1-1/+12
Hacked as it is, fsm-to-dot is capable of detecting action functions transitioning to states that are not allowed according to the FSM definition struct. Draw those in red and output a warning. Found these osmo-bsc gscon errors with this patch: ERROR: gscon_fsm_active() triggers a transition to ST_WAIT_HO_COMPL, but this is not allowed by the FSM definition ERROR: gscon_fsm_wait_ho_compl() triggers a transition to ST_WAIT_MDCX_BTS_HO, but this is not allowed by the FSM definition Related: OS#3109 Change-Id: Ic6319a958b3c7247510c1930bac8b02b95f9dcf2
2018-03-26contrib/fsm-to-dot: don't match on event names in commentsNeels Hofmeyr1-0/+4
Strip comments from function bodies before matching on event names. In osmo-bsc's gscon FSM, there often are event names in comments. The naive parsing of fsm-to-dot.py mistakes these as events causing state transitions, but the comments are just explaining how states interact. Makes me reconsider parsing the C with clang instead, but I got away with a dirty hack once more. Change-Id: I56d70ae14d363f7ca655dced16d93d795b3f940d
2018-03-26contrib/fsm-to-dot: allow transition from and to the same stateNeels Hofmeyr1-3/+5
In osmo-bsc's new gscon FSM, there is an osmo_fsm_inst_state_chg() from ST_ACTIVE to ST_ACTIVE. Avoid an exception triggering on this simple fact. Change-Id: I420c7be84e3af555cc5e8bddbff7261013348375
2018-03-26contrib/fsm-to-dot: add -h option to print basic instructionsNeels Hofmeyr1-0/+4
Change-Id: I196033e44d50ebb73cf9b44cbdc94a2b8b4f98ce
2018-03-24cosmetic: gsm0808_test: drop extraneous assertionNeels Hofmeyr1-1/+0
Recent commit I77cd4b9142510c6914298b720d9c19ab68f9ebef left an obsolete assertion around. It is already done in the if-body now. Change-Id: I1bb2ea363e8a9d86b24338df3584abc93ebc6dd4
2018-03-23fix gsm0808_enc_cell_id_list2 for leading-zero MNCNeels Hofmeyr2-6/+3
Use non-deprecated API to decode encode in gsm0808_enc_cell_id_list2(). Adjust gsm0808_test.c to now expect the correct results instead of previous failure. Change-Id: I1ce78883995e0d484368046b69db5afb2b4adc97
2018-03-23show failure in gsm0808_enc_cell_id_list2() in gsm0808_testNeels Hofmeyr1-4/+8
Change-Id: I763b18d2922701ad97382269747ff0cbb7bd657b
2018-03-23gsm0808_test: cosmetic: test non-hex MCCNeels Hofmeyr1-6/+6
The test currently sets the MCC by a hex value, which is a weird choice. The MCC gets BCD'd and hence we will see the decimal values 1:1 in the encoded octets as hex digits. Using hex as input obscures that: Right now it sets mcc = 0x123, which is actually 291 in decimal, and we hence see "92 .1" in the expected BCD result. Using 0x124 in the test source actually makes it hard to see where the 0x123 went. Change the MCC to decimal notation (123, 124, 125) and adjust the expected encoded output. Change-Id: I973835c54a90fefe50d2b3581324d12556715f58
2018-03-23gsm0808_test: cosmetic: re-arrange struct init; print hexdump on failureNeels Hofmeyr1-24/+32
I am going to ehance the test to actually include leading-zero MNC, but first I would like to simplify how the test source struct is initialized, before I edit around in it. Also, when the memcmp() fails, print hexdumps of expected and actual result for comparison. I needed it to figure out a test failure, might as well keep it. Change-Id: I77cd4b9142510c6914298b720d9c19ab68f9ebef
2018-03-23gsm_08_08: correct speech codec defaultsPhilipp Maier3-13/+13
The speech codec defaults are not correct. The defaults recommended in 3GPP TS 28.062, Table 7.11.3.1.3-2 are limited by 3GPP TS 48.008, Section 3.2.2.103. Some defaults are actually reserved for future use. Also the endianess of the 16 bit values is reversed. - correct values so that they match the specification - transmit bytes in the correct endianess Change-Id: I6c3a34d39a375d71c4128fd38f06629e8b98b100
2018-03-19fsm: Update the name as well if the id is updated and accept NULLDaniel Willmann2-14/+26
If the name stays the same the log messages will still log with the old id. Since we can now change the id we need to update the name as well. NULL as id was allowed before so we should allow that as well. Change-Id: I6b01eb10b8a05fee3e4a5cdefdcf3ce9f79545b4
2018-03-17abis_nm: Introduce abis_nm_dump_foh()Harald Welte3-9/+15
This is a more modern way of printing the Abis OML Formatted Object Header, without assuming that it would be used in a log statement or prescribing the log level to be used. Change-Id: I9b2c2afec28882b817d104d5b062651ade7aadd8
2018-03-16add a regression test for TLV parsing with repeated IEsStefan Sperling2-2/+33
Since commit bf383a1d83661af26ccd6521c49b655fb22531d4 tlv_parse() will return the first occurrence of a repeated IE. Add a test to verify this behaviour. This test passes with the current code and fails if bf383a1d83661af26ccd6521c49b655fb22531d4 is reverted. While here, fix lies in documentation about the return value of tlv_parse() and fix a typo in another comment. Change-Id: I041f38548c5e4236920991d6c681c1c1e04de9ca Related: OS#2904
2018-03-16add a test for CELL_IDENT_WHOLE_GLOBAL cell identifier listsStefan Sperling1-0/+61
Add a regression test which encodes and decodes a cell identifier list of type CELL_IDENT_WHOLE_GLOBAL. Change-Id: Ie633d9e55c6a30555c0153d35aaf9f982d6e0088 Depends: If0fafbc7171da2a3044bfa9a167208a1afa1c07b Related: OS#2847