| #ifndef STAT_GENERAL_H |
| #define STAT_GENERAL_H |
| |
| #include <unistd.h> |
| #include <assert.h> |
| #include <signal.h> |
| #include <time.h> |
| |
| #include <uci.h> |
| #include <libubox/blobmsg_json.h> |
| #include <libubox/blob.h> |
| #include "libubus.h" |
| |
| #ifndef STAT_CONFIG_FILE |
| /*the config file : /etc/config/statistics*/ |
| #define STAT_CONFIG_FILE "statistics" |
| #endif |
| |
| #ifndef SER_SOCK_PATH |
| #define SER_SOCK_PATH "/tmp/ser_sock" |
| #endif |
| |
| #define MAX_STAT_FILE_LEN 64 |
| #define STAT_IFACE_MAX_NUM 16 |
| |
| #define STAT_RETURN_OK 0 |
| #define STAT_RETURN_ERROR -1 |
| |
| #ifndef MAX_LL_LEN |
| #define MAX_LL_LEN 32 |
| #endif |
| |
| #ifndef UNUSESET |
| #define UNUSESET(param) (void)(param) |
| #endif |
| |
| typedef enum { |
| USB, |
| WLAN, |
| WLAN1 |
| } client_type; |
| |
| typedef enum { |
| CONN, |
| DIS_CONN, |
| BLOCK, |
| |
| } client_state; |
| typedef enum { |
| GET_ALL_CLIENTS_STAT, |
| GET_CONN_CLIENTS, |
| } get_clients_type; |
| |
| struct client_info { |
| unsigned char ip[6]; |
| unsigned char mac[8]; |
| char name[32]; |
| client_type type; |
| client_state status; |
| time_t last_conn_time; |
| time_t last_update_time; |
| long long total_conn_time; |
| long long cur_conn_time; |
| long long total_rx; |
| long long unsave_rx; |
| long long total_tx; |
| long long unsave_tx; |
| long long last_ndays_tx; |
| long long last_ndays_rx; |
| long long this_mon_tx; |
| long long this_mon_rx; |
| struct client_info *next; |
| }; |
| |
| enum stat_msg_type { |
| /*stat req */ |
| STAT_UPDATE_SETTINGS_REQ = 0, |
| STAT_GET_DATA_REQ, |
| STAT_ADJUST_MON_REQ, |
| STAT_ADJUST_IDLE_REQ, |
| STAT_ADJUST_PERIOD_REQ, |
| STAT_ADJUST_PAYDAY_REQ = 5, |
| STAT_GET_COMMON_REQ, |
| STAT_GET_ALL_CLIENTS_INFO_REQ, |
| STAT_GET_CONN_CLIENTS_INFO_REQ, |
| UPDATE_WAN_INFACES_REQ, |
| STAT_CNF_OK = 10, |
| STAT_GET_ONE_CLIENT_CNF_OK, |
| STAT_CLEAR_MONITOR_DATA_REQ, |
| STAT_CLEAR_COMMON_DATA_REQ, |
| STAT_GET_CCINET_REQ, |
| /*stat req */ |
| |
| /*client manage req */ |
| CLIENTS_BLOCK_MAC_REQ = 15, |
| CLIENTS_UNBLOCK_MAC_REQ, |
| CLIENTS_CONN_REQ, |
| CLIENTS_DISCONN_REQ, |
| CLIENTS_CLEAR_HISTORY_REQ, |
| CLIENTS_RESET_DATA_REQ = 20, |
| WIFI_OFF_EVENT_REQ, |
| /*client manage req */ |
| |
| /*DAY_CHANGE_REQ */ |
| DAY_CHANGE_REQ, |
| TIME_SETTINGS_REQ, |
| |
| /*DHCP_ACTION_REQ*/ |
| DHCP_ACTION_REQ, |
| |
| STAT_DATA_FLUSH = 25, |
| }; |
| #if 0 |
| struct stat_msg_data { |
| long long basic_mon_used; |
| long long period_used; |
| long long idle_used; |
| long long total_mon_used; |
| long long adjust_value; |
| int active_clients; |
| }; |
| struct stat_msg { |
| int msg_type; |
| struct stat_msg_data data; |
| }; |
| #endif |
| struct stat_req_msg_data { |
| long long adjust_value; |
| char mac[18]; |
| }; |
| #if 0 |
| struct stat_cnf_msg_data { |
| long long basic_mon_used; |
| long long period_used; |
| long long idle_used; |
| long long total_mon_used; |
| int active_clients; |
| }; |
| #endif |
| struct stat_ctrl_msg_data { |
| long long basic_mon_used; |
| long long period_used; |
| long long idle_used; |
| long long total_mon_used; |
| int warning; |
| }; |
| struct stat_common_msg_data { |
| long long power_on_tx_bytes; |
| long long power_on_rx_bytes; |
| long long power_on_error_bytes; |
| long long total_rx_bytes; |
| long long total_tx_bytes; |
| long long total_error_bytes; |
| }; |
| |
| struct stat_ccinet_msg_data { |
| long long total_rx_bytes; |
| long long total_tx_bytes; |
| long long total_error_bytes; |
| long long total_rx_v6_bytes; |
| long long total_tx_v6_bytes; |
| long long total_v6_error_bytes; |
| int current_duration; |
| int total_duration; |
| }; |
| #if 0 |
| struct stat_req_msg { |
| int msg_type; |
| struct stat_req_msg_data data; |
| }; |
| #endif |
| |
| struct stat_nw_notify_data { |
| int status; |
| int cid; |
| int iptype; |
| int current_duration_time; |
| int duration_time; |
| int notify_ticks; |
| }; |
| struct dhcp_action_msg{ |
| char mac[18]; |
| char ip[16]; |
| char name[32]; |
| }; |
| |
| struct stat_req_msg { |
| int msg_type; |
| union { |
| long long adjust_value; |
| char mac[18]; |
| struct stat_nw_notify_data nw_msg; |
| struct dhcp_action_msg dhcp_msg; |
| int cid; |
| } data; |
| int ap_index; |
| }; |
| |
| struct stat_cnf_msg { |
| int msg_type; |
| union { |
| struct stat_ctrl_msg_data ctrl_data; |
| struct stat_common_msg_data common_data; |
| struct stat_ccinet_msg_data ccinet_data; |
| int active_clients; |
| } msg_data; |
| }; |
| struct client_info_msg { |
| int msg_type; |
| struct client_info node; |
| }; |
| #endif |