Commit Graph

217 Commits

Author SHA1 Message Date
Harald Welte c3de9a62aa Store identity of VLR/SGSN in UpdateLocation
The HLR must store the least-recently used VLR and SGSN identities in
its database to ensure subsequent mobile-terminated transactions can
be routed accordingly.

Change-Id: Ib2611421f3638eadc361787af801fffe9a34bd8a
Closes: OS#2796
2018-07-30 16:34:33 +02:00
Harald Welte 08d5204f0c USSD: Add support for internal USSD handlers
There are some requests that are best served inside the HLR, as it
has access to subscriber information such as MSISDN and IMSI.

This unfortunately required quite some restructuring of the USSD
related structures including the VTY syntax for adding routes.

The default config file has been updated to replicate the *#100#
built-in behavior of old OsmoNITB.

Closes: OS#2566
Change-Id: I1d09fab810a6bb9ab02904de72dbc9e8a414f9f9
2018-07-30 16:34:26 +02:00
Harald Welte edc1fc0c25 Add osmo-euse-demo as minimalistic test of a External USSD (EUSE) handler
This is a small program which simply echo's the USSD request message it
gets in a quote back to the sender.  Its purpose is to illustrate how
EUSEs can be implemented using libosmo-gsup-client.

Change-Id: I3fb8554ca329cb609c591058254117006f665e73
2018-07-30 16:33:41 +02:00
Harald Welte e2e5cefda9 USSD: Add new "DSS" logging category and use it appropriately
Change-Id: I0ac198a49ba70ea40fea18464325f1925797a6e8
2018-07-30 16:33:26 +02:00
Harald Welte 9e59287467 USSD: Further unification of log output; Use LOGPSS when possible
Change-Id: I2c508fe70337d24c4a8b48e0393ad3c979eea0e7
2018-07-30 16:33:26 +02:00
Harald Welte 7057711ca9 USSD: Send ReturnError component if USSD Code unknown / EUSE disconnected
Change-Id: Ieef06cec05dd81f600594465d18804362e0fafd6
2018-07-30 16:33:26 +02:00
Harald Welte 3a190461ee hlr_ussd: Introduce LOGPSS() macro
Change-Id: I1058ef9fd67af2224c991e43bab02bcf21c9f174
2018-07-30 16:33:26 +02:00
Harald Welte f76578d6a8 USSD: Add basic dispatch + decode of GSUP-encapsulated SS/USSD
We don't want any SS session to run for more than 30s.  The timeout
is currently not refreshed.

If we need more comprehensive timeout handling, using osmo_fsm for SS
sessions might make sense.

Change-Id: I5c9fb6b619402d2a23fea9db99590143d85ac11a
2018-07-30 16:33:24 +02:00
Harald Welte 2c8bfe7278 USSD: Add Core USSD handling + VTY routing config to HLR
Change-Id: I3cfd7cd401ea32b7e92f1124d129099d9f7dc6e6
2018-07-30 16:33:20 +02:00
Harald Welte 0c0c3a1dde hlr: Export + Declare global g_hlr symbol
Change-Id: I6f3e50f071fb2fbbe58413b4760dc2215055a444
2018-07-30 16:33:20 +02:00
Harald Welte d1bc55c3b6 GSUP: Log GSUP route add/remove
Change-Id: I1768d0b8ee7e2821e40a799c9a1c1d900a7ddc48
2018-07-30 16:33:20 +02:00
Harald Welte 953d27ce8f gsup_client: rename gsup_client_* to osmo_gsup_client_*
As we're moving this to a common/shared library now, we need to use
the osmo_ namespace prefix for symbol names, struct/type names and
constants.

Change-Id: I294f8f96af4c5daa2b128962534426e04909290e
2018-07-30 13:07:08 +00:00
Harald Welte ec6915a771 import gsup_client.c as new libosmo-gsup-client
This imports the code from osmo-msc 6afef893e17bce67e4d4119acd34d480ed03ba77
with minimal changes to make it compile.  Symbol renaming ot osmo_
prefix is done separately in a follow-up patch to have a as-clean-as-possible
import first.

Requires: libosmocore.git Change-Id Ie36729996abd30b84d1c30a09f62ebc6a9794950
Change-Id: Ief50054ad135551625b684ed8a0486f7af0b2940
2018-07-30 13:07:08 +00:00
Vadim Yanitskiy 9fdb854174 hlr.c: track the use of talloc NULL memory contexts
Tracking NULL memory contexts allows one to detect memory chunks
allocated outside the application's root context, which in most
cases are the result of some mistake.

For example, the VTY implementation still uses the NULL context,
so we have to clean up it manually until this is fixed.

At the moment we have at least one chunk allocated outside the
application's root context (excluding the VTY context):

  full talloc report on 'null_context' (total 24 bytes in 2 blocks)
    struct lookup_helper  contains  24 bytes in  1 blocks

Change-Id: I7ea86730e090c06b2a5966ae4d04b8144b1cd20a
2018-07-30 04:11:20 +07:00
Vadim Yanitskiy 4793a7efc3 hlr.c: free root talloc context on exit
This makes both ASAN and Valgrind happy, because they do expect
all allocated heap chunks to be released on exit.

Change-Id: I7345dec8d06b0b71a859c16132dc0008cfe17cba
2018-07-30 03:57:03 +07:00
Vadim Yanitskiy 527d934807 hlr.c: move deinitialization code from SIGINT handler
There were a few lines of dead code below the osmo_select_main()
loop, while the actual deinitialization code was a part of SIGINT
handler. Let's reanimate this dead zone by moving the code there
and introducing a global 'loop-breaker' variable.

Change-Id: I0e2d673b420193e2bdc1a92377aca542f3a19229
2018-07-30 02:42:25 +07:00
Pau Espin 6b274b95fc sql/Makefile: Create empty /var/lib/osmocom directory at install time
Otherwise osmo-hlr is unable to start correctly.

Change-Id: I1233fc9b3dc685561f79a34e1c32c459dc1aa685
2018-07-02 17:47:24 +02:00
Pau Espin edca4f88a6 sql/Makefile: Install sql files under doc/.../sql subdir
Change-Id: I1c9008d4692412a0cfe39d05216fc9c857cf1e8a
2018-07-02 17:44:35 +02:00
Pau Espin b9c1028cb0 sql/Makefile: Install hlr_data.sql as example together with hlr.sql
Change-Id: Id4a12252b309f03bb393fa26612c305744e14403
2018-07-02 17:27:44 +02:00
Pau Espin 1442e3a3d3 debian: Avoid installing duplicate cfg file in /etc
Change-Id: Ieb25cc8195a2fe7f81b7a39955e0bca5d5c510eb
2018-07-02 17:15:13 +02:00
Martin Hauke 0b8f054b5f sql/Makefile.am: Make docsdir completely configurable
$(docdir) defaults to $(datadir)/doc/osmo-hlr

Change-Id: I77fa16d0edcf88a8e120921504cd088328077836
2018-06-24 17:14:04 +00:00
Harald Welte fa7ee333f7 Add "show gsup-connections" VTY command
This can help with debugging and give operational insight.

Change-Id: I977b4b8cdb36dab42b3d736a28d8b5f17cff04cd
2018-06-24 14:06:56 +02:00
Harald Welte 8fbf82b83f gsup_router: Use "#pragma once" and add missing #includes
Change-Id: I2cc43ea5846e5b98281efc897252c8dcc3ef5728
2018-06-24 11:49:16 +02:00
Harald Welte bd72f1331d move osmo_gsup_addr_send() declaration from luop.h to gsup_router.h
Change-Id: I33165b7b58bd8c863083ed50ce21e3c032c579f5
2018-06-24 11:49:13 +02:00
Harald Welte 32acace879 gsup_server: Add "priv" pointer and make it point to 'struct hlr'
Change-Id: Iada68996b7f4cbdcca92b254ddaf6b88b962e6f1
2018-06-16 20:21:45 +02:00
Harald Welte b85f60477f disable blind subscriber insertion into every VLR/SGSN
During the attempt to fix OS#2785 in Change-Id
I6a92ca34cdaadca9eacc774bb1ca386c325ba865, we introduced logic that
would blindly insert a subscriber *concurrently* in all VLRs/SGSNs of
the network on any update of the subscriber.

Before that patch, we didn't update the current serving SGSN/VLR,
and after the change we created subscribers in all SGSNs/VLRs, of which
all-1 are not serving the subscriber at that time.

We'll have to go back to the original behavior until a proper fix can
be introduced.

Change-Id: Ibf6f1b21b08560d4d8f41bbe7782d40abf4585f8
Related: OS#3091
Related: OS#2785
2018-06-15 18:01:14 +02:00
Harald Welte a1d3b048fb Return proper GSUP error in case of too short IMSI
This fixes HLR_Tests.TC_gsup_sai_err_invalid_imsi

Change-Id: I4f51abdf44dfc62d7e8792341aad6dafe58923da
Closes: OS#3028
2018-06-11 20:28:35 +02:00
Stefan Sperling f83432c25c move creation of insert subscriber data messages to a common function
Move code to create an Insert Subscriber Data message into a common
function which can be shared by hlr.c and luop.c.

As a consequence, we always encode gsup.cn_domain in the corresponding
msgb and must adjust expected output of the 'gsup' test accordingly.

Change-Id: I6a92ca34cdaadca9eacc774bb1ca386c325ba865
Requested-by: neels
Related: OS#2785
2018-05-18 12:18:32 +02:00
Pau Espin 78f4301025 Bump version: 0.2.0.3-1b8a → 0.2.1
Change-Id: I9c457e9baeb546bfefacacddddd48996902e587a
2018-05-04 18:41:35 +02:00
Neels Hofmeyr 1b8a1dc00a add error handling to osmo_gsup_configure_wildcard_apn()
Follow-up to I83d9ef2868bbb01e3f1ddb7920fe735aca172b15 as requested in code review.

Change-Id: Ifcee1e0d275741c1172b208600851861adb13238
2018-05-04 16:48:26 +02:00
Neels Hofmeyr 9d307ec7ae add gsup_test to catch OS#3231
Encode an Insert Subscr Data with is_ps == true to trigger the encoding bug
described in OS#3231, i.e. show that it is fixed.

Move osmo_gsup_addr_send() to a separate .c file, so that it can be overridden
in the regression test to just dump the msgb instead.

I used this test to reproduce issue OS#3231, and now that it's here we might as
well keep it, and possibly expand on it in the future.

Related: OS#3231
Change-Id: Id1453351758f3e1a9ff03bd99fefaf51886e77da
2018-05-04 16:12:19 +02:00
Neels Hofmeyr 5aeb438194 fix luop crash: use buffer for APN that remains valid
In osmo_gsup_configure_wildcard_apn(), do not compose APN into a local buffer
that becomes invalid as soon as the function exits. Instead, use a caller
provided buf.

Fixes OS#3231 crash:

  ==20030==ERROR: AddressSanitizer: stack-buffer-underflow on address 0x7fffffffd9c0 at pc 0x7ffff6e9b6c2 bp 0x7fffffffd900 sp 0x7fffffffd0b0
  READ of size 2 at 0x7fffffffd9c0 thread T0
      #0 0x7ffff6e9b6c1  (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x766c1)
      #1 0x7ffff6314419 in tlv_put ../../../../src/libosmocore/include/osmocom/gsm/tlv.h:107
      #2 0x7ffff6314419 in msgb_tlv_put ../../../../src/libosmocore/include/osmocom/gsm/tlv.h:299
      #3 0x7ffff6314419 in encode_pdp_info ../../../../src/libosmocore/src/gsm/gsup.c:419
      #4 0x7ffff6314419 in osmo_gsup_encode ../../../../src/libosmocore/src/gsm/gsup.c:535
      #5 0x555555580016 in _luop_tx_gsup ../../../src/osmo-hlr/src/luop.c:54
      #6 0x5555555809d8 in lu_op_tx_insert_subscr_data ../../../src/osmo-hlr/src/luop.c:264
      #7 0x55555558b356 in rx_upd_loc_req ../../../src/osmo-hlr/src/hlr.c:306
      #8 0x55555558b356 in read_cb ../../../src/osmo-hlr/src/hlr.c:365
      #9 0x555555586671 in osmo_gsup_server_read_cb ../../../src/osmo-hlr/src/gsup_server.c:105
      #10 0x7ffff5b35911 in ipa_server_conn_read ../../../src/libosmo-abis/src/input/ipa.c:356
      #11 0x7ffff5b35911 in ipa_server_conn_cb ../../../src/libosmo-abis/src/input/ipa.c:387
      #12 0x7ffff5e5541f in osmo_fd_disp_fds ../../../src/libosmocore/src/select.c:216
      #13 0x7ffff5e5541f in osmo_select_main ../../../src/libosmocore/src/select.c:256
      #14 0x5555555791b6 in main ../../../src/osmo-hlr/src/hlr.c:600
      #15 0x7ffff4707a86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21a86)
      #16 0x555555579679 in _start (/usr/local/bin/osmo-hlr+0x25679)

  Address 0x7fffffffd9c0 is located in stack of thread T0 at offset 16 in frame
      #0 0x7ffff63131ff in osmo_gsup_encode ../../../../src/libosmocore/src/gsm/gsup.c:481

    This frame has 1 object(s):
      [32, 64) 'bcd_buf' <== Memory access at offset 16 underflows this variable

Related: OS#3231
Change-Id: I83d9ef2868bbb01e3f1ddb7920fe735aca172b15
2018-05-04 16:02:46 +02:00
Pau Espin cb360f06c8 Bump version: 0.1.0.39-1cb4-dirty → 0.2.0
Change-Id: I2a9fdd140d68053bc7c8354bf2b3a0293c514516
2018-05-03 16:27:14 +02:00
Stefan Sperling 1cb489231a don't forget to mark luop as a packet switched connection
In rx_upd_loc_req() we set the connection's supports_ps field but
forgot to also set the equivalent field in the corresponding luop.

Change-Id: Ie175a067ac1324cdd39d7f756a40fab923421793
Related: OS#2785
2018-05-03 14:05:56 +02:00
Stefan Sperling 93c5b10310 rewrite subscriber_update_notify() without calls into luop
This function relied on implementation details of the luop code.
Port what is necessary for an independent Insert Subscriber Data
Tx operation from the luop code into this function.

A next possible step would be to try to merge both of these
into a common implementation. This will be addressed in a
follow-up change as soon as this change is merged.

The TTCN3 test TC_vty_msisdn_isd is still passing (it currently
triggers the "circuit switched domain" case because it does not
advertise itself as an SGSN in the IPA unit name).

Change-Id: I06c43ece2b48dc63d599000eb6d6d51e08963067
Related: OS#2785
2018-05-02 13:34:38 +02:00
Pau Espin ec9440f1bc Remove unused src/db_test.c
There's a larger test suite in use in tests/db/db_test.c

Change-Id: Ifa409df9b4bb94bd4e8f15568486066393009494
2018-04-17 15:10:05 +02:00
Pau Espin 51530311a8 use osmo_init_logging2
Change-Id: If4449cce1af46be22cc370abd3a6da8e22a31fa5
2018-04-17 15:07:06 +02:00
Stefan Sperling f162252a08 notify GSUP clients when HLR subscriber information changes
Add a function which triggers subscriber update notifications to
all connected GSUP clients, and invoke it when the MSISDN of a
subscriber is changed via VTY.

This makes the TTCN3 HLR test TC_vty_msisdn_isd pass.

Note that the new function currently relies on implementation
details of the Location Update Operation (luop) code.
Because of this we currently log a slightly misleading message
when the updated Insert Subscriber Data message is sent:
  "luop.c:161 LU OP state change: LU RECEIVED -> ISD SENT"
This message is misleading because, in fact, no location update
message was received from a GSUP client at that moment.

So while this change fixes the externally visible behaviour, we may
want to follow this up with some refactoring to avoid relying on
luop internals. It seems acceptable to do that in a separate step
since such a change will be more involved and harder to review.

We may want to trigger such notifications in other situations as well.
This is left for future work, too. There are no TTCN3 test cases for
other situations yet, as far as I can see.

Related: OS#2785
Change-Id: Iffe1d7afb9fc7dbae542f70bbf5391ddc08a14b4
2018-04-10 07:57:49 +02:00
Stefan Sperling 8f8401453c more robust usage of osmo_timer API for osmo-hlr luop timer
Use osmo_timer_setup() to set up the luop timer, instead of
settting the timer up manually.

Delete the timer before the luop is freed to prevent a potential
crash in case the timer is already armed and the function call
chain leading up to lu_op_free() does not cancel the timer.

Found while studying code to prepare work on issue OS#2785.

This change has been tested with 'make check' and TTCN3 HLR tests.

Related: OS#2785
Change-Id: I1a7596675b2d94217895f0f3d3f67b86ef123c2e
2018-03-29 18:17:00 +02:00
Neels Hofmeyr 70e7f21cb1 jenkins.sh: use --enable-werror configure flag, not CFLAGS
Change-Id: I5fe776cf9ccb5d462c3c1fbbb1e31abe6f42bde6
2018-03-05 20:54:54 +01:00
Neels Hofmeyr 2e78858756 configure: add --enable-werror
Provide a sane means of adding the -Werror compiler flag.

Currently, some of our jenkins.sh add -Werror by passing 'CFLAGS="-Werror"',
but that actually *overwrites* all the other CFLAGS we might want to have set.

Maintain these exceptions from -Werror:
a) deprecation (allow upstream to mark deprecation without breaking builds);
b) "#warning" pragmas (allow to remind ourselves of errors without breaking
   builds)

As a last configure step before generating the output files, print the complete
CFLAGS and CPPFLAGS by means of AC_MSG_RESULT.

Change-Id: Id5c0740a37067cbe8986d52d63c6134769c71c47
2018-03-05 20:42:57 +01:00
Harald Welte 3f2a9a2ab1 Fix responses to PURGE MS
When performing PURGE MS, OsmoHLR before this patch used toreturn
an error even in the successful case.  The reasone for this is some
wrong assumptions about the return values of db_subscr_purge().

Change-Id: Ie3005e2eeb424715fd77f202e9fe18464ba211b7
2018-03-01 23:35:35 +01:00
Harald Welte 880a34d2ef vty: Don't print error if removing auth data while none present
It's a bit confusing to the user if he wants to set AUD=none
and it's already none.  Avoid printing error messages in that case.

Change-Id: I5f32dd5d6e4939c738faf442c7e86671d18777f8
2018-03-01 21:33:35 +01:00
Harald Welte 7ee6e554af osmo-hlr: Add talloc context introspection via VTY
This requires libosmocore with Change-Id
I43fc42880b22294d83c565ae600ac65e4f38b30d or later.

Change-Id: Ibc2c333b83f85fa69a364e3e342f12f50dbc2f70
2018-02-14 08:25:52 +01:00
Harald Welte 9214c6c7ef Fix expected test output after new 'logging print file 1' vty command
Ever since libosmocore Change-Id I1c931bff1f1723aa82bead9dfe548e4cc5b685e0
was merged, the VTY tests were broken. Let's fix that by adjusting
the expected test output.

Change-Id: I929ca7f366220b5d1238d43eddc96fa9dde916b6
2018-02-09 14:27:22 +01:00
Alexander Huemer 79fc6984ac Add missing build products in .gitignore
Change-Id: I48b93adc280c1b0521e7f5acc1f66ce5db462915
2018-01-29 09:29:18 +01:00
Neels Hofmeyr ba1605afdc fix build: db_test: missing LIBOSMOABIS_CFLAGS and _LIBS
Change-Id: I2539f5dc7a512a57ad36c460a11195ccbd84d7d6
2018-01-16 13:35:46 +01:00
Max b6265d1a55 Enable sanitize for CI tests
Change-Id: I112307b5eaf494062b2e8498ff2e9217fb8db925
2018-01-08 13:09:24 +00:00
Neels Hofmeyr 6c84da5942 ctrl test: fix: adjust expectations after stricter ctrl parsing
After libosmocore I96a9b6b6a3a5e0b80513aa9eaa727ae8c9c7d7a1 the CTRL interface
returns stricter errors. Adjust the expectations of
test_subscriber_errors.ctrl to fix the external tests on master.

Change-Id: I9337b6b4f3fa8822c91760deb01f18a77a073d19
2018-01-07 22:27:08 +01:00
Neels Hofmeyr 84c2f43d00 fix debug log: put 'deriving 2G from 3G' in proper place
Don't log "deriving 2G from 3G" when we're actually calculating separately; log
it when we're actually deriving from 3G.

Add log "calculating 2G separately" in the right place.

The test output changes show that each test said "separate 2G" at the top while
logging "deriving 2G from 3G" further down, which was obviously wrong.

Change-Id: I6679d7ef8fdcae39a0c2aff7ac638e63dddb10dc
2017-12-20 00:10:34 +01:00