Commit Graph

55 Commits

Author SHA1 Message Date
Sylvain Munaut adea4f1bf8 db: Use proper %llu for subscriber ID in format string.
This was causing weird crashes when running in 32 bit linux.

Thanks to horiz0n for taking the time to debug this with me on IRC.

Written-by: horiz0n <cscan@gmx.net>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-07-03 22:24:13 +02:00
Sylvain Munaut 31ac307130 db: Fix typo in sync_lastauthtuples SQL UPDATE stmt
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-14 20:43:51 +02:00
Sylvain Munaut 92b2ff5081 db: Change naming convention for auth info functions
- exported function have a 'db_' prefix
 - use 'sync' vs 'set'
 - use 'for' vs 'by'

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-14 20:43:50 +02:00
Sylvain Munaut 10bf812a6a db: Use subscriber_id as primary key for AuthKeys/AuthLastTuples
It's unique and not null and we never use 'id' anyway.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-14 20:43:50 +02:00
Sylvain Munaut c614a6a199 db: Rename AuthTuples to AuthLastTuples
Ultimately, we'll need to store both the last used tuple by a
subscriber and a list of known tuples (for unknown Ki). What's
currently implemented for AuthTuples is the former behavior, so
reflect that.

The second use case will be added as a separate table with separate
accessors later on.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-14 20:43:50 +02:00
Harald Welte d94d6a02d5 DB: don't use reserved "index" word in SQL table field name 2010-05-14 17:38:47 +02:00
Harald Welte c191986691 [GPRS] NS: more rate counters for BLOCK / DEAD count 2010-05-13 12:55:20 +02:00
Harald Welte f2b4cd7b86 [GPRS] NS: Start to use rate_ctr_group code from libosmocore
Every NS-VC now has a set of counters for incoming and outgoing
number of packets and bytes.

We also split the VTY part of the gprs_ns.c implementation into gprs_ns_vty.c
to make sure the protocol can actually be used without the VTY code being
present.
2010-05-13 11:45:07 +02:00
Holger Hans Peter Freyther ceb072da34 db: Fix aliasing warning by casting the signed char to a struct
When we have assigned the cn we will use mempcy to copy the one
byte into the target. Use a static assert to assure that the type
have the same size.

warning: dereferencing type-punned pointer will break strict-aliasing rules
2010-03-30 15:30:14 +02:00
Holger Hans Peter Freyther acf8a0c59f [misc] Remove whitespace from the end of the line. 2010-03-29 08:47:44 +02:00
Holger Hans Peter Freyther b464fb4a89 db: Fix a bug where no pending SMS were found
The "sms send pending" VTY command did not work due a mismatch
of types. We are specifying a unsigned long long in the query
and provided DBI with a signed integer type. The result was a
failure do find any information.

Change the API to operate on unsigned long long that is matching
the id of the SMS and the Subscriber and the mismatch with the
query string is gone and pending SMS are sent.
2010-03-25 09:59:30 +01:00
Harald Welte dfe6c7d910 split 'libosmocore' from openbsc codebase
This library is intended to collect all generic/common funcitionality
of all Osmocom.org projects, including OpenBSC but also OsmocomBB

The library currently includes the following modules:

bitvec, comp128, gsm_utils, msgb, select, signal, statistics, talloc, timer,
tlv_parse, linuxlist

msgb allocation error debugging had to be temporarily disabled as it depends on
'debug.c' functionality which at the moment remains in OpenBSC
2010-02-20 16:27:23 +01:00
Sylvain Munaut 062d5efc5c db: Add methods to set auth{info,tuple} for a subscriber
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-01-03 10:50:34 +01:00
Sylvain Munaut e1cb4debb0 db: Fix bad size comparison when retrieving Ki
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-01-03 10:48:42 +01:00
Sylvain Munaut 70881b7e8a db: Add issued/use_count/key_seq fields to AuthTuples
Theses will be useful to know if we can reuse the tuples or if
we should renew. The 'issued' is currently purely informative.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-01-03 10:17:35 +01:00
Sylvain Munaut 77d334ac4d db: Fix type of algorithm_id (NUMERIC -> INTEGER)
This fixes a DB warning and no need for NUMERIC here.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-01-03 10:16:15 +01:00
Sylvain Munaut deebb113ac db: Fix missing commas in AuthTuples table creation
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-01-03 10:13:14 +01:00
Harald Welte (local) 441e483bd4 [db] A new subscriber is an INFO event, not NOTICE 2009-12-26 22:47:48 +01:00
Harald Welte (local) 1f3ecd4050 'classmark1' is not an integer field in the database 2009-12-26 22:47:43 +01:00
Harald Welte ae1f159dc4 Converrt the database later to use DEBUGP/LOGP instead of stderr 2009-12-24 11:39:51 +01:00
Harald Welte 0b906d0e1a db: coding style cleanup 2009-12-24 11:39:51 +01:00
Harald Welte 09f7ad0ff7 fix merge artefact from db.c 2009-12-24 09:42:07 +01:00
Harald Welte 3606cc5765 [authentication] Code for retrieving authentication data from SQL DB
This is the first step towards supporting actual A3/A8 authentication.
2009-12-24 09:37:34 +01:00
Harald Welte f9a43c45ea fix sql table creation for 'Counters' table 2009-12-22 21:40:42 +01:00
Harald Welte ffa55a4e87 statistics: Introduce 'struct counter' instead of using unsigned long
This has the advantage that counters can be added all over the code
very easily, while having only one routine that stores all of the
current counter values to the database.  The counters are synced
every 60 seconds, providing relatively fine grained statistics
about the network usage as time passes by.
2009-12-22 20:42:40 +01:00
Sylvain Munaut ff1f19e199 Implement a better sending of pending SMS
The previous implementation had some shortcomings:
 - If the MIN ID given was not the exact id of the first unsent SMS,
 it would try to submit the same sms several time until id++ finally
 made id go to the next one.
 - If a subscriber had several SMS pending it would try to submit
 them individually (only to get rejected because a paging for that
 subscriber was already in progress)

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2009-12-22 13:22:29 +01:00
Sylvain Munaut d5778fc4c7 [db] Fix queries for unsent SMS
- Need to use sms.id for the ORDER BY since 'subscriber' also has 'id'
- Need to add the join clause between 'SMS' and 'subscriber'
- Add a LIMIT 1 (probably no impact for the db size we're dealing with
here, but with large DB and mysql/postgresql this can help the planner)
- (fix a wrong comment in passing ...)

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2009-12-21 01:09:57 +01:00
Harald Welte 4669f3d9c8 fix compile warning in db.c 2009-12-09 19:19:45 +01:00
Harald Welte d409be7fae change some identifiers from u_int64_t to unsigned long long
makes printf much easier on 64bit platforms...
2009-11-07 00:06:19 +09:00
Holger Hans Peter Freyther 2657abfe35 [db] Fix compile warnings in db.c
For the compiler classmark1 is a struct and the compiler is
unaware that it fits into an unsigned int. Use memcpy to
copy it to a u_int8_t (the compiler should inline this).

dbi_conn_quote_binary_copy works on unsigned char* change
q_apdu to be unsigned char.
2009-10-22 15:34:37 +02:00
Holger Hans Peter Freyther 2223025e21 [tmsi] Make the tmsi a 4 octet number
tmsi is four octets long, there is no need to make it a string
and then jump through hoops to convert it to a number. Keep the database
using it as a string to benefit from the NULL handling of the db.

Introduce the reserved tmsi which has all bits set to 1 according
to GSM 03.03 §2.4 and start checking for it and make sure the db
code will never allocate such a tmsi.
2009-09-28 05:14:25 +02:00
Harald Welte 55726d73d7 Use correct capitalization on SQL statements
otherwise, SQLite seems to return the wrong data types ?!?

Signed-off-by: Mike Haben <michael.haben@btinternet.com>
2009-09-26 18:54:59 +02:00
Harald Welte (local) ee4410a4f3 actual code running at end of har2009 2009-08-17 09:39:55 +02:00
Harald Welte (local) 026531ec92 store all APDU's received from the MS in the database
This helps us to analyze data such as RRLP location information for
later analysis.
2009-08-16 10:40:10 +02:00
Harald Welte (local) db552c56bb don't try to deliver sms to a subscriber that's not registered 2009-08-15 20:15:14 +02:00
Harald Welte (local) 3feef255d2 fix token allocation sql strings 2009-08-13 13:26:11 +02:00
Jan Luebbe f0b4cef137 fix random extension generation 2009-08-12 22:22:53 +02:00
Jan Luebbe 9eca37f93c fix problems with tmsi uniqueness in the subscriber table 2009-08-12 22:22:42 +02:00
Jan Luebbe 1da59edf83 fix a wrong format specifier 2009-08-12 22:22:26 +02:00
Jan Luebbe ebcce2aae1 allocate an extension when creating the subscriber 2009-08-12 22:22:20 +02:00
Jan Luebbe 31bef49be2 token support in the DB 2009-08-12 22:21:56 +02:00
Jan Luebbe b0dfc31d7d flag new subscriber structs in memory and send a signal 2009-08-12 21:03:00 +02:00
Holger Hans Peter Freyther 850326e377 db.c: Move the schema revision check after creating the tables
When starting the first time there are no tables, doing a revision
check will fail and bsc_hack will exit without tables created. Do
the revision check within db_prepare and allow new tables to be
created before.
2009-08-10 08:36:04 +02:00
Holger Hans Peter Freyther 966de68539 db: Fix warning about truncating the size
We are truncating the size and might should simply use a MIN
here to get the returned size or the maximum we can hold..
2009-08-10 08:26:07 +02:00
Holger Hans Peter Freyther 34e97495a6 misc: Add prototypes to header files, include more header files
Fix various warnings about implicit declarations of functions.
2009-08-10 07:54:02 +02:00
Harald Welte 2ebabca32a new db_sms_get_unsent_for_subscr() function
The function retrieves the oldest not-yet-sent SM for the given subscriber
2009-08-09 19:05:21 +02:00
Harald Welte d0b7b7719f add ud_hdr_ind to SMS table
we also implement verification of the database schema number by
using the 'Meta' table.
2009-08-09 19:03:42 +02:00
Harald Welte 76042188e0 first 'working' SMS implementation
we now have the full path from the MS into the database (SUBMIT), as well as
back from the database to the MS (DELIVER).  The database gets correctly
updated once a SMS has been successfully delivered.

What's still missing is the periodic scan over all undelivered messages,
trying to deliver them to the respective MS.  So far, you have to manually
trigger this on the telnet interface with 'sms send pending 1'
2009-08-08 16:03:15 +02:00
Harald Welte f3efc597d1 further steps towards better, transaction based SMS 2009-07-27 20:11:35 +02:00
Harald Welte 9176bd46e3 make sure subscr->net is always set
since a subscriber is an element of the gsm_network, we have to ensure
subscr->net is always set correctly.  We do this by using gsm_network
as an argument to all functions that resolve or create a subscriber.
2009-07-23 18:46:00 +02:00