Commit Graph

2356 Commits

Author SHA1 Message Date
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
Vadim Yanitskiy fd744ceeae gsm0480: move SS request length check to parse_ss()
Change-Id: I8e7ce5bd97f3a8731924264c92afb9a7183937dc
2018-01-17 10:45:40 +00:00
Vadim Yanitskiy 7689e0f1a2 gsm0480: pass exact GSM 04.80 payload length to parse_ss()
Change-Id: I9608d4ad16d7581320615c140beaac36628c31a4
2018-01-17 10:45:40 +00:00
Vadim Yanitskiy 44ebb939eb gsm0480: add specification reference to SS message type
Change-Id: Iff0210e995053e270939a774db33f55b22545204
2018-01-17 10:45:40 +00:00
Vadim Yanitskiy 394447bb4b gsm0480: handle GSM0480_OP_CODE_PROCESS_USS_DATA
Change-Id: I470290c2b544555e53cedd849b1d6a961db7b5a4
2018-01-17 10:45:39 +00:00
Vadim Yanitskiy 511426de0a gsm0480: handle USS_NOTIFY and USS_REQUEST with PROCESS_USS_REQ
Change-Id: If7cc6a966dfc17d37e22338ecc1f239f908a9f2e
2018-01-17 10:45:39 +00:00
Vadim Yanitskiy 7f16c443bc gsm0480: handle GSM0480_CTYPE_RETURN_RESULT
Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
2018-01-17 10:45:39 +00:00
Vadim Yanitskiy c30431ffc7 gsm0480: parse GSM0480_MTYPE_FACILITY separately
Change-Id: I6e029c436a50fa8c2823ea39c5d123ee701becfa
2018-01-17 10:45:39 +00:00
Vadim Yanitskiy 01b85724af gsm0480: handle UnstructuredSS Request with DSC != 0x0F
According to GSM 04.08, 4.4.2 "ASN.1 data types":
the USSD-DataCodingScheme shall indicate use of
the default alphabet using the 0x0F value.

Previously, the UnstructuredSS Request messages with not
default alphabet were not being handled. Let's fix this.

Change-Id: I73d602f6f20b0afe7600d16bbd432069ae7be788
2018-01-17 10:45:39 +00:00
Vadim Yanitskiy 5b0790df52 gsm0480: clean up the parse_process_uss_req() code
This change reduces the degree of code nesting...

Change-Id: I467f75794c5ac9df75c001245b18bbdfcfaadd88
2018-01-17 10:45:39 +00:00
Vadim Yanitskiy fa6c2b9b53 gsm0480: fix USSD OCTET STRING length confusion
According to the GSM 04.80 (version 5.0.0) specification Annex A
"Expanded ASN.1 Module "SS-Protocol", the maximum size of a USSD
OCTET STRING is 160 bytes.

Thus according to ETSI TS 123 038 (version 10.0.0) specification
6.1.2.3 "USSD packing of 7 bit characters", in 160 octets, it's
possible to pack (160 * 8) / 7 = 182.8, that is 182 characters.
The remaining 6 bits are set to zero.

This change defines both mentioned values:

  - GSM0480_USSD_OCTET_STRING_LEN  160
  - GSM0480_USSD_7BIT_STRING_LEN   182

keeping the old MAX_LEN_USSD_STRING 'as is' due to compatibility
reasons. Now the new value is used for ss_request structure, while
old one is still used for deprecated ussd_request structure.

Change-Id: I6dead74f9ecea079752ff2400cdaf7c30187784e
2018-01-17 10:45:39 +00:00
Sergey Kostanbaev 04ee9c04f4 gsm0480: skip length check for 'RELEASE COMPLETE' message
According to GSM 04.80 Section 2.5 'Release complete' Table 2.5,
the 'RELEASE COMPLETE' message payload is optional, so let's drop
the length check in gsm0480_decode_ss_request() for this type.

Change-Id: I63b7f8ce403169a9dbdbdb031db16693de2196d6
2018-01-17 10:45:38 +00:00
Max d00a43f148 Log lapd_datalink state on errors
It's not very useful to get just the raw pointer address in case of
lapd_datalink receive error. Log it's state in addition.

Change-Id: Ie8c5df262312f886f509113f2707e36811df3bd5
2018-01-16 17:07:45 +01:00
Philipp Maier 40def49ac4 libosmocodec: implement ECU (Error Concealment Unit) for FR
When a bad GSM voice frame is received, it's being replaced
by a silence frame. This may cause unpleasant audio effects.

This change implements a functionality to craft a replacement
frame from the last known good frame. Currently, only FR is
supported, support for other codecs may be added latter.

Change-Id: I06a21f60db01bfe1c2b838f93866fad1d53fdcd1
2018-01-15 20:12:03 +00:00
Vadim Yanitskiy c0771d62c1 ussd_test.c: fix rc / len debug output confusion
Both len and rc values were swapped in the test output.

Change-Id: Iebd82531c6ced5d16b15dad4ff4ce654c82db309
2018-01-13 03:21:08 +06:00
Neels Hofmeyr bb62cbc099 logging-gsmtap: send only basename of source file
GSMTAP doesn't have a lot of space for the source file name. It is better to
send only the basename of the file, because only the first bit of a long path
may not convey the source file at all, needing guess work from the line number.

Before:  "Source File Name: ../../../../src/libosmocore/src"
After:   "Source File Name: telnet_interface.c"

Change-Id: Ie8fc9e782bcf8fa6e2e957d02e7d73c3a7c2bca8
2018-01-12 16:55:18 +00:00
Max 309d0e5483 Deprecate gsm48_construct_ra()
It's just a tiny wrapper around gsm48_encode_ra() with less strict type
signature.

Related OS#1640
Change-Id: I79d6d1133afbf32e891a6b0e3a244c6885ea9614
2018-01-12 14:15:03 +00:00
Max c90f40a277 Allow multiple 'log gsmtap' sinks
Previously we've checked for existing log target with a given hostname
from vty code but it was ignored inside the check so only the very first
'log gsmtap' entry was enabled while the rest were silently ignored.

Change-Id: I8fd8bda9e07d403a54735da30addb742e56538a2
2018-01-12 14:06:02 +00:00
Max 68bf16ab6f log: print loginfo assertions source
Print which function has triggered assert_loginfo(). It's handy in
debugging logging-related issues in libosmocore.

Change-Id: I8418d0c431106f50aa8779cd89396f02373304ad
2018-01-12 13:57:49 +00:00
Stefan Sperling 1e50e2ad48 TLVP_PRESENT() should not return TRUE after tlv_parse() fails.
If the length provided in the patcket exceeds the buffer length,
tlv_parse() returns -2 but leaves tlv.val and tlv.len initializd.

Many callers of tlv_parse() do not check its return value, but
rely on TLVP_PRESENT() to see if a particular TLV was parsed
successfully. By clearing tlv.val and tlv.len we make it less
likely that those callers will use an overlong TLV length value.

Change-Id: I4dda6938e1650b4bcaac45809a4763f86f5a9794
2018-01-12 13:48:59 +00:00
Neels Hofmeyr ffad574a4b gsm: add gsm0808_speech_codec_type_names
Used for logging Speech Codec List entries in osmo-bsc, during handover
decision.

Change-Id: Ie6418d16db333188e9bcd2b32b7216f277ae8832
2018-01-12 05:34:05 +01:00
Max e29ec85375 Use existing function for TLLI encoding
Use bssgp_msgb_tlli_put() instead of copy-pasted code.

Change-Id: I06d60566a19dcae701f8648c19fbd8db6d586f77
2018-01-08 14:07:47 +01:00
Max f1ad60e4d8 Add function to properly encode RAI
Add gsm48_encode_ra() which takes appropriate struct as [out] parameter
instead of generic buffer. Using uint8_t buffer instead of proper struct
type prooved to be error-prone - see Coverity CID57877, CID57876.

Old gsm48_construct_ra() is made into tiny wrapper around new
function. The test output is adjusted because of the change in function
return value which was constant and hence ignored anyway.

Related: OS#1640
Change-Id: I31f9605277f4945f207c2c44ff82e62399f8db74
2018-01-08 13:02:07 +00:00
Max e1a511b031 coding: move eB adjustement to appropriate place
As a leftover from code move from OsmoBTS we have eB adjustement outside
of eB check in gsm0503_tch_burst_map() which is rightfully noted by
Coverity. Let's fix this by moving the adjustement under the
corresponding if.

Change-Id: I385cd6ffea4d13ef911910fc87c92b73809888a2
Fixes: CID57691
2018-01-05 10:12:35 +00:00