blob: 131670f4399180ad209179571b70866af623e05f [file] [log] [blame]
Kyle Swenson7900a3c2021-08-12 14:34:44 -06001/* cdu_db.h
2 *
3 * This file defines client data usage database interface.
4 *
5 * Author: Cradlepoint Technology, Inc. <source@cradlepoint.com>
6 * Adrian Sitterle <asitterle@cradlepoint.com>
7 *
8 * Copyright (C) 2019 Cradlepoint Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 * as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 */
19
20#pragma once
21#include "cdu_types.h"
22
Kyle Swenson7900a3c2021-08-12 14:34:44 -060023
24#define CDU_DB_UPDATE_PERMA_SET 1
25#define CDU_DB_UPDATE_EPHEM_SET 0
26#define CDU_DB_CONNTR_NOCLEAR 0
27
28extern struct hlist_head cdu_db_usage_hash[USAGE_HASH_BITS] __read_mostly;
Kyle Swensonb770f212022-01-24 08:34:00 -070029extern struct list_head cdu_db_usage_list;
Kyle Swenson7900a3c2021-08-12 14:34:44 -060030extern spinlock_t cdu_db_hash_lock;
31
32int cdu_db_init(void);
33void cdu_db_uninit(void);
34void cdu_db_remove(struct usage_entry *obj);
35void cdu_db_flush(void);
36void cdu_db_update_entry(const struct nf_conn *ct, bool persist, bool clear);
37void cdu_db_clear_stats(struct usage_entry *obj, bool persist);
38void cdu_db_get_stats(struct usage_stats *upload, struct usage_stats *download, const struct usage_entry *obj);
39void cdu_db_add_entry_ifmissing(const struct nf_conn *ct);
40
41void cdu_db_read_conn(bool clear);