Commit Graph

321 Commits

Author SHA1 Message Date
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
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
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
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
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
Pau Espin fc96f688d4 luop.c: Transform FIXME from warning to pragma message
This way the issue is still visible but we can enable Werror to avoid
introducing new warnings.

Change-Id: I6c9b195bf0e3f853e202cdbdb72d35d83cd2a2ab
2017-12-15 19:05:12 +01:00
Neels Hofmeyr ab4d509a83 osmo-hlr: log details for unknown IMSI / no auth data / db error
For unknown IMSI and no auth data for a known IMSI, log respective messages on
NOTICE level.

For database error, log on ERROR level.

Change-Id: I3838fa78567e7e92d797d90b8b90865d9ebba90a
2017-11-29 16:22:46 +00:00
Neels Hofmeyr bd1dca0859 db_get_auth_data / db_get_auc: clarify return values
Differentiate between "IMSI unknown" and "IMSI has no auth data": in case of
known IMSI lacking auth data, return -ENOKEY instead of -ENOENT.

Fix API doc comments to reflect what the functions actually return, on top of
adding the -ENOKEY detail.

Adjust db_test expectations from -ENOENT to -ENOKEY where appropriate.

Adjust VTY and CTRL command rc evaluation.

A subsequent patch will use these return values to log details on each of these
situations.

Change-Id: Icf6304d23585f2ed45e050fa27c787f2d66fd3f7
2017-11-29 16:22:29 +00:00
Neels Hofmeyr 33cbde9ced return GMM_CAUSE_IMSI_UNKNOWN if there is no auth data
If we have a subscriber entry that lacks auth data, we currently return
GMM_CAUSE_NET_FAIL, which in the MSC log looks like the HLR is not connected or
something grave. Instead, return GMM_CAUSE_IMSI_UNKNOWN.

This changes the OsmoMSC log in this way:
Before:

  DVLR <001e> VLR_Authenticate(901700000014701)[0x5555558dabb0]{VLR_SUB_AS_NEEDS_AUTH_WAIT_AI}: GSUP: rx Auth Info Error cause: 17: Network failure

After:

  DVLR <001e> VLR_Authenticate(901700000014701)[0x5555558dabb0]{VLR_SUB_AS_NEEDS_AUTH_WAIT_AI}: GSUP: rx Auth Info Error cause: 2: IMSI unknown in HLR

A better cause value would be something that says "IMSI known, but we have no
auth data", but since such cause value is not defined, the plain "IMSI unknown"
seems to be the best match.

Change-Id: I90df7b255317df1e5d968e7ce3b9d2c404b98db8
2017-11-22 20:49:43 +01:00
Neels Hofmeyr 671db90ac3 cosmetic: rx_send_auth_info(): decide error cause with switch()
Prepare for tweaking error handling in a subsequent patch: use switch() instead
of if().

Prepares-for: I90df7b255317df1e5d968e7ce3b9d2c404b98db8
Change-Id: I1f628aa9d62b778951726bebec8cf338444fc897
2017-11-22 20:42:49 +01:00
Neels Hofmeyr d3814b936b db_test: don't verify SQLite issued error messages, they might change
A user on openbsc@ complained that with SQLite 3.8.2, the db_test fails with

  --- expected
  +++ stderr
  -DDB (2067) abort at 18 in [INSERT INTO subscriber (imsi) VALUES ($imsi)]: UNIQUE constraint failed: subscriber.imsi
  +DDB (2067) abort at 35 in [INSERT INTO subscriber (imsi) VALUES ($imsi)]: UNIQUE constraint failed: subscriber.imsi

i.e. a trivial difference in the error message issued by SQLite.

For db_test, don't output any SQLite error messages: Add argument
enable_sqlite_logging, pass as true, except in db_test.c.
Remove the SQLite error messages from expected output.

(Note that there is a src/db_test.c program that's not of interest here, this
is about the tests/db/db_test.c)

Change-Id: I2513d71cc0072aef8d08f47d0a1959f311176229
2017-11-21 12:33:45 +01:00
Neels Hofmeyr 8db490695d db-tool: error-exit on too many arguments
Each arg parsing should increment optind, so if there are any surplus args in
the end, that's an error.

Change-Id: I9fc0a87d11db8c35061568e3f8b5a5547931a961
2017-11-12 14:22:00 +00:00
Neels Hofmeyr c82e6ad190 db-tool: cosmetic: tweak printf output
Say <nitb.db> to indicate a filename.
No need to print the cmd and arg count, really.

Change-Id: I3be31754db5297b3f6028877068f97ce1be4d74b
2017-11-12 14:22:00 +00:00
Neels Hofmeyr 0959e8b354 db-tool: add command 'create'
Change-Id: Ic4997d17763e50fb63c36fc0001570230bf64a12
2017-11-12 14:22:00 +00:00
Neels Hofmeyr 4f3841c153 cosmetic: add comment on ignored return value
Coverity wants us to evaluate sqlite3_reset, but it is of no use to do so.

Related: coverity CID#178653
Change-Id: I64ac8c148f48be60f9c0d346df0c5152bb527494
2017-11-11 23:25:06 +00:00
Harald Welte bd0d5bf5d8 hlr.c: Avoid overflow of lu_operation.subscr.imsi
It appears that hlr_subscriber.imsi is 16 buffers in size:
15 chars for IMSI + 1 byte NUL.  However,  osmo_gsup_message.imsi
is 17 bytes (for whatever reason), so we cannot simply do a strpy()
as this might overflow the hlr_subscriber.imsi field!

TODO: check if weactually ever receive a too-long IMSI in GSUP and
reject that at an earlier time in the code flow.

Fixes: Coverity CID#164746

Change-Id: I9ff94e6bb0ad2ad2a7c010d3ea7dad9af0f3c048
2017-11-10 21:26:53 +00:00
Neels Hofmeyr 87a04b6b95 hlr_db_tool: fix error log strerror invocation
The db API returns negative errno values, need to flip the sign before feeding
to strerror.

Fixes: coverity CID#178658
Change-Id: Iaab46f565a1112d8a7def8ea90a5cd440c0a3b41
2017-11-08 02:29:05 +00:00
Neels Hofmeyr 85e8a64bb4 vty: skip installing cmds now always installed by default
vty_install_default() and install_default() will soon be deprecated.

Depends: I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b
Change-Id: I09762f110c7bcaf85c0ef2f472eb43ac543c74e9
2017-11-01 00:50:13 +01:00
Neels Hofmeyr 73d14af278 add osmo-hlr-db-tool, program to migrate from osmo-nitb db
Move macro copy_sqlite3_text_to_buf() to db.h, so it can be used in
hlr_db_tool.c.

Add _dbd_decode_binary() from libdbi to avoid depending on the entire libdbi
just for KI BLOB decoding. Add it in a separate file, copying its own license,
the lGPL.

Offer commandline option "import-nitb-db" to read in an old osmo-nitb database
and copy subscriber IMSIs and 2G auth data to OsmoHLR db format.

Anticipate future command line options like "import-csv", so keep the code
generalized.

Change-Id: I0dfa6ec033dd93161c1adc2ce1637195fe5b7a63
2017-10-28 20:34:01 +02:00
Neels Hofmeyr 6eb231eccc fix default logging levels to NOTICE, not DEBUG
Tweak unit test binaries to still used DEBUG loglevels, so that their expected
outputs remain unchanged (and nicely verbose).

Adjust test_nodes.vty, now expecting the 'notice' log levels upon
'show running-config'.

Change-Id: Ic061e61c9625b49cef8bc2a2c0b936e262c22268
2017-10-28 16:49:46 +00:00
Neels Hofmeyr dbced93b5f cosmetic: rename SL3_TXT macro, use osmo_strlcpy()
Rename SL3_TXT to more accurate copy_sqlite3_text_to_buf(), and use
osmo_strlcpy() instead of essentially dup'ing it.

The macro will also be used by hlr_db_tool.c in upcoming patch. This patch
prepares for a move to db.h.

Change-Id: I1dadeddddcfe0109195c09c0e706201b0df009cc
2017-10-28 16:49:33 +00:00
Neels Hofmeyr 7750d2cedc automatically create db tables on osmo-hlr invocation
If a database file is missing, osmo-hlr creates it, as is the default sqlite3
API behavior -- before this patch, that db file is created, but lacks useful
tables. Actually also create initial tables in it, as osmo-nitb did.

In effect, the 'vty-test' target in tests/Makefile.am no longer needs to create
a database manually. (The 'ctrl-test' still does, because it also wants to add
subscriber data on top of the bare tables.)

Note: it could be desirable to bail if the desired database file does not
exist. That is however a different semantic from this patch; this is not
changing the fact that a db file is created, this just creates a usable one.

Note: I am about to add osmo-hlr-db-tool to do database migration from
osmo-nitb. For that, it is desirable to bootstrap a usable database, which is
the core reason for this patch.

Don't plainly duplicate hlr.sql to .c, but create db_bootstrap.h as a
BUILT_SOURCE from reading in sql/hlr.sql and mangling via sed to a list of SQL
statement strings. On each db_open(), run this bootstrap sequence.

In sql/hlr.sql, these tweaks are necessary:
* Add 'IF NOT EXISTS' to 'CREATE TABLE', so that the bootstrap sequence can be
  run on an already bootstrapped db.
* Drop the final comment at the bottom, which ended up being an empty SQL
  statement and causing sqlite3 API errors, seemed to have no purpose anyway.

Note: by composing the statement strings as multiline and including the SQL
comments, sqlite3 actually retains the comments contained in table definitions
and prints them back during 'sqlite3 hlr.db .dump'.

Change-Id: If77dbbfe1af3e66aaec91cb6295b687f37678636
2017-10-28 16:49:33 +00:00
Neels Hofmeyr 446eb0f1bc ctrl: completely replace all CTRL commands
The previous commands are not conforming to how the CTRL interface is intended
to work:

  SET enable-ps <IMSI>
  SET disable-ps <IMSI>
  SET status-ps <IMSI>

'status-ps' is a write-only command even though it returns the status.
'enable-ps' / 'disable-ps' indicate the value instead of a variable name of an
entity. The entity <IMSI> takes the place of the variable value.

See also https://lists.osmocom.org/pipermail/openbsc/2017-September/011236.html

Instead, replace with

  SET subscriber.by-imsi-123456.ps-enabled {0,1}
  GET subscriber.by-imsi-123456.ps-enabled

and also provide further CTRL functions while at it:

  {SET,GET} subscriber.by-{imsi,msisdn,id}-123456.{cs,ps}-enabled {0,1}
  GET subscriber.by-{imsi,msisdn,id}-123456.{info,info-aud,info-all}

Provide CTRL tests in the form of transcripts.

Adjust tests/test_subscriber.sql to feature nonzero SQN, to see some values for
SQN in the CTRL transcript tests. (This does not affect the VTY tests, because
that creates its own subscribers, and there's no VTY command to set the SQN.)

This is the first time an application uses CTRL_NODE ids that are defined
outside of libosmocore, see 'Depends' below.

Implementation choice: the first idea was to have a '.' between the 'by-xxx'
and the value, like:

  subscriber.by-xxx.123456.function

but the difficulty with subscribers is that they are not in RAM, and I can't
just point node_data at a struct instance that is always there (like, say, a
global bts[0] struct in osmo-bsc). Instead, I want to store the selector and
later decide whether to read from the DB or whatever. With a '.' separating
things, the only way in a ctrl function to obtain both 'by-xxx' and '123456'
for picking a subscriber record would be to parse the entire variable path
string elements, including 'subscriber' and 'function', which would then also
clumsily fix at which node level we hook these commands; there could have been
separate CTRL_NODE_SUBSCR_BY_{IMSI,MSISDN,ID} parent nodes, but we cannot
introspect the current parent node dynamically within a ctrl function handler
(plus I'm not sure whether it's possible and a good idea to have the same
command under multiple parent nodes).

Rather than that, I store the 'by-foo-123' token in the node_data pointer to
have both bits of information pointed at by a single pointer; I use the
incoming command parsing to get this token pre-separated from surrounding node
names, and no need to re-allocate it, since the vector of tokens lives until
after command execution is complete. Each leaf command obtains this token from
cmd->node (aka node_data), and feeds this token to a common static function to
parse selector and value from it and to retrieve a subscriber record as needed.

(BTW, I have mentioned on the mailing list that this way might be necessary to
avoid numeric-only CTRL node names, but we don't need to, and that is not at
all related to this choice of structure.)

Depends: libosmocore I1bd62ae0d4eefde7e1517db15a2155640a1bab58
         libosmocore Ic9dba0e4a1eb5a7dc3cee2f181b9024ed4fc7005
Change-Id: I98ee6a06b3aa6a67adb868e0b63b0e04eb42eb50
2017-10-27 02:35:49 +02:00
Neels Hofmeyr 234f9cb701 cosmetic: tweak params of hlr_controlif_setup()
Cosmetically prepare for adding new CTRL commands in hlr_controlif_setup():
- drop unused 'gs' param.
- use ctrl_interface_setup_dynip2(), so far with default CTRL nodes; custom
  nodes will be added soon.

Prepares: I98ee6a06b3aa6a67adb868e0b63b0e04eb42eb50
Change-Id: I63004a7953b04988449697dbc5d55d7ed0c6d82d
2017-10-27 00:35:01 +00:00
Neels Hofmeyr 16140f70c5 db api: fix/add API docs
Change-Id: I854fafd8e56bd0b8394f8ed79d023c11c2fdbdca
2017-10-25 19:21:40 +02:00
Neels Hofmeyr 36bec87104 vty: fix output of empty IMSI
Check *subscr->imsi, not subscr->imsi, since it is a char[]; same as msisdn
below already does.

Was introduced in change I42b3b70a0439a8f2e4964d7cc31e593c1f0d7537 / commit
183e7009af.

Fixes: coverity CID 178166
Change-Id: I72e13efefbac0495b8dd1949a39fa44ebfd46b56
2017-10-23 18:47:58 +02:00
Neels Hofmeyr 00b1d43435 add hlr_subsrc_nam to put GSUP client notification in proper API
This code should not live in a CTRL interface function but be proper hlr_* API.

Change-Id: I4c9b8f9ad51d49517474e8b51afc3cc2e1c9299a
2017-10-17 02:28:43 +00:00
Neels Hofmeyr 7ae8d878cf api doc: say that lu_op_tx_del_subscr_data() doesn't free
Change-Id: Ia341d8e5bfc6eb0dc59945281ce88eecfaab057e
2017-10-17 02:03:42 +02:00
Neels Hofmeyr 68f87915e4 fix mem leak in handle_cmd_ps(): free luop
Each GSUP client creates a luop, but since lu_op_tx_del_subscr_data() doesn't
free the luop, each allocated luop leaks memory.

Change-Id: If912dc992bc7f18c49d22ec0436d9679c1cd04f6
2017-10-17 02:03:01 +02:00
Neels Hofmeyr e86437cae4 luop: fix mem leak upon error in lu_op_alloc_conn()
Free allocated luop if osmo_gsup_conn_ccm_get() fails.

Change-Id: I3ebd5fb5e313be452de893248dd58b2bb73ba94a
2017-10-17 02:01:48 +02:00
Neels Hofmeyr 200f56e995 add lu_op_free(), use in luop.c
Add to luop.h, it will be used in db_hlr.c in an upcoming patch.

Change-Id: Ib44d9062edc957d2e0710b7e485604f97e4d5612
2017-10-17 02:01:08 +02:00
Neels Hofmeyr 183e7009af implement subscriber vty interface, tests
Implement VTY commands for subscriber manipulation:
- create / delete subscriber
- modify MSISDN
- add/edit/remove 2G and 3G authentication data
- show by IMSI, MSISDN or DB ID.
(enable/disable CS/PS and purge/unpurge to follow later.)

Implement VTY unit tests for the new commands using new
osmo_verify_transcript_vty.py from osmo-python-tests.

Depends: libosmocore I1e94f5b0717b947d2a7a7d36bacdf04a75cb3522
         osmo-python-tests Id47331009910e651372b9c9c76e12f2e8964cc2c
Change-Id: I42b3b70a0439a8f2e4964d7cc31e593c1f0d7537
2017-10-17 00:59:00 +02:00
Neels Hofmeyr b6837e36a3 fix db_subscr_get_by_*(): clear output data; test in db_test.c
db_subscr_get_by_*() failed to clear the out-param struct, meaning that data
could remain in a struct even though it is not present in the database. Always
zero out the struct before writing to it.

Adjust the db_test to catch this error by writing "-invalid-data-" to each
struct before running db get functions.

Change-Id: I038bd437452c87841d709fcdd5ac30ab1356b2db
2017-10-15 05:52:39 +02:00
Neels Hofmeyr c5122f2829 code undup: use db_bind_text() in db_get_auth_data()
To make the db_bind_text() error reporting mention "imsi", change the
DB_STMT_AUC_BY_IMSI to use a named parameter.

Change-Id: I49bd5eb78170cf4cdf8abb386c766d20d9f1cf73
2017-10-11 22:32:19 +02:00
Neels Hofmeyr 1cbdb70b27 fix db_update_sqn(): reset stmt in all error cases
Use the common db_bind_int64() so that the stmt bindings are cleared for any
errors and to get error logging for free.

On error with sqlite3_step(), log the SQL error message, and make sure the stmt
is cleared of bindings and reset.

After sqlite3_step(), verify that exactly one row was modifed, log and return
errors otherwise.

After this patch, the DB interaction closely matches the other (refactored) DB
functions.

Change-Id: I0d870d405e2e0a830360d9ad19f0a3f9e09d8cf2
2017-10-11 22:32:19 +02:00
Neels Hofmeyr 76328e57d1 code undup: use db_remove_reset() in db_auc.c
Change-Id: I32d728e2b8a9771421c097647aa0e060e29a601f
2017-10-11 22:32:19 +02:00
Neels Hofmeyr 57a8792f23 refactor db_get_auth_data return val
Adopt the error handling of the other db functions: return -ENOENT on unknown
subscriber and -EIO on SQL failure. Return 0 for no error, instead of the
number of rows modified.

Adjust the single caller: db_get_auc()
(and db_test.c).

Change-Id: I006f471962bdad95d00a3a4c41a28ebbc9740884
2017-10-11 22:32:19 +02:00
Neels Hofmeyr 1332a17a3d add db_subscr_update_aud_by_id(), complete db_subscr_delete_by_id()
Add ability to add and remove auc_2g and auc_3g table rows with
db_subscr_update_aud_by_id().

In db_subscr_delete_by_id(), make sure that when deleting a subscriber, also
all auth data associated with that user ID is removed as well. A newly created
subscriber must not obtain the same auth tokens just by getting the same id.

Depends: libosmocore Idf75946eb0a84e145adad13fc7c78bb7a267aa0a
Change-Id: Icb11b5e059fb920447a9aa414db1819a0c020529
2017-10-11 22:32:19 +02:00
Neels Hofmeyr e50121ec96 refactor db_subscr_purge
Use named parameters in the SQL statements.

Use db_bind_* functions to drop some code dup.

Adopt error handling (rc and logging) to match the other db functions: return
-ENOENT for unknown subscriber, -EIO for SQL failures.

Change-Id: Iad49d29b90a708c6cf55bfb3bcc02d9e29001a15
2017-10-11 22:32:19 +02:00
Neels Hofmeyr dd783056f7 refactor db_subscr_lu()
Use named parameters in the SQL statement.
Use db_bind_* functions to drop some code dup.
Use explicit subscriber id arg instead of subscriber struct.
Match return values and error logging to other db functions.

Change-Id: I35665e84ddbe54a6f218b24033df969ad2e669a0
2017-10-11 22:32:19 +02:00
Neels Hofmeyr e8ccd5013a refactor db_subscr_ps() to db_subscr_nam()
Allow to set nam_ps and nam_cs from this same function, by adding the is_ps
arg.

Combine both NAM_PS stmts to DB_STMT_UPD_NAM_PS_BY_IMSI, add another such stmt
for CS. Use named parameters instead of parameter indexes.

Improve error return values as well as error logging to clearly indicate
whether the operation could not find the requested IMSI, or other errors
occured.

Adjust the single caller.

This prepares for upcoming VTY and possibly CTRL commands, and the error
handling introduced here has been or will be adopted by other functions in
previous or subsequent patches.

Change-Id: I6e70e15228f5bb10bee6758ae5dc9687d65839bd
2017-10-11 22:32:19 +02:00
Neels Hofmeyr 9c2bbc840f add db_subscr_get_by_msisdn() and db_subscr_get_by_id()
Factor out the selected SQL columns as SEL_COLUMNS macro, so that each of the
new DB_STMTs will select identical columns: the old DB_STMT_SEL_BY_IMSI as well
as the new DB_STMT_SEL_BY_MSISDN and DB_STMT_SEL_BY_ID.

Add the new functions db_subscr_get_by_msisdn() and db_subscr_get_by_id() and
factor out common parts with db_subscr_get_by_imsi() to static db_sel().

Change-Id: I6d0ddd1b7e3f6b180b4b1b2663c5725d2a4a9428
2017-10-11 22:32:19 +02:00
Neels Hofmeyr 32633e2b89 db: use int64_t as subscriber id
The SQLite db does not support uint64_t, and we are always binding the uint64_t
id actually as signed int64_t. Hence be consistent and actually handle it as
int64_t in the code as well.

This means that if we ever see a negative subscriber ID in the SQL database
(however unlikely), we will also see it negative in our log output.

The SQN handled in osmo_auth* is actually of unsigned type, and, unless we
store the SQN as 64bit hex string, we are forced to feed this unsigned value as
signed int64_t to the SQLite API. The upcoming db regression test for SQN in
change-id I0d870d405e2e0a830360d9ad19f0a3f9e09d8cf2 verifies that the SQN
uint64_t translates to signed int64_t and back as expected.

Change-Id: I83a47289a48ac37da0f712845d422e897a5e8171
2017-10-11 22:32:19 +02:00
Neels Hofmeyr d7d9697d85 less noise: simplify db_remove_reset()
db_remove_reset() needs to be called after each stmt run, whether it succeeded
or not.

In case sqlite3_clear_bindings() would fail to unbind a stmt, we would anyway
be beyond recovery. There seem to be no plausible situations where such failure
would occur, unless there have been no bindings in the first place.

In case there was an SQL stmt failure, sqlite3_reset() will re-barf the same
error message, we will always have logged it earlier already in the proper
context.

We are never evaluating the return value, nor would we know how to recover from
non-success.

The conclusions:
- db_remove_reset() does not need to log any errors.
- db_remove_reset() does not need to return success.

Change-Id: I21678463e59f607f5f5c5732963e274392f0fffd
2017-10-11 22:32:19 +02:00
Neels Hofmeyr f7c3e6e3a2 add db_subscr_create(), db_subscr_delete(), db_subscr_update_msisdn_by_imsi()
These will be needed by VTY commands to create, delete and modify subscribers.

Auth data editing will follow in another patch.

The FIXME "also remove authentication data from auc_2g and auc_3g" will get
fixed in change-id Icb11b5e059fb920447a9aa414db1819a0c020529.

Change-Id: I725273d36234331093e7fff7d5f12f6be6ab2623
2017-10-11 22:28:09 +02:00
Neels Hofmeyr 28da26ec19 add db_bind_int() and db_bind_int64()
Will be used in upcoming patches, e.g. change-IDs
- I6e70e15228f5bb10bee6758ae5dc9687d65839bd
- I83a47289a48ac37da0f712845d422e897a5e8171

Change-Id: I705a15eef242c98feb6e95a883916f6cf8173d70
2017-10-11 22:28:09 +02:00
Neels Hofmeyr cd83b8a44c cosmetic: don't log about missing SQLite log cb
SQLite3 seems to be commonly compiled without log callback support. It is then
misleading to see a seeming error message about this on each osmo-hlr startup.

Avoid the impression that we would miss out on important logging: query
sqlit3_compileoption_get() whether SQLITE_CONFIG_SQLLOG is enabled. Try to
register the callback only if present, if not, say so on DEBUG log.

See https://sqlite.org/compile.html "SQLITE_ENABLE_SQLLOG"

Change-Id: I78d75dc351eb587b0a022f82f147e9a31c0324c5
2017-10-11 22:28:08 +02:00
Neels Hofmeyr 1e31d18822 cosmetic: db_hlr: SL3_TXT: clarify indenting
Before, it looked like the nul term was within the if () body (despite no body
being present).

While at it, also remove one of the two tabs of indenting and put the opening
'do {' on its own line.

Change-Id: I8d03433b6fba90f4e46814bc54636bc3a444cc46
2017-10-11 20:25:29 +00:00
Neels Hofmeyr e9c0c5b272 cosmetic: log: "SQLite" with capital L
Change-Id: I43a6ea646f14cfea3a7cd4eb88237ada6d47f5f1
2017-10-11 20:25:29 +00:00
Neels Hofmeyr 40aa61ccf0 cosmetic: log IMSI='<imsi>', log "no such subscriber"
In LOGHLR and LOGAUC, log IMSI='<imsi>' instead of just <imsi>:
In the log, it is not always obvious to the reader that the printed number
refers to an IMSI (vs. an MSISDN or in the future an IMEI).

In db_get_auth_data(), log "No such subscriber" instead of just "Unknown", to
clarify what exactly is meant.

Change-Id: I2ec8ab5e67d4e95083f6e39232fc91ebaa080cb8
2017-10-10 02:39:09 +02:00
Neels Hofmeyr 0cac0a067e cosmetic: multi-line DB_STMT_AUC_BY_IMSI
In multiple lines, the statement becomes more readable.

I'd like to get this change out of the way before upcoming SQL statement edits
and additions.

Change-Id: Icf09f4bbb298a516aa52c81e3ca67d9d91d8c7c2
2017-10-10 02:38:56 +02:00
Neels Hofmeyr f31445915e cosmetic: refactor db_bind_imsi() as db_bind_text()
There are more uses for a generalized db_bind_text(), and in an upcoming patch
there will be similar functions like db_bind_int().

Also, add argument param_name, optionally indicating a named SQL parameter to
bind to, which will be used in subsequent patches. So far, all callers pass
NULL to yield previous db_bind_imsi() behavior of binding to the first param.

Change-Id: I87bc46a23a724677e8319d6a4b032976b7ba9394
2017-10-10 02:38:46 +02:00
Neels Hofmeyr 518335e688 cosmetic: rename db_subscr_get() to db_subscr_get_by_imsi()
There will be more additions, _by_msisdn() and _by_id(), to serve the upcoming
VTY commands, to allow flexibly selecting subscribers as in the old OsmoNITB.

Change-Id: I32fa676ccc5c10eba834c4390c8a42476b9c1961
2017-10-10 02:38:37 +02:00
Neels Hofmeyr 4bde949b34 cosmetic: prepend DB_STMT_ to enum stmt_idx entries
There are upcoming additions, and some seem too general without a proper common
prefix in the identifiers, like 'CREATE'.

Change-Id: I51b677db31a1ebbbc45dc7925074de7493fbde1f
2017-10-10 02:38:24 +02:00
Neels Hofmeyr 84201d3a4b use OSMO_GSUP_PORT == 4222 instead of hardcoded 2222
Depends: I4222e21686c823985be8ff1f16b1182be8ad6175 (libosmocore)
Change-Id: I9b372a4ac38677773bf813acba80cebcd88e2e20
2017-07-21 16:19:56 +02:00
Pau Espin ce9bc40846 VTY: Add hlr node and bind ip field
With this patch the address osmo-hlr binds to can be changed to
something else than 0.0.0.0

Change-Id: I79f7a300480f308b21116dd14d1698be38725afd
2017-06-01 11:31:39 +02:00
Neels Hofmeyr 743cf42ac5 fix db_subscr_ps error handling
Reset stmt and return right away on failure to execute.

Change-Id: I27e8b46915efd678c72138e250a9cbb4c9c8ac20
Fixes: Coverity Scan CID#164747
2017-03-20 00:21:58 +00:00
Neels Hofmeyr edebc22989 debug log: output ind slot, previous sqn, and sqn db update
Change-Id: Ib86442ea45f6c1948b3d260f59d35bdca38fbd32
2017-03-16 05:51:58 +01:00
Neels Hofmeyr cab2fcd5b5 UMTS AKA: implement SQN increment according to SEQ and IND
Add ind_bitlen column to auc_3g to record each USIM's IND size according to
3GPP TS 33.102 -- default is 5 bits, as suggested by the spec.

Introduce auc_3g_ind to each connecting GSUP client to use as IND index for
generating auth tuples sent to this client.

With osmo_gsup_server_add_conn(), implement a scheme where clients receive
fixed auc_3g_ind indexes based on the order in which they connect; each new
connection takes the lowest unused auc_3g_ind, so in case one of the clients
restarts, it will most likely receive the same auc_3g_ind, and if one client
disconnects, no other clients' auc_3g_ind are affected.

Add gsup_server_test.c to test the auc_3g_ind index distribution scheme.

Depends: libosmocore I4eac5be0c0b2cede04464c4c3a0873102d952453 for llist_first
Related: OS#1969
Change-Id: If4501ed4ff8e923fa6fe8b80c44c5ad647a8ed60
2017-03-16 05:51:11 +01:00
Neels Hofmeyr ee392bb3b1 fix debug log: adjust to new SQN increment scheme
We can no longer accurately print the SQN from AUTS resync, since the SQN is
incremented after AUTS. Instead, always print the SQN from the generated tuple,
i.e. exactly the one left in auth data *after* the tuple was generated.

This change was forgotten in recent adjustments to the new SQN incrementing
scheme from libosmocore, in change-id I4ec5a578537acb1d9e1ebfe00a72417fc3ca5894
for libosmocore change-id Iadf43f21e0605e9e85f7e8026c40985f7ceff1a3.

It should have been obvious that something was missing in the previous patch
from the auc_test output: the SQN in the output changed while the AUTN remained
the same. That slipped by without being noticed :/

Change-Id: I0e1e828da931a3d22c75306c55bdb7f44df6512f
2017-03-16 05:46:40 +01:00
Neels Hofmeyr 5ecdc56ad4 fix: properly handle error rc by osmo_gsup_conn_ccm_get()
Change-Id: I70e4a5e75dd596052e61df9a6ad52b7f56fb6b26
2017-03-07 23:23:16 +00:00
Max 9cacb6f74b CTRL: add enable/disable packet service cmds
Add commands to enable/disable Packet Service for a given IMSI. Changes
are synced to DB and propagated at runtime to SGSN (in case of disable
command).

Change-Id: I23163ce8667292443ed61cb15c928357dba4b4be
Related: OS#1645
2017-03-06 13:58:04 +01:00
Max 372868baa3 Add CTRL interface
* add command to query Packet Services (GPRS etc.) for particular IMSI.
* add vty command to configure ctrl bind address
* add missing vty copyright notice

Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb
Related: OS#1645
2017-03-06 13:57:59 +01:00
Max adc6648841 Make subscr parameter to db_subscr_get() optional
This allows to check for subscriber's presence in DB without the need to
bother with unused structure allocation.

While at it also call to db_remove_reset() and return explicitly instead
of using goto to make it a bit easier to follow the code.

Change-Id: I83b0f4a5dacb97614721690ef55bc1311624a58e
2017-03-05 12:25:37 +00:00
Max d4bebbd855 Add global HLR struct
Introduce g_hlr of type 'struct hlr' which holds pointers to all
globally accessible variables.

Change-Id: I275d3d54482f696e3378606b2406c7e0ad939e0f
Related: OS#1645
2017-03-05 12:25:37 +00:00
Neels Hofmeyr b5b11e31fb auc_compute_vectors(): fix AUTS resync for multiple vectors
Fix bug where AUTS was fed to each vector generation and thus each vector was
generated with the same SQN. In auc_3g_test, adjust the bug indicating test
expectations to now expect the proper results.

Depends: libosmocore change-id If943731a78089f0aac3d55245de80596d01314a4
Change-Id: I425a1d92c85896227341f565f5361c0d830ce866
2017-02-22 03:25:30 +01:00
Neels Hofmeyr 8d97d34f58 cosmetic: refactor auc_compute_vectors(), add debug log
Make the generation logic easier to understand (hopefully).

Massively extend debug logging, which serves to illustrate the current AUTS
failure shown by auc_3g_test.

Since DAUC now logs the vectors, there is no need to print the vectors in
VEC_IS() in auc_3g_test and auc_ts_55_205_test_sets anymore. Adjust testlog
expectations accordingly.

Change-Id: Ifb36d010a4ac64c765517e15b9074424ec19cc60
2017-02-22 03:25:30 +01:00
Neels Hofmeyr 569d322597 auc_gen_vectors(): ensure sane arguments, test
In auc_gen_vectors(), add various checks that the auth data arguments passed
make sense, and add unit test to verify that they work. (Caught a segfault due
to NULL dereference with this.)

Change-Id: I775652b6a91d382707ce32176a3fe4ef547cbca7
2017-02-22 03:25:29 +01:00
Max 3ce3686768 Add routines to update nam_ps
Add SQL queries to change nam_ps value and function which uses them.

Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef
2017-02-21 11:45:08 +01:00
Max 58d4a84a31 Fix compiler's warning about printf security
Also, fix log formatting: SQL statements do not have '\n' at the end.

Note: sqlite should be compiled with SQLITE_ENABLE_SQLLOG for this code
to work at all.

Change-Id: I5e53de54ad1b9da18e1f414932cfd21be71ab154
2017-02-20 13:38:26 +01:00
Max 00b3715723 db: move duplicated code into helper functions
* move common cleanup code into separate function
* add helper function for IMSI binding
* use errno.h instead of numbers

Change-Id: Iec81b56ab1ccc948807854a3947b04355a555c10
2017-02-20 13:37:08 +01:00
Max ea8b0d46eb Move lu_operation into separate file
Create luop.(c|h) and move lu_operation and corresponding TX
functions there to facilitate re-use in upcoming control interface.

Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813
Related: OS#1645
2017-02-16 12:29:12 +01:00
Max aa0fefd5d6 Use strings for GSUP message type
Change-Id: Idf57a314f5c8cfbd4818600c90020e3ed3decc77
2017-02-16 12:26:43 +01:00
Max 27c6b9016a Move GSUP msg init into separate function
* move common copy-pasted code to initialize GSUP message into static
  function
* use osmo_strlcpy() to copy imsi for added safety

Change-Id: Icd6e2479aa111ff820d53711222d46c6522033e6
2017-02-13 18:04:58 +01:00
Max f8c7b6f3c9 Log error cause as a string
Use gsm48_gmm_cause_names to log error cause instead of numerical code.

Change-Id: I846d488ed163e137164976738e55674f0eaee190
2017-02-13 15:53:38 +01:00
Neels Hofmeyr 912a303fec UMTS AKA resync: fix argument ordering
According to libosmocore change-id I0dcbd49759fc32d3b8974102dbd1d6703364ebf4
this argument ordering will not result in successful AUTS. Pass in order
auts, auts_rand so that these are passed correctly to our milenage code.

Change-Id: I6aa19004ec27bad5e9c2bf688d9bbc55d697ccb0
2017-02-03 06:02:30 +01:00
Neels Hofmeyr 8cde66242a tests: auc_3g_test: implement vector generation test
Change-Id: I291bccd62661ff5790dc43d91dc63a9e4b0e0ff2
2017-02-01 14:22:26 +01:00
Neels Hofmeyr 7685a78757 main: add VTY and '-c config-file' option
Add config file, mainly for logging control.

Open VTY on the OMSO_VTY_PORT_HLR added to libosmocore in
commit 92fa18e6b800a27aa064a5fb8321cddd7383ae20
aka change-id I08cb52d9399a27e6876e45da36f434708c4fddef.

Add hlr_vty.h/c for standard VTY setup.
Add -c option to pass config file.
Add --version option.

Change-Id: Iedb884345a597371a337b0c67eb6013b7d5d1ce1
2017-02-01 13:58:50 +01:00
Neels Hofmeyr 7f9491fe5f main: add option parsing with db file and default options
Parse commandline options, supporting general Osmocom options as copied from
osmo-nitb (bsc_hack.c): version, logging and daemonize options.

Set the HLR database file from cmdline option, log the filename in db_open().

(VTY config file in next patch.)

Change-Id: I279d517e1310e398b0a2382349e62be8e65364c1
2017-02-01 13:58:50 +01:00
Neels Hofmeyr ca43e30be3 main: add and use root talloc ctx
Create hlr_ctx and pass on to DB and GSUP server code.
Add call msgb_talloc_ctx_init(hlr_ctx).

Instead of printing the entire talloc context on exit, just print the hlr_ctx
upon SIGUSR1 (like our other binaries do). Otherwise we will get pages of
talloc output on each program exit as soon as we add a VTY (next patch).

Change-Id: I3c64cb4ad7a681b88c7409296ad3afeb8000e2a4
2017-02-01 04:20:51 +01:00
Neels Hofmeyr 5b581ac6eb auc.c: typo in comment
Change-Id: I4652e932f1bdb7767b5394c09e7436812488aa74
2017-01-19 15:54:01 +01:00
Neels Hofmeyr 0acd31e9a6 log: move a log from info to debug level
This basically duplicates an info log further below that says "Generated..."

Change-Id: I32f22f71adc6dc2fbc7bcca5d277337baef3cd6d
2016-12-21 23:11:25 +01:00
Neels Hofmeyr 4307ad94b6 debug log: log computed vector kinds
Change-Id: Iffb9b0f99e3006861599c921d037504a7bc8d976
2016-12-21 23:11:25 +01:00
Neels Hofmeyr 627de84abe gsup: send subscriber MSISDN
Change-Id: Iace97a1a828b29ce11913a14243bcf80bbae9136
2016-12-21 15:00:13 +01:00
Max 2fc63a6e84 Add hardcoded APN
Add APN '*' to PDP info part of GSUP response to make it possible to
test SGSN 'auth-policy remote'.

Change-Id: I95d69508aafc13e82f5f51fc6fe8f56cd7f45e2b
Related: OS#1794
2016-12-21 10:53:55 +01:00
Neels Hofmeyr cb2a63406e build: recoin db_test as non-installable program
Change-Id: Id21e7cc1d94824af75a5639810c7d61d7fa7964c
2016-12-12 17:34:25 +01:00
Neels Hofmeyr 3e6a69d2ab fix DLGSUP logging cat after change in libosmocore
DLGSUP must no longer be added to applications' logging category arrays after
change-id Id974c7be158e4d60421a98110f5c807aefd31119 in libosmocore.

Todo: once above change is merged to libosmocore, bump the required libosmocore
version in configure.ac.

Change-Id: I74ab1a031d1ed144468b016294d2965eba5e7d1d
2016-12-11 01:22:45 +01:00
Neels Hofmeyr ec1b959496 fix various compiler warnings
Change-Id: I3bf3b351535843bde9c0c1d955315615bb7c30b2
2016-12-11 01:22:45 +01:00
Neels Hofmeyr 6eed322063 fix build on FreeBSD: eliminate implicitly declared functions
Change-Id: I4f7222f19e4d7129a5cef828a28dd12a40824a59
2016-12-11 01:22:45 +01:00
Neels Hofmeyr 40d8b01dea build with autoconf/automake, add jenkins.sh script
Add configure.ac and Makefile.ams to build with
  autoreconf && ./configure && make
like most other Osmocom projects.

Add jenkins.sh for a gerrit build job to verify patches.

Change-Id: I6b4419dd519f3d0a75235d0c22bf899f075347a3
2016-12-11 01:07:26 +01:00
Max b5bce1e485 Fix build on Ubuntu
Linked libraries supposed to come _after_ the objects which uses
functions from them.
2016-06-30 12:58:49 +02:00
Harald Welte 9be0d2f1a8 fix authentication re-sync (pass RAND+AUTS along) 2016-06-10 17:34:02 +02:00
Harald Welte 79f7140cdf fix PURGE_MS sqlite3 access 2016-06-10 17:33:38 +02:00
Harald Welte fbaa54b957 LU: remote oudated FIXME comments 2016-05-05 21:05:17 +02:00
Harald Welte 53b8678cfc LU: correctly determine and use is_ps
Don't use a local uninitialized variable but the luop->is_ps instead.
2016-05-05 21:04:11 +02:00
Harald Welte b18f0e04f3 implement PURGE-MS from VLR/SGSN to HLR
Using this procedure, the VLR/SGSN can set the cs/ps purged
flag for the subscriber.  We might not even need to store this
persistent in the database according to spec, but let's do it anyway, at
least until it turns out to be a performance issue.
2016-05-05 21:03:03 +02:00
Harald Welte 999092790c some more comment / todo updates 2016-05-05 18:24:15 +02:00
Harald Welte 64f3ca3864 AUC: use osmo_hexparse() when reading key material from db
The database stores the key material as hex-ascii, we thus need to go
through osmo_hexparse() when reading.  We could also store the material
as BLOB in the database.  That would however complicate matters, as it
would basically mean using the sqlite3 command to manually
inspect/modify data from the console would no longer be easily possible.

Using this commit I have 2G authentication working against osmo-sgsn
with GSUP and 'auth policy remote'.
2016-05-05 17:08:48 +02:00
Harald Welte 15db8264c0 State number of auth vectors in SAI response 2016-05-05 16:50:39 +02:00
Harald Welte cfc752bd85 AUC: Differentiate between actual error and unknown IMSI
When responding to a SendAuthInfo.req, we need to differentiate
an error case caused by an unknown IMSI, or an error caused by
an error regarding accessing the database or data integrity.
2016-05-05 16:38:14 +02:00
Harald Welte 6048b59649 populate_hlr_db.pl: Script to generate a HLR database
It currently creates a database with 1 million subscribers, all of which
are provisioned for both 2G and 3G authentication using the same key
material.
2016-05-03 18:51:40 +02:00
Harald Welte 936f6724ec add copyright statements to all files 2016-05-03 18:51:18 +02:00
Harald Welte b6522c0874 db_auc: remove some debugging code about column types 2016-05-03 18:51:04 +02:00
Harald Welte abd1a54183 db: Use Write-Ahead Logging mode of SQLite3 2016-05-03 18:50:41 +02:00
Harald Welte e687be5f2d Major update; Code now supports SAI, LU and ISD transactions
We also introduce a 'gsup_router' which enables us to route
a transaction to a given VLR.  It works based on the SERIAL attribute
communicated at time of the IPA multiplex setup as part of the CCM
sub-protocol.
2016-05-03 18:49:27 +02:00
Harald Welte a7617e9126 Fix memory leakage in gsup_server
Once a remote IPA client is gone, we need to remove the associated
osmo_gsup_conn object.
2016-04-28 12:57:10 +02:00
Harald Welte 5341b5d972 ensure we release memory for all received msgb. 2016-04-28 12:48:39 +02:00
Harald Welte aabae9e7ca hlr: install signal handlers for SIGINT/USR1/HUP 2016-04-28 12:48:14 +02:00
Harald Welte f2d96dad3b more verbose error handling in osmo_gsup_server_read_cb() 2016-04-28 11:13:15 +02:00
Harald Welte 173afdbdbf gsup_server: Implement IPA CCM handling using new libosmo-abis function 2016-04-28 11:13:04 +02:00
Harald Welte e72cf55347 initial import of osmo-gsup-hlr code so far 2016-04-28 07:18:49 +02:00