Commit Graph

6934 Commits

Author SHA1 Message Date
Vadim Yanitskiy 09ce3dcbdf libmsc/msc_vty.c: print subscriber expiration time
Change-Id: I092691a8c443f4c5ed4d33de2e551fef592c1baf
2019-07-09 07:14:09 +00:00
Vadim Yanitskiy d14422a236 Fix: add missing semicolons to OSMO_ASSERT statements
Change-Id: I4fae5fbab5fdbcce35906601d4f1031d971f4931
2019-07-09 07:13:45 +00:00
Vadim Yanitskiy 1c50044efb libmsc/ran_msg_iu.c: fix: properly handle SAPI IE of RANAP_DirectTransfer
The RANAP DirectTransfer message may contain an optional SAPI IE.
Thanks to our TTCN-3 tests (and Wireshark!), it was discovered
that this IE is ignored, so even if the MO SMS related messages
arrive on SAPI 3 (as per GSM TS 04.11, section 2.3) OsmoMSC sends
MT messages on SAPI 0.

In ran_iu_decode_l3() we need to check if the SAPI IE is present,
and tag the NAS PDU message buffer with a proper DLCI value.

This change makes the failing SMS related test cases pass.

Change-Id: I728b55b04e87fc23be6d4f8735e8cad82b6f640e
2019-06-20 16:54:45 +00:00
Vadim Yanitskiy 7659482318 libmsc/gsm_04_11.c: do not abuse LOG_TRANS() in gsm411_alloc_mt_trans()
This change is similar to I6b68a0f0b32eb126e0f7e914a314130254d28467.
If we 100% sure that trans == NULL, it makes more sense to use
generic LOGP(DLSMS, LOGL_*, ...) call, so the logs can reflect
more information than such dummy prefix:

  trans(NULL NULL callref-0x0 tid-0) ...

Change-Id: I3c1e633aee5dd7cd0d367404a3def9cffe0b3baa
2019-06-20 16:54:45 +00:00
Vadim Yanitskiy 59e0c6b46a gsm_04_11_gsup.c: fix broken reference counting for vsub
This change is similar to I5540556b1c75f6873883e46b78656f31fc1ef186.
In gsm411_gsup_rx() we do call vlr_subscr_find_by_imsi(), which
increases subscriber's reference count by one using the function
name as the token. However, we never release this token, so the
reference count grows on every received GSUP FORWARD-SM message.

Change-Id: Ic729beb5f94cbbfbb251bc9ab66a5e7b799286c0
2019-06-20 16:54:45 +00:00
Pau Espin fe5b7046ea sms_queue.c: Improve misleading log line
Otherwise when read in a log file it seems it's really going to send 20
sms even if there's none to send.

Change-Id: Ieb9bb61a90f295d2ba5fb67a2abee2d30785876d
2019-06-20 10:45:37 +02:00
Vadim Yanitskiy 718f32fa88 libvlr/vlr.c: do not expire subscribers if periodic LU is disabled
When periodic Location Update is disabled (T3212 = 0), it was noticed
that OsmoMSC does expire subscribers quite soon - after 60 seconds
(VLR_SUBSCRIBER_LU_EXPIRATION_INTERVAL) since the last LU.

In order to avoid that, we need to check T3212 timer value in
vlr_subscr_expire_lu(), and if it's equal to 0, do not expire
anybody until the explicit IMSI Detach.

Change-Id: I2ead2241a3394dbdd5417f4554190df3fd698af2
2019-06-19 14:36:28 +07:00
Vadim Yanitskiy 188dd5f4df tests/msc_vlr: fix: do not pass RAT type to expect_bssap_clear()
The function name implies OSMO_RAT_GERAN_A, and it has nothing
to do with other OSMO_RAT_* types. Found using clang:

  warning: too many arguments in call to 'expect_bssap_clear'
           expect_bssap_clear(OSMO_RAT_GERAN_A);
	                      ^^^^^^^^^^^^^^^^

Change-Id: Id3a3af33fcc5da4ca4c48a2f589a69f3568d2586
2019-06-19 02:05:08 +07:00
Daniel Willmann 7a2c9c91e9 manuals: Include overview chapter about counters
Change-Id: I8c3e8bcda27f35118ab0e3d75621a02eec86f15c
2019-06-18 18:07:43 +02:00
Daniel Willmann fb73e0c654 manuals: Update counter/vty documentation
Change-Id: I1ef0e8ae166d7fdc5e85716a961e8387d26bdd2c
Related: OS#1700
2019-06-18 12:51:07 +00:00
Daniel Willmann a794ff4f46 manuals: Add script to update vty/counter documentation from docker
Change-Id: I3f5573f81460b40d4606fbcf0febcfd078a7bdca
Related: OS#1700
2019-06-18 12:51:07 +00:00
Vadim Yanitskiy b3bdc768be libmsc/gsm_09_11.c: do not suppress rc of gsup_client_mux_tx()
Change-Id: Ide2440188fb6fe1c54681fef8ec4fed9e6da66e2
2019-06-17 22:23:09 +07:00
Vadim Yanitskiy 6632251572 libmsc/gsm_09_11.c: do not abuse LOG_TRANS() in gsm0911_rcv_nc_ss()
If we 100% sure that trans == NULL, it makes more sense to use
generic LOGP(DSS, LOGL_*, ...) call, so the logs can reflect
more information than such dummy prefix:

  trans(NULL NULL callref-0x0 tid-0) ...

Change-Id: I6b68a0f0b32eb126e0f7e914a314130254d28467
2019-06-17 22:13:03 +07:00
Vadim Yanitskiy e0da446e76 libmsc/gsm_09_11.c: fix broken reference counting for vsub
In gsm0911_gsup_rx() we do call vlr_subscr_find_by_imsi(), which
increases subscriber's reference count by one using the function
name as the token. However, we never release this token, so the
reference count grows on every received GSUP PROC-SS message.

Change-Id: I5540556b1c75f6873883e46b78656f31fc1ef186
2019-06-17 21:57:30 +07:00
Vadim Yanitskiy 944d6a2acb libmsc/gsm_09_11.c: avoid double zero-initialization of gsup_msg
Change-Id: Ib991b01534499401e7a0c3de49ceba770fdd9b48
2019-06-17 21:57:30 +07:00
Vadim Yanitskiy f177590488 libmsc/gsm_09_11.c: properly handle OSMO_GSUP_MSGT_PROC_SS_ERROR
This message can be used by the HLR/EUSE to indicate that something
went wrong, e.g. the connection with EUSE is lost, EUSE or the MS
did not respond in time, etc. OsmoMSC needs to release the SS/USSD
transaction, and send GSM 04.80 RELEASE COMPLETE message to the MS
if there is an active RAN connection.

Change-Id: I076d12ef24d7320eda1df1ee4588da7375ef3d9e
Related: (TTCN-3) I5586a88136c936441a842f49248824680603672e
Related: OS#2931
2019-06-17 21:08:14 +07:00
Vadim Yanitskiy 7480852eea libmsc/gsm_09_11.c: inform HLR/EUSE if Paging has failed
Change-Id: Ie2ac06aadb18251310e0cfd85bb0d9865470aab7
Related: (TTCN-3) I1f53c56d569c8ac4071835685bbe3bc9e0ebd7f0
Related: OS#2931
2019-06-17 21:06:43 +07:00
Vadim Yanitskiy 805eca2b3e libmsc/msc_net_init.c: pass pointer to gsm_network directly
Change-Id: I122d2880b356997c60df5f0cf4f5ecb3abb2e672
2019-06-17 21:06:43 +07:00
Vadim Yanitskiy 95b040c45a libmsc/gsm_09_11.c: drop meaningless check for concurrent paging
This check was copy-pasted from the CC handling code during the
initial development of "SS/USSD over GSUP" feature. It probably
makes sense for MT calls, but definitely not for SS/USSD.

Change-Id: I2899a23ee49fd7917443943629603700a5025cf4
2019-06-17 21:06:43 +07:00
Vadim Yanitskiy ae95436c7a libmsc/gsm_09_11.c: drop rudimentary vsub->cgi.lai.lac check
This check was copy-pasted either from CC, or from SMS handling
code during the initial development of "SS/USSD over GSUP". Now
this is the only one survived after the recent refactoring.

I doubt this is exactly the right way to check whether subscriber
is attached or not. Moreover, this check should rather be done in
a single place, rather then in each CC/SS/SMS handler separately.

Change-Id: I7bd48860e923cb1f1a5bccc4b0f497ec1a7bcf84
2019-06-17 21:06:43 +07:00
Vadim Yanitskiy db5bc701a8 libmsc/gsm_09_11.c: log network-originated session establishment error
Change-Id: I090c25de3421f770115ed68a7ecc050694cedff7
2019-06-17 21:06:43 +07:00
Vadim Yanitskiy 10c3ce563b libmsc/gsm_09_11.c: do not abuse LOG_TRANS() and early trans allocation
In case of network-originated SS/USSD session establishment, we
need to verify the received GSUP PROC_SS_REQ message and make
sure that all mandatory IEs are present.

There is no sensible need to allocate a new transaction before
doing all the checks, other than the ability to use LOG_TRANS().
This complicates the code, so let's avoid the early allocation.

Change-Id: I4e027b19e8065a39324a1647957cef4066b82ce7
2019-06-17 21:01:09 +07:00
Eric Wild 58abc67caa libvlr: fix sgsn tmsi creation, replace constant with define
reported by _dev_zero in #osmocom

Change-Id: Ib5679ab5d06b6ef735725b4a68eeb1e9cbcc11ba
Depends-On: libosmocore I52b9f6b5f3e96d85a390ba2af21d7814df8aaeec
2019-06-17 12:51:27 +00:00
Vadim Yanitskiy 01926fc240 libmsc/paging.c: cosmetic: remove leading space in log line
Change-Id: Ie7816f3b30a6c6ac5175646b479eb9a3e76429e1
2019-06-16 00:22:13 +07:00
Vadim Yanitskiy 08553e0f10 libmsc/paging.c: cosmetic: actually use default branch of switch
Change-Id: I9b566885f722a28816760532b645f606fdf4faeb
2019-06-16 00:22:13 +07:00
Vadim Yanitskiy a12ac82352 libmsc/paging.c: avoid double zero-initialization
Change-Id: Icc839370fc39ab57078ec6deeac337ed2f37793c
2019-06-16 00:22:13 +07:00
Vadim Yanitskiy 6539bfb8e3 libmsc/msc_a.c: fix: remove dummy allstate_action of msc_a_fsm
Since [1] has been merged to libosmocore, it was discovered that
the 'msc_a' FSM has a dummy 'allstate_action' handler assigned,
but 'allstate_event_mask' is 0x00 at the same time.

It basically doesn't make any sense, and moreover does cause
warnings and build failures.

[1] https://git.osmocom.org/libosmocore/commit/?id=b3f94eb39e19366c3458643ee329a73155d46ff8
[1] https://gerrit.osmocom.org/#/c/libosmocore/+/14361/

Change-Id: Ieb81b7a07ced1c40ba70d2adb0df68160ee62118
2019-06-16 00:12:17 +07:00
Vadim Yanitskiy 49d45f1e85 libmsc/gsm_04_08.c: clean up unused leftover includes
During the recent refactoring, some code parts has been moved out
of 'gsm_04_08.c', but the related header files were forgotten.

Change-Id: I61e728069a1e79bf72c01ef9d9fc5fb171d3892e
2019-06-15 11:24:00 +00:00
Vadim Yanitskiy efb1f60c76 libmsc/gsm_09_11.c: send GSUP PROS_SS ERROR message when needed
OsmoMSC should notify the remote SS/USSD entity if:

  - received GSUP message has unexpected session state;
  - received GSUP message has unknown session ID;
  - received GSUP message missing mandatory IE(s);
  - NCSS transaction establishment failed;
  - NCSS message delivery failed.

Change-Id: Ief9f8a197b0860072b671edfc55180f619860d9d
Related: (TTCN-3) Ie267ee174c5061cd3fc102a2824abe03d73f3aac
Related: OS#2931
2019-06-15 15:38:03 +07:00
Vadim Yanitskiy 04bbfb83d4 libmsc/gsm_09_11.c: fix: return trans from establish_nc_ss_trans()
It is expected that establish_nc_ss_trans() returns an allocated
transaction in successful case, or NULL in case of error. The
function assumes two scenarios:

  - the subscriber already has an active RAN connection,
  - RAN connection needs to be established (Paging).

In the first case, a pointer to the transaction is returned as
expected, but in case of Paging, NULL has always been returned,
even if there were no errors. Let's fix this.

Change-Id: I9dcee64dd0b435ef29630c223132b81724701f93
2019-06-15 15:38:03 +07:00
Vadim Yanitskiy 20edc9723e gsup_client_mux_tx_error_reply(): fix: do not omit SM-RP-MR IE
The SM-RP-MR (Message Reference for SM Service) value in the response
(no matter result or error) shall match the value from the request.

Change-Id: Ifb6e749928548e6febfe7768aefe9a2a3ecf4de0
2019-06-15 13:13:50 +07:00
Vadim Yanitskiy c33d94be93 gsup_client_mux_tx_error_reply(): fix: do not omit message class IE
Found using the new TC_mt_ussd_for_unknown_subscr test case.

Change-Id: Id00a99b713a6b97c455b8e6ae49abea163e8281f
Related: (TTCN-3) Id35cd3ec15d1bab15260312d7bbb41e2d10349fe
Related: OS#2931
2019-06-15 13:13:50 +07:00
Vadim Yanitskiy 463005e246 gsup_client_mux_tx_error_reply(): fix: do not omit session IEs
For SS/USSD, it's important to have both session state and ID IEs.
Found using the new TC_mt_ussd_for_unknown_subscr test case.

Change-Id: I57317a7b8036d1ffd36e2021efc146db4633da84
Related: (TTCN-3) Id35cd3ec15d1bab15260312d7bbb41e2d10349fe
Related: OS#2931
2019-06-15 13:13:50 +07:00
Vadim Yanitskiy 4d0066ceb6 gsup_client_mux_tx_error_reply(): fix: do not override IMSI
I am not a big fan of using such syntax sugar for initializing
structures, and this is one of the reasons: it's much easier
to shoot yourself in the foot.

IMSI was copied to the new GSUP message, but then overridden.
Found using the new TC_mt_ussd_for_unknown_subscr test case.

Change-Id: If81c3fa56951185339f33a523ab6364594101be1
Related: (TTCN-3) Id35cd3ec15d1bab15260312d7bbb41e2d10349fe
Related: OS#2931
2019-06-14 21:51:49 +00:00
Vadim Yanitskiy 3d603034a9 libmsc/gsm_0(4|9)_11_gsup.c: print error message if subscr is not known
Change-Id: I0b9d4128c853866d7d834f381ad520f78f441afe
Related: (TTCN-3) Id35cd3ec15d1bab15260312d7bbb41e2d10349fe
Related: OS#2931
2019-06-15 01:15:06 +07:00
Vadim Yanitskiy 79e6db0f07 libmsc/mncc_builtin.c: drop dummy switch in int_mncc_recv()
Change-Id: I24153919596d58b495f9c9057dfc230e1501b95f
2019-06-14 22:58:33 +07:00
Vadim Yanitskiy 570b4c8be2 libmsc/db.c: get rid of hard-coded SMS expiry threshold
The initial idea of the SMS expiry threshold was to avoid storing
SMS messages with too long validity time (e.g. 63 weeks).
Unfortunately, neither this feature was properly documented, nor
the expiry threshold is configurable. Moreover, it has been
implemented in a wrong way, so instead of deleting the oldest
expired message, it would delete the youngest one or nothing:

  SELECT ... FROM SMS ORDER BY created LIMIT 1;

while it should be sorted by 'valid_until' in ascending order:

  SELECT .. FROM SMS ORDER BY valid_until LIMIT 1;

Thus, if the oldest message is expired, it gets deleted. If the
oldest message is not expired yet, there is nothing to delete.

Change-Id: I0ce6b1ab50986dc69a2be4ea62b6a24c7f3f8f0a
2019-06-07 08:05:24 +07:00
Vadim Yanitskiy 0d13e8358e libmsc/db.c: warn user about SMS text truncation
In general, neither TP-User-Data nor decoded text should be
truncated. If the SMSC's database for some reason does contain
such weird messages, let's at least let the user know about it.

Change-Id: I75e852ebe44ba4784572cbffa029e13f0d3c430c
2019-06-06 19:45:20 +00:00
Vadim Yanitskiy ea24bb50cc libmsc/db.c: introduce and use parse_sm_ud_from_result()
The following functions:

  - sms_from_result(),
  - sms_from_result_v3(),
  - sms_from_result_v4(),

do retrieve the TP-UD, TP-UDL and text in the same way.

A consequence of such duplication is [1], which fixed potential
NULL-pointer dereference for sms_from_result(), but not for two
other functions: sms_from_result_v3() and sms_from_result_v4().

[1] I545967464c406348b8505d1729213cfb4afcd3e2

Change-Id: If67dfb9f7d2a55fa3d45dc4689a2acff9909faf6
2019-06-06 19:45:20 +00:00
Vadim Yanitskiy ad585d8895 libmsc/db.c: fix potential integer overflow
The value of 'sms->user_data_len' is fetched from the database:

  sms->user_data_len = dbi_result_get_field_length(result, "user_data");

and this is where the problem is. As per the libdbi's documentation
(see 3.5.3), dbi_result_get_field_length() returns the length in
bytes of the value stored in the specified field:

  unsigned int dbi_result_get_field_length(dbi_result Result,
                                           const char *fieldname)

so 'unsigned int' is assigned to 'uint8_t', what could lead to an
integer overflow if the value is grather than 0xff. As a result,
if the database for some reason does contain such odd TP-UD,
the truncation of 'user_data' would be done incorrectly.

Let's avoid such direct assignment, and use a separate variable.
Also, let's warn user if TP-UDL value is grether than 140, as
per 3GPP TS 03.40.

Change-Id: Ibbd588545e1a4817504c806a3d02cf59d5938ee2
Related: OS#3684
2019-06-06 19:45:20 +00:00
Pau Espin 4474f35770 db_sms_test: Remove libdbi expected driver load errors
Newer versions of libdbi print to stderr unconditionally when trying to
load drivers from /usr/lib/dbd. This makes test output to change
depending on host/distro set up (installed modules).

Let's get those messages out to make it easier for people having tests
pass.

We swap stderr/stdout instead of mixing to avoud future possible race
conditions if both get content writen into them.

Change-Id: Iec78826d28435f464be22e81b3776a6ae8326d59
2019-06-05 17:01:06 +00:00
Vadim Yanitskiy f523f22899 debian/control: add missing libdbd-sqlite3 to Build-Depends
The libdbd-sqlite3 provides SQLite3 driver for libdbi. We use it
by default for the built-in SMS Centre. Since [1], we have unit
test coverage for the db_sms_* API, thus we need libdbd-sqlite3
to be installed at build-time.

[1] Id94ad35b6f78f839137db2e17010fbf9b40111a3

Change-Id: Ice9fb11f5b8a39abecee426d2fadcf62b7ee47c4
2019-06-05 18:31:53 +07:00
Pau Espin 17aa464b99 db_sms_test: Do not print exact memcmp result
man memcp doesn't define exact values for returned integer, it only
specifices a meaning for the sign of it.
So it happens that different versions/implementations actually return
different values when this test is run, making it fail.
Let's simply drop that info from logs since anyways it's not useful.

Change-Id: I771fb8f4fc56f337b16561d005ff1803a386d1c6
2019-06-04 11:18:39 +02:00
Pau Espin 7f97d67108 db: Fix call to mempcy with NULL src ptr
Catched by ASan on db_sms_test unit test:
DDB NOTICE test_db_sms_get('Empty TP-UD'): osmo-msc/src/libmsc/db.c:796:2: runtime error: null pointer passed as argument 2, which is declared to never be null

That happens on empty PDU because dbi_result_get_binary returns NULL,
and sms->user_data_len is 0, so it's harmless but we can avoid calling
mempcy and make ASan happy.

Change-Id: I545967464c406348b8505d1729213cfb4afcd3e2
2019-06-03 18:51:04 +02:00
Vadim Yanitskiy 9d61db7f06 libmsc/db.c: fix storing SMS with empty TP-User-Data
Thanks to db_sms_test, it was discovered that storing an SMS with
empty TP-User-Data (TP-UDL=1) causes buffer overruns in libdbi
and it's SQLite3 driver (libdbdsqlite3):

  DDB NOTICE test_db_sms_store('Empty TP-UD'): ==7791== Invalid write of size 2
  ==7791==    at 0x857DC60: dbd_quote_binary (in /usr/lib/x86_64-linux-gnu/dbd/libdbdsqlite3.so)
  ==7791==    by 0x5B2B321: dbi_conn_quote_binary_copy (in /usr/lib/x86_64-linux-gnu/libdbi.so.1.1.0)
  ==7791==    by 0x4073B1: db_sms_store (db.c:701)
  ==7791==    by 0x405BB5: test_db_sms_store (db_sms_test.c:310)
  ==7791==    by 0x405BB5: main (db_sms_test.c:546)
  ==7791==  Address 0x7ed1cf0 is 0 bytes after a block of size 0 alloc'd
  ==7791==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==7791==    by 0x857DC4B: dbd_quote_binary (in /usr/lib/x86_64-linux-gnu/dbd/libdbdsqlite3.so)
  ==7791==    by 0x5B2B321: dbi_conn_quote_binary_copy (in /usr/lib/x86_64-linux-gnu/libdbi.so.1.1.0)
  ==7791==    by 0x4073B1: db_sms_store (db.c:701)
  ==7791==    by 0x405BB5: test_db_sms_store (db_sms_test.c:310)
  ==7791==    by 0x405BB5: main (db_sms_test.c:546)

  ...

  DDB NOTICE test_db_sms_get('Empty TP-UD'): ==8051== Invalid read of size 1
  ==8051==    at 0x5B30510: _dbd_decode_binary (in /usr/lib/x86_64-linux-gnu/libdbi.so.1.1.0)
  ==8051==    by 0x857D957: dbd_fetch_row (in /usr/lib/x86_64-linux-gnu/dbd/libdbdsqlite3.so)
  ==8051==    by 0x5B2C86E: dbi_result_seek_row (in /usr/lib/x86_64-linux-gnu/libdbi.so.1.1.0)
  ==8051==    by 0x40828F: next_row (db.c:188)
  ==8051==    by 0x40828F: db_sms_get (db.c:805)
  ==8051==    by 0x406C29: test_db_sms_get (db_sms_test.c:390)
  ==8051==    by 0x405C14: main (db_sms_test.c:547)
  ==8051==  Address 0x8f74641 is 0 bytes after a block of size 1 alloc'd
  ==8051==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==8051==    by 0x5DBEB49: strdup (strdup.c:42)
  ==8051==    by 0x857D93C: dbd_fetch_row (in /usr/lib/x86_64-linux-gnu/dbd/libdbdsqlite3.so)
  ==8051==    by 0x5B2C86E: dbi_result_seek_row (in /usr/lib/x86_64-linux-gnu/libdbi.so.1.1.0)
  ==8051==    by 0x40828F: next_row (db.c:188)
  ==8051==    by 0x40828F: db_sms_get (db.c:805)
  ==8051==    by 0x406C29: test_db_sms_get (db_sms_test.c:390)
  ==8051==    by 0x405C14: main (db_sms_test.c:547)
  ==8051==
  success, as expected
  DDB NOTICE verify_sms('Empty TP-UD'): user_data_len mismatch: E0 vs A3

Apparently, dbi_conn_quote_binary_copy() doesn't properly handle
zero-length input. Let's guard against this.

Observed with:

  - libdbi-dev 0.9.0-1
  - libdbd-sqlite3:amd64 0.9.0-2ubuntu2

Change-Id: If0b2bb557118c5f0e520a2e6c2816336f6028661
2019-06-03 17:28:44 +07:00
Vadim Yanitskiy e1e7247500 Introduce initial unit test for db_sms_* API
Since OsmoMSC has built-in SMSC, it needs to store the messages
somewhere. Currently we use libdbi and SQLite3 back-end for that.

For a long time, the db_sms_* API remained uncovered by unit tests.
This change aims to fix that, and does cover the following calls:

  - db_sms_store(),
  - db_sms_get(),

  - db_sms_get_next_unsent(),
  - db_sms_mark_delivered(),

  - db_sms_delete_sent_message_by_id(),
  - db_sms_delete_by_msisdn(),
  - db_sms_delete_oldest_expired_message().

Due to performance reasons, the test database is initialized in
RAM using the magic filename ':memory:'. This is a feature of
SQLite3 (and not libdbi), see:

  https://www.sqlite.org/inmemorydb.html

Of course, this unit test helped to discover some problems:

  1) Storing an SMS with empty TP-User-Data (TP-UDL=0) causes
     buffer overruns in both db_sms_store() and db_sms_get().

  2) TP-User-Data-Length is always being interpreted in octets,
     regardless of DCS (Data Coding Scheme). This results in
     storing garbage in the database if the default 7-bit
     encoding is used. Fortunately, the 'user_data' buffer
     in structure 'gsm_sms' is large emough, so we don't
     experience buffer overruns.

  3) db_sms_delete_oldest_expired_message() doesn't work
     as expected. Instead of removing the *oldest* expired
     message, it tries to remove the *newest* one.

The current test expectations do reflect these problems.
All of them will be fixed in the follow-up patches.

Change-Id: Id94ad35b6f78f839137db2e17010fbf9b40111a3
2019-06-03 17:28:35 +07:00
Vadim Yanitskiy 98f0675ffc tests: share stubs.h from msc_vlr_test as stubs.c
We also need stubs for the upcoming db_sms tests.

Due to a known bug of automake [1], we cannot use 'subdir-objects',
so as a side effect this change introduces some autoreconf warnings.

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=752993

Change-Id: I8846c940f2695fd33e1007fecac83e73f508bb34
2019-06-03 17:17:58 +07:00
Vadim Yanitskiy dcf2868e62 libmsc/msc_vty.c: do not abuse strlen() to check char buffers
In the most cases we need to check whether particular char buffer
is empty or not. Using strlen() for that involves more CPU power,
so let's just check the first character against '\0'.

Change-Id: I8728876b80c870e82247e6e56f719e10ed322a95
2019-06-03 07:18:41 +00:00
Vadim Yanitskiy 8014917f0a libmsc/msc_vty.c: refactor 'show subscr / conn / trans' commands
The current way of printing subscriber, connection, and transaction
info is ugly (sorry) and has several problems:

  - the terminal width should be large enough to fit quite long lines,
    otherwise the output is unreadable and looks misaligned;

  - some fields (such as subscriber name) can be larger than it's
    expected, so either they're getting truncated, or again, the
    output is misaligned and unreadable;

  - adding new info fields would require one to think about the
    alignment and would make the output even more cumbersome.

Here is an example output of 'show connection' command:

  _Subscriber_______________________________________ _LAC_ _RAN___________________ _MSC-A_state_________ _MSC-A_use_
  IMSI-123456789012345:MSISDN-12345:TMSI-0x12345678      1 GERAN-A-4294967295:A5-3 WAIT_CLASSMARK_UPDATE 2=cm_service,trans_cc
  IMSI-123456789012356:MSISDN-234567:TMSI-0x123ABC78 65535     UTRAN-Iu-4294967295         COMMUNICATING 2=cm_service,trans_sms
  IMSI-262073993158656:MSISDN-123456:TMSI-0x493026BA     1               GERAN-A-1 MSC_A_ST_COMMUNICATING 1=1 (silent_call)

Another 'show subscriber' command mixes the information about
subscriber, its connections and transactions without any alignment,
what also decreases the readability.

This change introduces a hierarchical approach, based on the old
'field per line' formatting. First of all, the VTY commands were
extended with optional flags:

  show connection [trans]
  show subscriber cache [(conn|trans|conn+trans)]
  show subscriber TYPE ID [(conn|trans|conn+trans)]

so it can be decided, whether to print child connections and/or
transaction, or not. For example:

  show connection trans

would print all connections and their child transactions with
hierarchical alignment:

  Connection #00:
    Subscriber: IMSI-262073993158656:MSISDN-123456:TMSI-0x76760B75
    RAN connection: GERAN-A-1
    RAN connection state: MSC_A_ST_COMMUNICATING
    LAC / cell ID: 1 / 0
    Use count total: 1
    Use count: 1 (silent_call)
    Transaction #00:
      Unique (global) identifier: 0x00000000
      GSM 04.07 identifier (MT): 0
      Type: silent-call

another example is:

  show subscriber cache conn+trans

which would print all known subscribers,
their active connections and transactions:

  Subscriber #00:
    MSISDN: 123456
    LAC / cell ID: 1 / 0
    RAN type: GERAN-A
    IMSI: 262073993158656
    TMSI: 76760B75
    ...
    Connection:
      RAN connection: GERAN-A-1
      RAN connection state: MSC_A_ST_COMMUNICATING
      ...
      Transaction #00:
        Unique (global) identifier: 0x00000000
	GSM 04.07 identifier (MT): 0
	Type: silent-call
      Transaction #01:
        Unique (global) identifier: 0x00000001
	GSM 04.07 identifier (MO): 0
	Type: SMS
      Transaction #02:
        Unique (global) identifier: 0x00000002
	GSM 04.07 identifier (MT): 0
	Type: SMS

Please note that we don't print redundant info in child nodes
(i.e. connection and transaction info), such as subscriber name
in connection info, nor connection name in transaction info - it
is clear from the hierarchical formatting.

Change-Id: I5e58b56204c3f3d019e8d4c3c96cefdbb4af4d47
2019-06-03 07:18:41 +00:00
Oliver Smith a2273f5f1d debian: create -doc subpackage with pdf manuals
I have verified, that the resulting debian packages build in my own OBS
namespace (see the -doc packages):
https://download.opensuse.org/repositories/home:/osmith42/Debian_9.0/all/
https://build.opensuse.org/project/show/home:osmith42

Depends: Ib7251cca9116151e473798879375cd5eb48ff3ad (osmo-ci)
Related: OS#3899
Change-Id: Iafa9fba60b3ad4478ec24d6ba8538ec80ce99f52
2019-05-29 12:14:16 +02:00