1 /* 2 * Copyright (C) 2015 Nikos Mavrogiannopoulos 3 * 4 * Author: Nikos Mavrogiannopoulos 5 * 6 * This file is part of ocserv. 7 * 8 * ocserv is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public License 10 * as published by the Free Software Foundation; either version 2.1 of 11 * the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, but 14 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public License 19 * along with this program. If not, see <http://www.gnu.org/licenses/> 20 */ 21 #ifndef MAIN_BAN_H 22 # define MAIN_BAN_H 23 24 # include "main.h" 25 26 typedef struct inaddr_st { 27 uint8_t ip[16]; 28 unsigned size; /* 4 or 16 */ 29 } inaddr_st; 30 31 typedef struct ban_entry_st { 32 inaddr_st ip; 33 unsigned score; 34 35 time_t last_reset; /* the time its score counting started */ 36 time_t expires; /* the time after the client is allowed to login */ 37 } ban_entry_st; 38 39 void cleanup_banned_entries(main_server_st *s); 40 unsigned check_if_banned(main_server_st *s, struct sockaddr_storage *addr, socklen_t addr_size); 41 int add_str_ip_to_ban_list(main_server_st *s, const char *ip, unsigned score); 42 int remove_ip_from_ban_list(main_server_st *s, const uint8_t *ip, unsigned size); 43 unsigned main_ban_db_elems(main_server_st *s); 44 void main_ban_db_deinit(main_server_st *s); 45 void *main_ban_db_init(main_server_st *s); 46 47 int if_address_init(main_server_st *s); 48 void if_address_cleanup(main_server_st * s); 49 50 #endif 51