suricata
util-flow-rate.h
Go to the documentation of this file.
1/* Copyright (C) 2025 Open Information Security Foundation
2 *
3 * You can copy, redistribute or modify this Program under the terms of
4 * the GNU General Public License version 2 as published by the Free
5 * Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * version 2 along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18/**
19 * \file
20 *
21 * \author Shivani Bhardwaj <shivani@oisf.net>
22 */
23
24#ifndef SURICATA_UTIL_FLOW_RATE_H
25#define SURICATA_UTIL_FLOW_RATE_H
26
31
32typedef struct FlowRateDirStore_ {
33 /* Ring buffer to store byte count per second in */
34 uint64_t *buf;
35 /* Total sum of bytes per direction */
36 uint64_t sum;
37 /* Last index that was updated in the buffer */
38 uint16_t last_idx;
39 /* Size of the ring; should be same for both directions */
40 uint16_t size;
41 /* start timestamp to define and track the beginning of buffer */
43 /* last timestamp that was processed in the buffer */
46
50
52
53bool FlowRateStorageEnabled(void);
57void FlowRateStoreUpdate(FlowRateStore *, SCTime_t, uint32_t, int);
59
60#ifdef UNITTESTS
61void FlowRateRegisterTests(void);
62#endif
63
64#endif
FlowRateDirStore dir[2]
FlowStorageId FlowRateGetStorageID(void)
struct FlowRateDirStore_ FlowRateDirStore
struct FlowRateStore_ FlowRateStore
struct FlowRateConfig_ FlowRateConfig
void FlowRateRegisterTests(void)
FlowRateStore * FlowRateStoreInit(void)
bool FlowRateStorageEnabled(void)
void FlowRateStoreUpdate(FlowRateStore *, SCTime_t, uint32_t, int)
bool FlowRateIsExceeding(FlowRateStore *, int)
FlowRateConfig flow_rate_config
void FlowRateRegisterFlowStorage(void)