Commit Graph

2831 Commits

Author SHA1 Message Date
Pau Espin 8a757d20f7 ipa: Document ipa_msg_recv* functions
Change-Id: Ie81e9dd9f9936a414e7cebb2bccffa6f42a302a7
2018-08-22 14:17:58 +02:00
Neels Hofmeyr 983dcb9af3 use __FILE__, not __BASE_FILE__
The intention was to use the file's basename, but __BASE_FILE__ means "the root
file that is being parsed and contains #include statements".

If we had a function using __BASE_FILE__ and that was defined in an #included
file, __BASE_FILE__ would indicate the first file where the #include is, and
not the file where the function is defined. __BASE_FILE__ works for us because
we don't ever include function definitions that log something, so __BASE_FILE__
always coincides with __FILE__ for our logging; but still __BASE_FILE__ is
semantically the wrong constant.

Related: OS#2740
Change-Id: Ibc1d3746f1876ac42d6b1faf0e5f83bd2283cdcc
2018-08-20 20:23:18 +00:00
Pau Espin b3a9820bfc vty: Makefile: Fix LIBVERSION typo introduced in 0.12.0 release
Setting age to 5 is cleary an error, it should be increment by one
instead as APIs were added 0.11->0.12 and none modified or removed.

Change-Id: I3b3bc808349bc2f949ef9eef64f39e7202ddf946
2018-08-20 15:51:29 +02:00
Pau Espin 8ce6f488b6 msgb: Introduce msgb_{de,en}queue_count APIs
It's a common pattern having a list of msgb and having to maintain its
size (for instance, to limit the maximum size of the list). Having the
counter updated at the same time that the msgb is enqueued or dequeued
helps avoiding introducing new bugs by forgetting to update the size
counter at the right places.

Change-Id: I33b501e89a8f29e4aa121696bcbb13d4b83db40f
2018-08-17 10:34:15 +02:00
Pau Espin 0b6fcb0349 signal: Introduce API osmo_signal_talloc_ctx_init
Otherwise applications need to use "extern void* tall_sigh_ctx" and set
it manually (that symbol is not exported in any header file) or end up
allocating struct signal_handler into the NULL talloc ctx.

API created in a similar way as already existing msgb_talloc_ctx_init(),
but without the pool_size because it's not considered necessary in this
case.

Change-Id: Id58ca18eb826b8f4183a7cf0dbb2b38cba702a09
2018-08-16 21:03:32 +02:00
Alexander Couzens acc0a070c7 bssgp: introduce flush queue functions
To reset the state of BSSGP allow to flush the BSSGP queues.
When testing (with TTCN3) the test object should be resetted between
each test.

Introduce the functions:
bssgp_fc_flush_queue() - flushs a single flow control object
bssgp_flush_all_queues() - flushs queues of all BSSGP connections

Change-Id: I29b6ad6742ddf9b0b58b4af37d9a1cf18e019325
2018-08-10 06:55:43 +00:00
Harald Welte d14eccd1a7 debian/rules: Don't overwrite .tarball-version
The .tarball-version file should contain the *source version* uniquely
identifying the git commit, and not the Debian package name.

With https://gerrit.osmocom.org/#/c/osmo-ci/+/10343/ there is a correct
.tarball-version file in the .tar.xz of the nightly source packages.

Change-Id: Ibeb6d273e2d26f37a36cbde4a948ce95395491f8
Related: OS#3449
2018-08-06 11:09:40 +02:00
Vadim Yanitskiy 30cfeeb4a0 libosmogsm: (re)introduce gsm48_push_l3hdr()
There was gsm0480_l3hdr_push() declared in a header file, but
not exposed in 'libosmogsm.map'. Furthermore, for some reason
it was a part of GSM 04.80 API, what is not actually correct.

Let's rename this symbol, and properly expose it as a part of
the GSM 04.08 API. Also, let's introduce an auxiliary wrapper
for messages, where the transaction identifier is required
(see GSM 04.07, section 11.2.3.1.2).

Change-Id: I8a045efe8335d83fcbe8d43eb180972e3b1d9dda
2018-08-05 23:21:43 +07:00
Vadim Yanitskiy 39a36d0193 gsm/gsm0480.c: use the local msgb allocator
Change-Id: I23b4b0e1c237b9b27c1db1c9a824b5329d41a38b
2018-08-05 14:48:27 +07:00
Vadim Yanitskiy 3fc4616224 gsm/gsm0480.c: prevent NULL-pointer dereference
Change-Id: I444d95941837458b46e581298f76f3a9926c8552
2018-08-05 07:14:19 +00:00
Mykola Shchetinin 893e49e993 vty/vty.c: fix bug in vty_config_write
the vty_config_write function should write:
line vty
 login
to the configuration file when the login is enabled. Otherwise after
saving the configuration the next login will be performed without
password checking (password_check variable will be 0 though it must be 1)

Change-Id: I39050b6bf617dac10d3fccc3106f67bdcca1d05a
2018-08-05 07:01:53 +00:00
Kevin Redon 7ecb034f87 comp128v23 (minor): update original code site and author
I was contacted by the (previously unknown) author who provided
the new location of the original code.

Change-Id: I2dabab20ad018ce473817986bdb250131c010bf1
2018-08-04 17:23:23 +02:00
Philipp Maier 99f706d336 socket: do not set SO_REUSEADDR for IPPROTO_UDP
When UDP is used as protocol (proto=IPPROTO_DUP), then we should not set
SO_REUSEADDR in the socket option. Because if we do, we allow two
processes to bind on the same UDP port. The errornous situation will be
undetectable to both applications. So lets only set SO_REUSEADDR when we
do not use UDP.

- Add check if we use UDP, if yes do not set SO_REUSEADDR

Change-Id: I4a8ffb8d598aca88801a4a0322944d7cdd8d4047
Related: OS#3441
2018-08-02 11:19:38 +02:00
Philipp Maier 0659c5d2f3 socket: check return code of setsockopt
the return code of the last setsockopt() call in osmo_sock_init() is not
checked. Since all other calls to setsockopt are checked, lets check
this one as well.

- check return code of setsockopt() and close the socket on failure

Change-Id: I96dbccc3bcff35bf39979dbe0c44aadc8ce20c83
2018-08-02 11:19:38 +02:00
Harald Welte 5a7740d1db re-introduce ipa_ccm_idtag_parse_off()
In the previous commit we deprecated ipa_ccm_idtag_parse() but
also removed ipa_ccm_idtag_parse_off(), for which I couldn't find
any users.  However, legacy openbsc.git still uses this function,
so let's re-introiduce it in its original form.

Change-Id: Ibfe53b04340eb355c8bfb8453a2af1522a4b6baf
2018-08-01 17:42:06 +02:00
Harald Welte 61650d5117 jenkins_arm.sh: Use same Werror related options as on other builds
Change-Id: I45ab11b461a35923853f38b5bedd5025f53cc5b5
2018-08-01 17:42:06 +02:00
Harald Welte 7869baf843 Deprecate ipa_ccm_idtag_parse() with ipa_ccm_id_{get,resp}_parse()
In the past, the function ipa_ccm_idtag_parse() was used to parse
the payload of IPA CCM ID RESP packets.  However, the function was
based on a possible misunderstanding of the message encoding, and
callers actually counted the first (upper) length nibble as part
of the header and passed a pointer to the second
(lower) length nibble of the first TLV into this function.  As such,
it was unfixable, and had to be replaced with a new function called
ipa_ccm_id_resp_parse().  At the same time, we also add
ipa_ccm_id_get_parse() to parse the slightly different format of
the IPA CCM ID GET payload.

We can never be 100% sure what is "correct", as our understanding
of the protocol is entirely based on protocol analysis, without any
official documentation available.

This patch also introduces unit test coverage for both of the new
functions.

Revert "ipa: Add libosmogsm.map entry for ipa_ccm_idtag_parse_off"
This reverts commit 7f31c90b80.

Revert "ipa: Properly parse LV stream of a ID_GET request"
This reverts commit f558ed4bb9.

It introduced a function/behavior that was not originally intended:
The parse of IPA CCM ID GET (8bit length followed by 1 byte tag
and variable-length payload) instead of the IPA CCM ID RESP (16bit
length followed by 1 byte tag and variable-length payload).

Change-Id: I1834d90fbcdbfcb05f5b8cfe39bfe9543737ef8f
2018-08-01 13:38:17 +02:00
Harald Welte 48fd019b43 cosmetic: More context / naming / comment for test_idtag_parsing()
Change-Id: I1ebeba2067549e0dd1541fa84715d44321ff3b43
2018-07-31 20:19:49 +02:00
Harald Welte 6db529aedd import oap_client_test from osmo-sgsn
As oap_client has moved from osmo-sgsn to libosmogsm, it is only fair
that the related unit test shall also be moved here.

Change-Id: I9d64e10b4bacac9b530cf077841bad762fc6d558
2018-07-30 18:24:49 +02:00
Harald Welte 9b04c17c7a oap_client: Rename symbols with osmo_ prefix
As we're moving this to a common/shared library now, we need to use
the osmo_ namespace prefix for symbol names, struct/type names and
constants.

Change-Id: Ie36729996abd30b84d1c30a09f62ebc6a9794950
2018-07-30 12:50:51 +02:00
Harald Welte fdd366ed1b import oap_client into libosmogsm
This imports the code from osmo-msc 6afef893e17bce67e4d4119acd34d480ed03ba77
with minimal changes to make it compile.  Symbol renaming to osmo_
prefix is done separately in a follow-up patch to have a as-clean-as-possible
import first.

Change-Id: I9bc38102318da02d1fe46ef516df3cfd6bf8e3da
2018-07-30 12:16:11 +02:00
Vadim Yanitskiy baed91709c vty/vty.c: remove dead unused tall_bsc_ctx
Change-Id: I160728544c0effe45757df22f1ff2314fcb13dd1
2018-07-30 03:43:00 +07:00
Harald Welte 7ecc4a3171 04.80: New gsm0480_gen_{reject,return_error}() functions
Add functions to generate TS 04.80 (supplementary services)
Reject and ReturnError components.

Change-Id: I6e5ee39c3d03364f7833ec717593d5ddb0a4c5f9
2018-07-29 14:39:36 +00:00
Harald Welte b0d9594081 USSD: Introduce gsm0480_gen_ussd_resp_7bit()
Contrary to the existing gsm0480_create_ussd_resp(), the new function
only generates the value part of the FACILITY IE, and not the IE
Tag/Length or the 04.08 L3 header.  This is needed in the context of
GSUP-encapsulated USSD, as here we don't work with L3 messages, but
only pass on the FACILITY IE value.

Change-Id: Ide240279240322f643e142229eb7829f538c6314
2018-07-29 14:39:36 +00:00
Harald Welte 88fa5a3e1e gsm0480: Factor out msgb allocation helper function
Change-Id: If25b467481023eadaaf3f78157eceff4b81d24d2
2018-07-29 14:39:36 +00:00
Alexander Couzens 49865053bc ctrl/vty: fsm: use correct element when iterating over fsm->proc.children
Fixes crashes when using vty `show fsm-instances all`
when fsm children are present.

Change-Id: I4ae0bee7f7f57ec6675cfb52ca6cf0d523d15362
2018-07-29 14:35:00 +00:00
Neels Hofmeyr 95fdbc14ff cosmetic: osmo-sim-test.c: use memcpy instead of strncpy
gcc 8.1.0 complains that the terminating \0 is not copied by strncpy, while
this code intends to do exactly that. Use memcpy instead.

Change-Id: I8d66fa22502c04d11ae153b9856d7e54f3492dd6
2018-07-27 18:15:44 +00:00
Neels Hofmeyr 1cea7b5a97 fix strncpy bugs in socket.c
Change-Id: Iddf36d26b23dcef4f9b291fd7ead1907e38c3486
2018-07-27 18:15:44 +00:00
Neels Hofmeyr ebe4ef7383 fix strncpy bugs in gsm/ipa.c
Change-Id: I423a24c55c9b9aa6fc8f501df94fe54c71ee2b2b
2018-07-27 18:15:44 +00:00
Kevin Redon 0bc3b83654 GSMTAP: add SIM sub_types
In SIMtrace 1 the ATR was sent the same way as an APDU.
The ATR is not an APDU, and could be mis-interpreted as valid APDU.
This change allows to make the difference between actual APDU and
the ATR, but also adds sub_types for future SIMtrace 2 use cases.

Change-Id: I5bd0dff5a4a90cfe96d9c4f3dec6657e1d85bf7a
2018-07-27 17:19:47 +00:00
Pau Espin 924ef0bc72 Bump version: 0.11.0.91-9d4a3-dirty → 0.12.0
Change-Id: I7e66432f37e13fd4c31389e3d89593fa0981e58f
2018-07-27 17:31:47 +02:00
Pau Espin 9d4a36e060 logging.c: Fix whitespace typo
Change-Id: I943763e175dca6f3078923a494b052319b78574d
2018-07-26 11:55:51 +02:00
Pau Espin d51c98e7bf logging_vty: Simplify code in config_write_log_single
Since we ignore "logging level CAT everything" in logging_level_cmd, we
can never run into the case in which we have loglevel==EVERYTHING, so we
can simplify this code and make it esier for later removal of everything
keyword.

Change-Id: I4e76c65a11cc22616c6dfc632435617ebb861c03
2018-07-25 18:51:32 +00:00
Pau Espin 53a1e49354 logging: log_vty_command_string: Fix undercount of buf alloc size
Change-Id: I7aca0ce3d2981001e8081f7cee0dea3e2aaf8f7c
2018-07-25 18:51:20 +00:00
Alexander Couzens 9af7076b01 stats_statsd: sanitize statsd name
The statsd protocol use ':' as seperator between name and value.
It's not allowed to use the seperator in a name. Replace ':' with '.'
before sending the packet to the statsd server.

Change-Id: Ib46d08481e8ca04afd97cb9ae241e4e39c91ad66
2018-07-25 18:45:48 +00:00
Daniel Willmann d910a35227 stats_vty: Add asciidoc sections between the different counters
Change-Id: Ie37be744abd8c47211d64877bcd17f94465bd423
2018-07-24 20:01:26 +02:00
Harald Welte 83361bd963 gprs_ns.h: Declare gprs_ns_cause_str() which already existed in c file
Change-Id: Ia95f0cc8d110f95814173bb5a1c11bd85d8cd533
2018-07-22 15:14:58 +02:00
Pau Espin dfc52a1d5e rate_ctr: Improve logging
Previous logic regarding logging of verification and mangling of
rate_ctr groups made it difficult to debug when an issue occurrs.

Change-Id: I992d165cab5ee6ca9b5b7e4a2210a0951954bd34
2018-07-21 08:22:57 +00:00
Pau Espin 421068e643 tests: codec: ecu_fr: Add buffer with unequal XMAXC values
This buffer verifies that all XMAXC fields must be zero before the
entire buffer is considered as silent by osmo_ecu_fr_conceal().

Change-Id: I14a192d001b5e167437cedbe76a1a3dd84dde35c
2018-07-21 07:40:20 +00:00
Pau Espin bbccca60d6 tests: codec: ecu_fr: Print XMAXC fields
This makes it easy to debug how XMAXC fields are decreased every
iteration in osmo_ecu_fr_conceal().

Change-Id: I678d4be5e0b15b05873b0d3bf5ea5bbee7bef839
2018-07-21 07:40:20 +00:00
Pau Espin 9bb966afb0 libosmocodec: FR err concealment: Fix too many silent frames generated
As stated in its own documentation, reduce_xmaxcr_all() should only
return true when ALL XMAXC fields return true. However, previous
implementation returned true when at least one of them returned true.

As a result, if any of the sections is silent (for instance because one
of the bursts was lost), the whole frame is silenced, returning a zeroed buffer.

Related: OS#2700
Fixes: 40def49ac4 ("libosmocodec: implement ECU (Error Concealment Unit) for FR")
Change-Id: I1624b7c6574f53d0593a61645d4fdc5d56cabe96
2018-07-21 07:40:20 +00:00
Alexander Couzens ab383e6d27 vty: initialize termios before using it
valgrind complains about using unitialised bytes in syscalls.
I could imagine this happens when tcgetattr fails to set termios.

Change-Id: I9d165911fa3127afa8f836fa5c5c2e14a949474a
2018-07-20 20:40:48 +00:00
Neels Hofmeyr 59f4caf4ef add osmo_sockaddr_to_str_and_uint()
This came from osmo-bsc refactoring patch I82e3f918295daa83274a4cf803f046979f284366
https://gerrit.osmocom.org/#/c/osmo-bsc/+/9671/6/src/osmo-bsc/gsm_data.c@1708

Add regression test in utils_test.c.

Change-Id: I1f2918418c38918c5ac70acaa51a47adfca12b5e
2018-07-20 14:02:21 +00:00
Neels Hofmeyr 1504211fdc utils_test: check stderr to catch sanitizer issues
Recent OS#3407 shows that we should verify stderr to catch sanitizer failures.
(They might not always be ignorable like that one.)

Change-Id: Ic9e437a1cc96ae081e0fd6a9b6e3156987e14c0c
2018-07-20 14:02:21 +00:00
Neels Hofmeyr 6979c54793 utils_test: fix isqrt_test calculation range
Multiplying the uint16_t x by itself seems to default to be calculated in
int32_t range, while it obviously needs uint32_t. This causes sporadic
sanitizer barfs:

    Testing integer square-root
    utils_test.c:445:18: runtime error: signed integer overflow: 60369 * 60369 cannot be represented in type 'int'

The final result is still correct, because it is in fact interpreted as uint32_t.

Cast to uint32_t to make sure the sanitizer doesn't complain.

Related: OS#3407
Change-Id: I83c14e38deaa466d977ee43c9420534ed90f090d
2018-07-20 14:02:21 +00:00
Pau Espin f81d03f7dd libosmocoding: clarify return values for TCH decoding functions
Change-Id: I7d6c61e6a1b5d1fae26f385b420ff55246c4b62f
2018-07-19 18:30:07 +02:00
Pau Espin b885ef88c1 tests: ctrl: Test received ERROR messages are handled correctly
Change-Id: I3c8e95aaa1ca222d4cd1395e548f8461bf9d4cd6
2018-07-16 17:56:25 +00:00
Pau Espin 59e6059447 ctrl: ctrl_handle_msg: Avoid sending back received ERROR msgs
Change-Id: I396fd1e7548beea31b2b7aa9f764edb765b02941
2018-07-16 17:56:25 +00:00
Pau Espin 239ed3b3ee ctrl: Introduce ctrl_cmd_parse3 API
Callers require to know whether the returned ERROR cmd was received or
generated locally, in order to send it or do something with it locally.

Related: OS#3394

Change-Id: Ide9170e5c31967c353f8fe4e8227e64130b91eae
2018-07-16 17:56:25 +00:00
Alexander Chemeris ed7d2ddb15 coding: Documentation typo fix.
Change-Id: I6ca873b3decaf50e7b79b5ab2269919c862a4fe0
2018-07-14 21:12:47 +02:00