Commit Graph

2379 Commits

Author SHA1 Message Date
Martin Hauke 13e7f05611 build: Ensure all .pc files are installed
Change-Id: I824e63087021adfda81bd0f867a3fdb5e9efcf7a
2018-02-14 00:47:19 +00:00
allesklar2 eb18282031 gsmtap.h: define TETRA DMO mode channels
Change-Id: I98976c0ff16a69b2508a79259ed1aeaec51e7549
2018-02-14 00:41:33 +00:00
Stefan Sperling 1859515c69 Add helper functions for ACC bit flags in rach control IE.
Add inline functions to manipulate and query ACC flag bits
in the rach_control.t2 and rach_control.t3 octets.
These function definitions also serve as documentation of
the purpose of rach_control.t2/t3.

Change-Id: I8f0a65c2980f86eb5c43f3bebe727f4d4d973163
Related: OS#2591
2018-02-13 15:11:20 +01:00
Harald Welte 554780836f Add GSM 04.08 type-of-number / numbering-plan-id definitions
Change-Id: Idd8d8a7a1c7f0b6cb9318e4f19ebadb415df2ed1
2018-02-09 22:40:09 +01:00
Harald Welte 4bfa171e92 debian/control: Fix Vcs-Browser URL
Change-Id: I89bff8fcb8e0b7c0a0e415d4eee1636c21b8f8de
2018-02-09 12:12:03 +01:00
Harald Welte ebd2b0f405 osmo_msgbdump_{l2,l3}(): Proper typecast
This avoids compiler warnings like

/tmp/work/sysmobts_v2-poky-linux-gnueabi/osmo-pcu/0.4+gitAUTOINC+4c112dc5a6-r1.18/recipe-sysroot/usr/include/osmocom/core/msgb.h: In function 'const char* msgb_hexdump_l2(const msgb*)':
error: invalid conversion from 'void*' to 'const unsigned char*' [-fpermissive]
    return osmo_hexdump(msgb_l2(msg), msgb_l2len(msg));

which we've been getting in osmo-pcu builds on some platforms.

Change-Id: I0ec652a1a569ec1507d8411cf1ef87afabcca799
2018-02-09 10:28:13 +00:00
Harald Welte 6590044337 Revert "fsm: do not terminate child FSMs early"
This reverts commit 5ec91980ac.

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-09 10:01:31 +00:00
Harald Welte 4e4521b3d5 Revert "Use python 3 for utilities"
This reverts commit 76c6c50405, which broke the obs builds. I'm really starting to get annoyed by ongoing python related breakage without ever fixing any bugs!

Change-Id: I4d76e897d4f746ff9ea4e06f2efc708a12cc2944
2018-02-09 08:49:26 +00:00
Philipp Maier 5ec91980ac fsm: do not terminate child FSMs early
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-09 02:25:58 +00:00
Harald Welte 572177063d msgb: Add msgb_hexdump_{l2,l3}() to dump l2 or l3 part of message buffer
Change-Id: I98e85397fb541ee0fd711f2e1852f63f3bb87359
2018-02-09 02:21:34 +01:00
Harald Welte bf383a1d83 tlv_parser: Report *first* occurrence of repeated IEs
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-09 02:02:42 +01:00
Pau Espin 6de34ee46b tests: utils_test: Fix test failure when compiling with -O0
It seems with default flags in_buf was being memzeroed by the compiler.
When compiling with -O0, that's not the case anymore and printf prints
after first 16 bytes, printing extra garbage which doesn't match the
expected output.

Change-Id: I736c1e4d625f647d3bb794fa717256e9dbf36e87
2018-02-08 09:41:36 +00:00
Pau Espin 41911d0380 tests: coding_test: Fix compilation with -O0
inline keyword is a hint for the compiler to inline the function, but
it's not mandatory. If no static or extern is specified, the definition
is only visible in the current unit but the identifier still has
external linkage.
When running with -O0 it seems the compiler (gcc 7.2.1) decides to use
the external linkage but at the same time it seems it's not generating
the function symbol. Fix it by explicitly stating that we want to use
static linking for this function.

coding/coding_test.o: In function `test_xcch':
libosmocore/tests/coding/coding_test.c:86: undefined reference to `dump_ubits'
libosmocore/tests/coding/coding_test.c:87: undefined reference to `dump_sbits'

Change-Id: I18018adec05ce1c2ddbca38653311d74c7454ce8
2018-02-08 09:41:35 +00:00
Max 76c6c50405 Use python 3 for utilities
There're no python2-specific code in there so we can switch right away
without waiting till 2020 for python 2 deprecation.

Related: OS#2819
Change-Id: I8d34aed124b00c5dd2ab1bcc84bbfa8c620282cc
2018-02-08 09:31:04 +00:00
Neels Hofmeyr 22772cc529 vty: fix 'logging print file' output
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-06 02:04:51 +01:00
Max 80f4c4eb08 GSUP: change osmo_gsup_encode() return type
* 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-05 13:03:42 +01:00
Max 18c014de67 utils: add helper wrapper for osmo_strlcpy()
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-02-05 11:34:14 +00:00
Harald Welte f1076ed75a gsm48_hdr_msg_type(): SS is in the same group as MM/CC
Change-Id: I1ddadeacced9650885f454b81f3f0df531ea1e5d
2018-02-03 21:17:43 +01:00
Harald Welte 143aed7fa6 gsm48_hdr_msg_type[_r99]: Fix bit-masks
TS 24.007 is quite clear: The upper two bits of the message type
octet are *not* part of the message type in any of the L3 protocols
which implement sequence numbers.  it doesn't matter if it's R98 or
R99, or whether the sequence number is 1bit or 2bits wide.

Related: OS#2908
Change-Id: Iec875a77f5458322dfbef174f5abfc0e8c09d464
2018-02-03 21:17:43 +01:00
Harald Welte cd82710be7 gsm_04_08.h: Reduce T310 default to 30s.
3GPP doesn't specify a network-side T310 default, but waiting for 180s
(3 minutes!) for the next message after CALL CONFIRMED is clearly way
too long and will just use radio resources for no good reason.

Change-Id: Ia52f9358bc86b23c72af9c80e2fff5cb0004b57a
Related: OS#2884
2018-01-27 09:48:07 +01:00
Harald Welte e50b00911b gsm_04_08.h: Clearly annotate timers that don't have a 3GPP Default value
Change-Id: I44fffaec1f7c0d819aa2ebc85e97f19581fc689c
2018-01-27 09:48:07 +01:00
Harald Welte d60e17ab0e SMS: Add value_string for TS 04.11 CP and RP state
Change-Id: I1b2f6fc6f455b0ba2a5732c567a4867bca97c3b0
2018-01-24 16:50:59 +01:00
Harald Welte ea0bc9608c gsm48_pdisc_names: Use conscise, short names
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-24 16:50:59 +01:00
Max e41ad4d008 jenkins: move make invocation into shared function
Change-Id: Ied8c1085b8bee2cc4fa65592e805838b8cdae287
2018-01-24 11:33:19 +00:00
Max 8e8378a84d jenkins: remove obsolete scripts
* jenkins.sh is superseded by jenkins_amd64.sh
* jenkins-arm.sh is superseded by jenkins_arm.sh

N. B: this requires I76dfc11a05007ae5c6e0554fe8132695b67cccaa in
osmo-ci.

Change-Id: Ifbd253cff88c3ac18e469c34e79f1501501e1657
2018-01-24 11:33:10 +00:00
Philipp Maier 2a06a491b1 fsm: add functions for unlinking and changing parents
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-24 12:03:28 +01:00
Vadim Yanitskiy a55fe9f322 libosmocoding: use frame length definitions from codec.h
Since commit e094157e12, TCH frame
length definitions were added to libosmocodec.
No need to define them again.

Change-Id: Id8c6132534e36ea1e368432bb259fd4f3a531f90
2018-01-24 09:17:37 +00:00
Vadim Yanitskiy 9a232fd91b libosmocoding: fix typo in library documentation
Change-Id: I535d4eba5bad9094a1e9e662f32cd2bfac5b0cef
2018-01-23 18:16:02 +00:00
Philipp Maier 91cfda81b5 socket: use inet_ntop() instead of inet_ntoa() in osmo_sock_local_ip()
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-22 17:04:29 +01:00
Max 49382720f8 GSUP: don't fail test on first error
Instead of forcing test failure via assert on first error encountered,
let it run until completion and print detailed error log. This
simplifies troubleshooting by letting user to see more errors from
single run and more details on each of the errors. Update test output
with explicit test results.

Change-Id: I016a28fe04f7b194e22c15e936095004c5f079d1
2018-01-22 15:32:28 +00:00
Philipp Maier 8b7975b6aa socket: fix socket leak in osmo_sock_local_ip()
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-22 15:00:21 +00:00
Vadim Yanitskiy bd33a9568e tests/ussd: prevent uninitialized memory access
Previously an incorrect length value was passed to both
gsm_7bit_decode_n_ussd() and gsm_7bit_encode_n_ussd()
functions during test_7bit_ussd() execution, due to:

   octets_written = strlen(decoded);

The problem is that a 7-bit encoded string takes less memory
than its 8-bit equivalent. So, here strlen() returns one-byte
bigger value, that octets_written is. This then causes the
uninitialized memory access.

Found using Valgrind:

Conditional jump or move depends on uninitialised value(s)
   at 0x506DCCC: gsm_7bit_decode_n_ussd (gsm_utils.c:248)
   by 0x40134B: test_7bit_ussd (ussd_test.c:104)
   by 0x400F5D: main (ussd_test.c:161)

Conditional jump or move depends on uninitialised value(s)
   at 0x506DBB7: gsm_7bit_decode_n_hdr (gsm_utils.c:220)
   by 0x506DC9E: gsm_7bit_decode_n_ussd (gsm_utils.c:246)
   by 0x40134B: test_7bit_ussd (ussd_test.c:104)
   by 0x400F5D: main (ussd_test.c:161)

Conditional jump or move depends on uninitialised value(s)
   at 0x506DBCB: gsm_septet_lookup (gsm_utils.c:153)
   by 0x506DBCB: gsm_7bit_decode_n_hdr (gsm_utils.c:224)
   by 0x506DC9E: gsm_7bit_decode_n_ussd (gsm_utils.c:246)
   by 0x40134B: test_7bit_ussd (ussd_test.c:104)
   by 0x400F5D: main (ussd_test.c:161)

Change-Id: Ic31805b6a5a917dfc6284edba6ffdd21246ac20c
2018-01-22 10:35:53 +00:00
Max 3da793857d Embedded: add sercomm stubs
The sercomm functions are unavailable in case of embedded build. Add
stub and link the tests against it.

Change-Id: I9bc5cb2f822b1a3ffdc6ec29f46b6bac8288314e
2018-01-21 19:08:05 +00:00
Max 89c8c4027b Embedded: disable stats test
As of 67bdd80a96 the stats.c is
effectively disable so we should disable the corresponding tests as
well.

Change-Id: I42ff7a6619c0a5926fdc2ec779cf04689c567e15
2018-01-21 19:05:00 +00:00
Harald Welte 0bbf67dfd3 MNCC: Add MNCC to string dumper
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-19 23:52:42 +01:00
Neels Hofmeyr c6fd24576c logging vty: add 'logging print file (0|1|basename)' cmd
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-19 15:46:49 +00:00
Neels Hofmeyr 0e2a94326e logging: allow to log only the basename of each source
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-19 15:46:49 +00:00
Neels Hofmeyr bd7bd3947d logging: separate the '<000b>' subsys from filename logging
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-19 15:46:49 +00:00
Max 1ac277dcef jenkins: add dispatcher script
Similar to the way we test osmo-bts, add simple dispatcher script which
calls appropriate test depending on a given parameter. This will allow
to simplify the job description. While at it, also rename jenkins-arm.sh
-> jenkins_arm.sh to match the OsmoBTS.

The older scripts are preserved for compatibility and shall be removed
once we update job description in osmo-ci.

Change-Id: I2955e866bce4f000a53369bd601a346c36c82468
2018-01-18 19:17:45 +01:00
Neels Hofmeyr c4759885d7 cosmetic: logging: if color is disabled, don't print ""
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-17 23:16:16 +00:00
Philipp Maier 23d3161d4b fsm: fix double llist_del in osmo_fsm_inst_term()
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-17 13:33:27 +00:00
Neels Hofmeyr 5e518b5b4c fix -Werror build: logging.c: always use literal with snprintf
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-17 13:27:55 +01:00
Neels Hofmeyr e653472573 logging: color the log category according to level
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-17 11:13:58 +00:00
Neels Hofmeyr f3fa3694f5 logging: color the log level
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-17 11:13:58 +00:00
Neels Hofmeyr 886e548ab0 logging: add ability to log the log-level with API and vty
Log the log level string after the category name, if enabled.

The default behavior remains unchanged.

Change-Id: Ie6be365cfa6aeabdf115bff19bac198440c9adf1
2018-01-17 11:13:58 +00:00
Vadim Yanitskiy 3cafc06014 gsm0480: parse optional IEs for RELEASE COMPLETE message
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-17 10:45:41 +00:00
Vadim Yanitskiy b92a27f694 gsm0480: parse all SS info elements in a message
Some SS messages (e.g. RELEASE COMPLETE) may contai multiple
IEs (Information Elements). Let's parse them all.

Change-Id: I20cc59c25fdbda176bcf76437174cda829518d60
2018-01-17 10:45:41 +00:00
Vadim Yanitskiy ac3b6ac301 tests/ussd: fix wrong GSM 04.80 payload length
Previously the same length value was used for both ussd_request
and interrogate_ss payloads, despite they are different.

Change-Id: I90ae7c51b75dcdb9d8ee042af23d127e6db8771d
2018-01-17 10:45:40 +00:00
Vadim Yanitskiy b41c70f4e6 gsm0480: correct parse_ss_info_elements() declaration
Change-Id: I64df293188908c7eb10a61941db76656340d3a8e
2018-01-17 10:45:40 +00:00
Vadim Yanitskiy f07c58cb36 gsm0480: refactor gsm0480_decode_ss_request
Change-Id: Iba734db97ab516f8fce816c4e4225b97b93619f1
2018-01-17 10:45:40 +00:00