-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
926 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/* | ||
* Gatekeeper - DoS protection system. | ||
* Copyright (C) 2016 Digirati LTDA. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef _SPACE_SAVING_H_ | ||
#define _SPACE_SAVING_H_ | ||
|
||
#include <rte_hash.h> | ||
|
||
#include "gatekeeper_gk.h" | ||
#include "gatekeeper_net.h" | ||
#include "gatekeeper_flow.h" | ||
|
||
/* Data structure for Counter Table */ | ||
struct counter_table { | ||
|
||
/* Counter for IPV4 address */ | ||
struct rte_hash *ct_ip4; | ||
|
||
/* Counter for IPV6 address */ | ||
struct rte_hash *ct_ip6; | ||
}; | ||
|
||
/* Data structure for Counter bucket */ | ||
struct counter_bucket { | ||
|
||
int proto; | ||
|
||
union { | ||
/* Bucket for IPV4 address */ | ||
struct rte_hash *bkt_ip4; | ||
|
||
/* Bucket for IPV6 address */ | ||
struct rte_hash *bkt_ip6; | ||
} bkt; | ||
}; | ||
|
||
/* Data present in a Counter bucket */ | ||
struct bucket_data { | ||
|
||
int err; | ||
struct ip_flow flow; | ||
}; | ||
|
||
/* Data structure of IP data */ | ||
struct ip_data { | ||
|
||
int bkt_id; | ||
struct bucket_data bkt_data; | ||
}; | ||
|
||
static int | ||
setup_bucket_params(unsigned int socket_id, int bkt_id, int bkt_size, | ||
int ip_ver, struct rte_hash_parameters *bkt_hash_params); | ||
|
||
static int | ||
create_bucket(struct gatekeeper_if *iface, struct gk_config *gk_conf, | ||
int bkt_id); | ||
|
||
static int | ||
get_bucket(int bkt_id, int proto, struct counter_bucket *ct_bkt); | ||
|
||
static int | ||
get_bucket_entry(struct counter_bucket *ct_bkt, struct ip_flow *flow, | ||
struct bucket_data *bkt_data); | ||
|
||
static int | ||
add_bucket_entry(struct counter_bucket *ct_bkt, struct ip_flow *flow, | ||
struct bucket_data *bkt_data); | ||
|
||
static int | ||
delete_bucket_entry(struct counter_bucket *ct_bkt, struct ip_flow *flow); | ||
|
||
static int | ||
setup_counter_params(unsigned int socket_id, int identifier, int ht_size, | ||
int ip_ver, struct rte_hash_parameters *ct_hash_params); | ||
|
||
static int | ||
create_counter_table(struct gatekeeper_if *iface, struct gk_config *gk_conf); | ||
|
||
static int | ||
get_bucket_id(struct counter_table *ct_table, struct ip_flow *flow, | ||
int *bkt_id); | ||
|
||
static int | ||
add_bucket_id(struct counter_table *ct_table, struct ip_flow *flow, | ||
int *bkt_id); | ||
|
||
static int | ||
delete_bucket_id(struct counter_table *ct_table, struct ip_flow *flow); | ||
|
||
static int | ||
update_bucket_id(struct counter_table *ct_table, struct ip_flow *flow); | ||
|
||
static int | ||
get_ip_data(struct counter_table *ct_table, struct ip_flow *flow, | ||
struct ip_data *data); | ||
|
||
static int | ||
add_ip_data(struct counter_table *ct_table, struct ip_flow *flow, | ||
struct ip_data *data); | ||
|
||
static int | ||
delete_ip_data(struct counter_table *ct_table, struct ip_flow *flow); | ||
|
||
static int | ||
update_ip_data(struct counter_table *ct_table, struct ip_flow *flow, | ||
struct gatekeeper_if *iface, struct gk_config *gk_conf); | ||
|
||
static int | ||
space_saving(struct counter_table *ct_table, struct ip_flow *flow, | ||
struct gatekeeper_if *iface, struct gk_config *gk_conf); | ||
|
||
int run(struct gatekeeper_if *iface, struct gk_config *gk_conf); | ||
#endif /* _SPACE_SAVING_H */ | ||
|
Oops, something went wrong.