aboutsummaryrefslogtreecommitdiffstats
path: root/sql
AgeCommit message (Collapse)AuthorFilesLines
2019-11-27db v4: add column last_lu_seen_psNeels Hofmeyr1-2/+3
Location Updating procedures from both CS and PS overwrite the same last_lu_seen field of a subscriber. For upcoming D-GSM it will be important to distinguish those, because only CS attaches qualify for MSISDN lookup. Add column last_lu_seen_ps, and upon PS LU, do not overwrite last_lu_seen, so that last_lu_seen now only reflects CS LU. In the VTY, dump both LU dates distinctively. Change-Id: Id7fc50567211a0870ac0524f6dee94d4513781ba
2019-11-12hlr db schema 3: hlr_number -> msc_numberNeels Hofmeyr1-2/+2
The osmo-hlr DB schema indicates a hlr_number column and references it as 3GPP TS 23.008 chapter 2.4.6. However, chapter 2.4.6 refers to the "MSC number", while the "HLR number" is chapter 2.4.7. Taking a closer look, 2.4.6 says "The MSC number is [...] stored in the HLR", while 2.4.7 says "The HLR number may be stored in the VLR". As quite obvious, the HLR does not store the HLR number. This was a typo from the start. The osmo-hlr code base so far does not use the hlr_number column at all, so we get away with renaming the column without any effects on the code base. However, let's rather make this a new schema version to be safe. Change-Id: I527e8627b24b79f3e9eec32675c7f5a3a6d25440
2019-10-31hlr.sql: move commentNeels Hofmeyr1-1/+2
Move a comment for ind_bitlen column to a separate line, so that it doesn't show in PRAGMA_TABLE_INFO('subscriber'). An upcoming patch introduces db_upgrade_test, which dumps a sorted db schema. In newer sqlite3 versions, a comment following a 'DEFAULT' keyword actually shows up in the PRAGMA_TABLE_INFO() results (on my machine), but older versions (on the build slaves) drop that comment. The ind_bitlen column is the only one producing this odd side effect, because it is the last column and has no comma between 'DEFAULT' and the comment. The easiest way to get matching results across sqlite3 client versions is to move the comment to above ind_bitlen instead of having it on the same line. (Adding a comma doesn't work.) Change-Id: Id66ad68dd3f22d533fc3a428223ea6ad0282bde0
2019-01-24Add IMEI column to subscriber tableOliver Smith1-2/+4
Extend the database scheme, add imei to the hlr_subscriber struct and create db_subscr_update_imei_by_imsi() and db_subscr_get_by_imei(). The new functions are used in db_test, and in follow-up commits [1], [2]. Upgrade DB schema to version 2. SQLite can only insert new columns at the end of the table, so this happens when upgrading the database. In new databases, the column is placed after the IMEISV column (where it makes more sense in my opinion). This should not have any effect, as we never rely on the order of the columns in the tables. Follow-up commit [1] will make use of this column to save the IMEI as received from the MSC/VLR with the Check-IMEI Procedure. It was decided to use Check-IMEI instead of the recent Automatic Device Detection Procedure (which would send the IMEISV) in OS#3733, because with Check-IMEI we don't need to rely on very recent releases of the specification. [1] change-id I09274ecbed64224f7ae305e09ede773931da2a57 "Optionally store IMEI in subscriber table" [2] change-id I1af7b573ca2a1cb22497052665012d9c1acf3b30 "VTY: integrate IMEI" Depends: Id2d2a3a93b033bafc74c62e15297034bf4aafe61 (libosmocore) Related: OS#2541 Change-Id: If232c80bea35d5c6864b889ae92d477eeaa3f45d
2018-12-07store a timestamp of the last location update seen from a subscriberStefan Sperling1-2/+7
Timestamps are stored in the HLR DB in the new 'last_lu_seen' column of the 'subscriber' table, in UTC and in granularity of seconds. At present, osmo-hlr only records these timestamps but otherwise makes no use of them. Because the timestamps are stored in a human-readable form, they may already provide value to external processes which need this information. For example: sqlite> select imsi,last_lu_seen from subscriber; 901990000000001|2018-12-04 14:17:12 I didn't bother adding additional tests because the code added with this commit is already being exercised by several calls to db_subscr_lu() in db_test.c. This change requires a HLR DB schema update. Existing databases won't be upgraded automatically. However, osmo-hlr will refuse to operate with databases which are not upgraded. Change-Id: Ibeb49d45aec18451a260a6654b8c51b8fc3bec50 Related: OS#2838
2018-12-04add database schema versioning to the HLR databaseStefan Sperling1-6/+9
Make use of pragma user_version to store our database schema version. The present schema is now identitifed as 'version 0', which is also the default value for databases on which we never ran the statement 'pragma user_version' before. Only bootstrap the database if it hasn't been bootstrapped yet. Previously, bootstrap SQL statements ran every time osmo-hlr opened the database, and any errors were being ignored in SQL. Instead, we now first run a query which checks whether tables already exist, and only create them if necessary. This change will allow future schema updates to work properly. Prepare for future schema upgrades by adding a new command-line option which enables upgrades. This option defaults to 'false' in order to avoid accidental upgrades. Change-Id: I8aeaa9a404b622657cbc7138106f38aa6ad8d01b Related: OS#2838
2018-07-02sql/Makefile: Create empty /var/lib/osmocom directory at install timepespin/debianPau Espin Pedrol1-0/+7
Otherwise osmo-hlr is unable to start correctly. Change-Id: I1233fc9b3dc685561f79a34e1c32c459dc1aa685
2018-07-02sql/Makefile: Install sql files under doc/.../sql subdirPau Espin Pedrol1-2/+2
Change-Id: I1c9008d4692412a0cfe39d05216fc9c857cf1e8a
2018-07-02sql/Makefile: Install hlr_data.sql as example together with hlr.sqlPau Espin Pedrol1-1/+1
Change-Id: Id4a12252b309f03bb393fa26612c305744e14403
2018-06-24sql/Makefile.am: Make docsdir completely configurableMartin Hauke1-1/+1
$(docdir) defaults to $(datadir)/doc/osmo-hlr Change-Id: I77fa16d0edcf88a8e120921504cd088328077836
2017-10-28cosmetic: sql/hlr.sql: move commentsNeels Hofmeyr1-3/+2
By moving the comments inside the table row definitions, they are dumped back during 'sqlite3 hlr.db .dump'. When they are between SQL statements like before this patch, the comments are lost. Tweak wording. Change-Id: I280c2e2d3e9b7f1dc632722724d9e1c54d041820
2017-10-28automatically create db tables on osmo-hlr invocationNeels Hofmeyr1-6/+5
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-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-05-22install hlr.sql in prefix/doc/osmo-hlr/Neels Hofmeyr1-0/+3
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-03-16UMTS AKA: implement SQN increment according to SEQ and INDNeels Hofmeyr1-1/+2
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-02-01sql: add unique constraints to IMSI and MSISDNNeels Hofmeyr1-2/+2
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-01comment: sql: describe auc_2g and auc_3g columnsNeels Hofmeyr1-7/+7
Change-Id: Ie4edc69ff11a83a4c0f79097f43a2cb206dfe405
2017-02-01sql: auc_3g: set sqn NOT NULL DEFAULT 0Neels Hofmeyr1-1/+1
Change-Id: Ibb765f30295b441e563bb0e06ed39987f79a60d6
2017-02-01cosmetic: sql: indicate VARCHAR size of key columns as 32Neels Hofmeyr1-3/+3
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-01sql: fix 3g_auc's column K data typeNeels Hofmeyr1-1/+1
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-01-19hlr.sql: typo in commentNeels Hofmeyr1-1/+1
Change-Id: I8f16944f966bd40540d5b5396873b873685c18e9
2016-12-11build with autoconf/automake, add jenkins.sh scriptNeels Hofmeyr1-0/+4
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-05-05implement PURGE-MS from VLR/SGSN to HLRHarald Welte1-0/+2
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-03hlr.sql: Don't use TRUE/FALSE as DEFAULT, they will be strings :(Harald Welte1-4/+5
SQLite has this crappy type system where you can put a string into a boolean or integer column, which of course will break once you try to read it as bool.. Also, add an index by IMSI to the SUBSCRIBER table.
2016-04-28initial import of osmo-gsup-hlr code so farHarald Welte2-0/+80