blob: 07135937b585f75312cbc8d115f992738b09c5ce [file] [log] [blame]
Jan Luebbefaaa49c2008-12-27 01:07:07 +00001/* (C) 2008 by Jan Luebbe <jluebbe@debian.org>
Holger Freyther12aa50d2009-01-01 18:02:05 +00002 * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
Jan Luebbefaaa49c2008-12-27 01:07:07 +00003 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 */
20
21#ifndef _DB_H
22#define _DB_H
23
Jan Luebbe5c15c852008-12-27 15:59:25 +000024#include <sys/types.h>
Jan Luebbefaaa49c2008-12-27 01:07:07 +000025
Jan Luebbe5c15c852008-12-27 15:59:25 +000026#include <openbsc/gsm_subscriber.h>
Jan Luebbefaaa49c2008-12-27 01:07:07 +000027
Holger Freyther12aa50d2009-01-01 18:02:05 +000028/* one time initialisation */
Holger Freytherc7b86f92009-06-06 13:54:20 +000029int db_init(const char *name);
Jan Luebbefaaa49c2008-12-27 01:07:07 +000030int db_prepare();
31int db_fini();
32
Holger Freyther12aa50d2009-01-01 18:02:05 +000033/* subscriber management */
Harald Welte9176bd42009-07-23 18:46:00 +020034struct gsm_subscriber* db_create_subscriber(struct gsm_network *net,
35 char *imsi);
36struct gsm_subscriber* db_get_subscriber(struct gsm_network *net,
37 enum gsm_subscriber_field field,
38 const char *subscr);
Holger Freyther12aa50d2009-01-01 18:02:05 +000039int db_sync_subscriber(struct gsm_subscriber* subscriber);
Jan Luebbe5c15c852008-12-27 15:59:25 +000040int db_subscriber_alloc_tmsi(struct gsm_subscriber* subscriber);
Jan Luebbe9eca37f2009-08-12 21:04:54 +020041int db_subscriber_alloc_exten(struct gsm_subscriber* subscriber);
Jan Luebbe31bef492009-08-12 14:31:14 +020042int db_subscriber_alloc_token(struct gsm_subscriber* subscriber, u_int32_t* token);
Holger Freyther12aa50d2009-01-01 18:02:05 +000043int db_subscriber_assoc_imei(struct gsm_subscriber* subscriber, char *imei);
Holger Hans Peter Freyther34e97492009-08-10 07:54:02 +020044int db_sync_equipment(struct gsm_equipment *equip);
Jan Luebbefaaa49c2008-12-27 01:07:07 +000045
Harald Welte7e310b12009-03-30 20:56:32 +000046/* SMS store-and-forward */
47int db_sms_store(struct gsm_sms *sms);
Harald Welte9176bd42009-07-23 18:46:00 +020048struct gsm_sms *db_sms_get_unsent(struct gsm_network *net, int min_id);
Harald Welte2ebabca2009-08-09 19:05:21 +020049struct gsm_sms *db_sms_get_unsent_for_subscr(struct gsm_subscriber *subscr);
Harald Welte7e310b12009-03-30 20:56:32 +000050int db_sms_mark_sent(struct gsm_sms *sms);
Harald Welte (local)026531e2009-08-16 10:40:10 +020051
52/* APDU blob storage */
53int db_apdu_blob_store(struct gsm_subscriber *subscr,
54 u_int8_t apdu_id_flags, u_int8_t len,
55 u_int8_t *apdu);
Jan Luebbefaaa49c2008-12-27 01:07:07 +000056#endif /* _DB_H */