blob: 988c9bd6eb9657c365cafce6240084d6632aa45c [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
Harald Welte9af6ddf2011-01-01 15:25:50 +01006 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
Jan Luebbefaaa49c2008-12-27 01:07:07 +00008 * (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
Harald Welte9af6ddf2011-01-01 15:25:50 +010013 * GNU Affero General Public License for more details.
Jan Luebbefaaa49c2008-12-27 01:07:07 +000014 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010015 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Jan Luebbefaaa49c2008-12-27 01:07:07 +000017 *
18 */
19
20#ifndef _DB_H
21#define _DB_H
22
Maxe6052c42016-06-30 10:25:49 +020023#include <stdbool.h>
24
Holger Hans Peter Freyther81863cd2011-04-12 21:33:35 +020025#include "gsm_subscriber.h"
Jan Luebbefaaa49c2008-12-27 01:07:07 +000026
Holger Hans Peter Freyther28dcbc52010-12-22 18:21:14 +010027struct gsm_equipment;
28struct gsm_network;
29struct gsm_auth_info;
30struct gsm_auth_tuple;
31struct gsm_sms;
Holger Hans Peter Freyther28dcbc52010-12-22 18:21:14 +010032
Holger Freyther12aa50d2009-01-01 18:02:05 +000033/* one time initialisation */
Holger Freytherc7b86f92009-06-06 13:54:20 +000034int db_init(const char *name);
Harald Welted1476bc2011-07-16 13:24:09 +020035int db_prepare(void);
36int db_fini(void);
Jan Luebbefaaa49c2008-12-27 01:07:07 +000037
Harald Welte7e310b12009-03-30 20:56:32 +000038/* SMS store-and-forward */
39int db_sms_store(struct gsm_sms *sms);
Holger Hans Peter Freyther812dad02010-12-24 23:18:31 +010040struct gsm_sms *db_sms_get(struct gsm_network *net, unsigned long long id);
Harald Welte2483f1b2016-06-19 18:06:02 +020041struct gsm_sms *db_sms_get_next_unsent(struct gsm_network *net,
42 unsigned long long min_sms_id,
43 unsigned int max_failed);
44struct gsm_sms *db_sms_get_next_unsent_rr_msisdn(struct gsm_network *net,
45 const char *last_msisdn,
46 unsigned int max_failed);
47struct gsm_sms *db_sms_get_unsent_for_subscr(struct vlr_subscr *vsub,
48 unsigned int max_failed);
Alexander Chemeris1e77e3d2014-03-08 21:27:37 +010049int db_sms_mark_delivered(struct gsm_sms *sms);
Holger Hans Peter Freyther212e1052010-09-17 00:35:46 +080050int db_sms_inc_deliver_attempts(struct gsm_sms *sms);
Harald Welte2483f1b2016-06-19 18:06:02 +020051int db_sms_delete_by_msisdn(const char *msisdn);
Harald Welteffa55a42009-12-22 19:07:32 +010052
53/* Statistics counter storage */
Pablo Neira Ayusodfb342c2011-05-06 12:13:10 +020054struct osmo_counter;
55int db_store_counter(struct osmo_counter *ctr);
Harald Weltef2b4cd72010-05-13 11:45:07 +020056struct rate_ctr_group;
57int db_store_rate_ctr_group(struct rate_ctr_group *ctrg);
Harald Welteffa55a42009-12-22 19:07:32 +010058
Jan Luebbefaaa49c2008-12-27 01:07:07 +000059#endif /* _DB_H */