blob: d9463a6846ba60bae531366bfd520db4a79e721c [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
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +010027#define VSUB_USE_SMS_RECEIVER "SMS-receiver"
28
Holger Hans Peter Freyther28dcbc52010-12-22 18:21:14 +010029struct gsm_network;
Holger Hans Peter Freyther28dcbc52010-12-22 18:21:14 +010030struct gsm_sms;
Holger Hans Peter Freyther28dcbc52010-12-22 18:21:14 +010031
Holger Freyther12aa50d2009-01-01 18:02:05 +000032/* one time initialisation */
Holger Freytherc7b86f92009-06-06 13:54:20 +000033int db_init(const char *name);
Harald Welted1476bc2011-07-16 13:24:09 +020034int db_prepare(void);
35int db_fini(void);
Jan Luebbefaaa49c2008-12-27 01:07:07 +000036
Harald Welte7e310b12009-03-30 20:56:32 +000037/* SMS store-and-forward */
38int db_sms_store(struct gsm_sms *sms);
Holger Hans Peter Freyther812dad02010-12-24 23:18:31 +010039struct gsm_sms *db_sms_get(struct gsm_network *net, unsigned long long id);
Harald Welte2483f1b2016-06-19 18:06:02 +020040struct gsm_sms *db_sms_get_next_unsent(struct gsm_network *net,
41 unsigned long long min_sms_id,
42 unsigned int max_failed);
43struct gsm_sms *db_sms_get_next_unsent_rr_msisdn(struct gsm_network *net,
44 const char *last_msisdn,
45 unsigned int max_failed);
46struct gsm_sms *db_sms_get_unsent_for_subscr(struct vlr_subscr *vsub,
47 unsigned int max_failed);
Alexander Chemeris1e77e3d2014-03-08 21:27:37 +010048int db_sms_mark_delivered(struct gsm_sms *sms);
Holger Hans Peter Freyther212e1052010-09-17 00:35:46 +080049int db_sms_inc_deliver_attempts(struct gsm_sms *sms);
Harald Welte2483f1b2016-06-19 18:06:02 +020050int db_sms_delete_by_msisdn(const char *msisdn);
Stefan Sperling6ba2d5a2018-01-18 18:55:26 +010051int db_sms_delete_sent_message_by_id(unsigned long long sms_id);
Stefan Sperling87cba1f2018-01-22 17:05:37 +010052int db_sms_delete_expired_message_by_id(unsigned long long sms_id);
Stefan Sperling14e05172018-01-22 17:31:20 +010053void db_sms_delete_oldest_expired_message(void);
Harald Welteffa55a42009-12-22 19:07:32 +010054
Jan Luebbefaaa49c2008-12-27 01:07:07 +000055#endif /* _DB_H */