1#ifndef __AF_CLIENT_H__
2#define __AF_CLIENT_H__
3#include "app_filter.h"
4
5extern rwlock_t af_client_lock;
6
7extern u32 nfc_debug_level;
8
9#define MAX_AF_CLIENT_HASH_SIZE 64
10#define NF_CLIENT_TIMER_EXPIRE 1
11#define MAX_CLIENT_ACTIVE_TIME 90
12
13#define AF_CLIENT_LOCK_R() read_lock_bh(&af_client_lock);
14#define AF_CLIENT_UNLOCK_R() read_unlock_bh(&af_client_lock);
15#define AF_CLIENT_LOCK_W() write_lock_bh(&af_client_lock);
16#define AF_CLIENT_UNLOCK_W() write_unlock_bh(&af_client_lock);
17
18#define NIPQUAD(addr)                \
19	((unsigned char *)&addr)[0],     \
20		((unsigned char *)&addr)[1], \
21		((unsigned char *)&addr)[2], \
22		((unsigned char *)&addr)[3]
23#define NIPQUAD_FMT "%u.%u.%u.%u"
24
25enum NFC_PKT_DIR
26{
27	PKT_DIR_DOWN,
28	PKT_DIR_UP
29};
30
31#define MAX_VISIT_HISTORY_TIME 24
32#define MAX_RECORD_APP_NUM 64
33
34typedef struct app_visit_info
35{
36	unsigned int app_id;
37	unsigned int total_num;
38	unsigned int drop_num;
39	unsigned long latest_time;
40	unsigned int latest_action;
41	unsigned int total_down_bytes;
42	unsigned int total_up_bytes;
43	unsigned long history_time[MAX_VISIT_HISTORY_TIME];
44	unsigned int action[MAX_VISIT_HISTORY_TIME];
45} app_visit_info_t;
46
47typedef struct af_client_info
48{
49	struct list_head hlist;
50	unsigned char mac[MAC_ADDR_LEN];
51	unsigned int ip;
52	unsigned long create_jiffies;
53	unsigned long update_jiffies;
54	unsigned int visit_app_num;
55	int report_count;
56	app_visit_info_t visit_info[MAX_RECORD_APP_NUM];
57} af_client_info_t;
58
59int af_client_init(void);
60
61void af_client_exit(void);
62af_client_info_t *find_af_client_by_ip(unsigned int ip);
63af_client_info_t *find_af_client(unsigned char *mac);
64
65void check_client_expire(void);
66
67void af_visit_info_report(void);
68
69void af_client_list_reset_report_num(void);
70af_client_info_t *nf_client_add(unsigned char *mac);
71af_client_info_t *find_and_add_af_client(unsigned char *mac);
72
73#endif
74