Commit Graph

3176 Commits

Author SHA1 Message Date
Harald Welte 2324506266 Bump version: 1.3.1.2-69b71 → 1.3.2
Version 1.3.2 is a patch release fixing compilation of 1.3.1 with gcc-10.

Change-Id: I30e89cf227ea71ec76ecbc819cb2a86cf556ce5a
2020-07-26 10:49:52 +02:00
Harald Welte 69b717a466 gsm_29_118.h: Fix compilation with gcc-10
this causes problems when compiling user applications
/usr/bin/ld: ../../src/libvlr/libvlr.a(vlr_lu_fsm.o):/usr/local/include/osmocom/gsm/protocol/gsm_29_118.h:184: multiple definition of `sgsap_ie_tlvdef'; msc_main.o:/usr/local/include/osmocom/gsm/protocol/gsm_29_118.h:184: first defined here

Change-Id: Iaa1d36c7a9bb64aa84ee85fa3e40f6b3560fe693
2020-07-26 10:47:00 +02:00
Harald Welte 305e254af2 gsm0503_parity: Fix compilation with gcc-10
/usr/bin/ld: .libs/gsm0503_coding.o:/home/laforge/projects/git/libosmocore/src/coding/../../include/osmocom/coding/gsm0503_parity.h:16: multiple definition of `gsm0503_mcs_crc12'; .libs/gsm0503_parity.o:/home/laforge/projects/git/libosmocore/src/coding/../../include/osmocom/coding/gsm0503_parity.h:16: first defined here

Change-Id: I15945bbf59c873e50154c40fed0ba3d6b4d7c399
2020-07-26 10:46:53 +02:00
Harald Welte 0274d7f9d9 Bump version: 1.3.0.1-cb929 → 1.3.1
Change-Id: Icf316253799df5f5ee5bf64e35c9cbe88f663bf1
2020-03-16 11:41:51 +01:00
Harald Welte cb929c5d66 libosmosim: Build irrespective of PC/SC support
libosmosim contains a variety of definitions and utility fuinctions
useful when working with SIM card [protocol].  They can not only
be used with PC/SC readers but also in other contexts.

Change-Id: I741940d3dc2a5653c760e9d1597d7f08afb3b631
2020-03-16 11:34:53 +01:00
Pau Espin 2862f9082e Bump version: 1.2.0.108-c6a8-dirty → 1.3.0
Change-Id: I5698bfe45467a8b0e44549105aaf27b8da500de8
2020-01-02 18:42:30 +01:00
Pau Espin dddeaa9868 Drop empty file debian/patches/series
Change-Id: I1a4aa5d6785aa7ff7dc454930a84d73fe1114726
2020-01-02 18:35:50 +01:00
Pau Espin 5d39e05bf4 osmo-release.sh: Improve of PKG_CHECK_MODULES from configure.ac
Remove brackets and check for "(" after PKG_CHECK_MODULES to avoid
getting comments containing the keyword.

Change-Id: Ie2b9a65d42615aa3cce6906ddd53758bc3052942
2020-01-02 18:33:26 +01:00
Harald Welte c6a8697800 Introduce helper functions for safe fork+exec of processes
In some situations, we want to execute an external shell command
in a non-blocking way.  Similar to 'system', but without waiting for
the child to complete.  We also want to close all file descriptors
ahead of the exec() and filter + modify the environment.

Change-Id: Ib24ac8a083db32e55402ce496a5eabd8749cc888
Related: OS#4332
2019-12-17 13:49:28 +01:00
Harald Welte 22c7ec3b60 debian/control: Add missing libusb-1.0-0-dev dependency
In Change-Id I656a1a38cbb5b1f3a9145d2869d3b4d0adefcae3 we introduced
USB support and also updated debian pacakaging informatio for this
new package - however, I missed to add a realted Build-Depends line :(

Change-Id: Ib0446510c8ba49623914b6103ea9cfa88c208d50
Related: #4299
2019-12-17 13:49:28 +01:00
Harald Welte d462e3fa7b usb: Import a variety of libusb utility functions from simtrace
Those functions were originally developed as part of simtrace; let's
import them to libosmousb as they are truly generic.

Change-Id: I2c18b938e4e1ea5b8a521a386f00db3a7389e47a
Related: OS#4299
2019-12-16 00:17:27 +01:00
Harald Welte da432cdc35 libosmocore libusb integration
Osmocom applications typically use libosmocore select.[ch] event loop
code as their main event dispatch mechanism.  When they want to deal
with libusb in a non-blocking/asynchronous way, they need to integrate
libusb into that select().

The new libosmousb is doing exactly that: Providing a shared utility
library for Osmocom programs that wish to use libusb.  This is useful
for example in simtrace2 host utilitie as well as osmo-e1d.

Change-Id: I656a1a38cbb5b1f3a9145d2869d3b4d0adefcae3
Closes: OS#4299
2019-12-16 00:17:27 +01:00
Harald Welte 7d0fe2ae6f gprs_bssgp: Work around gcc-9 claiming "error=stringop-overflow"
gcc-9.2.1 issues the following errror when compiling with -Werror:

In function ‘tl16v_put’,
    inlined from ‘tvlv_put’ at ../../include/osmocom/gsm/tlv.h:156:9,
    inlined from ‘tvlv_put’ at ../../include/osmocom/gsm/tlv.h:147:24,
    inlined from ‘msgb_tvlv_put’ at ../../include/osmocom/gsm/tlv.h:223:9,
    inlined from ‘bssgp_tx_paging’ at gprs_bssgp.c:1250:2:
../../include/osmocom/gsm/tlv.h:131:2: error: ‘memcpy’ reading between 128 and 65535 bytes from a region of size 9 [-Werror=stringop-overflow=]
  131 |  memcpy(buf, val, len);
      |  ^~~~~~~~~~~~~~~~~~~~~

Unfortunately I've not been able to work around it with some nice GCC
	#pragma GCC diagnostic ignored "-Wstringop-overflow"

Change-Id: I22a0c399c6c00eaf87277002096a82844c9e198e
2019-12-15 21:56:39 +01:00
Oliver Smith a47d37c946 debian, utils: switch to python 3
Make build and external tests work with python3, so we can drop
the python2 dependency.

This should be merged shortly after osmo-python-tests was migrated to
python3, and the jenkins build slaves were (automatically) updated to
have the new osmo-python-tests installed.

Related: OS#2819
Depends: osmo-python-tests I3ffc3519bf6c22536a49dad7a966188ddad351a7
Change-Id: I84ef43f700e125c7a65f92347f12844e07e65655
2019-12-12 09:24:04 +00:00
Vadim Yanitskiy 87b51439c1 core/defs.h: introduce and use OSMO_DEPRECATED_OUTSIDE
The new OSMO_DEPRECATED_OUTSIDE macro is similar to the existing
OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE, but allows to override the
deprecation message.

Let's use it to suspend deprecation warnings related to:

  - gsm48_decode_bcd_number(),
  - osmo_ecu_fr_conceal(),
  - osmo_ecu_fr_reset(),

as they're intentionally used in scope of the library.

Change-Id: I1b0eff1396776900c1286e41da3aee3ff78b326e
2019-12-11 12:42:05 +00:00
Eric Wild 94cd4acef8 sim: allow opening reader# > 0
Change-Id: I4b1abc8d8aae4bd9a32f927269d7ebfef902d7c5
2019-12-09 12:54:43 +01:00
Harald Welte 49ddef610a gsup: Introduce OSMO_GSUP_NUM_VECTORS_REQ_IE
This is a bit of a hack, as we want to maintain binary compatibility
without breaking existing users of libosmocore.  To do so, we use the
'num_auth_vectors' field in two ways now:

* In the existing use case as part of SEND_AUTH_INFO_RESPONSE, it
  indicates the number of vectors stored in the 'auth_vectors' field

* In the new use case as part of SEND_AUTH_INFO_REQUEST, it indicates
  the number of vectors actually requested by the MSC/SGSN/MME.

Change-Id: Iaecc47280f8ce54f3e3a888c1cfc160735483d0f
2019-12-09 10:54:30 +00:00
Harald Welte 278a6c8fcf utils: exit(2) on unsupported positional arguments on command line
Change-Id: Icc76cae2225ec4e664b950176dd861fa15712f59
2019-12-03 21:35:48 +01:00
Harald Welte f7404bb473 osmo-arfcn: Fix '-h' option
Change-Id: I13decca25dcdb75191c1e78058704ae8efa69b33
2019-12-03 21:35:48 +01:00
Pau Espin 24277b4db5 osmo-release.sh: Use set -e before applying changes to prepare release
Change-Id: I783c3645537258a75ae6f5a684489d629b852188
2019-12-03 17:36:20 +01:00
Harald Welte 797d533072 gprs_ns_instantiate(): propagate errors from gprs_sns_init() to caller
Change-Id: I71f347a2f0376716e5f83d33a7931eb8a99aad77
2019-12-01 13:48:55 +01:00
Harald Welte ae5016f193 Check for osmo_fsm_register() error return value
Change-Id: Idbc1557739b2a253b73914e6f1f18a6d169d882e
2019-12-01 13:45:03 +01:00
Vadim Yanitskiy 7a35b78648 libosmovty: simplify condition checking vty->fd in vty_close()
On POSIX systems, standard I/O streams - stdin, stdout, and stderr,
always have default file descriptors 0, 1, and 2 respectively.

Change-Id: Ied35d142af0ba0f5ad78975b8f22c35b32d6ff71
2019-11-30 18:49:33 +00:00
Vadim Yanitskiy 54df08e3fa libosmovty: properly initialize vty->fd in vty_new()
Since we're using talloc_zero(), vty->fd is initialized with 0,
which corresponds to stdin. Let's set an invalid value to prevent
potential bugs like the one fixed by the recent change [1].

[1] Icdeaea67a06da3a2f07b252e455629559ecc1829

Change-Id: Iec15649781317a23e13d2c2840a8f672050f76c1
2019-11-30 18:49:33 +00:00
Harald Welte a3e9ef9289 04.80: Deprecate gsm0480_create_ussd_resp()
In July 2018 in commit Ide240279240322f643e142229eb7829f538c6314 we
introduced the successor gsm0480_gen_ussd_resp_7bit(), which is also
what both libosmogsm-internal code as well as osmo-hlr have been ported
to.  For some reason it wasn't marked deprecated back then.

Change-Id: Iff4c91b5b98a73d9a30aa42f6b2a1ebcc8a45343
2019-11-30 12:39:39 +00:00
Vasil Velichkov 499510bd52 Add code coverage support
The coverage report shows what code is covered by tests and what is not
and the ratio could be tracked over time. These reports will allow us
to identify code that is not being tested and improve the test suites.

To enable the reports configure with --enable-code-coverage and execute
"make check-code-coverage". The HTML report will be generated in a
subdirectory with name libosmocore-$(PACKAGE_VERSION)-coverage/index.html

The report is generated using gcov, lcov and lcov_cobertura tools and
the OSMO_AC_CODE_COVERAGE macro. The osmo_ax_code_coverage.m4 is a copy of
ax_code_coverage.m4 taken from autoconf-archive v2018.03.13. It was
copied to avoid the additional external dependency and renamed to avoid
overwriting it in case autoconf-archive is already installed as we are
going to install it in $(datadir)/aclocal in order to be reused in other
osmocom's projects.

Closes: OS#1987
Change-Id: I6f4ffb91bd7f3dd070aa09dd16d5ad1faf130a4c
2019-11-30 02:17:23 +00:00
Neels Hofmeyr 153642348f add all missing OSMO_GSUP_TO_MSGT_*() macros
OSMO_GSUP_TO_MSGT_RESULT() is needed by osmo-hlr for osmo_gsup_req.
The others are added for completeness' sake.

Related: I3a8dff3d4a1cbe10d6ab08257a0138d6b2a082d9
Change-Id: I6e38a3bb8447f8f212f8d6f5b10a5d0df59323d7
2019-11-28 22:57:22 +01:00
Pau Espin 392f607f2d Introduce fields related to DTAP DLCI
Change-Id: Iec448af02d28e6c5c573e68a0b4a86067ec7e561
2019-11-27 15:26:12 +01:00
Neels Hofmeyr 8a7eed50db add osmo_escape_cstr and osmo_quote_cstr
Provide string escaping that
- returns the required buffer size, so it can be used with OSMO_STRBUF_APPEND().
- uses C compatible string constant escaping sequences.

This is intended as a replacement for all previous osmo_escape_str* and
osmo_quote_str* API. It pains me that I didn't get them right the first nor the
second time:
- The buffer functions do not return the chars needed, which is required for
  allocating sufficient memory in the *_c versions of the functions.
- Because of that, these functions are accurately usable for
  OSMO_STRBUF_APPEND(), producing truncated strings, for example when dumping a
  GSUP message.
- They do not use the C equivalent string constant escaping: for some reason I
  thought "\15" would be valid, but it should be "\x0f".
If I could, I would completely drop those mislead implementations ... but
backwards compat prohibits that.

A previous patch already provided internal static functions that accurately
return the required buffer size. Enhance these to also support C compatible
string escaping, and use them as implementation of the new functions:

osmo_escape_cstr_buf()
osmo_escape_cstr_c()
osmo_quote_cstr_buf()
osmo_quote_cstr_c()

In the tests for these, also test C string equivalence.

Naming: from API versions, it would be kind of logical to call them
osmo_escape_str_buf3() and osmo_escape_str_c2(). Since these anyway return a
different escaping, it makes sense to me to have distinct names instead.

Quasi missing are variants of the non-C-compatible weird legacy escaping that
return the required buffer size, but I refrain from adding those, because we
have enough API cruft as it is. Just always use these new cstr variants.

Change-Id: I3dfb892036e01000033dd8e7e4a6a0c32a3caa9b
2019-11-24 19:59:35 +01:00
Neels Hofmeyr 70ce871532 vty_app_info.is_config_node: add OSMO_DEPRECATED
Although this OSMO_DEPRECATED doesn't seem to generate a warning when compiling
code that sets .is_config_node = foo, it seems a good idea to add the
deprecation tag.

It is deprecated since commit "vty: track parent nodes also for telnet sessions"
I2b32b4fe20732728db6e9cdac7e484d96ab86dc5

Change-Id: I800507b27cb0d536c1a4c203d7f7b90eec05a69c
2019-11-24 19:59:35 +01:00
Neels Hofmeyr d31de23758 vty: track parent nodes also for telnet sessions
Keep track of parent nodes and go back hierarchically, not only for .cfg file
reading, but also for telnet VTY sessions.

A long time ago cfg file parsing was made strictly hierarchical: node exits go
back to parent nodes exactly as they were entered. However, live telnet VTY
sessions still lacked this and depended on the go_parent_cb().

From this commit on, implementing a go_parent_cb() is completely optional. The
go_parent_cb() no longer has the task to determine the correct parent node,
neither for cfg files (as already the case before this patch) nor for telnet
VTY sessions (added by this patch). Instead, a go_parent_cb() implementation
can merely take actions it requires on node exits, for example applying some
config when leaving a specific node.

The node value that is returned by the go_parent_cb() and the vty->node and
vty->index values that might be set are completely ignored; instead the
implicit parent node tracking determines the parent and node object.

As a side effect, the is_config_node() callback is no longer needed, since the
VTY now always implicitly knows when to exit back to the CONFIG_NODE.

For example, osmo_ss7_is_config_node() could now be dropped, and the
osmo_ss7_vty_go_parent() could be shortened by five switch cases, does no
longer need to set vty->node nor vty->index and could thus be shortened to:

int osmo_ss7_vty_go_parent(struct vty *vty)
{
        struct osmo_ss7_asp *asp;
        struct osmo_xua_server *oxs;

        switch (vty->node) {
        case L_CS7_ASP_NODE:
                asp = vty->index;
                /* If no local addr was set */
                if (!asp->cfg.local.host_cnt) {
                        asp->cfg.local.host[0] = NULL;
                        asp->cfg.local.host_cnt = 1;
                }
                osmo_ss7_asp_restart(asp);
                break;
        case L_CS7_XUA_NODE:
                oxs = vty->index;
                /* If no local addr was set, or erased after _create(): */
                if (!oxs->cfg.local.host_cnt)
                        osmo_ss7_xua_server_set_local_host(oxs, NULL);
                if (osmo_ss7_xua_server_bind(oxs) < 0)
                        vty_out(vty, "%% Unable to bind xUA server to IP(s)%s", VTY_NEWLINE);
                break;
        }
        return 0;
}

Before parent tracking, every program was required to write a go_parent_cb()
which has to return every node's parent node, basically a switch() statement
that manually traces the way back out of child nodes. If the go_parent_cb() has
errors, we may wildly jump around the node tree: a common error is to jump
right out to the top config node with one exit, even though we were N levels
deep. This kind of error has been eliminated for cfg files long ago, but still
exists for telnet VTY sessions, which this patch fixes.

This came up when I was adding multi-level config nodes to osmo-hlr to support
Distributed GSM / remote MS lookup: the config file worked fine, while vty node
tests failed to exit to the correct nodes.

Change-Id: I2b32b4fe20732728db6e9cdac7e484d96ab86dc5
2019-11-24 19:59:35 +01:00
Neels Hofmeyr 951d32b817 osmo_sockaddr_str: deprecate osmo_sockaddr_str_*_32n()
Follow up for patch I3cf150cc0cc06dd36039fbde091bc71b01697322

osmo_sockaddr_str_{from,to}_32n actually use host byte order. Deprecate these
and introduce a more accurately named version ending in h.

Change-Id: Ic7fc279bf3c741811cfc002538e28e8f8560e338
2019-11-24 19:59:35 +01:00
Neels Hofmeyr 06356fd9c3 utils: add osmo_strnchr()
When finding a char in a string, I want to be able to limit the search area by
size, not only by nul terminator.

Change-Id: I48f8ace9f51f8a06796648883afcabe3b4e8b537
2019-11-24 19:59:35 +01:00
Neels Hofmeyr ff65d24ec4 utils_test: add osmo_print_n_test()
A couple of times recently I've needed to copy out a substring to a buffer with
limited size. Use of strncpy() or osmo_strlcpy() are nontrivial here.
I wanted to have a dedicated function.

After I wrote that function with a test, I noticed that I had already
implemented the same thing a while ago, as osmo_print_n() :P
So here is just the test.

Change-Id: Ia716abdc1f58af6065b84f4f567388a32a7b39fc
2019-11-24 19:59:35 +01:00
Neels Hofmeyr 63cb949ebc msgb_put: more elaborate logging of head/tailroom failure
Change-Id: I55b68098e1037c74ebe5faa86e34bd4494f5b726
2019-11-24 19:59:35 +01:00
Neels Hofmeyr 344776d251 fsm.h: add missing include of logging.h
Change-Id: I783bf0eb40b674fb6a77f7673563fdf156975f5a
2019-11-24 19:59:35 +01:00
Neels Hofmeyr 249e005350 GSUP: rename E_ROUTING_ERROR to ROUTING_ERROR
GSUP routing was introduced when adding the E interface. Hence that was the
first realm where routing errors could occur. I did notice back then that this
message type was special: it does not convey a response to a particular message
kind -- it does not make sense, for example, to return an Updating Location
Error cause, and do that for all conceivable message types. Instead, this tells
the sender that a deeper error exists, i.e. that the desired peer is completely
gone and unreachable.

I did not foresee though that for D-GSM, there would also be arbitrary GSUP
proxy routing, and that this error is not limited to E interface semantics.
From today's point of view, adding the "_E_" in the name was a mistake.

Remove that "_E_" to yield OSMO_GSUP_MSGT_ROUTING_ERROR (with unchanged message
type discriminator), but provide a #define linking the old name
OSMO_GSUP_MSGT_E_ROUTING_ERROR to the new one.

The only visible change should be that osmo_gsup_message_type_names[] now
returns the new name without "_E_". I am not aware of any regression test
fallout from that.

Change-Id: Ic8e8bd11522d6c51ac7aaf946516cbce26bc6e1e
2019-11-24 19:58:57 +01:00
Neels Hofmeyr c36e2e4924 fix osmo_escape_str_c() and osmo_quote_str_c()
The osmo_escape_str_c() and osmo_quote_str_c() functions return truncated
results when characters need escaping. For example:

  osmo_quote_str_c(NULL, "foo"); --> "foo"
  osmo_quote_str_c(NULL, "foo\n"); --> "foo\n
  osmo_quote_str_c(NULL, "foo\tbar\t\n"); --> "foo\tbar\t

Implement these _c variants using OSMO_NAME_C_IMPL() to always allocate
sufficient memory.

However, current osmo_escape_str_buf2() and osmo_quote_str_buf2() fail to
return the required buffer size (even though that information is readily
avaiable), so these don't qualify for accurate use of OSMO_NAME_C_IMPL().

Hence, move the implementations of osmo_escape_str and osmo_quote_str to an
internal static function that returns the characters needed, so that all
dynamically allocating implementations can return un-truncated results.

Of course, external callers would also benefit from escape/quote API that
accurately returns the amount of characters needed, but I am not changing
public API in this patch, on purpose, ... yet.

Change-Id: I16c08eced41bf1b7acf6e95f658068ace99ca4c8
2019-11-23 07:58:47 +00:00
Neels Hofmeyr 823073aa91 utils.h: add OSMO_NAME_C_IMPL() macro
Provide a common implementation for foo_name_c() functions that base on
foo_name_buf() functions.

  char *foo_name_c(void *ctx, example_t arg)
  {
          OSMO_NAME_C_IMPL(ctx, 64, "ERROR", foo_name_buf, arg)
  }

Rationale: the most efficient way of composing strings that have optional parts
or require loops for composition is by writing to a ready char[], and this in
turn is easiest done by using OSMO_STRBUF_* API. Using such a basic name string
implementation which typically returns a length, I often want a more convenient
version that returns a char*, which can just be inlined in a "%s" string format
-- crucially: skipping string composition when inlined in a LOGP(). This common
implementation allows saving code dup, only the function signature is needed.

Why not include the function signature in the macro? The two sets of varargs
(1: signature args, 2: function call args) are hard to do. Also, having an
explicit signature is good for readability and code grepping / ctags.

Upcoming uses: in libosmocore in the mslookup (D-GSM) implementation
(osmo_mslookup_result_name_c()), and in osmo_msc's codec negotiation
implementation (sdp_audio_codecs_name_c(), sdp_msg_name_c(), ...).
I54b6c0810f181259da307078977d9ef3d90458c9 (libosmocore)
If3ce23cd5bab15e2ab4c52ef3e4c75979dffe931 (osmo-msc)

Change-Id: Ida5ba8d9640ea641aafef0236800f6d489d3d322
2019-11-23 07:58:47 +00:00
Neels Hofmeyr df22b00633 osmo_sockaddr_str: API doc: fix 32bit addr mixup of host/network byte order
Of course both v4 and v6 addresses are kept in network byte order when
represented in bytes, but when writing, I somehow must have assumed that
inet_pton() returns host byte order. Fix that mixup in the API docs:

osmo_sockaddr_str_from_32() and osmo_sockaddr_str_to_32() actually use network
byte order.

osmo_sockaddr_str_from_32n() and osmo_sockaddr_str_to_32n() actually use host
byte order, though reflecting 'n' in their name.

sockaddr_str_test: use hexdump instead of %x to show the
osmo_sockaddr_str_to_32*() conversions so that the error becomes obvious.
(Printing %x reverses the bytes again and made it look correct.)

Change-Id: I3cf150cc0cc06dd36039fbde091bc71b01697322
2019-11-23 07:58:47 +00:00
Neels Hofmeyr e883de54f8 cosmetic: logging.h: fix comment s/levels/subsystems
Change-Id: I242a4a44649bc4dac055985ba8fd63b2f784ee6d
2019-11-23 07:58:47 +00:00
Neels Hofmeyr c5b71752d5 fix DLSMS logging category color: '[1:38m' isn't actually defined
Instead it apparently renders as bright white, so just use that constant
instead.

Change-Id: Ic775b6e37ccf61dc71a540b41d6a16a8a9291dc2
2019-11-23 07:58:47 +00:00
Neels Hofmeyr f2644aee55 logging.h: define ansi color constants
It's hard to figure out what color logging categories have with those ANSI
color code strings. Instead, define these OSMO_LOGCOLOR_* constants.

Naming: commonly, the logging.h header has the "LOG" prefix in the name, but it
seems saner to include the OSMO_ prefix: it seems too likely that some
libosmocore user somewhere already has defined "LOGCOLOR_RED" somewhere.

Change-Id: I03b6b1f73ae7ee61d37ff921e071a3d0881d3e9a
2019-11-23 07:58:47 +00:00
Daniel Willmann a981f9dfd4 libosmogsm: add support for XOR authentication
Change-Id: I1afaf0a9e2dce43aec87964bacefb21ed4d3d565
Related: OS#2475
2019-11-22 17:39:42 +00:00
Neels Hofmeyr dd7b6f97df utils.c: fix various inaccurate API doc about return values
Change-Id: I9ee6416decd23f8d5d634197620a63ae408cead3
2019-11-21 21:17:12 +01:00
Neels Hofmeyr 002a51d731 add osmo_sockaddr_str_cmp()
Currently planned user: for Distributed GSM in osmo-hlr: setting per-MSC
service addresses in VTY: replace/remove existing entries.

osmo_sockaddr_str_cmp() is useful to catch identical resulting IP addresses,
regardless of differing strings (e.g. '0::' and '::' are equal but differ in
strings).

Change-Id: I0dbc1cf707098dcda75f8e07c1b936951f9f9501
2019-11-21 21:17:12 +01:00
Vadim Yanitskiy 02f25ea77b logging/vty: fix: do not close stderr in vty_close()
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
2019-11-21 16:22:21 +07:00
Vadim Yanitskiy b639b4d4f7 logging/vty: fix vty_read_file(): do not write warnings to stdin
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
2019-11-21 10:48:30 +07:00
Vadim Yanitskiy 4abda9ea26 logging/vty: fix: actually ignore deprecated logging commands
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
2019-11-21 10:48:02 +07:00
Vadim Yanitskiy 75c242e6a2 logging/vty: use LOG_LEVEL_ARGS in logging_vty_add_deprecated_subsys()
Change-Id: I862c3cce0147ee8cf4013501132584ea09c58b53
2019-11-21 00:07:08 +07:00