Kyle Swenson | 7900a3c | 2021-08-12 14:34:44 -0600 | [diff] [blame] | 1 | /* 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 | |
| 23 | #define USAGE_HASH_BITS 16 |
| 24 | |
| 25 | #define CDU_DB_UPDATE_PERMA_SET 1 |
| 26 | #define CDU_DB_UPDATE_EPHEM_SET 0 |
| 27 | #define CDU_DB_CONNTR_NOCLEAR 0 |
| 28 | |
| 29 | extern struct hlist_head cdu_db_usage_hash[USAGE_HASH_BITS] __read_mostly; |
| 30 | extern spinlock_t cdu_db_hash_lock; |
| 31 | |
| 32 | int cdu_db_init(void); |
| 33 | void cdu_db_uninit(void); |
| 34 | void cdu_db_remove(struct usage_entry *obj); |
| 35 | void cdu_db_flush(void); |
| 36 | void cdu_db_update_entry(const struct nf_conn *ct, bool persist, bool clear); |
| 37 | void cdu_db_clear_stats(struct usage_entry *obj, bool persist); |
| 38 | void cdu_db_get_stats(struct usage_stats *upload, struct usage_stats *download, const struct usage_entry *obj); |
| 39 | void cdu_db_add_entry_ifmissing(const struct nf_conn *ct); |
| 40 | |
| 41 | void cdu_db_read_conn(bool clear); |