path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2018-02-15fsm: Add a function to change the FSM instance ID laterDaniel Willmann1-6/+25
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
2018-02-15Add function to encode classmarkMax2-0/+17
The code is based on Osmocom-BB implementation. Change-Id: I78f6968edaa3ed535673411fb2a80060a472290f
2018-02-15Add generic Mobile Identity encoderMax2-14/+18
Add generic function which allows caller to set Mobile Identity explicitly. This allows to use IMEI or IMEISV for example. Make gsm48_generate_mid_from_imsi() into wrapper around new function. Change-Id: Id79be7abfff75ecd0d248bbeed93e605abeec9b3
2018-02-14talloc_ctx_vty: Fix help strings (missing \n at end of line)Harald Welte1-3/+3
This was causing build failures in applications using this library feature: Documentation error (missing docs): <command id='show talloc-context (application|all) (full|brief|DEPTH) tree ADDRESS'> <param name='ADDRESS' doc='(null)' /> Documentation error (missing docs): <command id='show talloc-context (application|all) (full|brief|DEPTH) filter REGEXP'> <param name='REGEXP' doc='(null)' /> Documentation error (missing docs): <command id='show talloc-context (application|all) (full|brief|DEPTH) tree ADDRESS'> <param name='ADDRESS' doc='(null)' /> Documentation error (missing docs): <command id='show talloc-context (application|all) (full|brief|DEPTH) filter REGEXP'> <param name='REGEXP' doc='(null)' /> Change-Id: I785c852e3313d20eade79746a7cd485d2d5908ea
2018-02-09Revert "fsm: do not terminate child FSMs early"Harald Welte1-4/+3
This reverts commit 5ec91980ac2224aa1e9bf070a0e382d0d8c2b729. More or less like I expected, it creates fall-out. osmo-msc master builds are failing, as are the open build service builds. The patch has therefor *not* been sufficiently tested. Change-Id: I8d961d7bbd91b6a8d7691f24cb67720c3d001c7e
2018-02-09fsm: do not terminate child FSMs earlyPhilipp Maier1-3/+4
The function _osmo_fsm_inst_term() terminates all child FSMs befor it calls fi->fsm_cleanup(). This prevnts the cleanup callback to perform last actions on the child FSMs (e.g. osmo_fsm_inst_unlink_parent()). move the function call to _osmo_fsm_inst_term_children() below the call to fi->fsm->cleanup(). Change-Id: Ie89d435417306c6bf897274eabc3ed0a46485c26
2018-02-09tlv_parser: Report *first* occurrence of repeated IEsHarald Welte1-2/+7
Most GSM related specifications require the receiver to use the *first* occurrence of repeated IEs. The Osmocom TLV parser so far did the opposite: It reported only the *last* occurrence in case of repeated IEs. Let's change our implementation to be more in-line with relevant specs, such as 3GPP TS 24.008 8.6.3. Change-Id: Icde09e075f68c842a7a96cf7160c8e44b77cf82d
2018-02-06vty: fix 'logging print file' outputNeels Hofmeyr1-8/+11
In If1bd79026a3c680ccf7587d545d12f7759a998fc, an erratic logging output crept in for an earlier patch state and was merged by accident; fix 'logging print file (0|1|basename)' output. Add value string to map LOG_FILENAME_* enum to VTY args, use for both command evaluation as well as printing the vty config. The default is 'logging print file 1', hence we could omit an output when '1' is chosen. But for clarity, always output the current setting. Change-Id: I1c931bff1f1723aa82bead9dfe548e4cc5b685e0
2018-02-05GSUP: change osmo_gsup_encode() return typeMax1-4/+9
* match return type of osmo_gsup_encode() with osmo_gsup_decode() to allow propagating error to caller * check return value of osmo_gsup_encode() in GSUP test * return errors instead of braking app with aseert Change-Id: Idaa1deecb6d9e15329bd51867b4f6a03357461f0 Related: OS#2864
2018-02-05utils: add helper wrapper for osmo_strlcpy()Max1-4/+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
2018-01-24SMS: Add value_string for TS 04.11 CP and RP stateHarald Welte3-0/+16
Change-Id: I1b2f6fc6f455b0ba2a5732c567a4867bca97c3b0
2018-01-24gsm48_pdisc_names: Use conscise, short namesHarald Welte1-15/+15
Some times I *really* regret ever having merged OSMO_VALUE_STRING, as it generates completely unusable and way too long strings :( Change-Id: I8de7c01f9ea1d66c384e57449c4140186f5ce6c5
2018-01-24fsm: add functions for unlinking and changing parentsPhilipp Maier1-3/+34
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
2018-01-24libosmocoding: use frame length definitions from codec.hVadim Yanitskiy1-7/+0
Since commit e094157e125a70b9a384ba3cec01261624f4eb59, TCH frame length definitions were added to libosmocodec. No need to define them again. Change-Id: Id8c6132534e36ea1e368432bb259fd4f3a531f90
2018-01-23libosmocoding: fix typo in library documentationVadim Yanitskiy1-1/+1
Change-Id: I535d4eba5bad9094a1e9e662f32cd2bfac5b0cef
2018-01-22socket: use inet_ntop() instead of inet_ntoa() in osmo_sock_local_ip()Philipp Maier1-2/+2
The function inet_ntoa() stores its result in a static buffer and returns the pointer. When inet_ntoa() is called subsequently it overwrite the content of its static buffer with the new result. Since we osmo_sock_local_ip() is a library function we should use the more safe variant inet_ntop() in order to prevent unintentionally overwriting data that the caller might still need. Such an error would be hard to find. - Use the more safe inet_ntop() inestead of inet_ntoa() Change-Id: I9852b57736432032542bd96b6fdd4a2f08fc1f64
2018-01-22socket: fix socket leak in osmo_sock_local_ip()Philipp Maier1-0/+1
The socket that is opend to probe the correct local ip-address is not closed when the test is done. - Close socket when it is not needed anymore Change-Id: I7f3562a344b58f6298d2068314be1626a96e1b1d
2018-01-19MNCC: Add MNCC to string dumperHarald Welte3-1/+420
As MNCC is rather hard to debug (wireshark cannot trace UNIX domain sockets), let's add our own decoder that we can use from related debug log statements in the respective programs. Change-Id: I216aaf70868ba5f3860a60c4b2442957531a3011
2018-01-19logging vty: add 'logging print file (0|1|basename)' cmdNeels Hofmeyr1-0/+27
Add a VTY command that allows configuring the output of source filename. So far, this was not configurable by VTY at all. Change-Id: If1bd79026a3c680ccf7587d545d12f7759a998fc
2018-01-19logging: allow to log only the basename of each sourceNeels Hofmeyr1-0/+14
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
2018-01-19logging: separate the '<000b>' subsys from filename loggingNeels Hofmeyr2-6/+61
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
2018-01-17cosmetic: logging: if color is disabled, don't print ""Neels Hofmeyr1-5/+6
If color output is disabled, skip the empty snprintf() to (not) clear the ANSI color. Also, no need to use a format string of "%s", just pass the string constant directly. That is a micro optimisation as well as clarification of the code. Change-Id: Ie7cb06de160830d2f8ee5718246c0fe311f68d49
2018-01-17fsm: fix double llist_del in osmo_fsm_inst_term()Philipp Maier1-2/+3
llist_del(&fi->proc.child) is executed always, regardless whether a parent is configured or not. This may lead into a double llist_del when the child has been previously unlinked. - check if fi->proc.parent is set, and only then execute llist_del(&fi->proc.child); Change-Id: I4b33d508c8a11b72fbf30125088a882894d9e6ac
2018-01-17fix -Werror build: logging.c: always use literal with snprintfNeels Hofmeyr1-1/+1
A recent commit added an snprintf that passes a pointer to a literal directly to snprintf. Since passing pointers to printf formats is a vulnerability in case user supplied data may be passed in the format, modern compilers warn against that, which breaks our -Werror builds. Even though this is just a pointer to a literal, it needs to be an actual literal to make compilers happy. Use printf("%s", c) instead of printf(c). Note that our current build slave's gcc does not enforce that yet, while newer compilers do. logging.c:338:4: warning: format not a string literal and no format arguments [-Wformat-security] ret = snprintf(buf + offset, rem, c_subsys); Change-Id: Ifa4eb8a9fab66dcd987986065351b4a06421f1ec
2018-01-17logging: color the log category according to levelNeels Hofmeyr1-1/+5
When log_set_use_color() is enabled, color the log category string according to the log level. The log line before and after the log category is printed in the category's configured color. ERROR and FATAL are red, NOTICE is yellow, INFO is green and DEBUG is blue. The default behavior remains unchanged; If color is enabled, the category string will now always be colored in the log level color, not the log category color, and will stand out from the rest of the line. Change-Id: I84f886ac880e9056a666bbb231ae06cbaaf65f44
2018-01-17logging: color the log levelNeels Hofmeyr1-4/+26
When log_set_use_color() is enabled, color the log level string according to the log level. The log line before and after the log level is printed in the category's color. ERROR and FATAL are red, NOTICE is yellow, INFO is green and DEBUG is blue. The default behavior remains unchanged. Change-Id: If2e52ae9ab83e538e04321c338e3fdffb2c7f9d3
2018-01-17logging: add ability to log the log-level with API and vtyNeels Hofmeyr2-0/+38
Log the log level string after the category name, if enabled. The default behavior remains unchanged. Change-Id: Ie6be365cfa6aeabdf115bff19bac198440c9adf1
2018-01-17gsm0480: parse optional IEs for RELEASE COMPLETE messageVadim Yanitskiy1-1/+5
According to GSM 04.80 section 2.5 "Release complete", a message of the mentioned type may contain optional IEs, such as Cause and Facility. Let's parse them. Change-Id: Ib8fc1f6bae472b0b264b6158f372b6cce255b222
2018-01-17gsm0480: parse all SS info elements in a messageVadim Yanitskiy1-1/+10
Some SS messages (e.g. RELEASE COMPLETE) may contai multiple IEs (Information Elements). Let's parse them all. Change-Id: I20cc59c25fdbda176bcf76437174cda829518d60
2018-01-17gsm0480: correct parse_ss_info_elements() declarationVadim Yanitskiy1-1/+1
Change-Id: I64df293188908c7eb10a61941db76656340d3a8e
2018-01-17gsm0480: refactor gsm0480_decode_ss_requestVadim Yanitskiy1-7/+14
Change-Id: Iba734db97ab516f8fce816c4e4225b97b93619f1
2018-01-17gsm0480: move SS request length check to parse_ss()Vadim Yanitskiy1-12/+11
Change-Id: I8e7ce5bd97f3a8731924264c92afb9a7183937dc
2018-01-17gsm0480: pass exact GSM 04.80 payload length to parse_ss()Vadim Yanitskiy1-4/+4
Change-Id: I9608d4ad16d7581320615c140beaac36628c31a4
2018-01-17gsm0480: add specification reference to SS message typeVadim Yanitskiy1-0/+1
Change-Id: Iff0210e995053e270939a774db33f55b22545204
2018-01-17gsm0480: handle GSM0480_OP_CODE_PROCESS_USS_DATAVadim Yanitskiy1-0/+5
Change-Id: I470290c2b544555e53cedd849b1d6a961db7b5a4
2018-01-17gsm0480: handle USS_NOTIFY and USS_REQUEST with PROCESS_USS_REQVadim Yanitskiy1-0/+2
Change-Id: If7cc6a966dfc17d37e22338ecc1f239f908a9f2e
2018-01-17gsm0480: handle GSM0480_CTYPE_RETURN_RESULTVadim Yanitskiy1-0/+82
Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
2018-01-17gsm0480: parse GSM0480_MTYPE_FACILITY separatelyVadim Yanitskiy1-1/+17
Change-Id: I6e029c436a50fa8c2823ea39c5d123ee701becfa
2018-01-17gsm0480: handle UnstructuredSS Request with DSC != 0x0FVadim Yanitskiy1-0/+20
According to GSM 04.08, 4.4.2 "ASN.1 data types": the USSD-DataCodingScheme shall indicate use of the default alphabet using the 0x0F value. Previously, the UnstructuredSS Request messages with not default alphabet were not being handled. Let's fix this. Change-Id: I73d602f6f20b0afe7600d16bbd432069ae7be788
2018-01-17gsm0480: clean up the parse_process_uss_req() codeVadim Yanitskiy1-19/+20
This change reduces the degree of code nesting... Change-Id: I467f75794c5ac9df75c001245b18bbdfcfaadd88
2018-01-17gsm0480: fix USSD OCTET STRING length confusionVadim Yanitskiy1-2/+2
According to the GSM 04.80 (version 5.0.0) specification Annex A "Expanded ASN.1 Module "SS-Protocol", the maximum size of a USSD OCTET STRING is 160 bytes. Thus according to ETSI TS 123 038 (version 10.0.0) specification "USSD packing of 7 bit characters", in 160 octets, it's possible to pack (160 * 8) / 7 = 182.8, that is 182 characters. The remaining 6 bits are set to zero. This change defines both mentioned values: - GSM0480_USSD_OCTET_STRING_LEN 160 - GSM0480_USSD_7BIT_STRING_LEN 182 keeping the old MAX_LEN_USSD_STRING 'as is' due to compatibility reasons. Now the new value is used for ss_request structure, while old one is still used for deprecated ussd_request structure. Change-Id: I6dead74f9ecea079752ff2400cdaf7c30187784e
2018-01-17gsm0480: skip length check for 'RELEASE COMPLETE' messageSergey Kostanbaev1-3/+10
According to GSM 04.80 Section 2.5 'Release complete' Table 2.5, the 'RELEASE COMPLETE' message payload is optional, so let's drop the length check in gsm0480_decode_ss_request() for this type. Change-Id: I63b7f8ce403169a9dbdbdb031db16693de2196d6
2018-01-16Log lapd_datalink state on errorsMax1-5/+5
It's not very useful to get just the raw pointer address in case of lapd_datalink receive error. Log it's state in addition. Change-Id: Ie8c5df262312f886f509113f2707e36811df3bd5
2018-01-15libosmocodec: implement ECU (Error Concealment Unit) for FRPhilipp Maier2-1/+166
When a bad GSM voice frame is received, it's being replaced by a silence frame. This may cause unpleasant audio effects. This change implements a functionality to craft a replacement frame from the last known good frame. Currently, only FR is supported, support for other codecs may be added latter. Change-Id: I06a21f60db01bfe1c2b838f93866fad1d53fdcd1
2018-01-12logging-gsmtap: send only basename of source fileNeels Hofmeyr1-0/+5
GSMTAP doesn't have a lot of space for the source file name. It is better to send only the basename of the file, because only the first bit of a long path may not convey the source file at all, needing guess work from the line number. Before: "Source File Name: ../../../../src/libosmocore/src" After: "Source File Name: telnet_interface.c" Change-Id: Ie8fc9e782bcf8fa6e2e957d02e7d73c3a7c2bca8
2018-01-12Allow multiple 'log gsmtap' sinksMax1-2/+9
Previously we've checked for existing log target with a given hostname from vty code but it was ignored inside the check so only the very first 'log gsmtap' entry was enabled while the rest were silently ignored. Change-Id: I8fd8bda9e07d403a54735da30addb742e56538a2
2018-01-12log: print loginfo assertions sourceMax1-8/+8
Print which function has triggered assert_loginfo(). It's handy in debugging logging-related issues in libosmocore. Change-Id: I8418d0c431106f50aa8779cd89396f02373304ad
2018-01-12TLVP_PRESENT() should not return TRUE after tlv_parse() fails.Stefan Sperling1-4/+10
If the length provided in the patcket exceeds the buffer length, tlv_parse() returns -2 but leaves tlv.val and tlv.len initializd. Many callers of tlv_parse() do not check its return value, but rely on TLVP_PRESENT() to see if a particular TLV was parsed successfully. By clearing tlv.val and tlv.len we make it less likely that those callers will use an overlong TLV length value. Change-Id: I4dda6938e1650b4bcaac45809a4763f86f5a9794
2018-01-12gsm: add gsm0808_speech_codec_type_namesNeels Hofmeyr2-0/+15
Used for logging Speech Codec List entries in osmo-bsc, during handover decision. Change-Id: Ie6418d16db333188e9bcd2b32b7216f277ae8832
2018-01-08Use existing function for TLLI encodingMax2-15/+5
Use bssgp_msgb_tlli_put() instead of copy-pasted code. Change-Id: I06d60566a19dcae701f8648c19fbd8db6d586f77