Commit Graph

1111 Commits

Author SHA1 Message Date
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
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 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 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
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
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
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 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
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
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
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
Neels Hofmeyr 0d39a8de3c osmo_rat_type: add OSMO_RAT_EUTRAN_SGS
osmo-msc is about to implement the SGs interface and requires a RAT indicator
for that.

Change-Id: I00588396bfe03feba38ecb0717d584594f0b2b46
2019-01-04 04:38:54 +01:00
Neels Hofmeyr 5b5c3499cf gsm_utils: add enum osmo_rat_type, from osmo-msc enum ran_type
In the MSC, we have RAN types GERAN_A and UTRAN_IU, now we need a similar enum
in osmo-hlr's GSUP client.

Naming: in the MAP specifications, the RAN type is mostly called RAT type,
(Radio Access Network vs. Radio Access Technology?). Since GSUP is more about
MAP messages, I'm calling the enum osmo_rat_type.

Rationale: osmo-msc and osmo-sgsn want to tell the osmo-hlr which RAT a
subscriber is calling on. A subsequent patch will extend the GSUP protocol and
add a RAT types IE.

Change-Id: I659687aef7a4d67ca372a39fef31dee07aed7631
2019-01-03 02:21:23 +01:00
Neels Hofmeyr 691ba52194 add LOGPFSMSL(), LOGPFSMSLSRC()
Using an FSM instace's logging context is very useful. Sometimes it makes sense
to log something on a different logging category than the FSM definition's
default category.

For example, an MSC conn has aspects concerning MM, CC, RR, MGCP, ..., and
currently all of those log on DMM.

This came up in I358cfbaf0f44f25148e8b9bafcb9257b1952b35a, where I want to log
an MGCP event using a ran_conn context, and used the conn->fi->id. That of
course omits context like the current conn FSM state...

I remember at least one other place where I recently added logging using some
fi->id as context, so it might turn out useful in various places.

Change-Id: I11b182a03f5ecb6df7cd8f260757d3626c8e945d
2019-01-03 00:11:49 +01:00
Neels Hofmeyr b0b39af1bc LOGPFSM*: guard against fi == NULL
The LOGPFSM macros are in such wide use that they should guard against a NULL
fi pointer. In case of NULL, default to subsys = DLGLOBAL, loglevel =
LOGL_ERROR and state = "fi=NULL".

Change-Id: I9eaf8b7e2cf1e450ae626cb2fc928862008f6233
2019-01-03 00:11:49 +01:00
Neels Hofmeyr b11ff7c537 add API doc for LOGPFSM* macros
Change-Id: I3bf6500889aa58195f50a726dec0876c0c2baec3
2019-01-03 00:11:49 +01:00
Max 470221575d LCLS: enc/dec entire parameter set instead of GCR
In 3GPP TS 48.008 the Global Call Reference IE is only used in HANDOVER
REQUEST (§3.2.1.8) and ASSIGNMENT REQUEST (§3.2.1.1) messages which
also include LCLS Config and CSC parameters. Hence, there's no point in
using GCR encode/decode functions alone.

Introduce gsm0808_dec_lcls() and gsm0808_enc_lcls() as trivial wrappers
on top of GCR enc/dec routines which are made static. Adjust tests
accordingly. Test output intentionally left unchanged.

Change-Id: Icfbb2404e1a1d500243e2071173299b557369335
2018-12-23 10:20:05 +00:00
Neels Hofmeyr e5bde90532 define LOGPFSM fmt only once, in LOGPFSMLSRC
Instead of duplicating the fmt and args in LOGPFSML and LOGPFSMLSRC, rather
make LOGPFSML invoke LOGPFSMLSRC with __FILE__ and __LINE__.

This is a cosmetic preparation for more tweaks coming up.

Change-Id: I2f23c57ebfdb5355919c06ac5ded7732e3b17a97
2018-12-23 10:08:55 +00:00
Holger Hans Peter Freyther 99ae401e49 vty: Make TCP port configurable and introduce telnet_init_default
Extend the vty_bind_cmd VTY command to allow to optionally specify
a port in addition to the IPv4 address.

Introduce telnet_init_default to relieve client code from having
to query the bind IPv4 address (and now the TCP port). Instead a
client only needs to pass the default TCP port to use.

Client code should use it like:

	int rc = telnet_init_default(ctx, priv, OSMO_VTY_PORT_SGSN);

Change-Id: Id5fb2faaf4311bd7284ee870526a6f87b7e260f3
2018-12-23 04:20:08 +00:00
Oliver Smith 10db2817e5 GSUP: add CHECK-IMEI message
Implement necessary messages for Procedure Check_IMEI_VLR (TS 23.018
Chapter 7.1.2.9). This lets the VLR ask the EIR to check if an IMEI
is valid. In the Osmocom stack, we don't have an EIR and this request
will be handled by the HLR. We will be able to store the IMEI in the
HLR as side-effect (OS#2541).

This is roughly based on TS 29.002 8.7.1 MAP_CHECK_IMEI service, but
only implements the bare minimum required IEs (imei and imei_result).

Related: OS#3733
Change-Id: I085819df0ea7f3bfeb0cabebb5fd1942a23c6155
2018-12-21 13:13:30 +01:00
Oliver Smith 19742408cf GSUP: add end marker to enum osmo_gsup_iei
Simplify gsup_test.c by defining an end marker in gsup.h. No need to
manually update the last element every time anymore.

The C standard guarantees, that the end marker will have the last value
plus one: "Each subsequent enumerator with no = defines its enumeration
constant as the value of the constant expression obtained by adding 1 to
the value of the previous enumeration constant." (From C99: 6.7.2.2
Enumeration specifiers)

Change-Id: I2aab7245e209f0ebd2f33a83d4d181dd3339cb17
2018-12-21 13:13:11 +01:00
Max bd6d5c10db TLV: add convenience function for 1-byte values
Similar to existing 16 and 32 bit value helpers but simpler because we
don't have to worry about alingment and endianness.

Change-Id: Ic0a148bd04b8860e321f509fdcd913f688c8e920
2018-12-20 09:52:15 +00:00
Max e6f63f22c5 TLV: fix doc copy-paste error
Change-Id: I8aa79cab7505585de00ee2aaae125462108906e8
2018-12-20 09:52:15 +00:00
Max af25c37f90 Use define for key buffers
Add corresponding spec. references and comments where appropriate.

Change-Id: If5e2aad86eaecd8eada667b3488ba415d81c6312
2018-12-20 09:51:02 +00:00
Stefan Sperling 6cb833608f rename CELL_IDENT_LAI_AND_LAC to CELL_IDENT_LAI
The name "LAI AND LAC" makes no sense because a LAC
is part of a LAI. Keep the old name available for
API backwards compatibility.

Change-Id: I2749cf75b7b45de0cd43cf4c696a6b6984f5a065
Related: OS#3124
2018-12-19 19:58:18 +01:00
Neels Hofmeyr b26003963e add/clean big-endian packed structs (struct_endianess.py)
This is 1:1 the result of doing

  cd libosmocore
  ./contrib/struct_endianess.py
  git commit -a

Running struct_endianess.py again should result in no changes.

That means we could include such a check in the gerrit verification job now.

Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2
2018-12-19 18:40:03 +00:00
Neels Hofmeyr 0145751a97 add to osmo_sock_get_name*() API
Basically, I am applying code review that I would have given had I not been on
vacation when the last osmo_sock_get_name* stuff was merged.

osmo_sock_get_name2() is so far a static internal function. However, it is
nothing like osmo_sock_get_name(), so instead rename it to
osmo_sock_get_ip_and_port(). Also make it public API, no need to hide it.  I'm
adding an "and" in the name to hopefully clarify: "ip_port" vs. "ip_and_port"
-- there already are _get_X_ip_port() functions that only return the port
string, despite "ip" in the name.

Add new public osmo_sock_get_name2(), which is like osmo_sock_get_name(),
except it uses a static string instead of talloc, and omits the braces. This
is most convenient for log statement formats, avoiding dyn allocations.

Add new osmo_sock_get_name_buf(), which is like osmo_sock_get_name2() but
writes to a caller provided char buffer.

Use osmo_sock_get_name_buf() in the implementation of osmo_sock_get_name(),
but use another (non-static) local string buffer, because adding braces is too
complex without talloc_snprintf().

Rationale:

I want to improve the logging of socket errors, e.g. change

  DLMGCP ERROR Failed to read: 111/Connection refused (mgcp_client.c:720)

to

  DLMGCP ERROR Failed to read: r=10.0.99.2:2427<->l=10.0.99.2:2728: 111='Connection refused' (mgcp_client.c:721)

but it is just not handy to compose logging with the current API:

- osmo_sock_get_name() requires a talloc_free().
- all the others require output buffers.
- the only way to conveniently compose a logging string and,
- notably, the only trivial way to skip the string composition if the logging
  level is currently muted, is to have a function that returns a static string:
  the new osmo_sock_get_name2().
- (I think the osmo_sock_get_{local,remote}_* convenience wrappers should never
  have been added, because they encourage the caller to invoke the same code
  twice, for IP addr and port, and throw away one half each time.)

Related: Iae728192f499330d16836d9435648f6b8ed213b6 (osmo-mgw)
Change-Id: I8ad89ac447c9c582742e70d082072bdd40a5a398
2018-12-19 03:25:55 +01:00
Vadim Yanitskiy f9ee8da0cd GSUP/SMS: introduce READY-FOR-SM message
According to 3GPP TS 29.002, section 12.4, MAP-READY-FOR-SM is
used between the MSC and VLR as well as between the VLR and the
HLR to indicate that a subscriber has memory available for SMS.

This change replicates this service in GSUP as READY_FOR_SM_*.
The only mandatory IE for this service (excluding Invoke ID) is
'Alert Reason' that is replicated by OSMO_GSUP_SM_ALERT_RSN_IE.

Change-Id: Ic37f3b2114b8095cfce22977e67133b9103942e3
Related Change-Id: (docs) I549b6c8840a1e86caac09e77fb8bc5042d939e62
Related Change-Id: (TTCN) If2256607527ecfcb10285583332fb8b0515d7c78
Related: OS#3587
2018-12-18 21:52:06 +07:00
Vadim Yanitskiy c2628317cc GSUP/SMS: introduce MO-/MT-FORWARD-SM messages
According to 3GPP TS 29.002, there are two services:

  - MAP-MO-FORWARD-SHORT-MESSAGE (see 12.2),
  - MAP-MT-FORWARD-SHORT-MESSAGE (see 12.9),

which are used to forward MO/MT short messages.

This change replicates both services as GSUP messages:

  - OSMO_GSUP_MSGT_MO_FORWARD_SM_*,
  - OSMO_GSUP_MSGT_MT_FORWARD_SM_*.

Please note, that only the 'must-have' IEs are introduced
by this change, in particular the following:

  - OSMO_GSUP_SM_RP_MR_IE (see note below),
  - OSMO_GSUP_SM_RP_DA_IE (see 7.6.8.1),
  - OSMO_GSUP_SM_RP_OA_IE (see 7.6.8.2),
  - OSMO_GSUP_SM_RP_UI_IE (see 7.6.8.4),
  - OSMO_GSUP_SM_RP_MMS_IE (see 7.6.8.7),
  - OSMO_GSUP_SM_RP_CAUSE_IE (see GSM TS 04.11, 8.2.5.4),

where both SM_RP_DA and SM_RP_OA IEs basically contain
a single nested TV of the following format:

  - T: identity type (see 'osmo_gsup_sms_sm_rp_oda_t'),
  - V: encoded identity itself (optional).

According to GSM TS 04.11, every single message on the SM-RL has
an unique message reference (see 8.2.3), that is used to link
an RP-ACK or RP-ERROR message to the associated (preceding)
RP-DATA or RP-SMMA message transfer attempt.

In case of TCAP/MAP, this message reference is being mapped to the
Invoke ID. But since GSUP has no 'Invoke ID' IE, and it is not
required for other applications (other than SMS), this change
introduces a special 'SM_RP_MR' IE that doesn't exist in MAP.

Change-Id: Ibe325c64ae2d6c626b232533bb4cbc65fc2b5d71
Related Change-Id: (docs) Ie0150756c33c1352bc4eb49421824542c711175c
Related Change-Id: (TTCN) Ibf49474a81235096c032ea21f217170f523bd94e
Related: OS#3587
2018-12-18 21:52:01 +07:00
Max 5207432780 LCLS: add gsm0808_create_ass2()
It allows setting additional assignment parameters explicitly.

Change-Id: Id89765df3f8c12f55f73f1d7a9d90c8883eb3bba
Related: OS#2487
2018-12-14 13:15:39 +00:00
Max 969fb2ed84 LCLS, TS 48.008: add GCR IE encoding/decoding
* add functions to encode Global Call. Ref. from TS 29.205 as 3GPP TS
  48.008 §3.2.2.115 information element
* add corresponding tests

Change-Id: I82ce0207dc8de50689a8806c6471ad7fbae6219d
2018-12-14 13:15:39 +00:00
Max 7918f84aeb LCLS, TS 29.205: add GCR routines
Add functions to encode and decode Global Call Reference as per
3GPP TS 29.205 Table B 2.1.9.1 add corresponding tests.

Change-Id: Iee95aa4e5c056645b6cb5667e4a067097d52dfbf
Related: OS#2487
2018-12-14 13:15:39 +00:00
Pau Espin 2bf01d439c stats.h: Fix build on MacOS
Otherwise struct osmo_stats_config is not defined and compiler fails.

Related: OS#3722
Change-Id: I037c3ca141ecee2d457e0a881a56e32ee24cec4d
2018-12-13 13:01:28 +00:00
Max db038255eb msgb: add test helpers
It's often handy to compare certain msgb layer to a given array and
print the position where they differ. Add simple pretty-printer and
corresponding L* wrappers.

Change-Id: I3bc95f2f5ab6e3f4b502647fb3e0aaaf1f7c4cf5
2018-12-12 09:34:12 +00:00
Neels Hofmeyr 7079e69848 add osmo_bcd2str()
Add a standalone bcd-to-string conversion function with generic parameters.
Add a regression test in utils_test.c.

So far there is no single universal implementation that converts a BCD to a
string. I could only find gsm48_mi_to_string(), which also interprets
surrounding bytes, MI type and TMSI as non-BCD value.

The idea is to use this function from gsm48_mi_to_string() and similar
implementations in subsequent commits.

Root cause: in osmo-msc, I want to have an alternative MI-to-string function
for composing an FSM name, which needs the BCD part of gsm48_mi_to_string() but
not the TMSI part.

Change-Id: I86b09d37ceef33331c1a56046a5443127d6c6be0
2018-12-10 17:06:30 +00:00