Commit Graph

2758 Commits

Author SHA1 Message Date
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
Alexander Chemeris 147051f1a1 coding: Fix (E)GPRS BER calculation to correctly account for puncturing.
Previously we didn't take into account puncturing and BER was always around
30% for GPRS/EDGE bursts because of they use puncturing coding unlike
"classical" GSM bursts.

Change-Id: I9da22e7051522d06d923fcec3b63cbed8db93910
2018-07-14 21:12:46 +02:00
Pau Espin f2cda621c0 gsm0808: Add value_string for encryption algorithms
Change-Id: Iadf6460c438d02c53c2eaa9e42d51844ad28859a
2018-07-12 20:58:23 +02:00
Pau Espin 40ad91330d ctrl: Fix parsing of ERROR recvd msgs with id=err
Our implementation generates ERROR CTRL messages with ID=error when it
is unable to parse a CMD. However, it doesn't account for them when
trying to receive and parse this kind of message. As a result, it will
return an ERROR message with a different description. This commit fixes
the old behaviour to success at parsing and returning the received
description to the caller.

Change-Id: I564ab1a7e845388f87accda44fbf165e5adc2480
2018-07-12 18:47:57 +00:00
Pau Espin 55088b76ce ctrl: Log CMD TYPE on invalid ID number
Change-Id: Ia890d4b841ef02342cc1cf7f5926866b040dc8ab
2018-07-12 18:47:57 +00:00
Philipp Maier cdd05816da gsm_08_08: gsm0808_permitted_speech does not have value strings
enum gsm0808_permitted_speech does not have any value strings. Lets
add value strings to make debugging easier.

Change-Id: I5b5612a5df2758b0137a34c17f7c8c2b3f07c806
2018-07-12 18:18:39 +00:00
Philipp Maier 5796a218db gsm_04_08: add function to get value string
The value string table gsm48_chan_mode_names[] lacks a function
to get the value string by a value. Lets add one.

Change-Id: I0757bcc278c140e18249e35864338e19cdaa3cf7
2018-07-12 18:18:39 +00:00
Neels Hofmeyr 5314c513f2 vty: fix use-after-free and memleaks in is_cmd_ambiguous()
vty_test: add test against ambiguous cmd causing use-after-free and memory
leaks. Add this test along with the fix, because the new test triggers the
memory use-after-free and leaks, causing build failures.

Add cmd_deopt_with_ctx() to allow passing a specific talloc ctx.

is_cmd_ambiguous(): keep all cmd_deopt() allocations until the function exits.
Add a comment explaining why. Before this, if a command matched an optional
"[arg]" with square brackets, we would keep it in local var 'matched', but we
would free the string it points to at the end of that loop iteration; upon
encountering another match, we would attempt to strcmp against the freed
'matched'. Instead of adding hard-to-read and -verify free/alloc dances to keep
the 'matched' accurately freed/non-freed/..., just keep all cmd_deopt() string
allocated until done.

Needless to say that this should have been implemented on a lower level upon
inventing optional args, but at least this is fixing a program crash.

Related: OS#33903390
Change-Id: Ia71ba742108b5ff020997bfb612ad5eb30d04fcd
2018-07-11 15:47:08 +02:00
Neels Hofmeyr 4e0add239f vty: cosmetic: cmd_deopt(): use talloc_strndup(), not memcpy()
Change-Id: Ibf870ae02be706f802482f7cff6589a70cde8320
2018-07-09 23:41:11 +02:00
Neels Hofmeyr f2d323ef0f vty/command.c: talloc from tall_vty_cmd_ctx, not NULL
Change-Id: Iaa409b4f63557c8fb028bbb322b5e7253393c05c
2018-07-09 23:41:11 +02:00
Vadim Yanitskiy 94c0031297 Don't enforce Python 2 for utilities
The conv_gen.py utility was tested against both Python 2 and 3,
so there is no need to enforce Python 2. Also, having:

  #!/usr/local/bin/python{2|3}

is a bad idea, because Python may be installed in a different location.

Change-Id: I6007d481047b584db13d6eda70fb99f11f9ddaa1
2018-07-02 20:30:31 +07:00
Harald Welte bc568d0b9f osmo_panic(): Annotate as __attribute__ ((noreturn))
In Change-Id I5a70eb65952cbc329bf96eacb428b07a9da32433 we redirected
all OSMO_ASSERT() via osmo_panic().  However, this caused various
applications to have build failures, as OSMO_ASSERT() now appeared
to be able to return to the call site.  Let's inform the compiler
explicitly that there's no return from osmo_panic().

Change-Id: I8adf4c7b0ee6a4581cef8dd4e9f6a1dfde70ee55
2018-06-29 20:32:57 +02:00
Harald Welte 459a180877 Don't call abort() directly, always use osmo_panic()
A loooong time ago, we introduced osmo_panic() as a wrapper around
abort().  The advantage is, that this wrapper can be overridden, and
that it will also work in embedded (bare iron) targets, where the
abort simply translates to an infinite loop.

Change-Id: I5a70eb65952cbc329bf96eacb428b07a9da32433
2018-06-28 10:57:42 +02:00
Harald Welte 79d49af93a jenkins_arch.sh: Exit with error on unknown architecture
The jenkins build job used to call this script using an "arch"
it doesn't understand.  This should have resulted in an error,
but it didn't as there was a missing "exit 1" statement :(

Related: OS#3360
Change-Id: Ib27c9ebaf2630c432b1923f8e14b36e7772a6033
2018-06-28 10:57:42 +02:00
Harald Welte cae93e51d9 jenkins_arch.sh: Accept "arm-none-eabi" as alias for "arm"
The jenkins build job is calling the script using "amd64" and
"arm-none-eabi", while the script expects "amd64" and "arm".

Let's add "arm-none-eabi" as an alias for "arm".

Closes: OS#3360
Change-Id: Idedd4778a63d67cdbf4f4d538bf4a225abb7547a
2018-06-28 10:57:42 +02:00
Harald Welte 1e78313e8e jenkins_arm.sh: Don't run 'make check' on embedded builds
If we're cross-compiling for arm-none-eabi, we cannot execute test
programs.

Change-Id: I64e88a31091b67c37c308c44013c42d4574d2312
2018-06-28 10:57:42 +02:00
Harald Welte 14c4c498b1 Fix embedded (arm-none-eabi) builds
Due to OS#3360, build testing for arm-none-eabi was unfortunately
skipped for a long time.  This is a number of fixes that make the
compile test pass again.

Related: OS#3360
Change-Id: I88e3c8e1a8786ca2a6a023b0d27c74be200a8588
2018-06-28 10:30:34 +02:00
Stefan Sperling f1e13d6081 return error to sender upon bssgp_tlv_parse() failure
Return "invalid mandatory information" error status to
the sender in case bssgp_tlv_parse() failed.
To avoid loops, do not respond with an error status to
STATUS PDUs which failed parsing.

Change-Id: If73719b75a94d6742bdefc9b6572525cb00a96ee
Related: OS#3178
2018-06-25 12:59:23 +02:00
Stefan Sperling 2b544b257f check bssgp_tlv_parse() return code in bssgp_rcvmsg()
The return code from bssgp_tlv_parse() was not checked for a parsing
error. In case of a parsing error the stored return code could have
been overwritten later in this function.

Explicitly check for a parsing error and log corresponding packets.

Change-Id: Id3d7c52ec3df2bcf4efcee0e0b14fe22ef96964e
Related: OS#3178
2018-06-25 12:20:43 +02:00
Neels Hofmeyr 60f3153125 add and tweak inter-BSC HO API
Add:
gsm0808_create_handover_detect()
gsm0808_create_handover_complete()
gsm0808_create_handover_failure()

To existing structs gsm0808_old_bss_to_new_bss_info and
gsm0808_handover_required, add a final 'more_items' flag that makes future
extensions API and ABI compatible.

Fix the msgb string for Handover Request Ack.

Extend some API doc comments.

Related: OS#2283 (inter-BSC Handover, BSC side, MT)
Change-Id: I03ee7ce840ecfa0b6a33358e7385528aabd4873f
2018-06-18 17:32:58 +00:00
Pau Espin 1eb270bda8 gsm: lapdm.c: Add missing new line char in notice log string
Change-Id: I92c78ea01570dc1f4be11b113c07f0aa3b342c8f
2018-06-18 19:23:11 +02:00
Harald Welte b1a35d63b9 gsm 04.80: Add value_string for component type and op code
Change-Id: I2615a88db5224d65f37c7cc505e183ec8b196e8a
2018-06-16 18:39:59 +02:00
Harald Welte 6a6a609309 gsup: Add value_string for Session State IE
In Change-Id I1cee271fed0284a134ffed103c0d4bebbcfde2a8 we added support
for a new session state IE, but we didn't add any value_string array
for string conversion of it.  Let's fix this.

Change-Id: I3d9f087786dc37c42498fa9a2be07483ec93ba7b
2018-06-16 11:11:08 +02:00
Daniel Willmann f1318fe371 Add function gprs_nsvc_state_append
A common function to append the nsvc state from osmo-sgsn or osmo-gbproxy

Change-Id: I7f0eaff7329ab98cad792d30b20ab053007aab85
2018-06-14 17:43:31 +02:00