aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2017-10-17implement subscriber vty interface, testsNeels Hofmeyr6-2/+859
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-15fix db_subscr_get_by_*(): clear output data; test in db_test.cNeels Hofmeyr2-3/+18
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-13debian: 'make check' needs sqlite3, add to Build-DependsNeels Hofmeyr1-1/+2
At some point we should rather offer DB bootstrap as a DB API function instead of an external .sql file, which would remove the dep on the sqlite3 binary. For now, we need the binary to build debian packages for the 'make check' step. Change-Id: I71938dff688675dcf1dbfbce2feb8b72b1de0910
2017-10-11code undup: use db_bind_text() in db_get_auth_data()Neels Hofmeyr2-9/+3
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-11fix db_update_sqn(): reset stmt in all error casesNeels Hofmeyr4-17/+317
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-11code undup: use db_remove_reset() in db_auc.cNeels Hofmeyr1-20/+2
Change-Id: I32d728e2b8a9771421c097647aa0e060e29a601f
2017-10-11refactor db_get_auth_data return valNeels Hofmeyr3-66/+67
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-11add db_subscr_update_aud_by_id(), complete db_subscr_delete_by_id()Neels Hofmeyr5-2/+1003
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-11refactor db_subscr_purgeNeels Hofmeyr6-17/+214
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-11refactor db_subscr_lu()Neels Hofmeyr5-32/+206
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-11refactor db_subscr_ps() to db_subscr_nam()Neels Hofmeyr6-20/+230
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-11add db_subscr_get_by_msisdn() and db_subscr_get_by_id()Neels Hofmeyr5-39/+185
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-11db: use int64_t as subscriber idNeels Hofmeyr2-6/+6
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-11less noise: simplify db_remove_reset()Neels Hofmeyr3-19/+4
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-11add initial db_test: creating and deleting subscribersNeels Hofmeyr7-0/+662
Change-Id: I2a0d277f55162bf5ceb0fc7d50390f2994daed71
2017-10-11add db_subscr_create(), db_subscr_delete(), db_subscr_update_msisdn_by_imsi()Neels Hofmeyr3-0/+128
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-11add db_bind_int() and db_bind_int64()Neels Hofmeyr2-0/+46
Will be used in upcoming patches, e.g. change-IDs - I6e70e15228f5bb10bee6758ae5dc9687d65839bd - I83a47289a48ac37da0f712845d422e897a5e8171 Change-Id: I705a15eef242c98feb6e95a883916f6cf8173d70
2017-10-11cosmetic: don't log about missing SQLite log cbNeels Hofmeyr1-3/+11
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-11gitignore: tests/package.m4Neels Hofmeyr1-0/+1
Change-Id: Ida4a61d4786d7db63dc59a641f44afb2ec2edd97
2017-10-11ctrl_test_runner.py: use proper constant as test db pathNeels Hofmeyr1-1/+1
Change-Id: I9533a9ff8c0f8d24c678583a9197143a187908f3
2017-10-11cosmetic: db_hlr: SL3_TXT: clarify indentingNeels Hofmeyr1-6/+7
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-11cosmetic: log: "SQLite" with capital LNeels Hofmeyr1-4/+4
Change-Id: I43a6ea646f14cfea3a7cd4eb88237ada6d47f5f1
2017-10-11debian/rules: show testsuite.log when tests are failingAlexander Couzens1-0/+4
Change-Id: If0b10c02f87ed81878593198e21da1fc9f8d4bbc
2017-10-10cosmetic: log IMSI='<imsi>', log "no such subscriber"Neels Hofmeyr2-3/+3
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-10cosmetic: multi-line DB_STMT_AUC_BY_IMSINeels Hofmeyr1-1/+6
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-10cosmetic: refactor db_bind_imsi() as db_bind_text()Neels Hofmeyr3-9/+18
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-10cosmetic: rename db_subscr_get() to db_subscr_get_by_imsi()Neels Hofmeyr4-6/+6
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-10cosmetic: prepend DB_STMT_ to enum stmt_idx entriesNeels Hofmeyr4-30/+30
There are upcoming additions, and some seem too general without a proper common prefix in the identifiers, like 'CREATE'. Change-Id: I51b677db31a1ebbbc45dc7925074de7493fbde1f
2017-10-02debian: remove unneeded dependency libdbd-sqlite3Pau Espin Pedrol1-2/+0
Take the opportunity to remove duplicated pkg-config dependency. Change-Id: I5bfe9c71740c1ced5bad0a41dfca568b9e00070c
2017-09-28add CTRL tests for enable-/disable-/status-psNeels Hofmeyr2-0/+55
Change-Id: I014437db9c0f15d818e04810f6cb14bf475ee002
2017-09-28add basic CTRL interface testsNeels Hofmeyr5-1/+503
Prepare for adding tests of enable-/disable-/status-ps CTRL commands. Change-Id: Ie195169c574716b514da7e04a3ce9727ef70a55e
2017-08-26Use value string check from osmo-ciMax1-3/+2
Change-Id: I56ea5be60d2a3cf8442f58e1121b13074e2e6a08
2017-08-25Use release helper from libosmocoreMax2-0/+6
Change-Id: I06b9ceff1e1ecfccc1b1a52ffe6b9d3f6dcaa34d Related: OS#1861
2017-08-15jenkins.sh: Proper error message if local environment isn't set upHarald Welte1-0/+7
Change-Id: I5251ba148f36014f70ce2838caff70062c1a3db1
2017-07-21use OSMO_GSUP_PORT == 4222 instead of hardcoded 2222Neels Hofmeyr1-1/+1
Depends: I4222e21686c823985be8ff1f16b1182be8ad6175 (libosmocore) Change-Id: I9b372a4ac38677773bf813acba80cebcd88e2e20
2017-07-13Another attempt at fixing .debMax2-2/+2
The previous efforts have failed: python3 does not supply /usr/bin/python symlink. Let's use python-minimal dependency. Change-Id: If9e3f31622efae132b25683c54ce09c83ce43415
2017-07-12deb: use python in shebangMax1-2/+2
This should fix the .deb build on OBS. Change-Id: I095e5c273e30a6e124833bf58b231c6367ab48d6
2017-07-11Attempt to fix .deb packageMax4-8/+8
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-06-07tests/auc: Don't require python3Daniel Willmann2-2/+2
Our jenkins buildslave does not have python3 installed so call python2 instead. Change-Id: Ifb59b79021b2c935b326496ed339f12e13c96b8e Ticket: SYS#3322
2017-06-03hlr_data.sql: Insert ki and opc instead of op to example dataDaniel Willmann1-2/+2
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-01VTY: Add hlr node and bind ip fieldPau Espin Pedrol5-5/+114
With this patch the address osmo-hlr binds to can be changed to something else than 0.0.0.0 Change-Id: I79f7a300480f308b21116dd14d1698be38725afd
2017-05-22install hlr.sql in prefix/doc/osmo-hlr/Neels Hofmeyr2-0/+4
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-03Add systemd service fileDaniel Willmann1-0/+11
Change-Id: I7fe9d4e0a8520c6394156bc2871777c6c38b0600
2017-04-27debian: remove obsolete dependencyMax1-2/+1
This should fix package build for latest Ubuntu. Change-Id: I132515cd4d89132bb59f9ee7804a5a50e8bd2775
2017-03-31add config example (mostly empty)Neels Hofmeyr1-0/+16
So far only the vty and ctrl bind configs exists. Change-Id: I38ef124e9f28bdd744bafd20fa8c310511c0b8ad
2017-03-20fix db_subscr_ps error handlingNeels Hofmeyr1-1/+2
Reset stmt and return right away on failure to execute. Change-Id: I27e8b46915efd678c72138e250a9cbb4c9c8ac20 Fixes: Coverity Scan CID#164747
2017-03-16jenkins: add value_string termination checkNeels Hofmeyr1-0/+3
Change-Id: I8cf15d898ef274c505cda0a6b8ddcbf01ba190d9 Depends: libosmocore change-id I2bc93ab4781487e7685cfb63091a489cd126b1a8
2017-03-16debug log: output ind slot, previous sqn, and sqn db updateNeels Hofmeyr4-1/+30
Change-Id: Ib86442ea45f6c1948b3d260f59d35bdca38fbd32
2017-03-16UMTS AKA: implement SQN increment according to SEQ and INDNeels Hofmeyr15-12/+354
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-16fix debug log: adjust to new SQN increment schemeNeels Hofmeyr4-37/+33
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