00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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(char *ip, char *mac, char *token);
00065
00067 t_client *client_list_find(char *ip, char *mac);
00068
00070 t_client *client_list_find_by_ip(char *ip);
00071
00072
00074 t_client *client_list_find_by_mac(char *mac);
00075
00077 t_client *client_list_find_by_token(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