Commit Graph

523 Commits

Author SHA1 Message Date
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
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
Neels Hofmeyr ec9036bdd2 auc_3g_test: add AUTS resync test
Used this to catch a bug where the AUTS process failed to copy RAND to the auth
vector (libosmocore).

Depends: libosmocore change-id If943731a78089f0aac3d55245de80596d01314a4
Change-Id: I06dd8671aa515139bdc3f08883f08276662cf25f
2017-02-22 03:22:06 +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 cc785f0c43 sql: add unique constraints to IMSI and MSISDN
Todo for later: table subscriber_multi_msisdn possibly allows duplicating the
MSISDN, so we should drop this table or have all MSISDNs in one table separate
from 'subscriber'.

Change-Id: I5737106a232e416d67a10634e6270a7a89cf1b05
2017-02-01 19:13:27 +00:00
Neels Hofmeyr 6b883f7848 auth: verify test sets from 3GPP TS 55.205
Put to-text conversion of the 3GPP TS 55.205 PDF's section defining the test
vectors in tests/auc/gen_ts_55_205_test_sets/ts55_205_test_sets.txt and add
python script to generate auc_ts_55_205_test_sets.c from that at build time.

The generated auc_ts_55_205_test_sets.c runs through all 19 test sets,
verifying that our gsm_milenage() matches the reference data.

Change-Id: Idff9d757ab956179aa41ada2a223fd9f439aafbd
2017-02-01 14:22:40 +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 00c069726e Add test suite skeleton with empty test (auc_3g_test)
Change-Id: I6359b0809ce8578850fd65887a568714fb35dbd8
2017-02-01 14:22:19 +01:00
Neels Hofmeyr 8089d51f74 comment: sql: describe auc_2g and auc_3g columns
Change-Id: Ie4edc69ff11a83a4c0f79097f43a2cb206dfe405
2017-02-01 13:58:50 +01:00
Neels Hofmeyr d71dbec7b6 sql: auc_3g: set sqn NOT NULL DEFAULT 0
Change-Id: Ibb765f30295b441e563bb0e06ed39987f79a60d6
2017-02-01 13:58:50 +01:00
Neels Hofmeyr 862f1dc4fd cosmetic: sql: indicate VARCHAR size of key columns as 32
Notably this has no functional effect (according to
https://sqlite.org/faq.html#q9 ), but it can't hurt to indicate intent.

Change-Id: I2b0f9369318085c1482c6d2d8db56699466bfbf3
2017-02-01 13:58:50 +01:00
Neels Hofmeyr 24537b95bd sql: fix 3g_auc's column K data type
K is the SIM card's 128bit secret key, so the type should be VARCHAR like the
other key columns. The db code already reads the column as text and parses as
hex, so a VARCHAR column matches that.

Change-Id: Iaa8d33e303760bd15dcb7dc8bb8b9b24bf6c8f14
2017-02-01 13:58:50 +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 2116ce2471 hlr.sql: typo in comment
Change-Id: I8f16944f966bd40540d5b5396873b873685c18e9
2017-01-19 15:50:59 +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
Max 21229a06be Add gerrit settings
Make it simple to setup and use this repo with 'git review' command.

Change-Id: Ic03e19e2bab46ae2383504cf26e3d7e29d361f05
2016-12-21 10:35:38 +01:00
Neels Hofmeyr 54db5e712d bump required libosmocore version to 0.9.5
0.9.5 tags the version from which on DLGSUP is properly handled in
libosmocore's internal logging.

This bump follows up on previous osmo-hlr change
I74ab1a031d1ed144468b016294d2965eba5e7d1d.

Change-Id: I2af7a9eff3f116bd3bd02edd42e6e0a64f8280cd
2016-12-15 20:16:50 +00:00
Neels Hofmeyr c317cc20c8 build: actually make sqlite mandatory
Change-Id: I9f7183c6a1e1b3a4bc887a67faf2a1c4dfb44762
2016-12-13 14:48:18 +00: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