summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* logging/vty: fix: do not close stderr in vty_close()Vadim Yanitskiy2019-11-211-1/+1
| | | | | | | | | Since Icdeaea67a06da3a2f07b252e455629559ecc1829, we use stderr for printing warnings while parsing the VTY configuration files. Make sure we do not close() stderr. Otherwise stderr logging gets broken. Change-Id: I6ecc85555d102f5911d50ed5ac54933c766fa84d Fixes: Icdeaea67a06da3a2f07b252e455629559ecc1829
* logging/vty: fix vty_read_file(): do not write warnings to stdinVadim Yanitskiy2019-11-212-5/+6
| | | | | | | | | Setting vty->fd to 0 is a bad idea, which may cause the process to write() warnings to its own _stdin_ (yes, it's possible). For example, when a configuration file contains deprecated logging commands. Let's use stderr by default. Change-Id: Icdeaea67a06da3a2f07b252e455629559ecc1829
* logging/vty: fix: actually ignore deprecated logging commandsVadim Yanitskiy2019-11-216-2/+15
| | | | | | | | | | | | | | | | | | | | | | | We shall not prevent programs from starting if their configuration files contain deprecated 'logging level ...' commands. Just print a warning and return CMD_SUCCESS instead of CMD_WARNING. While writing a unit test, another funny bug has been uncovered. Parsing of a deprecated command indeed triggers a deprecation warning, originated from libosmovty's log_deprecated_func(). This function simply calls vty_out(), but... Since the invocation of the vty_out() happens _before_ the VTY is initialized, the process is actually writing that warning to its own stdin! Most likely, because we use talloc_zero() to allocate a new instance of struct 'vty'. As a side effect, the evil warning magically appears in the output of 'make check', breaking the test statistics. Let's work around this bug for now by redirecting stdin to /dev/null. Change-Id: Ia934581410cd41594791d4e14ee74c16abe1009a Fixes: Ic9c1b566ec4a459f03e6319cf369691903cf9d00
* logging/vty: use LOG_LEVEL_ARGS in logging_vty_add_deprecated_subsys()Vadim Yanitskiy2019-11-211-2/+1
| | | | Change-Id: I862c3cce0147ee8cf4013501132584ea09c58b53
* logging/vty: do not print deprecated logging commands to stdoutVadim Yanitskiy2019-11-201-1/+0
| | | | | | | | Yes, we don't really need to poison stdout, as some osmo-* binaries (like osmo-gapk) may want to use it for non-logging purposes. This printf() call looks like a debugging leftover. Change-Id: Ida35865b1c0bb3d3567918f8e89c6551c6b34103
* fix OSMO_SOCKADDR_STR_FMT for IPv6Neels Hofmeyr2019-11-112-13/+17
| | | | | | | | | | | | | The format prints IP:port separated by a colon, which of course is confusing when the IPv6 address itself contains mostly colons. The new format adds square braces. cafe:face::1:42 -> [cafe:face::1]:42 The IPv4 format remains unchanged: 1.2.3.4:42 Change-Id: I161f8427729ae31be0eac719b7a4a9290715e37f
* test: add OSMO_SOCKADDR_STR_FMT to sockaddr_str_test.cNeels Hofmeyr2019-11-112-0/+24
| | | | | | | This shows the weird format choice for showing IPv6 addresses' port, fixed in subsequent patch. Change-Id: I8e5ebfbbc3a2b88aed820e8f845d9f6ededb29de
* GPRS/BSSGP: introduce bssgp_bvc_ctx_free()Vadim Yanitskiy2019-11-094-0/+13
| | | | | | | | | | So far we had a function to allocate a new bssgp_bvc_ctx, but not the opposite one. Let's finally introduce it, so it will be used at least in OsmoPCU. Please note that the new symbol has 'bssgp_' prefix, not 'btsctx_'. Change-Id: Ia78979379dbdccd6e4628c16f00d0c06d9212172
* select: Make file descriptor lists per-threadHarald Welte2019-11-072-3/+18
| | | | | | | | | | In a multi-threaded environemnt, it's likely that each thread will have its own, distinct set of file descriptors that it wants to watch. Hence, let's make the osmo_fd_* functions configure not one global list of file descriptors, but a thread-local list of file descriptors. Change-Id: I5082ed3e500ad1a7516e1785bc57e008da2fac9a
* gsm: gsm_04_08.h: Allow accessing classmark2 as struct instead of uint32_tPau Espin Pedrol2019-11-041-5/+28
| | | | | | | New fields are put inside a union to keep backward compatibility with potential older users of the struct. Change-Id: I235635800c0de47b1e2b9ec9c7191418f6003554
* gsm: gsm_utils: Fix return type of API ms_class_gmsk_dbm() and add unit testsPau Espin Pedrol2019-11-043-4/+23
| | | | | | | | Only known user of API is in osmocom-bb and it compiles fine after the change. Related: OS#4244 Change-Id: Ia10345008b3aca50b30482ef3b852b03eca71995
* gsm: Fix compilation error under some compilersPau Espin Pedrol2019-11-042-2/+2
| | | | | | | | | | | | | | Some compilers don't like declaration of enums in header files like we do sometimes for structs: enum gsm_band; void foobar(enum gsm_band band); triggers: error: use of enum 'gsm_band' without previous declaration Fixes: b99f4ca2d8517d99cdf8aa183dbfda7b233bb781 Related: OS#4244 Change-Id: I6c2102c763f565bbe3c8dd7e5b4e04c4a45fff67
* gsm_04_08.h: Introduce API osmo_gsm48_rfpowercap2powerclass()Pau Espin Pedrol2019-11-035-1/+49
| | | | | Related: OS#4244 Change-Id: I32e9cc1c2397b44f0d48db2acdf782a821365b63
* add osmo_sockaddr_str_is_nonzero()Neels Hofmeyr2019-11-014-0/+87
| | | | | | | | | | | | | | | | | | | | | Often, an IP address of 0.0.0.0 is considered an unset value (for clients requiring a server address; not for listening on "any"). osmo_sockaddr_str_is_set() does return false when the port is 0, but there is no simple way to tell whether the IP address is actually set to a server address. Add osmo_sockaddr_str_is_nonzero() to return false if: - the port is zero, or - the IP address is zero (0.0.0.0 or ::0), or - the IP address cannot be parsed. A practical use example: osmo-msc so far accepts an RTP IP address of 0.0.0.0 as valid. I noticed when trying to trigger error handling from a ttcn3 test. osmo-msc can use this function to reject invalid addresses from MGCP messages. Related: I53ddb19a70fda3deb906464e1b89c12d9b4c7cbd (osmo-msc) Change-Id: I73cbcab90cffcdc9a5f8d5281c57c1f87b2c3550
* cosmetic: gsm_04_08.h: Fix trailing whitespacePau Espin Pedrol2019-11-011-3/+3
| | | | Change-Id: I4b34dbd5f0176d1d8aa8cc96f642ed35d4214b7e
* fsm: refuse state chg and events after termNeels Hofmeyr2019-10-292-1996/+307
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refuse state changes and event dispatch for FSM instances that are already terminating. It is assumed that refusing state changes and events after FSM termination is seen as the sane expected behavior, hence this change in behavior is merged without being configurable. There is no fallout in current Osmocom code trees. fsm_dealloc_test needs a changed expected output, since it is explicitly creating complex FSM structures that terminate. Currently no other C test in Osmocom code needs adjusting. Rationale: Where multiple FSM instances are collaborating (like in osmo-bsc or osmo-msc), a terminating FSM instance often causes events to be dispatched back to itself, or causes state changes in FSM instances that are already terminating. That is hard to avoid, since each FSM instance could be a cause of failure, and wants to notify all the others of that, which in turn often choose to terminate. Another use case: any function that dispatches events or state changes to more than one FSM instance must be sure that after the first event dispatch, the second FSM instance is in fact still allocated. Furthermore, if the second FSM instance *has* terminated from the first dispatch, this often means that no more actions should be taken. That could be done by an explicit check for fsm->proc.terminating, but a more general solution is to do this check internally in fsm.c. In practice, I need this to avoid a crash in libosmo-mgcp-client, when an on_success() event dispatch causes the MGCP endpoint FSM to deallocate. The earlier dealloc-in-main-loop patch fixed part of it, but not all. Change-Id: Ia81a0892f710db86bd977462730b69f0dcc78f8c
* add osmo_fsm_set_dealloc_ctx(), to help with use-after-freeNeels Hofmeyr2019-10-294-26/+3508
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a simpler and more general solution to the problem so far solved by osmo_fsm_term_safely(true). This extends use-after-free fixes to arbitrary functions, not only FSM instances during termination. The aim is to defer talloc_free() until back in the main loop. Rationale: I discovered an osmo-msc use-after-free crash from an invalid message, caused by this pattern: void event_action() { osmo_fsm_inst_dispatch(foo, FOO_EVENT, NULL); osmo_fsm_inst_dispatch(bar, BAR_EVENT, NULL); } Usually, FOO_EVENT takes successful action, and afterwards we also notify bar. However, in this particular case, FOO_EVENT caused failure, and the immediate error handling directly terminated and deallocated bar. In such a case, dispatching BAR_EVENT causes a use-after-free; this constituted a DoS vector just from sending messages that cause *any* failure during the first event dispatch. Instead, when this is enabled, we do not deallocate 'foo' until event_action() has returned back to the main loop. Test: duplicate fsm_dealloc_test.c using this, and print the number of items deallocated in each test loop, to ensure the feature works. We also verify that the deallocation safety works simply by fsm_dealloc_test.c not crashing. We should probably follow up by refusing event dispatch and state transitions for FSM instances that are terminating or already terminated: see I0adc13a1a998e953b6c850efa2761350dd07e03a. Change-Id: Ief4dba9ea587c9b4aea69993e965fbb20fb80e78
* gprs_ns_vty: return success for disabled FR/GREOliver Smith2019-10-291-4/+0
| | | | | | | | | | | | Do not return a warning and therefore fail parsing the config when the "encapsulation framerelay-gre local-ip" command is used and FR/GRE is disabled. Having this in the config does no harm and allows keeping the same config if it is enabled later. This fixes the currently failing vty tests for osmo-sgsn. Fixes: a0c8195ad37292ab800a6c777fc28383995b4b64 ("vty: Return error if cmd returns CMD_WARNING while reading cfg file") Change-Id: Ic225232fbfca49ba868427eaf898e1f6e34e1ca8
* gsm0508: add functions to calculate beginning of a blockPhilipp Maier2019-10-287-0/+611
| | | | | | | | | | | The calculation of the beginning of a block for TCH/F, TCH/H and FACCH can be challenging since those channels are affected by the diagonal interleaving of the TCH channels. However, GSM 05.02 Section 7 Table 1 of 5 specifies how the blocks are distributed over the TDMA frame interval. Lets add a mapping function that is based on that table Related: OS#3803 Change-Id: I3d71c66f8c401f5afbad9b1c86c24580dab9e0ce
* vty: Return error if cmd returns CMD_WARNING while reading cfg filePau Espin Pedrol2019-10-285-2/+29
| | | | | | | Otherwise bad configurations can easily sneak in and produce unexpected behavior. Change-Id: Ic9c1b566ec4a459f03e6319cf369691903cf9d00
* configure: Introduce --disable-libsctp and error by default if libsctp not foundPau Espin Pedrol2019-10-242-11/+18
| | | | | | | | | | This way libosmocore build fails during configuring phase if expected default behavior (building with libsctp support enabled and providing osmo_sock_init2_multiaddr() API) fails. User is still provided with --disable-libsctp option in case he doesn't need those features or his environment doesn't provide required libsctp APIs. Change-Id: I710c9cb1c6da0e5fc94b792df8bf60194a72208f
* socket.c: build multiaddr socket API helpers only if used by public APIsPau Espin Pedrol2019-10-241-0/+4
| | | | | | | | | Those two functions are only used by osmo_sock_init2_multiaddr(), which is only built if HAVE_LIBSCTP is defined. Avoid compiler warning about unusued function helpers if osmo_sock_init2_multiaddr() is not being built. Change-Id: I52769d6b8f70af1a8bda23d60b3230a932e71fab
* libosmocore.pc.in: Append -lsctp to Libs.privatePau Espin Pedrol2019-10-221-1/+1
| | | | | | | It will be used by the linker when linking statically against libosmocore. Change-Id: I797b970b22053432b243e4ef9f6b0458727fc608
* socket: Remove unneeded condition check in osmo_sock_init2_multiaddr()Pau Espin Pedrol2019-10-211-15/+15
| | | | | | | | | Since we return error at the start of the function if proto != IPPROTO_SCTP, it makes no sense to check for proto != IPPROTO_UDP later on. Fixes: CID#205088 Change-Id: Ibba7eacaa9debb77d536d47dc85170c5ee79e479
* socket: Introduce API osmo_sock_init2_multiaddr()Pau Espin Pedrol2019-10-185-2/+307
| | | | | | | | | This API will be used by libosmo-netif's osmo_stream for SCTP sockets, which in turn will be used by libosmo-sccp to support multi-homed connections. Related: OS#3608 Change-Id: Ic8681d9e093216c99c6bca4be81c31ef83688ed1
* tdef: Return correct snprintf value for osmo_tdef_range_str_buf()Pau Espin Pedrol2019-10-181-2/+4
| | | | | | | | | | len provides extra information in the case the buffer was too small, because it tells the caller "the number of characters (excluding the terminating null byte) which would have been written to the final string if enough space had been available" (man snprintf). Change-Id: Icafe559e19a92e2ae72fdd0dd2d9a394b1eda878
* vty: Fix go_parent_cb not called for indented nodes at end of cfg filePau Espin Pedrol2019-10-111-0/+4
| | | | | | | | | | | | | | | | | Without this patch, for instance in this cfg file below, go_parent_cb is not called for nodes such as "listen" and "cs7": """ line vty no login cs7 instance 0 xua rkm routing-key-allocation dynamic-permitted listen m3ua 2905 accept-asp-connections dynamic-permitted local-ip 127.0.0.1 """ Related: OS#3608 Change-Id: Ia6d88c0e63d94ba99e950da6efbc4c1871070012
* socket.c: Move glibc workarounds to same place in addrinfo_helper()Pau Espin Pedrol2019-10-101-19/+10
| | | | Change-Id: Ifc3a30881f865f88bcfc1307a3c89c1ab79eecd4
* logging: Introduce mutex API to manage log_target in multi-thread envsPau Espin Pedrol2019-10-0912-100/+709
| | | | | | | | | | | | | | | | | | | | log_enable_multithread() enables use of locks inside the implementation. Lock use is disabled by default, this way only multi-thread processes need to enable it and suffer related complexity/performance penalties. Locks are required around osmo_log_target_list and items inside it, since targets can be used, modified and deleted by different threads concurrently (for instance, user writing "logging disable" in VTY while another thread is willing to write into that target). Multithread apps and libraries aiming at being used in multithread apps should update their code to use the locks introduced here when containing code iterating over osmo_log_target_list explictly or implicitly by obtaining a log_target (eg. osmo_log_vty2tgt()). Related: OS#4088 Change-Id: Id7711893b34263baacac6caf4d489467053131bb
* vty: Optionally Set/replace cfg file during cmd 'write file'Pau Espin Pedrol2019-10-071-2/+6
| | | | | | | | | | | This way if the process is started with no file associated (eg. no -c param and default cfg path doesn't exist), config can be later saved into a file by passing the parameter. Otherwise, until now this message was displayed: Can't save to configuration file, using vtysh. Related: OS#4024 Change-Id: I38edcf902a08b6bd0ebb9aa6fc1a7041421af525
* tdef_test: verify case where osmo_tdef_set returns -EEXISTPau Espin Pedrol2019-10-072-0/+4
| | | | Change-Id: I436daa804aac11622fde24afe9ea35193d9e9beb
* tdef: Introduce min_val and max_val fieldsPau Espin Pedrol2019-10-078-13/+175
| | | | | | | | | | | This is useful for timers expected to have a range of valid or expected values. Validation is done at runtime when timer values are set by the app or by the user through the VTY. Related: OS#4190 Change-Id: I4661ac41c29a009a1d5fc57d87aaee6041c7d1b2
* API doc tweaks (mncc.h, gsm_08_08.h)Neels Hofmeyr2019-10-042-5/+7
| | | | Change-Id: I9b4c7e737c83c65e358496e4540c14be5abc5474
* gsup: add OSMO_GSUP_SUPPORTED_RAT_TYPES_IE and OSMO_GSUP_CURRENT_RAT_TYPE_IENeels Hofmeyr2019-09-283-7/+49
| | | | | | | | | | | | | | OSMO_GSUP_SUPPORTED_RAT_TYPES_IE corresponds to the Supported RAT Types Indicator from 3GPP TS 29.002. See 8.1.2 MAP_UPDATE_LOCATION service, which indicates the capabilities of the MSC/VLR to the HLR. So far, have room for eight RAT types in the gsup_msg. That is an arbitrary random choice without any rationale. OSMO_GSUP_CURRENT_RAT_TYPE_IE is useful to communicate the currently used RAN / RAT type of the current subscriber during Location Updating Request. Change-Id: I93850710ab55a605bf61b95063a69682a2899bb1
* cosmetic: clarify c_iflag in osmo_serial_init()Harald Welte2019-09-281-1/+1
| | | | | | | We first set the ISTRIP bit only to remove it in the next line. Let's try to avoid confusing the reader. Change-Id: Icba43dd4b6dc4f9c7f8fcf91d24b3baac4e0c74a
* sim/class_tables: Fix typo in commentHarald Welte2019-09-281-1/+1
| | | | Change-Id: I837c8303a7bb47b690cc8841cf5cafba8ac338af
* gsm29205_test: fix error: missing braces around initializerVadim Yanitskiy2019-09-271-1/+7
| | | | | | | Since structure 'osmo_gcr_parsed' does contain arrays, GCC is not happy about the way we initialize it. Let's do it explicitly. Change-Id: Ia814b4a4ed5bec84ff1f69232f7f7d5ca0d19794
* No fail if no /proc/cpuinfoRuben Undheim2019-09-261-1/+1
| | | | Change-Id: I4b9e12e34f69d98fa87179c7ee390e31001ec943
* msgb: Allow size==headroom in msgb_alloc_headroom*()Pau Espin Pedrol2019-09-261-2/+2
| | | | | | | | | Nothinh really forbids this case, it's totally fine allocating all space of msgb as headroom. osmo-pcu actually does that in gprs_rlcmac_ul_tbf::snd_ul_ud(). Related: OS#4029 Change-Id: Ibe05d08e3169a2603e891f76682a3b352a93ec7a
* logging: Move extern declaration of osmo_log_target_list from logging.h to ↵Pau Espin Pedrol2019-09-202-1/+1
| | | | | | | | | logging_internal.h This list is really not needed by applications and currently only used internally in logging.c and logging_vty.c. Change-Id: I5dca069512bfcd0826194427c5482fad8bfd0232
* osmo-release.sh: update TODO-RELEASE for non-lib projects tooPau Espin Pedrol2019-09-201-5/+7
| | | | | | | | | | | | | | | | Projects not containing libraries may also want to contain a TODO-RELEASE in order to write down when a new API available only on libosmoXYZ current master (hence configure.ac and debian cannot be updated during the patch using the API until the APIs are available in a new release). This way, during release process of the project, the maintainer can see that a release of libosmoXYZ is needed beforehand and then update configure.ac of project accordingly with the new version of libosmoXYZ. Furthermore, we want to update the file only if mode DRY_RUN is not selected. Change-Id: I409b7eb8c23d21473f25dd2000f5d4447b24adb9
* ecu_fr: increase test coverage for FR ECU implementationPhilipp Maier2019-09-203-2/+88
| | | | | | | | | | | | | The ECU implementation for FR is currently tested by calling the related functions directly and by using the generic ECU abstraction layer. However, the test "test_fr_concealment" only tests directly. Lets add a version that uses the generic ECU abstraction layer as well. The generic ECU abstraction layer obsolets the public API functions osmo_ecu_fr_reset() and osmo_ecu_fr_conceal(), lets tag those functions as dprecated. Change-Id: Ib0c8a9b164f14ea4fa00688f760a76cdb4890af4
* cosmetic: Add comment on GSM-FR ECU structPhilipp Maier2019-09-201-0/+1
| | | | Change-Id: Ic0a3a407c592262104af315f845f0bbd116ab26b
* cosmetic: Move comment to the right placePhilipp Maier2019-09-201-1/+1
| | | | Change-Id: I3d548fcc7d500baf37134b14af91bc7b284ce6ad
* logging.h: add L1 SAPI related context and filterOliver Smith2019-09-181-0/+2
| | | | | | | First user is osmo-bts in I6b7bb2e1d61502b61214f854a4ec5cbb7267545b. Related: OS#2356 Change-Id: I814cb3328d99faca9220adb5a80ffb934f219d7d
* logging_internal.h: Fix osmo_log_info definitionPau Espin Pedrol2019-09-171-1/+1
| | | | | | | | | Global symbol osmo_log_info is declared in logging.c as non-const, because it is modified. As soon as logging_internal.h is included into logging.c, the compiler warns about osmo_log_info being declared twice differently. Change-Id: Iea961c3caeb12ddf60c99d4dca644bb9ab538767
* tdef: fixup osmo_tdef_set()Neels Hofmeyr2019-09-112-9/+7
| | | | | | | | | | | | I missed code review, so here are my comments in form of a follow-up patch for Id56a1226d724a374f04231df85fe5b49ffd2c43c. - Fix 'as_unit' arg name to 'val_unit' as in the C file and API doc. - Explain rounding-up behavior of value conversion in API doc. - Use osmo_tdef_get_entry() instead of a loop. Related: OS#4190 Change-Id: Ia91c2f17e40fb9e79ffa5a7f28ce9c3605664402
* tdef_vty.h: Add missing header dependenciesPau Espin Pedrol2019-09-071-0/+3
| | | | | | | enum node_type is defined in osmocom/vty/command.h va_list is defined in stdarg.h Change-Id: Ia439a7097ae7a9765e229e5f66e07af3fe490ecc
* tdef: Introduce API osmo_tdef_set()Pau Espin Pedrol2019-09-072-0/+21
| | | | | | | | | This API is already useful for users willing to set a given timer to a given value. It will also contain code later that checks for value being inside valid range for that timer. Related: OS#4190 Change-Id: Id56a1226d724a374f04231df85fe5b49ffd2c43c
* Introduce BTS_FEAT_ETWS_PN for communicating ETWS PN capabilityHarald Welte2019-09-052-0/+2
| | | | | | | | | | As 3GPP doesn't specify how the BSC shall communicate ETWS Primary Notifications over Abis/RSL, we have to use a vendor-specific RSL message for this. And in order to know if the peer supports this feature, we introduces BTS_FEAT_ETWS_PN. Change-Id: I89c24a81ada6627694a9632e87485a61cbd3e680 Related: OS#4046, OS#4047