Commit Graph

2832 Commits

Author SHA1 Message Date
Neels Hofmeyr 44c15b7a8f doxygen: allow manual 'make apidoc' even if --disable-doxygen
Even if ./configure --disable-doxygen was passed and doxygen builds are by
default skipped, provide a manual 'make apidoc' target that nevertheless
generates the API doc on the premise that a 'doxygen' program is available.

Especially since we do a two-pass doxygen build whenever any source file
changes, my guess is --disable-doxygen could be a common choice. It is then
cumbersome to have to ./configure just to get one doxygen build started.

Change-Id: If8d8dfb8365c8f28612b8ce2b8ddf88f74df9a90
2019-02-04 16:43:57 +00:00
Neels Hofmeyr 375bf6dcc5 doxygen: add source files as dependencies
So far, when modifying a source file, the doxygen docs were not regenerated
automatically. It required a manual 'rm -rf docs/core' or similar. Make it
rebuild automatically:

Add each library's source files to the list of dependencies for the first-pass
doxygen build.

Attention, since all libraries depend on the .map files of each other library,
and each library depends on its own source files, that means that a single
touch on one .c file anywhere will result in rebuilding the entire doxygen
docs. It is correct to do so, since any file may introduce \ref targets used
anywhere else. If you don't want that, --disable-doxygen.

Change-Id: I15ea96be6e7abe91264b91f0b06963a0f2d63b0b
2019-02-04 16:43:57 +00:00
Neels Hofmeyr 2fe50ac951 doxygen: enable cross referencing everywhere
doxygen \ref cross-references to groups or files from other libraries only work
when the .map file was present when the HTML was generated, and when that .map
file was listed in TAGFILES in the Doxyfile.

- Makefile.am: introduce a two-pass build for doxygen API docs.
  - First build pass makes sure the .tag files are present.
  - Second build pass picks up all the references, hence generates hyperlinks
    properly.
- Add all libraries to TAGFILES of all other libraries, so we can from now on
  freely criss-cross reference from everywhere to everywhere.
- Add all libraries' tag files as dependencies for all others.

Example: in upcoming tdef.h, I would like to cross reference to tdef_vty.h, and
vice versa, even though they are in libosmocore and libosmovty, respectively.
This is now possible.

We may still need to fix some problems with naming collisions, see for example
stats.h, which exists twice with identical doxygen handle (different source
dirs seems to not suffice for doxygen).

Change-Id: Ib03d0b70d536c8f1386def666c89106a840f7363
2019-02-04 16:43:57 +00:00
Neels Hofmeyr c1aa178c8b vty api: add vty_out_va()
Provide a va_list type vty_out() variant, to be able to pass on variable
arguments from other function signatures to vty_out().

This will be used by Ibd6b1ed7f1bd6e1f2e0fde53352055a4468f23e5 for osmo_tdef.

Change-Id: Ie6e6f11a6b794f3cb686350c1ed678e4d5bbbb75
2019-02-04 16:43:57 +00:00
Neels Hofmeyr 8d04f95d96 vty telnet: consistently never change nodes upon CTRL-C
Remove any special node exiting from the VTY CTRL-C handling.

From a curious VTY transcript test glitch, I noticed weird behavior by the VTY
telnet shell: usually, when the user hits CTRL-C, that means to cancel the
current command line and present a fresh, clean prompt. However, only on the
CONFIG_NODE and CFG_LOG_NODE, a CTRL-C also exits the current node and moves up
by one level. This behavior is unexplainable and makes zero sense.

No other nodes exit on CTRL-C:
- on the ENABLE node, a CTRL-C stays on the ENABLE_NODE and doesn't exit to the
  VIEW_NODE.
- any sub-nodes of the CONFIG_NODE stay unchanged, e.g. 'network' or 'bts' /
  'trx', etc.

There is no apparent special meaning of CTRL-C on CONFIG_NODE nor CFG_LOG_NODE
to justify this odd choice.

Particularly, the vty transcript tests using osmo_verify_transcript_vty.py rely
on sending CTRL-C to clear the command prompt, so that we can properly test
sending '?' to the VTY during transcripts. In a live session, a '?' prints
available options and then updates the prompt with identical command arguments.
In a transcript test, that doesn't make sense, because each time the transcript
writes out a new command to run. Consider e.g. a transcript test like:

	tdef_vty_test(config)# timer ?
	  tea       Tea time
	  test      Test timers
	  software  Typical software development cycle

	tdef_vty_test(config)# timer tea ?
	  [TNNNN]  T-number, optionally preceded by 't' or 'T'.

To be able to issue a fresh command after '?', osmo_verify_transcript_vty.py
explicitly sends a CTRL-C to clear the command buffer. Hence there we rely on
predictable behavior of CTRL-C.

More particularly, the upcoming osmo_tdef_vty transcript tests are apparently
the first that want to test '?' behavior on the CONFIG_NODE's root level and
fall on their face, because of the implicit exit that happens only there.

Change-Id: I4f339ba61f1c273fa7da85caf77ba116ae2697b1
2019-02-04 16:43:57 +00:00
Neels Hofmeyr 9ea9dd0d5f vty: enable tab-completion for optional-multi-choice args
In cmd_complete_command_real(), detect and strip square braces from
multi-choice arguments, to enable tab-completion for commands like

 > list
 cmd [(alpha|beta)]
 > cmd <TAB>
 alpha beta
 > cmd be<TAB>
 > cmd beta

Change-Id: I8c304300b3633bb6e9b3457fcfa42121c8272ac0
2019-02-04 16:43:57 +00:00
Neels Hofmeyr b55f4d2df2 vty: enable optional-multi-choice syntax: [(one|two)]
Since very recently we sensibly handle commands like

  cmd ([one]|[two]|[three])

as optional multi-choice arguments. In addition, support the more obvious
syntax of

  cmd [(one|two|three)]

Internally, the tokens are mangled to [one] [two] and [three], which is how the
rest of the code detects optional args, and makes sense in terms of UI:

  > cmd ?
  [one]
  [two]
  [three]

(i.e. optional arguments are always shown in braces in '?' listings)

Before this patch, commands defined with a syntax like [(one|two)], would lead
to an assertion (shows as "multiple") during program startup.

Change-Id: I952b3c00f97e2447f2308b0ec6f5f1714692b5b2
2019-02-04 16:43:57 +00:00
Neels Hofmeyr c197809deb vty: enable optional-multi-choice syntax: ([one]|[two])
Add basic optional multi-choice argument support.

The VTY detects optional arguments by square braces.

 > cmd ?
 [optional-arg]
 > cmd optional-arg
 ok
 > cmd
 ok

However, within multi-choice args, these braces were so far not treated as
optional:

 > list
 cmd2 ([one]|[two]|[three])
 > cmd2
 % Command incomplete

In preparation for I952b3c00f97e2447f2308b0ec6f5f1714692b5b2 which will enable
the more obvious syntax of

  cmd [(one|two)]

for reasons of internal implementation, first support a syntax of

  cmd ([one]|[two])

The internal vty implementation always needs square braces around each option.
There is currently no good way to prevent developers from defining braces
inside multi-arguments, so it is easiest to allow and handle them:

 > list
 cmd2 ([one]|[two]|[three])
 > cmd2
 ok

The VTY doesn't guard against a mix like

 cmd (one|[two])

With this patch, a multi-choice command is treated as optional iff the first
element is in square brackets. The remaining elements' square brackets have no
effect besides confusing the user. This is not explicitly checked against.

In general, I would prefer to check all of these details, but the current VTY
code with its endless code duplication and obscure string mangling just doesn't
provide that luxury. There are numerous worse errors hidden in there.

Change-Id: I9a8474bd89ddc2155c58bfca7bd038d586aaa60a
2019-02-04 16:43:57 +00:00
Neels Hofmeyr faa49e24cb add generic vty_transcript_test.c, vty_transcript_test.vty
I want to tweak general VTY features and need to cover with a transcript test
to show the differences. Start by showing the current situation of optional
and multi-choice arguments.

Change-Id: I5a79c83fabd02aba6406b6e0d620969c4bd0cc1d
2019-02-04 16:43:57 +00:00
Max b3e9b31383 socket.h: add missing include
socket.h uses INET6_ADDRSTRLEN without including arpa/inet.h where it's
defined which might break external users of socket.h

Fix this by adding missing include. The error was introduced in
64b51eb68b

Change-Id: I2883addcb81cec038577e401e356e8f07a947d4c
2019-02-04 13:48:22 +00:00
Oliver Smith d6ff9c8315 GSUP: deprecate osmo_gsup_get_err_msg_type()
Replace osmo_gsup_get_err_msg_type() with a wrapper to
OSMO_GSUP_TO_MSGT_ERROR(). This macro assumes, that all error messages
are (request message | 0x000001). Add a big comment header for
osmo_gsup_message_type, describing this already implicitly followed rule
and therefore making it explicit.

With this change, we don't need to maintain the request -> error message
mapping in osmo_gsup_get_err_msg_type() anymore.

Related: Iec1b4ce4b7d8eb157406f006e1c4241e8fba2cd6 (osmo-gsm-manuals)
Change-Id: I46d9f2327791978710e2f90b4d28a3761d723d8f
2019-02-04 10:42:12 +00:00
Neels Hofmeyr 89991fdb7c osmo_fsm_inst_state_chg(): clamp timeout_secs to <= ~68 years
During testing of the upcoming tdef API, it became apparent that passing very
large timeout values to osmo_fsm_inst_state_chg() wraps back in the number
range, and might actually result in effectively very short timeouts instead.

Since time_t's range is not well defined across platforms, use a reasonable
maximum value of signed 32 bit integer. Hence this will be safe at least on
systems with an int32_t for struct timeval.tv_sec and larger.

Clamp the osmo_fsm_inst_state_chg() timeout_secs argument to a maximum of
0x7fffffff, which amounts to just above 68 years:
float(0x7fffffff) / (60. * 60 * 24 * 365.25) = 68.04965038532715

(In upcoming patch Ibd6b1ed7f1bd6e1f2e0fde53352055a4468f23e5, this can be
verified to work by invoking tdef_test manually with a cmdline argument passed
to enable the range check.)

Change-Id: I35ec4654467b1d6040c8aa215049766089e5e64a
2019-01-31 17:40:24 +01:00
Neels Hofmeyr bd5a1dc84f osmo_fsm_inst_state_chg(): set T also for zero timeout
Before this patch, if timeout_secs == 0 was passed to
osmo_fsm_inst_state_chg(), the previous T value remained set in the
osmo_fsm_inst->T.

For example:

  osmo_fsm_inst_state_chg(fi, ST_X, 23, 42);
  // timer == 23 seconds; fi->T == 42
  osmo_fsm_inst_state_chg(fi, ST_Y, 0, 0);
  // no timer; fi->T == 42!

Instead, always set to the T value passed to osmo_fsm_inst_state_chg().

Adjust osmo_fsm_inst_state_chg() API doc; need to rephrase to accurately
describe the otherwise unchanged behaviour independently from T.

Verify in fsm_test.c.

Rationale: it is confusing to have a T number remaining from some past state,
especially since the user explicitly passed a T number to
osmo_fsm_inst_state_chg(). (Usually we are passing timeout_secs=0, T=0).

I first thought this behavior was introduced with
osmo_fsm_inst_state_chg_keep_timer(), but in fact osmo_fsm_inst_state_chg()
behaved this way from the start.

This shows up in the C test for the upcoming tdef API, where the test result
printout was showing some past T value sticking around after FSM state
transitions. After this patch, there will be no such confusion.

Change-Id: I65c7c262674a1bc5f37faeca6aa0320ab0174f3c
2019-01-29 10:25:26 +00:00
Neels Hofmeyr 4ff41d94ce jenkins distcheck: enable external tests
It was recently discovered that logging_vty_test.vty was missing from
EXTRA_DIST. To make sure we don't forget similar files in the future, add
python tests to 'make distcheck', by means of DISTCHECK_CONFIGURE_FLAGS.

Related: I1bcedf3097f02b2adc679560d1cbceb27dbc345e
Change-Id: Id569b2a932c1428cabb4d7ff17822cff8eee02af
2019-01-29 01:03:25 +01:00
Neels Hofmeyr 760c58f226 build: add missing logging_vty_test.vty to EXTRA_DIST
It was introduced and forgotten to add to EXTRA_DIST in:

"logging vty: add VTY transcript test"
commit 3a9ff11e57
change-Id I948e832a33131f8eab98651d6010ceb0ccbc9a9c

Change-Id: I1bcedf3097f02b2adc679560d1cbceb27dbc345e
2019-01-29 01:02:01 +01:00
Neels Hofmeyr 56632b69a7 osmo_fsm_state_name: make robust against NULL fi
Change-Id: I61d4f7dfada2763948f330745ac886405d889a12
2019-01-29 00:59:32 +01:00
Neels Hofmeyr 7740d26d7e add osmo_classmark_* API
osmo-bsc and osmo-msc implement identical Classmark structures. It makes sense
to define once near the gsm48 protocol definitions.

Also move along some generic Classmark API from osmo-msc.

Change-Id: Ifd27bab0380f7ad0c44c719aa6c8bd62cf7b034c
2019-01-29 00:59:32 +01:00
Neels Hofmeyr 0423b61aa8 add osmo_hexdump_buf() and test
Add osmo_hexdump_buf() as an all-purpose hexdump function, which all other
osmo_hexdump_*() implementations now call. It absorbs the static
_osmo_hexdump(). Add tests for osmo_hexdump_buf().

Rationale: recently during patch review, a situation came up where two hexdumps
in a single printf would have been useful. Now I've faced a similar situation
again, in ongoing development. So I decided it is time to provide this API.

The traditional osmo_hexdump() API returns a non-const char*, which should
probably have been a const instead. Particularly this new function may return a
string constant "" if the buf is NULL or empty, so return const char*. That is
why the older implementations calling osmo_hexdump_buf() separately return the
buffer instead of the const return value directly.

Change-Id: I590595567b218b24e53c9eb1fd8736c0324d371d
2019-01-28 23:58:53 +00:00
Neels Hofmeyr d01ef75ab8 gsm0808: add BSSMAP Cell Identifier matching API
Add
* osmo_lai_cmp() (to use in gsm0808_cell_id_u_matches())
* osmo_cgi_cmp() (to use in gsm0808_cell_id_u_matches())
* gsm0808_cell_id_u_match() (to re-use for single IDs and lists)
* gsm0808_cell_ids_match()
* gsm0808_cell_id_matches_list()
* Unit tests in gsm0808_test.c

Rationale:

For inter-BSC handover, it is interesting to find matches between *differing*
Cell Identity kinds. For example, if a cell as CGI 23-42-3-5, and a HO for
LAC-CI 3-5 should be handled, we need to see the match.

This is most interesting for osmo-msc, i.e. to direct the BSSMAP Handover
Request towards the correct BSC or MSC.

It is also interesting for osmo-bsc's VTY interface, to be able to manage
cells' neighbors and to trigger manual handovers by various Cell Identity
handles, as the user would expect them.

Change-Id: I5535f0d149c2173294538df75764dd181b023312
2019-01-28 23:58:53 +00:00
Harald Welte 2033be8902 Work around bogus gcc-8.2 array-bounds warning/error
gcc-8.2 is printing the following warning, which is an error
when used -Werror like our --enable-werror:

In file included from gprs_bssgp.c:34:
In function ‘tl16v_put’,
    inlined from ‘tvlv_put.part.3’ at ../../include/osmocom/gsm/tlv.h:156:9,
    inlined from ‘tvlv_put’ at ../../include/osmocom/gsm/tlv.h:147:24,
    inlined from ‘msgb_tvlv_push’ at ../../include/osmocom/gsm/tlv.h:386:2,
    inlined from ‘bssgp_tx_dl_ud’ at gprs_bssgp.c:1162:4:
../../include/osmocom/gsm/tlv.h:131:2: error: ‘memcpy’ forming offset [12, 130] is out of the bounds [0, 11] of object ‘mi’ with type ‘uint8_t[11]’ {aka ‘unsigned char[11]’} [-Werror=array-bounds]
  memcpy(buf, val, len);

Where "130" seems to be the maximum value of uint8_t, shifted right one +
2.  But even as we use strnlen() with "16" as maximum upper bound, gcc
still believes there's a way that the return value of gsm48_generate_mid_from_imsi()
could be 130.  In fact, even the newly-added OSMO_ASSERT() inside
gsm48_generate_mid() doesn't help and gcc still insists there is a problem :(

Change-Id: I0a06daa19b7b5b5badbb8b3d81a54c45b88a60ec
2019-01-22 14:53:54 +00:00
Harald Welte 1c3bae138c constrain gsm48_generate_mid() output array bounds
The longest BCd-digit type identity is the IMEISV with 16, so there's
no point in trying to parse up to 255 decimal digits, which will do
nothing but to overflow the caller-provided output buffer.

Let's also clearly define the required minimum size of the output
buffer and add a reltead #define for it.

Change-Id: Ic8488bc7f77dc9182e372741b88f0f06100dddc9
2019-01-22 14:53:46 +00:00
Harald Welte 1317771c93 gsm0408_test: Fix IMEI-SV related tests to use no more than 16 digits
The IMEI-SV is speified as a 16 digit number: 14 digits of IMEI plus
two digits of software version.  Let's not try to feed 18 digit long
numbers into our functions, as the resulting behavior is unspecified.

Change-Id: I6fb85a0516dc387902ad9de4fe8c1ba82d68cae6
2019-01-22 14:53:46 +00:00
Harald Welte d4c406a04e Release v1.0.1 on 2019-01-21.
-----BEGIN PGP SIGNATURE-----
 
 iQJJBAABCgAzFiEEigrqmUioHHGhfemTShB5H1XkRJYFAlxFzjQVHGxhZm9yZ2VA
 Z251bW9ua3Mub3JnAAoJEEoQeR9V5ESWjDsQAJ5OodnJQYmdoKnXLoSrSE5wnXKQ
 /9oYco2Nkm8ZOyOvXeUdkWwfEHAXjcAxCqHQx6kZehK+KCgI3F12Ja8BlJY2ODgT
 a5kMMZrBJLpbi9vNtlFcEnTwo2g72ukldngA7pqFKvJFBbAWXKIMnMIQ1BPft15Z
 uflrFIBgFgx6c8AuRGefw2Bb68QS8FlpVqZCJjlKbsURiUsOGZ0hw53+uXLu0ukv
 XJElBRsCg8q3YudBkY70tX8ZGOX2o+GBAtM/WYQ95N3awCxLywUp8kQJn6/2xJPT
 /WaDdSCYfjM5KDn62x1dx+5ejJlMkj3izUA+7cdsJewbICIKwr0cYuNRkF3MNYsS
 M/gg9AIGG0ySN66T5Yzdz+VXC/59vxm/Hwe6mKJEZEIDwtz+Xd0uWqw1klEQHTDh
 VV59kC8TlHAofgs5eLhzR0g24jLThb4PrMAGqZfxzRk6bAwnYOz7eSm/gh30k7zK
 eHRRxEQQRFi+UkkeeZ244yJnmG9z/2S/VS4PEcuhu4OhAx4shf5MMpo5E0GR7vVY
 jY4a8lLu4ZiqWKI8RQ1tgkC6Rd+wllqQ62ZAzetA2pP4itiqQ4n+ClrhdB9oKzh8
 M9CokQQom2Wsi2+1RQRpsg3G7MUYChFaYFrKVlL5HTp/DjOy337bL8Crr0hcdX9W
 ylBEUjPtkcsI4YyT
 =xncj
 -----END PGP SIGNATURE-----

Merge tag '1.0.1'

Release v1.0.1 on 2019-01-21.

Change-Id: I2b92a7cfcdc7ed9d6f835bd17c6b5d2ec939b568
2019-01-21 18:42:48 +01:00
Harald Welte 3927cc4368 Bump version: 1.0.0 → 1.0.1
Change-Id: I51696a3ace219ab69c294b0e3637371c5460291f
2019-01-21 17:40:34 +00:00
Oliver Smith 49fb992cd7 gsm_23_003.h: add GSM23003_IMEI_NUM_DIGITS_NO_CHK
Add new define for the 14 digit IMEI without the Luhn checksum, as it
is used in OsmoHLR.

Change-Id: I02b54cf01a674a1911c5c897fbec02240f88b521
2019-01-21 17:32:35 +01:00
Harald Welte 041ccd3aa7 Bump version: 1.0.0 → 1.0.1
Change-Id: I51696a3ace219ab69c294b0e3637371c5460291f
2019-01-21 14:50:43 +01:00
Max b27e6feb69 Rename msgb_wrap_with_TL()
This resolves an issue introduced in 84fb5bb6a0
when msgb_wrap_with_TL() was introduced as an inline function with
*exactly the same name* as in osmo-msc.git and openbsc.git.  We *NEVER*
do something like this.  Functions moved from applications to library
*MUST* always be renamed.  This has been the case for almost a decade
now.

With this subsequent change we make sure the libosmocore function
has a different name and doesn't clash.  After this commit, old
openbsc.git and osmo-bsc.git should again build fine.

Change-Id: If1e851ac605c8d2fde3da565b0bd674ea6350c2e
2019-01-21 13:47:08 +00:00
Harald Welte a0c1cba28a Bump version: 0.12.0.128-8dfde → 1.0.0
Change-Id: I1bd973754b1ebc42283f6a07defa60f58523f5a3
2019-01-19 22:07:56 +01:00
Max 6915a219b2 Prevent GCR encoder/decoder functions from being used directly
They only make sense in the context of LCLS so far - let's make sure
they're not used by external projects directly instead of gsm0808_*()
counterparts.

Change-Id: I4ae5a3472a20492d5f76170b722e4e2274a5c433
2019-01-19 21:06:16 +00:00
Max 3b90125346 LCLS: make GCR into static member of osmo_lcls
Most of the time we'll have GCR filled anyway so it make sense to have
it as static parameter instead of a pointer to separately allocated
structure. Update tests to cover both static and dynamic osmo_lcls
allocation variants.

Change-Id: I905c36d8455911c68c30bc429379b7313dd46aea
2019-01-19 21:06:03 +00:00
Max 414c8f565b LCLS: add status parameter to Assignment Completed message
* add gsm0808_create_ass_compl2() with additional gsm0808_lcls_status
  parameter and make gsm0808_create_ass_compl() into trivial wrapper
  around it
* update tests accordingly

Change-Id: I547c6b8707123aa8c1ef636db88908df112d90a4
Related: OS#2487
2019-01-19 21:03:56 +00:00
Philipp Maier d6ef6f1b91 gsm29118: fix coverity issues
The function msgb_sgsap_name_put() assignes the return code of
osmo_apn_from_str() directly to len. Len is an uint8_t and the return
code an int. If osmo_apn_from_str() returns -1. Len would become 0xFF
causing a buffer overrun with msgb_tlv_put. Lets use the proper type to
catch the return code and check it before using it as length.

Change-Id: Ic0bc5114eee47bdcf2300a6e4b0df473d3d1903a
Fixes: CID#190405
Fixes: CID#190401
Related: OS#3615
2019-01-18 08:21:00 +00:00
Philipp Maier 64b51eb68b socket: add define for socket name length
The function osmo_sock_get_name_buf() can be used to write a string
representation to a user provided memory. Unfortunately the proper
length for the user provided memory is not obvious. To make using
osmo_sock_get_name_buf() more practical, add a define constant that
defines the length of the required memory. Also use this define in
socket.c.

Change-Id: If8be8c2c0d4935da17ab13b2c2127b719ceefbcc
2019-01-17 17:46:08 +01:00
Max 1bec3908c6 LCLS: add GCR comparison helper
Change-Id: I9e3b5560a058b976638d03cb819415d237ae9984
2019-01-14 23:46:34 +00:00
Max 4fd64e5d93 LCLS: expand enc/dec tests
Change-Id: I8ed87f26216104d34c7bd11c1527b203843760a2
2019-01-14 23:46:34 +00:00
Neels Hofmeyr 6ad50aaebd comments: update/fix three 3GPP spec references
Change-Id: I3ab94f362866d752099000afe62922288b3dd118
2019-01-14 20:46:03 +01:00
Neels Hofmeyr f8963f9d4e change GSM48_CMSERV_* to enum type, add names
Prepare handling multiple CM Service Requests in osmo-msc: an enum is more
clear than an int and #defines for passing around and count CM Service types.

Change-Id: I9c2a7adc45ab7a1a7519168e965e7d805e1481ff
2019-01-14 17:42:03 +00:00
Oliver Smith 894be2d9da gsm23003: add osmo_imei_str_valid()
Verify 14 digit and 15 digit IMEI strings. OsmoHLR will use the 14
digit version to check IMEIs before writing them to the DB.

Place the Luhn checksum code in a dedicated osmo_luhn() function, so
it can be used elsewhere.

Related: OS#2541
Change-Id: Id2d2a3a93b033bafc74c62e15297034bf4aafe61
2019-01-14 14:39:57 +00:00
Stefan Sperling bd6e7a9f2d port rest octets encoding code from osmo-bsc
As part of fixing issue OS#3075, we want to migrate support
for encoding system information from osmo-bsc to libosmocore.

This change ports osmo-bsc code for encoding SI rest octets.

The conversion was a bit tricky in some places because some
functions receive a 'struct gsm_bts' parameter in osmo-bsc.
In this libosmocore version, such functions expect parameters
which correspond to the individual fields of 'struct gsm_bts'
which are used by these functions.

Several structs from osmo-bsc's system_information.h are now
also declared in libosmocore headers, with an added osmo_ prefix
to avoid collisions with existing definitions in osmo-bsc.

Some helpers were ported from osmo-bsc's system_information.c
to libosmocore's gsm48_rest_octets.c. Contrary to osmo-bsc's
implementation they are now only visible within this file.

Unfortunately, this code ported from osmo-bsc lacks unit tests.

Change-Id: I47888965ab11bba1186c21987f1365c9270abeab
Related: OS#3075
2019-01-12 09:51:08 +00:00
Stefan Sperling fdf8b7b1be port arfcn range encode support from osmo-bsc
As part of fixing issue OS#3075, we want to migrate support
for encoding system information from osmo-bsc to libosmocore.

This change ports one of the prerequisites for doing so:
osmo-bsc code for range-encoding ARFCNs, including tests.

An osmo_gsm48_ prefix has been prepended to public symbols in
order to avoid clashes with existing symbols in osmo-bsc code.

Change-Id: Ia220764fba451be5e975ae7c5eefb1a25ac2bf2c
Related: OS#3075
2019-01-12 09:51:05 +00:00
Max e118ed22e3 LCLS: use proper types for value_string wrappers
Change-Id: I0f47a610e06ac99bd60a5aad6f50f3658480165e
2019-01-09 16:17:17 +00:00
Oliver Smith d621a1ec2e Cosmetic: GSUP: note "on wire" for imei_result
Note that OSMO_GSUP_IMEI_RESULT_ACK is 0 on the wire, although the
enum value is 1. Same with NACK (1 on wire, enum 2).

I had implemented enum osmo_gsup_imei_result after
enum osmo_gsup_cancel_type above, where this comment exists as well,
and I incorrectly assumed that enum osmo_gsup_cn_domain in the middle
was also implemented this way and therefore adding the comments to each
enum would be redundant. But for cn_domain, the values on the wire are
the same as the enum values.

Change-Id: If97c34f117bfaab2232bbb625e9d118c8f390e58
2019-01-09 14:53:34 +00:00
Max a6749ac7d4 msgb: fix debug print
Since osmo_hexdump() use static buffers we can't re-use pointers to it
after subsequent osmo_hexdump() calls. Let's print data used for
comparison directly instead.

Change-Id: I24dc3fad6f64ef788da9b7d790f9d5f689190c42
2019-01-09 12:19:44 +00:00
Neels Hofmeyr 92f3f5e491 add osmo_lu_type_names[], osmo_lu_type_name()
Move lupd_names[] from osmo-msc to libosmo-gsm.

Change-Id: Ica25919758ef6cba8348da199b0ae7e0ba628798
2019-01-08 14:07:07 +00:00
Neels Hofmeyr 02fd83d799 add osmo_mi_name(), for MI-to-string like "IMSI-123456"
We have gsm48_mi_to_string() and osmo_bcd2str(), but still lack a function that
conveniently prints both MI type and value in one function call.

Related: http://people.osmocom.org/neels/mi_mi_mi.jpg
Change-Id: I7798c3ef983c2e333b2b9cbffef6f366f370bd81
2019-01-08 14:07:07 +00:00
Max 45f89c938d LCLS: fix LCLS-CONNECT-CONTROL encoder
Previously it could encode both incorrect values as well as incorrect
message. Let's fix this by explicitly checking for invalid values and
ensuring that at least one of the parameters is valid.

This function have no external or internal users so it's better to fix
type signature as well to match the rest of gsm0808_create_lcls_*().

Change-Id: I7b33a771acbd391c5f9a494d6450edb18511433f
2019-01-07 15:49:36 +00:00
Max 42e567c5a9 Automatically disable GnuTLS fallback
Disable GnuTLS fallback if sufficient glibc version detected. Previously
GnuTLS fallback was used regardless of getrandom() availability in
glibc. Fix this by automatically disabling it when not needed. This does
not affect the ability to manually disable it unconditionally.

Change-Id: Ibe2117afc050261668a4d5a590044aabcd08aefe
2019-01-07 15:45:00 +00:00
Max 0187c3ae37 Streamline glibc version check
* use macro for version check
* report glibc version upon random.h detection
* comment where various #endif belongs to
* explicitly check for embedded build (our target toolchain don't use
  libc so there's no point in checking its version)

Change-Id: Ia54f0b7a861f955be65bb0cf06eb10af9372d062
2019-01-07 15:45:00 +00:00
Vadim Yanitskiy 660729c398 tests/gsup_test.c: drop session IEs from MO-ForwardSM Error
Both session state and session ID IEs were left from the initial
version of Ibe325c64ae2d6c626b232533bb4cbc65fc2b5d71. There is
no need to use them (as we use SM-RP-MR), so let's clean up.

Change-Id: I0d910b87f15ffbc0aeeca9cb4fcbef32bdf3ef88
2019-01-05 10:15:47 +00:00
Neels Hofmeyr 86a5aae218 fix typo in enum BSS_MAP_MSG_TYPE: BSS_MAP_MSG_ASSIGMENT*
Keep #defines to still support previous wrong spelling.

Change-Id: Id4cf812f0bc3cd40f6bfa05166f817a07a647f71
2019-01-04 04:39:18 +01:00