Commit Graph

408 Commits

Author SHA1 Message Date
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 d3cd102505 gitignore: tests/package.m4
Change-Id: Ida4a61d4786d7db63dc59a641f44afb2ec2edd97
2017-10-11 20:25:29 +00:00
Neels Hofmeyr d4bb51ba1f ctrl_test_runner.py: use proper constant as test db path
Change-Id: I9533a9ff8c0f8d24c678583a9197143a187908f3
2017-10-11 20:25:29 +00: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
Alexander Couzens 3522819d8b debian/rules: show testsuite.log when tests are failing
Change-Id: If0b10c02f87ed81878593198e21da1fc9f8d4bbc
2017-10-11 07:10:57 +02: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
Pau Espin 32c38f09e5 debian: remove unneeded dependency libdbd-sqlite3
Take the opportunity to remove duplicated pkg-config dependency.

Change-Id: I5bfe9c71740c1ced5bad0a41dfca568b9e00070c
2017-10-02 15:00:16 +00:00
Neels Hofmeyr f88c914efd add CTRL tests for enable-/disable-/status-ps
Change-Id: I014437db9c0f15d818e04810f6cb14bf475ee002
2017-09-28 18:52:57 +02:00
Neels Hofmeyr f95ce04cbd add basic CTRL interface tests
Prepare for adding tests of enable-/disable-/status-ps CTRL commands.

Change-Id: Ie195169c574716b514da7e04a3ce9727ef70a55e
2017-09-28 18:52:57 +02:00
Max 05c8b465ab Use value string check from osmo-ci
Change-Id: I56ea5be60d2a3cf8442f58e1121b13074e2e6a08
2017-08-26 06:10:32 +00:00
Max 43bf7bc5c5 Use release helper from libosmocore
Change-Id: I06b9ceff1e1ecfccc1b1a52ffe6b9d3f6dcaa34d
Related: OS#1861
2017-08-25 18:27:28 +02:00
Harald Welte 0b1b6b1f1e jenkins.sh: Proper error message if local environment isn't set up
Change-Id: I5251ba148f36014f70ce2838caff70062c1a3db1
2017-08-15 20:03:41 +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
Max 62491379f1 Another attempt at fixing .deb
The previous efforts have failed: python3 does not supply
/usr/bin/python symlink. Let's use python-minimal dependency.

Change-Id: If9e3f31622efae132b25683c54ce09c83ce43415
2017-07-13 10:52:37 +02:00
Max 02098d9d22 deb: use python in shebang
This should fix the .deb build on OBS.

Change-Id: I095e5c273e30a6e124833bf58b231c6367ab48d6
2017-07-12 10:40:49 +02:00
Max 886ecef1c0 Attempt to fix .deb package
After recent switch to legacy python2 .deb fails on OBS. Let's put
known-to-work python3 dependency back but keep the script itself on
python without version specifier as it seems to work fine with both
versions.

This, in turn, causes tests to fail on FreeBSD so disable them for now.

Change-Id: I4a87252d411d840fca7362736a8c7877efa6ff52
Related: SYS#3322
2017-07-11 15:23:02 +02:00
Daniel Willmann 1f3a1ce1a3 tests/auc: Don't require python3
Our jenkins buildslave does not have python3 installed so call python2
instead.

Change-Id: Ifb59b79021b2c935b326496ed339f12e13c96b8e
Ticket: SYS#3322
2017-06-07 09:59:34 +02:00
Daniel Willmann 69f3860d28 hlr_data.sql: Insert ki and opc instead of op to example data
It depends on the cards whether you have op or opc, but the most cards in use
for 3G are using the opc. Change the example to reflect that.

Change-Id: I8f6051ea9b285ff6261bfe346cfc29d1167921f5
2017-06-03 14:55:56 +00: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 1790c8246a install hlr.sql in prefix/doc/osmo-hlr/
In particular I need this to start a fresh osmo-hlr instance on the
osmo-gsm-tester. Might also come in handy during packaging?

Change-Id: I08e48375814ab93691892299d34909c6d0bf12a2
2017-05-22 19:52:26 +02:00
Daniel Willmann 63b7e86dcf Add systemd service file
Change-Id: I7fe9d4e0a8520c6394156bc2871777c6c38b0600
2017-05-03 18:57:23 +02:00
Max 0ad929b418 debian: remove obsolete dependency
This should fix package build for latest Ubuntu.

Change-Id: I132515cd4d89132bb59f9ee7804a5a50e8bd2775
2017-04-27 10:20:52 +00:00
Neels Hofmeyr 6fb234c251 add config example (mostly empty)
So far only the vty and ctrl bind configs exists.

Change-Id: I38ef124e9f28bdd744bafd20fa8c310511c0b8ad
2017-03-31 12:06:37 +00: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 9d27398e5b jenkins: add value_string termination check
Change-Id: I8cf15d898ef274c505cda0a6b8ddcbf01ba190d9
Depends: libosmocore change-id I2bc93ab4781487e7685cfb63091a489cd126b1a8
2017-03-16 13:08:20 +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 ea1052d300 auc tests: fix after SQN scheme changes from libosmocore
In change-id Iadf43f21e0605e9e85f7e8026c40985f7ceff1a3, libosmocore changes
from incrementing SQN after tuple generation to incrementing SQN before tuple
generation. Thus we now need to pass desired_sqn - 1 to get the same tuples.

Adjust all regression tests, showing that the tuples as well as the SQNs used
to generate the tuples remain unchanged, and only the SQN before and after
generating reflect different values.

Related: OS#1968 OS#1969
Change-Id: I4ec5a578537acb1d9e1ebfe00a72417fc3ca5894
2017-03-15 03:39:04 +01:00
Neels Hofmeyr d846ae8978 auc tests: adjust cosmetically to prepare for SQN changes
The current auc tests test a lot with SQN == 0. An upcoming change in the SQN
algorithms from libosmocore [1] will require us to pass desired_sqn - 1,
because the tuple generation will increment the SQN before calculating.  Later
on [2] we will also want to employ ind_bits and ind in the test. In order to
have some room in the number range, cosmetically adjust the current SQN tested
for from 0 to 32, changing the generated AUTN. The upcoming adjustment to the
new situation will then be able to show that only the SQN values before and
after vector generation change while the auth tuples as well as the SQNs used
for generation remain the same (without having to trick around with wrapping
SQN past its maximum value).

Note that the TS 55.205 test sets include neither SQN nor AUTN. While AUTN
changes with changing SQN, all the other values are invariant of the SQN used.
So we can simply choose a different SQN and ignore the difference in the AUTN.

[1] change-id Iadf43f21e0605e9e85f7e8026c40985f7ceff1a3 "store last sqn"
[2] change-id Ibc97e1736a797ffcbf8c1f7d41c5c4518f4e41bf "fix SQN increment"

Related: OS#1969
Change-Id: I45d1866cde1b3e777460df76100af2fe4767c678
2017-03-15 03:38:45 +01:00
Max 7f39468c75 deb: fix OBS build
Add explicit dependency on python3 which is necessary for 'make check'
stage. While at it, add DH_VERBOSE option for debian/control to
facilitate future troubleshooting.

Change-Id: I0ed0bb0f889d4569c9229f3f12ad8bdb11cc1e7c
Related: OS#1948
2017-03-14 14:31:25 +01:00
Max e9d37db7f2 Add .deb packaging
Add initial metadata for .deb packages.

Change-Id: Ied02e445236410de51488fbb5aaea3170d02a31d
Related: OS#1948
2017-03-13 16:33:23 +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 4436dececd cosmetic: rename auc_3g_test.c to auc_test.c
The test includes 2G-only tests so the name is misleading. Splitting up makes
no sense.

Change-Id: I1a5a40413bf6636ead9370fb827aa0338c049e7f
2017-02-22 03:25:30 +01:00
Neels Hofmeyr 21380ae55e cosmetic: auc_3g_test: improve test debugging tools
In the test failure mismatch printf, better indicate the place of first
mismatch. Helpful if some byte within a hexdump differs, the case when
debugging AUTS.

Copy some optarg code from openbsc's msc_vlr tests to provide verbose mode that
prints log statements' source file and line.

Change-Id: I1b23da055b5edacba09310411caf43c4cd1c29bc
2017-02-22 03:25:30 +01: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 428c9478cd auc_3g_test: add AUTS test with N vectors, to show bug
Add test that shows how passing AUTS to auc_compute_vectors performs an AUTS
sync on each vector and hence produces the same SQN each time. This will
generate one working vector as resync result, and then N-1 more with the wrong
SQN as far as the USIM is concerned. This causes a resync to be necessary on
every authentication.

Depends: libosmocore change-id If943731a78089f0aac3d55245de80596d01314a4
Change-Id: I246c9edfb009b593f834bb5b0577b65bfde7083c
2017-02-22 03:25:30 +01:00
Neels Hofmeyr 3aa3c103c2 auc_3g_test: allow to inc fake rand bytes upon rand request
Preparing for upcoming unit test, in a separate commit for cosmetic reasons
(setting the flag to false across the code).

Change-Id: I6b9899cd898eecc95b244432f416041b194a7187
2017-02-22 03:25:30 +01:00