summaryrefslogtreecommitdiffstatshomepage
path: root/src/ratelimiter.h
blob: c4dc9a78d704ddc5fe043095184d9f4237013dd4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* Copyright (C) 2015-2017 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. */

#ifndef RATELIMITER_H
#define RATELIMITER_H

#include <uapi/linux/netfilter/xt_hashlimit.h>

struct wireguard_device;
struct sk_buff;

struct ratelimiter {
	struct net *net;
	struct xt_hashlimit_mtinfo1 v4_info;
#if IS_ENABLED(CONFIG_IPV6)
	struct xt_hashlimit_mtinfo1 v6_info;
#endif
};

int ratelimiter_init(struct ratelimiter *ratelimiter, struct wireguard_device *wg);
void ratelimiter_uninit(struct ratelimiter *ratelimiter);
bool ratelimiter_allow(struct ratelimiter *ratelimiter, struct sk_buff *skb);

int ratelimiter_module_init(void);
void ratelimiter_module_deinit(void);

#endif