37 lines
592 B
C
37 lines
592 B
C
#ifndef _KUSERHASH_H
|
|
#define _KUSERHASH_H
|
|
|
|
#include <linux/list.h>
|
|
|
|
/*定义hash表大小 */
|
|
#define HASH_SIZE 100
|
|
|
|
typedef struct userinfo
|
|
{
|
|
struct list_head hnode;
|
|
int user_id;
|
|
uint32_t user_ip;
|
|
}USERINFO;
|
|
|
|
/*init hashtable */
|
|
void init_hashMap(void);
|
|
|
|
/*获取hashtable位置索引 */
|
|
int get_hash_index(uint32_t ip);
|
|
|
|
/* search node */
|
|
USERINFO *search_user(uint32_t ip);
|
|
|
|
/*add user */
|
|
int add_user(uint32_t ip, int id);
|
|
|
|
/*delete a node */
|
|
void del_user(uint32_t ip);
|
|
|
|
/*delete all node */
|
|
void free_all_user(void);
|
|
|
|
/*printf all nodes */
|
|
void printk_all_user(void);
|
|
|
|
#endif |