Commit Graph

2676 Commits

Author SHA1 Message Date
Harald Welte 40f35212c7 Revert "osmo-config-merge: Add manual page"
This reverts commit 6dd00d876e.

Unfortunately, it seems older a2x versions don't support "-D" for
manpage generation:

All the osmocom master builds started to fail with:

make[2]: Entering directory '/build/deps/libosmocore/man'
a2x --doctype manpage --format manpage -D . osmo-config-merge.adoc
a2x: WARNING: --destination-dir option is only applicable to HTML based outputs
a2x: ERROR: "xmllint" --nonet --noout --valid "/build/deps/libosmocore/man/osmo-config-merge.xml" returned
non-zero exit status 127
Makefile:545: recipe for target 'osmo-config-merge.8' failed

Change-Id: I0f45362d3e978c328d962a5c0d883eade27b875c
2018-09-29 01:43:14 +02:00
Daniel Willmann 6dd00d876e osmo-config-merge: Add manual page
Change-Id: Ifaa5afe28779a805764caf76a89efb0a3169942e
2018-09-28 16:19:53 +02:00
Daniel Willmann 83c7134c7a osmo-config-merge: Fix some small issues
Allocate NULL context after exit_usage() calls and free it before exit
so * sanitizer is happy.
Also handle the error cases gracefully when a file is unreadable or
formatted wrong.

Change-Id: I966e63a3f7d0ff71ee0b88922aa3807d073aa232
2018-09-28 16:00:11 +02:00
Vadim Yanitskiy f7aec792f7 utils/osmo-config-merge: explicitly return from main()
This change fixes the following compiler warning:

  osmo-config-merge.c: In function ‘main’:
  osmo-config-merge.c:268:1: warning: control reaches end
                             of non-void function [-Wreturn-type]

Despite it isn't critical, let's get rid of this warning.

Change-Id: I7a80a85c8b3180dc086cd9fd20356aab16ea8100
2018-09-27 04:43:47 +07:00
Stefan Sperling 6afb3f5031 ensure unix socket paths are NUL-terminated for bind/connect
The unix(7) man page recommends that sun_path is NUL-terminated
when struct sockaddr_un is passed to a bind() or connect() call.
Non-NUL-terminated paths only need to be dealt with at the
receiving end of a UNIX domain socket.

Commit 896ff6d erroneously assumed otherwise.
This commit almost reverts 896ff6d: It only leaves the added
osmo_strlcpy() overflow check in place.

Change-Id: I6c4ac6b0a0eef4842beae4107f6f09f6cd29172a
Fixes: 896ff6db16
Related: OS#2673
2018-09-26 07:25:53 +00:00
Harald Welte eda6fe42a5 osmo-config-merge: Don't use C99 'for' loop initial declarations
The existing code passed gerrit build verification but failed the master
builds with the following error:

osmo-config-merge.c:148:4: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
    for (int i = 0; i < cur_indent - indent; i++) {
    ^
osmo-config-merge.c:148:4: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your
code

Change-Id: Ia29e85b648c1a427be88242306634efe890e250d
2018-09-25 22:52:22 +02:00
Harald Welte 0d67f483e2 logging_vty: Ensure writing well-formed config files
We want to have well-formed config files that print exactly one space
per VTY/config node level, and not two.

Change-Id: Ia75c7067284ea225cffe13ca71bad05a7747ae66
2018-09-25 20:25:30 +02:00
Harald Welte 81bfef931a Add new osmo-config-merge utility
This utility allows you to merge an incremental config "patch"
into an osmocom-style config file.

The patch file follows the same syntax as the original config file.

It works by appending the leaf nodes of the patch file to the respective
nodes of the input config file.

This process allows configuration file changes/updates to be performed
in a more stable/reliable way than by means of [unified] diff files,
as they break every time the context lines break.

osmo-config-merge doesn't suffer from this problem, as it understands
the tree-like nature of VTY config files.

NITE: This only works with configuration files that have proper
indenting, i.e. every level in the hierarchy must be indented excatly
one character, not multiple.

Change-Id: I61997a3668cc3a40d12ca023272f6d782e6fbefe
2018-09-25 20:05:02 +02:00
Philipp Maier 8515d035ae gsm0808: add function to convert AMR S15-S0 to gsm0408 settings
Add a function to convert S0-S15 bits to struct gsm48_multi_rate_conf,
which hold the codec settings for AMR.

Change-Id: I973736273c236eee84decf15868190e339c3fed4
Related: OS#3548
2018-09-25 15:32:29 +00:00
Philipp Maier b066305016 gsm_utils: add function to get value strings for gsm48_chan_mode
The enum gsm48_chan_mode has value strings, but no function to retrieve
those strings. Lets add one.

Change-Id: If715705e1ebdfcfdfae1c2099932f7bb8b3861a7
2018-09-25 13:07:45 +02:00
Neels Hofmeyr 5398911ddb vty: omit HIDDEN from vty reference
During 'show online help', the XML vty node dump, omit all commands marked
HIDDEN.

These commands were already hidden from the VTY reference prior to commit
I1f18e0e41da4772d092d71261b9e489dc1598923, because of broken/confusing bit and
boolean logic mixup. After that commit, HIDDEN commands end up in the doc.  So
practically, this patch here brings back the status quo of before above commit,
even though the previous code clearly "intended" to list HIDDEN commands in the
reference but failed to have that effect.

AFAICT the complete list of commands currently hidden is:

* osmo-bsc: bts/"training_sequence_code <0-7>",
* osmo-bsc: ts/"phys_chan_config PCHAN" for uppercase pchans;
* osmo-bts: bts/"rtp bind-ip A.B.C.D" which actually says
  vty_out(vty, "%% rtp bind-ip is now deprecated%s", VTY_NEWLINE);
* osmo-sgsn: 'reset sgsn state' used for SGSN testing.

Note that the osmo-sgsn build was broken by including hidden commands in the
vty reference, since one of its hidden commands had missing doc strings and
made osmotestconfig.py signal failure. This would fix that from the
hide-hidden-commands angle, and so would osmo-sgsn commit
I8b6e8615e409266910f2f76a10ced9ab33e4de91 from the fix-the-doc-strings angle.

Change-Id: I92c3c66ff69c186234276c64478d6342e061d25e
2018-09-24 19:01:42 +02:00
Neels Hofmeyr a7557fe0f5 vty list: fix deprecation/hidden bit logic
If a command is both hidden and deprecated, still don't show it for the 'list'
command.

We currently have no such nodes, as it seems, though.

Related: OS#3584
Change-Id: I07ec15cab057a3e09064e0420a69121ee8eb4253
2018-09-24 06:40:04 +00:00
Neels Hofmeyr cf8def25d5 vty reference: fix deprecation bit evaluation
In vty_dump_nodes(), make sure the bitwise & is evaluated first.

For the deprecation flag (0x1), the practical effect is most likely identical,
assuming that the boolean ! operator flips the first bit, so I expect no
visible functional difference. It still was confusing and wrong to look at.

Related: OS#3584
Change-Id: I1f18e0e41da4772d092d71261b9e489dc1598923
2018-09-24 06:40:04 +00:00
Vadim Yanitskiy e65c8bad46 vty/command.h: document and prettify CMD_ATTR_* flags
Since the CMD_ATTR_* flags are intended to be used in bitwise
operations, let's assign them proper values. Adding a new flag
(e.g. CMD_ATTR_FOO_BAR) could actually result in assigning 0x03
instead of expected (0x01 << 2).

Change-Id: I3b1badef830f7e6436a67673b5709ec33c060c68
Related: OS#3584
2018-09-24 13:02:07 +07:00
Philipp Maier 369015c535 gsm0808_utils: constify parameter
parameter cfg in gsm0808_sc_cfg_from_gsm48_mr_cfg() is used read only.
Lets add a const to make this clear to the compiler.

Change-Id: I31e8d273b070b0afc446a298299d4f502d6c396b
2018-09-21 09:07:42 +02:00
Philipp Maier 5f2eb15074 gsm0808: add function to convert amr gsm0408 setings to gsm0808
Add a function to convert struct gsm48_multi_rate_conf, which holds the
codec settings for AMR, to S0-S15 bit representation as defined in
3GPP TS 48.008 3.2.2.49

This resurrects change-id I4e656731b16621736c7a2f4e64d9ce63b1064e98
which was reverted in I9e0d405e303ed86d23703ca6362e958dddb2f861
due to gsm0808_test failing.

The test failure is fixed by properly clearing the struct
gsm48_multirate_cfg prior to running tests (add memset(0)).

Change-Id: Ia782e21c206c15e840226d79b4209d13658ee916
Related: OS#3548
2018-09-19 14:01:10 +00:00
Neels Hofmeyr 28fc078f9c logging vty: add 'logging level set-all <level>'
Add new command to once-off set each and every category to the given log level,
as discussed at length on the openbsc@ mailing list.

Show that it works in logging_vty_test.vty.

Change-Id: I4c3e4f786476cb813fdc0a7c64f30ee04758309d
2018-09-16 23:09:56 +02:00
Neels Hofmeyr dd8c73cc6d Revert "gsm0808: add function to convert amr gsm0408 setings to gsm0808"
This reverts commit 2fd4fe6aa1.

As shown in https://jenkins.osmocom.org/jenkins/view/master/job/master-libosmocore/475/a2=default,a3=default,arch=amd64,label=osmocom-master-debian9/console

This commit breaks gsm0808_test with:

stderr:
--- expout	2018-09-16 22:37:31.382280438 +0200
+++ /n/s/dev/make/libosmocore/tests/testsuite.dir/at-groups/21/stdout	2018-09-16 22:37:31.426281372 +0200
@@ -78,9 +78,9 @@
 Input:
  m4_75= 0   smod=  0
  m5_15= 0   spare= 0
- m5_90= 0   icmi=  0
+ m5_90= 0   icmi=  1
  m6_70= 0   nscb=  0
- m7_40= 0   ver=   0
+ m7_40= 0   ver=   6
  m7_95= 0
  m10_2= 0
  m12_2= 0
@@ -92,9 +92,9 @@
 Input:
  m4_75= 1   smod=  0
  m5_15= 0   spare= 0
- m5_90= 0   icmi=  0
+ m5_90= 0   icmi=  1
  m6_70= 0   nscb=  0
- m7_40= 0   ver=   0
+ m7_40= 0   ver=   6
  m7_95= 0
  m10_2= 0
  m12_2= 0
@@ -106,9 +106,9 @@
 Input:
  m4_75= 0   smod=  0
  m5_15= 1   spare= 0
- m5_90= 0   icmi=  0
+ m5_90= 0   icmi=  1
[...]

Change-Id: I9e0d405e303ed86d23703ca6362e958dddb2f861
2018-09-16 21:02:25 +00:00
Philipp Maier 2fd4fe6aa1 gsm0808: add function to convert amr gsm0408 setings to gsm0808
Add a function to convert struct gsm48_multi_rate_conf, which holds the
codec settings for AMR, to S0-S15 bit representation as defined in
3GPP TS 48.008 3.2.2.49

Change-Id: I4e656731b16621736c7a2f4e64d9ce63b1064e98
Related: OS#3548
2018-09-14 16:24:10 +02:00
Philipp Maier 4b081b1d88 gsm0808: fix wrong codec defaults for OFR_AMR_WB
3GPP TS 48.008 chapter 3.2.2.103 states that the configuration bits of
OFR_AMR_WB are coded as follows:

"S0, S2, S4 indicates the supported Codec Configurations. S1, S3, S5, S6,
S7 are reserved and coded with zeroes."

The current default setting of 0x3F violates this requirement. Lets set
the "forbidden" settings zu zero and keep only the allowed ones.

Change-Id: I4a481def59e9c98cfdcafc2b80c0ac7df0c14130
2018-09-14 09:14:08 +02:00
Neels Hofmeyr 9540c24058 logging vty: deprecate 'all', introduce 'force-all'
Add 'logging level force-all <level>' and 'no logging level force-all' as new
names for 'logging level all <level>' and 'logging level all everything'.

Resurrect the functionality of 'logging level all everything' -- even if it is
still deprecated because the name is confusing, it is now just an alias for
'no logging level force-all'.

Show in logging_vty_test.vty that we can now again lift the global logging
clamp, both with the new commands as well as with the deprecated ones.
Also show that 'force-all' is written back properly, if set.

Change-Id: I36f17c131cc70ce5a1aef62fd9693097de230cd4
2018-09-13 15:46:55 +00:00
Neels Hofmeyr 098038ab18 logging vty: write: check logging levels validity
Change-Id: If683b1272ad2d5b402b91c52c496aa7975bc6315
2018-09-13 15:46:55 +00:00
Neels Hofmeyr 7e0686c6b4 logging vty: deprecate the 'everything' keyword
The 'logging level all everything' has not had an effect for some time now. The
plan is to bring back its old functionality, but to keep it deprecated and
rather define a less confusing name.

* Deprecate 'everything'.
* Do not write 'everything' during 'write file' or 'show running-config', which
  we curiously still do until now.

BTW, the reason why we need to compose a complete list of categories for the
deprecated 'everything' command is explained in detail in the commit log for
I3b083f27e3d751ccec258880ae7676e9af959a63

Change-Id: Ib75fedb0572570a61bb34ee729a2af86cf5f16da
2018-09-13 15:46:55 +00:00
Neels Hofmeyr ba0762d6cb logging vty: rewrite 'logging level' vty cmd generation
Completely drop the implementations of log_vty_command_{str,description}().
These functions have been public API once, marked as deprecated since
c65c5b4ea0 (March 2017). I considered to keep
them, or reduce them to useless stubs, but it is quite silly, really. These
functions are completely and utterly useless outside of libosmocore. Any
program linking these deserves to fail.

Re-implement vty logging level command gen, in logging_vty.c. logging.c is
simply the wrong place for that.

Introduce logging_internal.h to share logging definitions to logging_vty.c
without publishing as API.

Introduce static gen_logging_level_cmd_strs() to compose a list of category
arguments with their descriptions for VTY commands. Use osmo_talloc_asprintf()
instead of the previous error prone and chaotic strlen() counting method.

Do not dynamically generate log level arguments, just keep static strings. We
are super unlikely to ever change the log levels we have.

No changes in logging_vty_test.vty: proves that there is no functional change.

All of this, besides introducing basic sanity, is cosmetic preparation to be
able to re-use the generic command generation code for arbitrary commands with
category or level args (for deprecated and new keywords).

Rationale: I want to hide 'all' and 'everything' from the VTY command
documentation, by means of deprecating. I first tried to simply define a
deprecated 'logging level CAT everything' command:

  logging level (all|rsl|rr|...) (debug|info|notice|error|fatal)
  logging level CAT everything                   # <- deprecated and hidden

But unfortunately, command matching doesn't work as intended when the CAT
argument reflects a valid category; I want it to invoke the deprecated function
as soon as the 'everything' keyword follows, but it stays stuck to the "valid"
command when the category argument matches an explicit keyword in that list,
and will throw an error on the following 'everything' keyword. I.e.:

  logging level rsl everything
  % Unknown command  # <-- leads to config file parse error

  logging level unknown_string everything
  % Ignoring deprecated 'everything'  # <-- works only for invalid categories

So I need to define 'everything' separately, again with a list of each valid
category instead of a generic CAT arg.

Change-Id: I3b083f27e3d751ccec258880ae7676e9af959a63
2018-09-13 15:46:55 +00:00
Neels Hofmeyr d79f01e0a6 jenkins: add --enable-external-tests
Run the new logging_vty_test.vty VTY transcript test in our CI.

Change-Id: Ic4ec1f6c131da50b3956f16f0b49375f387196b3
2018-09-13 15:46:55 +00:00
Neels Hofmeyr 2c79d55934 gsm0808: implement BSSMAP Classmark Request
Related: OS#3043
Change-Id: I4a2e1d3923e33912579c4180aa1ff8e8f5abb7e7
2018-09-13 14:27:26 +00:00
Neels Hofmeyr 3a9ff11e57 logging vty: add VTY transcript test
I am setting out to refactor various details about logging. To show the effect,
I am first adding this new test to illustrate the exact effects on the various
osmo programs.

Add logging_vty_test.c as a standalone program that simply defines a few
logging categories and opens a telnet vty to play with.

Add logging_vty_test.vty, as an osmo_verify_transcript_vty.py test script.

Add --enable-external-tests to configure.ac, to enable running
logging_vty_test.vty during 'make check'.

Also allow running 'make vty-test' without the need to first configure with
--enable-external-tests (a flexibility I've missed many times over in the other
osmo source trees).

Add a Makefile.am stub for external CTRL tests, basically a copy-paste from
osmo-msc.git. I doubt that libosmocore will get python driven CTRL interface
testing any time soon, but if so we will know to not run it concurrently.

Change-Id: I948e832a33131f8eab98651d6010ceb0ccbc9a9c
2018-09-12 03:06:37 +02:00
Neels Hofmeyr ec6fdbb128 fix tests linking: don't use system installed libs
Do not link against the system-wide installed libosmo* libs when building the
regression test programs. Always use the locally built ones.

Linking some libosmo libraries causes libtool to pull in other libosmo libs
even though they were not explicitly named. For example, ctrl_test explicitly
links libosmoctrl, but this also has dependencies to libosmovty and libosmogsm:

  ldd src/ctrl/.libs/libosmoctrl.so | grep osmo
    libosmocore.so.11 => /usr/local/lib/libosmocore.so.11 (0x00007f26c26d4000)
    libosmogsm.so.10 => /usr/local/lib/libosmogsm.so.10 (0x00007f26c22bb000)
    libosmovty.so.4 => /usr/local/lib/libosmovty.so.4 (0x00007f26c2171000)

If we omit explicit LDADD of these dependencies in the Makefile.am, libtool
will take the first canonical place to find them, which may just be the already
installed older versions of the same libs, which may or may not be compatible
with the current build. In any case, it is never intended to link installed
libs.

All library dependencies are listed by this quick script:

  cd libosmocore
  for l in $(find . -name "*.so") ; do echo; echo "$l"; ldd $l | grep libosmo; done

  ./.libs/libosmocore.so

  ./coding/.libs/libosmocoding.so
    libosmocore.so.11 => /usr/local/lib/libosmocore.so.11 (0x00007f25fc3c2000)
    libosmogsm.so.10 => /usr/local/lib/libosmogsm.so.10 (0x00007f25fbfa9000)
    libosmocodec.so.0 => /usr/local/lib/libosmocodec.so.0 (0x00007f25fbf9b000)

  ./codec/.libs/libosmocodec.so
    libosmocore.so.11 => /usr/local/lib/libosmocore.so.11 (0x00007fb4c900d000)

  ./ctrl/.libs/libosmoctrl.so
    libosmocore.so.11 => /usr/local/lib/libosmocore.so.11 (0x00007f5df5129000)
    libosmogsm.so.10 => /usr/local/lib/libosmogsm.so.10 (0x00007f5df4d10000)
    libosmovty.so.4 => /usr/local/lib/libosmovty.so.4 (0x00007f5df4bc6000)

  ./gb/.libs/libosmogb.so
    libosmocore.so.11 => /usr/local/lib/libosmocore.so.11 (0x00007f788e536000)
    libosmovty.so.4 => /usr/local/lib/libosmovty.so.4 (0x00007f788e3ec000)
    libosmogsm.so.10 => /usr/local/lib/libosmogsm.so.10 (0x00007f788dfd3000)

  ./vty/.libs/libosmovty.so
    libosmocore.so.11 => /usr/local/lib/libosmocore.so.11 (0x00007f3b7ed21000)

  ./gsm/.libs/libosmogsm.so
    libosmocore.so.11 => /usr/local/lib/libosmocore.so.11 (0x00007fc69472e000)

  ./sim/.libs/libosmosim.so
    libosmocore.so.11 => /usr/local/lib/libosmocore.so.11 (0x00007f2f6412d000)
    libosmogsm.so.10 => /usr/local/lib/libosmogsm.so.10 (0x00007f2f63d14000)

Add all explicit linking of all required library dependencies in all regression
test programs, as shown by above listing.

Example for reproducing a problem:

In libosmocore.a, introduce a new function, and call that from libosmovty code.
For example, I made loglevel_strs non-static in logging.c, and used that in
logging_vty.c. Build and install this in a place where libtool can find it.
Then go back to before this change and rebuild. You will see that linking
ctrl_test (before this patch) then complains about libosmovty requiring the
loglevel_strs symbol which it cannot find in libosmocore.so.

Change-Id: Id084e6e6efd25cd62b1bd7a4fc7c5985c39130c6
2018-09-11 23:21:28 +02:00
Neels Hofmeyr 7c749893bf add osmo_str_tolower() and _toupper() with test
We already have osmo_str2lower() and osmo_str2upper(), but these lack:
* proper destination buffer bounds checking,
* ability to call directly as printf() argument.

Deprecate osmo_str2upper() and osmo_str2lower() because of missing bounds
checking.

Introduce osmo_str_tolower_buf(), osmo_str_toupper_buf() to provide
bounds-safe conversion, also able to safely convert a buffer in-place.

Introduce osmo_str_tolower(), osmo_str_toupper() that call the above _buf()
equivalents using a static buffer[128] and returning the resulting string
directly, convenient for direct printing. Possibly truncated but always safe.

Add unit tests to utils_test.c.

Replace all libosmocore uses of now deprecated osmo_str2lower().

Naming: the ctype.h API is called tolower() and toupper(), so just prepend
'osmo_str_' and don't separate 'to_lower'.

Change-Id: Ib0ee1206b9f31d7ba25c31f8008119ac55440797
2018-09-07 04:28:39 +02:00
Neels Hofmeyr 03e7553cba api doc: fix osmo_quote_str_*
Change-Id: Ibfd8ff213630e34009936b0fcb3ee50dda65fb70
2018-09-07 03:51:54 +02:00
Alexander Chemeris 50f7d74fca coding: Always initialize bit counters in gsm0503_pdtch_egprs_decode().
Previsouly there were a lot of valid code paths which returned from the function
before setting bit counters which led to bogus BER output in osmo-bts-trx logs
when those code paths were hit.

Change-Id: I4722cae3794ccbb12001113c991d9cf345a52a96
2018-09-05 16:08:34 +03:00
Alexander Chemeris 9444326158 coding: Correctly count bits when decoding EDGE bursts with MCS >= 7.
They consist of two blocks, so we should count both blocks.

Change-Id: I560de192212dae4705054a1665726369b83d213a
2018-09-05 16:08:16 +03:00
Vadim Yanitskiy 5594430405 core/utils.h: move includes to the top
Having all inculdes listed in one place is a common good
practice, which prevents one from adding duplicates.

Change-Id: I3f52189d5e8f9afafc39525e95385a085f8f850a
2018-09-05 02:58:03 +07:00
Vadim Yanitskiy 80f4ff9368 core/utils.h: drop duplicate '<stdbool.h>' include
Change-Id: I0979ddda91c4c0aa080b714cf2a698d7634f5091
2018-09-05 02:57:25 +07:00
Harald Welte b99ed7ff18 Add RSPRO support to IPA and logging definitions
Change-Id: Iee79f5273f32cb9ce4bd7a984e7f0625542e776f
2018-09-03 14:21:54 +02:00
Keith Whyte 3cdaa8d525 Add CC_CAUSE value_string array
Adds a value_string array for GSM 04.08 Call Control
cause values

Change-Id: I296f208581ce2550805f9d96e20f7319e1199023
2018-09-02 12:33:54 +02:00
Pau Espin 1a72bafa5d osmo-release.sh: Add checks to help avoid libversion debian major mismatch
Change-Id: Ie0f6a2f9d60908b36f90921bfba3fc31606e5027
2018-08-30 14:07:11 +02:00
Pau Espin cf8497cb2f osmo-release.sh: Allow forcing release without LIBVERSION bump
Sometimes a fix release may be required which only contains fixes to
parts not related to a shared library, for instance a fix in the build
system. Thus allow releasing without bumping LIBVERSION, but only
through env var setting for people who know what they are doing.

Change-Id: I91e186d47638038bc2968ea0178879365ffc9512
2018-08-30 14:01:29 +02:00
Pau Espin 941fd9be1b osmo-release.sh: Add quotes to string to fix shellcheck warning
Change-Id: I40376c99d44552d9b8023fca8d319a9312b0fbb0
2018-08-30 12:42:37 +02:00
Stefan Sperling 896ff6db16 Properly deal with sockaddr_un socket path length limitations.
In osmo_sock_unix_init(), add support for non-NUL-terminated unix
socket paths and return an error if the supplied socket path exceeds
the maximum socket path length supported by the operating system.

Change-Id: I19d935e5e3dd7928e6e153c6f5ad7044de726016
Related: OS#2673
2018-08-29 07:39:55 +00:00
Stefan Sperling 3953f41bbd properly handle mandatory cli param of gsm0808_create_paging2
The cell identifier list parameter is mandatory. Document it as
such, and tweak code which treated it like an optional parameter.

No functional change. The existing code already asserts that
a non-NULL value is passed for this parameter.

Change-Id: I3716f9d5b210e0a7e6f45c9fe3fc34024e5234ad
Related: OS#3021
2018-08-29 07:38:11 +00:00
Neels Hofmeyr 43c266f6c6 gsm0808: inter-bsc HO messages: add missing BSSMAP header, x4
Change-Id: I9e128ba775227de5e4010f024338a78584f777ea
2018-08-28 19:41:06 +00:00
Neels Hofmeyr 77ae45d22f log: add 'last' option to 'logging print file'
Allow printing the source file information *after* the log information.

Add target->print_filename_pos, log_set_print_filename_pos() and enum
log_filename_pos, and the optional 'last' keyword to the 'logging print file'
vty command. (An enum in case we want to add other positions later.)

Rationale: on log lines, the logging context is usually printed first in the
logging text. Without the source file information, this logging context pretty
much aligns in an easily readable way. When adding the source file information,
each line's logging context info is shifted right by a pretty much random
amount and it is hard to spot recurring logging contexts.

One solution is to switch off source file info, of course, but that's not an
option when actively hacking on bugs and new features.

For example, it is unnecessarily hard to spot lchan FSM related log lines in
this osmo-bsc log snippet:

DRSL NOTICE mgw_endpoint_fsm.c:603 mgw-endpoint(conn0){WAIT_MGW_RESPONSE}: Freeing instance
DRSL NOTICE fsm.c:381 mgw-endpoint(conn0){WAIT_MGW_RESPONSE}: Deallocated
DMSC NOTICE mgw_endpoint_fsm.c:603 SUBSCR_CONN(conn0){CLEARING}: Received Event FORGET_MGW_ENDPOINT
DCHAN DEBUG lchan_rtp_fsm.c:741 lchan(0-0-1-TCH_F-0){WAIT_RLL_RTP_ESTABLISH}: Received Event LCHAN_EV_RTP_RELEASED
DCHAN DEBUG lchan_rtp_fsm.c:520 lchan_rtp(0-0-1-TCH_F-0){ROLLBACK}: Freeing instance
DCHAN DEBUG fsm.c:381 lchan_rtp(0-0-1-TCH_F-0){ROLLBACK}: Deallocated
DCHAN DEBUG lchan_rtp_fsm.c:520 lchan(0-0-1-TCH_F-0){WAIT_RLL_RTP_ESTABLISH}: Received Event LCHAN_EV_RTP_RELEASED
DCHAN DEBUG lchan_fsm.c:1232 lchan(0-0-1-TCH_F-0){WAIT_RLL_RTP_ESTABLISH}: state_chg to WAIT_RF_RELEASE_ACK
DRSL NOTICE handover_fsm.c:762 handover(interBSCin_conn0){WAIT_RR_HO_DETECT}: Terminating (cause = OSMO_FSM_TERM_REGULAR)
DRSL NOTICE handover_fsm.c:762 handover(interBSCin_conn0){WAIT_RR_HO_DETECT}: Freeing instance
DRSL NOTICE fsm.c:381 handover(interBSCin_conn0){WAIT_RR_HO_DETECT}: Deallocated
DCHAN DEBUG lchan_fsm.c:1196 lchan(0-0-1-TCH_F-0){WAIT_RF_RELEASE_ACK}: state_chg to BORKEN
DCHAN DEBUG lchan_fsm.c:354 lchan(0-0-1-TCH_F-0){BORKEN}: (type=TCH_F) Clearing lchan state
DLMGCP DEBUG mgcp_client.c:741 Tx MGCP msg to MGCP GW: 'DLCX 3 2@mgw MGCP 1.0'
DLMGCP DEBUG mgcp_client.c:743 Sending msg to MGCP GW size: 66
DRLL NOTICE mgcp_client_fsm.c:422 MGCP_CONN(to-BTS){ST_DLCX_RESP}: Received Event EV_DLCX_RESP

Placing the source file info behind the log text makes it much easier to
follow, while the source file info is still available:

DRSL NOTICE mgw-endpoint(conn0){WAIT_MGW_RESPONSE}: Freeing instance (mgw_endpoint_fsm.c:603)
DRSL NOTICE mgw-endpoint(conn0){WAIT_MGW_RESPONSE}: Deallocated (fsm.c:381)
DMSC NOTICE SUBSCR_CONN(conn0){CLEARING}: Received Event FORGET_MGW_ENDPOINT (mgw_endpoint_fsm.c:603)
DCHAN DEBUG lchan(0-0-1-TCH_F-0){WAIT_RLL_RTP_ESTABLISH}: Received Event LCHAN_EV_RTP_RELEASED (lchan_rtp_fsm.c:741)
DCHAN DEBUG lchan_rtp(0-0-1-TCH_F-0){ROLLBACK}: Freeing instance (lchan_rtp_fsm.c:520)
DCHAN DEBUG lchan_rtp(0-0-1-TCH_F-0){ROLLBACK}: Deallocated (fsm.c:381)
DCHAN DEBUG lchan(0-0-1-TCH_F-0){WAIT_RLL_RTP_ESTABLISH}: Received Event LCHAN_EV_RTP_RELEASED (lchan_rtp_fsm.c:520)
DCHAN DEBUG lchan(0-0-1-TCH_F-0){WAIT_RLL_RTP_ESTABLISH}: state_chg to WAIT_RF_RELEASE_ACK (lchan_fsm.c:1232)
DRSL NOTICE handover(interBSCin_conn0){WAIT_RR_HO_DETECT}: Terminating (cause = OSMO_FSM_TERM_REGULAR) (handover_fsm.c:745)
DRSL NOTICE handover(interBSCin_conn0){WAIT_RR_HO_DETECT}: Freeing instance (handover_fsm.c:745)
DRSL NOTICE handover(interBSCin_conn0){WAIT_RR_HO_DETECT}: Deallocated (fsm.c:381)
DCHAN DEBUG lchan(0-0-1-TCH_F-0){WAIT_RF_RELEASE_ACK}: state_chg to BORKEN (lchan_fsm.c:1196)
DCHAN DEBUG lchan(0-0-1-TCH_F-0){BORKEN}: (type=TCH_F) Clearing lchan state (lchan_fsm.c:354)
DLMGCP DEBUG Tx MGCP msg to MGCP GW: 'DLCX 3 12@mgw MGCP 1.0' (mgcp_client.c:741)
DLMGCP DEBUG Sending msg to MGCP GW size: 67 (mgcp_client.c:743)
DRLL NOTICE MGCP_CONN(to-BTS){ST_DLCX_RESP}: Received Event EV_DLCX_RESP (mgcp_client_fsm.c:422)

Implementation: for 'last', insert source file info only when an '\n' is found
at the end of the log line composition buffer, so that LOGP()...LOGPC()
constructs also print source file info only when a log line actually ends.

Change-Id: I393907b3c9e0cc1145e102328adad0a83ee13a9f
2018-08-27 20:52:04 +02:00
Philipp Maier b8a91625dd gsmtap_util: make sure SO_REUSEADDR is applied for GSMTAP
When gsmtap adding a new sink it does not supply OSMO_SOCK_F_UDP_REUSEADDR
in order to have SO_REUSEADDR applied. In most cases, the gsmtap sink is
just receiving packets to toss them immediately, so having one of them
is sufficient.  However, in other use cases - particularly virt_phy -
we actually want to receve and process GSMTAP messages via multicast
Applying SO_REUSEADDR (like we did before disabling it globally for UDP
in I4a8ffb8d598aca88801a4a0322944d7cdd8d4047 on August 1st) resolves
the issue.

Change-Id: I1399a428467ca12f1564a14eb8ffb294d4f59874
Related: OS#3497
2018-08-24 10:31:18 +00:00
Philipp Maier 73196e77fb socket: add flag to enforce SO_REUSEADDR on UDP sockets
When IPPROTO_UDP is used then SO_REUSEADDR omitted since UDP is
connection less we do not have to wait until lingering connections time
out. There were also negative effects such as that two applicatications
could use the same UDP port, normally one of the two applications would
get an error, but with SO_REUSEADDR this is supressed. However, there
are applications (UDP MULTICAST) where two applications must be able to
use the same port. In the osmocom project those are osmo-bts-virtual,
virtphy and gsmtap in general.

Lets introduce a flag that the API user can supply in order to have
SO_REUSEADDR applied.

- Add new flag OSMO_SOCK_F_UDP_REUSEADDR

Change-Id: I94aaf6d5224ab23bde5ea5c4a83569b6145ab32b
Related: OS#3497
2018-08-23 20:17:45 +02:00
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