Commit Graph

65 Commits

Author SHA1 Message Date
Harald Welte 9af6ddfcec License change: We are now AGPLv3+ instead of GPLv2+
The reason for this is quite simple: We want to make sure anyone
running a customized version of OpenBSC to operate a network will
have to release all custom modifiations to the source code.
2011-01-01 15:39:34 +01:00
Holger Hans Peter Freyther f64a20f2e8 db: Quote the IMEI string before passing it into the database. 2010-12-26 21:19:29 +01:00
Harald Welte 019d0167b6 [db] Properly quote name and extension for SQL access 2010-12-26 19:20:15 +01:00
Holger Hans Peter Freyther 73b878a85a db: Introduce a limit in delivery attempts for the SMS search
We do not want to attempt submitting SMS that has failed for
too many times. The failure could be due RF failure or due
a bug in the message handling.
2010-12-25 21:39:04 +01:00
Holger Hans Peter Freyther 812dad0ff7 db: Add method to load a SMS by id. 2010-12-25 21:39:04 +01:00
Holger Hans Peter Freyther abd0cac0c5 subscr: Add a VTY command to update the subscriber from the database. 2010-12-24 21:40:48 +01:00
Holger Hans Peter Freyther 28dcbc5ee5 misc: Remove gsm_subscriber.h from the db.h file
Reduce the dependencies on the header files.
2010-12-22 18:26:36 +01:00
Holger Hans Peter Freyther c5faf66b82 misc: Reorder includes, move osmocore to the end 2010-12-22 18:26:36 +01:00
Holger Hans Peter Freyther adb6e1cce1 janitor: Move the * to the variable name 2010-09-18 06:44:24 +08:00
Sylvain Munaut 7a7d364725 db.c: Fix some SQL queries for ambiguous column names
Thanks to Luca Bertoncello for pointing this out

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-07-03 22:24:13 +02:00
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