00001 /********************************************************************\ 00002 * This program is free software; you can redistribute it and/or * 00003 * modify it under the terms of the GNU General Public License as * 00004 * published by the Free Software Foundation; either version 2 of * 00005 * the License, or (at your option) any later version. * 00006 * * 00007 * This program is distributed in the hope that it will be useful, * 00008 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00009 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00010 * GNU General Public License for more details. * 00011 * * 00012 * You should have received a copy of the GNU General Public License* 00013 * along with this program; if not, contact: * 00014 * * 00015 * Free Software Foundation Voice: +1-617-542-5942 * 00016 * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 * 00017 * Boston, MA 02111-1307, USA gnu@gnu.org * 00018 * * 00019 \********************************************************************/ 00020 00021 /* $Id: client_list.h 1373 2008-09-30 09:27:40Z wichert $ */ 00027 #ifndef _CLIENT_LIST_H_ 00028 #define _CLIENT_LIST_H_ 00029 00032 typedef struct _t_counters { 00033 unsigned long long incoming; 00034 unsigned long long outgoing; 00035 unsigned long long incoming_history; 00036 unsigned long long outgoing_history; 00037 time_t last_updated; 00038 } t_counters; 00039 00042 typedef struct _t_client { 00043 struct _t_client *next; 00044 char *ip; 00045 char *mac; 00046 char *token; 00047 unsigned int fw_connection_state; 00049 int fd; 00052 t_counters counters; 00054 } t_client; 00055 00058 t_client *client_get_first_client(void); 00059 00061 void client_list_init(void); 00062 00064 t_client *client_list_append(const char *ip, const char *mac, const char *token); 00065 00067 t_client *client_list_find(const char *ip, const char *mac); 00068 00070 t_client *client_list_find_by_ip(const char *ip); /* needed by fw_iptables.c, auth.c 00071 * and wdctl_thread.c */ 00072 00074 t_client *client_list_find_by_mac(const char *mac); /* needed by wdctl_thread.c */ 00075 00077 t_client *client_list_find_by_token(const char *token); 00078 00080 void client_list_delete(t_client *client); 00081 00082 #define LOCK_CLIENT_LIST() do { \ 00083 debug(LOG_DEBUG, "Locking client list"); \ 00084 pthread_mutex_lock(&client_list_mutex); \ 00085 debug(LOG_DEBUG, "Client list locked"); \ 00086 } while (0) 00087 00088 #define UNLOCK_CLIENT_LIST() do { \ 00089 debug(LOG_DEBUG, "Unlocking client list"); \ 00090 pthread_mutex_unlock(&client_list_mutex); \ 00091 debug(LOG_DEBUG, "Client list unlocked"); \ 00092 } while (0) 00093 00094 #endif /* _CLIENT_LIST_H_ */