Commit Graph

2758 Commits

Author SHA1 Message Date
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
Vadim Yanitskiy d8fcef7794 gsm0480: fix copy-pasted note for gsm0480_gen_return_error()
InvokeID is mandatory for ReturnError component.

Change-Id: Ie1c7116d368c2029b9f524cb74ffa316e282ec83
2018-12-14 00:31:06 +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 48b2de0972 fix api doc for osmo_bcd2str()
Change-Id: I504ea849fc9daeb34a1b3c5343371161deba743e
2018-12-11 02:14:20 +01:00
Neels Hofmeyr 6adffb9573 gsm48_mi_to_string(): do not read from zero length input buffer
Change-Id: I12cada7c2c5187146ca5a33d1ebfefb4cad65632
2018-12-10 17:06:30 +00:00
Neels Hofmeyr ea2a0ab041 gsm48_mi_to_string(): guard against zero length output buffer
All successful cases already return from the switch(), so simply handle all
errors below it by returning an empty string (if there is enough string
buffer).

Change-Id: I709ac3b9efb7b4258d8660715b10312e11b9b571
2018-12-10 17:06:30 +00:00
Neels Hofmeyr 23187fa108 gsm48_generate_mid(): mask out ODD flag from mi_type
For MI encoding, see 3GPP TS 24.008, 10.5.1.4 Mobile Identity. The 'odd' flag
indicates whether the last BCD nibble is used. Of course that flag should be
made sure to reflect the actual length.

Change-Id: Id6e695ebf9f86b295eaa7e2c6228989256f37e68
2018-12-10 17:06:30 +00:00
Neels Hofmeyr 627e0113d1 gsm48_mi_to_string: use osmo_bcd2str(), fix some corner cases
By using osmo_bcd2str(), ensure that the resulting string is always nul
terminated, and always return strlen()+1 whether truncated or not.

Still keep up the previous return value style, even if that isn't consistent at
all.

The difference between IMSI/IMEI and TMSI return values remains and is not part
of this patch.

Change-Id: I1b51b72a721e1cc9d69796b804ebda741ff0f36b
2018-12-10 17:06:30 +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
Max c01cff1a50 Constify llist_count() parameter
Counting list entires should not alter the list content: let's make this
obvious from type signature.

Change-Id: I414e67a3de733fab407161b3264d3b89070ba537
2018-12-10 13:42:08 +00:00
Neels Hofmeyr 6aa20eee29 api doc: gsm48_mi_to_string(): warn of return value implementation
Change-Id: If5e7abd15dddf39cdfad8071f4cd5ca8244eabe0
2018-12-10 13:18:38 +01:00
Neels Hofmeyr 496862818d gsm0408_test: test encoding and decoding Mobile Identity
One would think by now we would solidly encode and decode Mobile Identities.
Well, guess again.

- rc is sometimes the amount of bytes written, sometimes actual strlen().

- on string truncation, rc is sometimes strlen() (assuming nul terminated), and
  sometimes snprintf()-style would-be strlen().

- returned string, when truncated by not enough buffer size, is sometimes nul
  terminated, sometimes not.

- gsm48_mi_to_string() happily reads a byte from zero-length input buffer.

- gsm48_mi_to_string() happily writes to zero length output buffer.

- gsm48_mi_to_string() returns nonempty string for empty input.

- encoding a MI type that still has the GSM_MI_ODD flag set results in encoding
  an even-length MI as odd-length (hence appending a stray 'F').

I am going to tweak the implementation of gsm48 mobile identity encoding /
decoding, so first pinpoint the current behavior in a unit test, and show how
perforated even such a seemingly trivial API can be.

Change-Id: Iaae3af87f82f1a8f2e6273984c011b2813038cf7
2018-12-10 13:18:38 +01:00
Pau Espin 2ca8cebac6 timer: Fix clockid_t undefined on MacOS < 10.12
Related: OS#3722
Change-Id: If466a64bd44dcb8ae8a9b7f82bc9c9435ba3e640
2018-12-10 11:02:16 +01:00
Philipp Maier 4f4905fac5 gsm0808: add encoder for cause codes and use it
At the moment the all gsm0808 cause codes are encoded directly using the
tlv API directly to put a one byte TLV field. This works ok for most
situations where the cause code consists of a single byte. However,
gsm0808 specifies a two byte cause code model where cause codes may be
extended up to two bytes. Instead of implementing the encoding over and
over and again, let's rather have an encoder function we can call.

- Add an encoder function that can generate single byte and extended
  cause codeds and makes the length decision automatically.

- Use only this function to append cause codes

Change-Id: I71d58fad89502a43532f60717ca022c15c73f8bb
2018-12-08 19:29:34 +00:00
Philipp Maier e190e032d9 gsm29118: add generator functions for GSM29118 messages
We already have some GSM29118 related definitions and functions in
libosmocore. Lets also add some functions to generate GSM29118 messages
(similar to those we have for GSM0808).

Change-Id: Ic87f8a771b87b52215d0a7451b67794557b80b8a
Related: OS#3615
2018-12-07 18:35:10 +01:00
Philipp Maier f98c78ec4a gsm_29_118.h: Add constant for default port
The specification defines a default port where the SGs interface should
be reachable. Lets add a define-constant for it.

Change-Id: Ia4b9f547dd980411d15b2691b7f535fa0463f0f1
Related: OS#3615
2018-12-07 12:03:44 +00:00
Philipp Maier 8a942d27b6 cosmetic apn: correct whitespace error
there is a whitespace between the * and osmo_apn_to_str(). Lets
remove this.

Change-Id: I094e6eb08eacf2d6459c47a7370837601aa92925
2018-12-07 11:53:23 +00:00
Max 9d7a247da4 Add osmo_sockaddr_in_to_str_and_uint()
It's similar to osmo_sockaddr_to_str_and_uint() but does not require odd
typecasting for AF_INET case. Make osmo_sockaddr_to_str_and_uint() into
wrapper around new function and make sure to check for address family
before typecasting. Also use proper return type.

Change-Id: Ie384483124d407a960ab6732e6a7fd90554389d2
2018-12-07 10:33:29 +00:00
Max 72dfd43799 Allow log_init() with NULL log_info
Since we have library-internal categories we don't have to force
application to supply its own categories. This is especially useful for
testing code inside libosmocore which only use internal categories
anyway.

Change-Id: I42159780b57684bff225789f036f28a4b25fc7b8
2018-12-06 15:52:28 +01:00
Philipp Maier 5986a3d89d gsm_29_118: add missing extern for struct value_string decl.
The value string arrays in the header file (gsm_29_118.h) are not
declared as extern. Lets add it now.

Change-Id: Ib6c4cbea649f790fa4db1ed2fe2b7e76a60291b4
Related: OS#3615
2018-12-05 19:35:47 +00:00
Max 14f24c678f LCLS: update osmo_lcls struct
* use pointer to proper struct type for GCR
* update comments to be useful for doxygen

Change-Id: I8ccfbd0c146e462e599e5305520cc89602364ec3
2018-12-04 10:26:42 +01:00
Max d82070c383 Add msgb_tl_put() helper
When adding complex TLV structures where length of V is not known in
advance it's handy to be able to simply add Tag and save the pointer to
the Length field so it can be updated once entire Value is added and its
length is known.

Change-Id: I8dc1e4880352833a0a49c1dd0d7cb4148ac43aff
2018-12-04 10:26:42 +01:00
Max 30b2e348df ctrl: use #define for TRAP id
We always use id = 0 when sending TRAP messages. Let's make this more
obvious by introducing appropriate define.

Change-Id: I33d7d4c6a1885a75a85d6f2f017430e0860b4126
2018-12-03 21:42:51 +00:00
Max cb02a391cd Update msgb Lx helpers
* add missing L1 and L4 hexdump
* add msgb_l4() for consistency and convert msgb_sms() into simple alias

Those will be used in follow-up patches for msgb debug/test helpers.

Change-Id: I8d6dd1b1ff3aa98a452711c692ca7dee0449203b
2018-12-03 16:11:58 +00:00
Philipp Maier 225bdf4779 gsm0808: add message generator for BSSMAP HANDOVER PERFORMED
We currently have no generator function that can generate BSSMAP
HANDOVER PERFORMED messages. Lets add function for this.

Change-Id: I825106858bd89afc9837811b8fed2e8accc82441
Related: OS#3645
2018-12-03 13:54:31 +00:00
Alexander Couzens a2f696fa5c configure.ac: check clock_gettime for glib < 2.17
glib < 2.17 doesn't support clock_gettime directly, it is available
via librt.

Change-Id: Ice853d85ffe859b1d4df48b91b050c24d85c861b
2018-12-03 13:52:29 +00:00
Max f69aa9cb6a Move BSSMAP_MSG_* defines to header file
This will be reused be several tests related to TS 48.008 and TS 29.205
in follow-up commits.

Change-Id: I4d8cc05b8df8e70c1f6257e53ae3acec7901681f
2018-11-30 17:45:57 +01:00
Max a66de71f8e ctrl: print textual error on IPA parsing failure
Change-Id: I49bb613b416d549f554fd9d23cd37b63954324db
2018-11-26 10:15:02 +01:00
Neels Hofmeyr 7ab5fc1f3b add contrib/struct_endianess.py
In libosmocore (and likely elsewhere) we have scores of packed structs with
sub-byte integer members that lack the necessary member reversal shims to be
able to work on big endian architectures.

Instead of manually editing each one of them and probably introduce errors in
the process, this script handles the change automatically, and in the future
allows us to verify correctness in gerrit verifications.

Change-Id: I8e75b17d8071c7b3a2a171ba776fb76854b28a53
2018-11-22 13:49:24 +00:00
Max 49c06680e7 Update gsm0808_create_ass() doxygen
* add spec reference
* remove LCLS note: CI parameter is optional but have nothing to do with
  LCLS

It's pretty hard to decipher from the spec what CI is useful for and we
have not used it anyway so let's just keep it as "Optional" for now.

Change-Id: I5552732afcec48047d993ae6ffb73a3e5d7c9202
2018-11-22 12:54:52 +00:00
Pau Espin c8772517d9 gsm: Deprecate buggy gsm_arfcn2band API and introduce gsm_arfcn2band_rc
ARFCNs are values in well defined ranges. Until this patch, ARFCNs not
belonging to any band were blindly assigned to DCS1800 by
gsm_arfcn2band, causing unnoticed bugs and misconfigurations in
osmo-bsc.

Previous API gsm_arfcn2band cannot accomodate this kind of check easily,
so let's deprecate it to tell people to use a new API gsm_arfcn2band_rc
which performs this kind of checks and allows callers to log failures,
misconfigurations, etc.
At the same time, modify implementation of gsm_arfcn2band to abort if an
invalid ARFCN is passed, this way users of this API can notice they are
passing wrong data to it that most probably will produce unexpected
results.

Related: OS#3063
Change-Id: I780d452dcebce385469e32ef2fd844df6033393a
2018-11-20 16:56:28 +00:00
Max 738782467f LCLS: add 48.008 parameter structure
It's convenient to hold all LCLS-related parameters from 3GPP TS 48.008
in a single structure.

This will be used in follow-up patch handling Assignment Request with
extended parameters as well as corresponding BSC code working with LCLS.

Change-Id: I4b873f9a3c5a5d33b438382971b3d92e40d48d62
Related: OS#2487
2018-11-20 12:32:56 +00:00
Stefan Sperling c6bfc63d10 document unblock-ack vs. signalling in gprs_ns_process_msg()
Since commit 797558ea17 we send the
NS_UNBLOCK_ACK message before dispatching the NS_UNBLOCK signal,
instead of afterwards.

Add comments which explain the intended order of events.

Suggested-by: Pau
Related: OS#2388

Change-Id: I4b93853c952a97302f8afc14f462f22c3e487564
2018-11-20 11:06:05 +01:00
Stefan Sperling 797558ea17 send NS_POUT_UNBLOCK_ACK before signalling S_NS_UNBLOCK
In gprs_ns_process_msg(), we were dispatching the S_NS_UNBLOCK
signal before sending out the NS_POUT_UNBLOCK_ACK message.

Signal handlers might send messages to the other side, assuming
that NS is now unblocked. However, since such messages will arrive
before the UNBLOCK_ACK message the receiver might discard them.
This problem has been observed with our TTCN3 BSSGP_Emulation
as a peer to osmo-pcu.

This patch makes TTCN3 PCU TC_paging() test pass regardless of
whether the test or osmo-pcu is started first. Before this patch,
this test would only pass if the test was started before osmo-pcu.
A remaining problem is that the test does not yet keep passing
reliably unless osmo-pcu is restarted between test runs.

Change-Id: I3af54a14bb6bcfa167c9a9d9f67835e7f5b9f1bb
Related: OS#2890
Related: OS#2388
2018-11-19 17:30:37 +01:00
Neels Hofmeyr 5a25c3ec4d gsm_44_318.h: remove #if 0 from struct gan_cch_desc_ie
These are actually parts of the struct in big endian order, which will soon be
done automatically by struct_endianess.py.

Change-Id: I9bc694f10fa9cef0bb7fc791bb40e7602459b16b
2018-11-19 14:38:45 +00:00
Max adc4172fe3 Add missing header include
That's necessary for 'struct tlv_parsed' definition although lack of it
does not cause build failure in libosmocore for me but does so for
osmo-bsc.

Change-Id: I3b2d3955d02b07dc7ec5e9f0c66cc477196703ed
2018-11-19 10:44:55 +01:00
Max ed651d2485 Support cipher mode reject with extended cause
* add function to generate cipher mode reject with extended (2-byte)
  Cause IE
* add function to get (extended) Cause value
* add corresponding (extended cause) test
* update existing (non-extended cause) test
* use enum as a parameter for existing non-extended version to make
  interface more unified

Change-Id: Id5509b94a18180a44f45300caaa02b843c166fa3
Related: OS#3187
2018-11-19 05:52:28 +00:00
Max 84fb5bb6a0 Move msgb_push helpers to public header
The msgb_wrap_with_TL() is generally useful so it make sense to make it
public to facilitate code re-use.

Other helpers can be implemented as trivial wrappers over existing tlv.h
functions. Update headers and code accordingly.

Change-Id: I37e91d031fba28cf1c6735b8069b0265746f55e6
2018-11-19 05:47:25 +00:00
Pau Espin d8d0c3e2d1 gsm48: gsm48_decode_freq_list: Improve documentation of paramter f
Change-Id: Id8e3afff737211ded3c5689f2c83b1a544b42f9d
2018-11-18 20:44:04 +00:00
Max 961db7c270 Update GSM0808_LCLS enums
Add values indicating that LCLS control/config/status value has not been
received yet.

Change-Id: I52dc6a52f5ee043ed2c1625ffecfd495e3c746b1
Related: OS#2487
2018-11-18 20:20:48 +00:00
Max aa93463053 Update 3GPP TS 08.08 Cause handling
* add Class definitions
* add helper to check for extended bit
* add helper to get Cause's Class
* use enum in gsm0808_cause_name() and gsm0808_create_cipher_reject() to
  avoid confusion between class and cause
* update gsm0808_create_cipher_reject() comments

Change-Id: I31b31dfc22eb4b6b07089e1255246ac458125340
Related: OS#3187
2018-11-18 20:14:06 +00:00
Max c0d1de36f3 Add helper wrapper for BSSAP TLV parsing
Change-Id: Ib228368901ce90a02a5664f2510593371c7d29cd
2018-11-18 20:13:15 +00:00
Philipp Maier af6710f4d4 fsm: fix apidoc of osmo_fsm_state_name()
The api documentation of osmo_fsm_state_name() refers to an FSM
instance, but it really means the state of an FSM.

Change-Id: I88ddd6048426d380c49170e66f57b3843398c046
2018-11-16 17:45:40 +01:00
Philipp Maier 086b345414 gsm29118: add value strings for SGSAP IEI
The value strings for the SGSAP IEI are missing, lets add a set of value
strings and a function to retrieve them.

Change-Id: I2787303174f74ffba86675bce2c12f680d8ea708
Related: OS#3615
2018-11-16 17:42:38 +01:00
Martin Hauke e63b887358 gsm/protocol/gsm_08_58.h: Fix typo
Fix a typo that prevents building on ppc64 (Power8, Big Endian).
Tested with gcc version: 8.2.1+r265487

/bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I..  -I../include -I../include  -DBUILDING_LIBOSMOCORE -Wall -Wall  -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -DBUILDING_LIBOSMOCORE -Wall -c -o panic.lo panic.c
 In file included from ../include/osmocom/gsm/rsl.h:6,
                  from gsmtap_util.c:37:
 ../include/osmocom/gsm/protocol/gsm_08_58.h:60:4: error: expected specifier-qualifier-list before 'sapi'
     sapi:3;
    ^~~~

Change-Id: I4a40fc68cb6dfdfadfcc34213c4ecdabbbc356f2
2018-11-15 14:53:13 +01:00
Oliver Smith 4c9d1479a6 merge_doc.xsl: move to osmo-gsm-manuals.git
Allows building the manuals without the checked out libosmocore source.

Related: OS#3385
Depends: I8e7036fae062ee783cb132b14608827a82c5e7c7 (osmo-gsm-manuals)
Change-Id: Ifb81b18422987cdf36b75993d2782abf93b5f48c
2018-11-12 14:07:05 +01:00