secgateway/Product/common/user_auth.h

65 lines
1.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef USER_AUTH_
#define USER_AUTH_
#include <time.h>
typedef enum {
AUTH_SUCCESS = 0,
AUTH_FAIL_PASSWD = 1,
AUTH_FAIL_VALID = 2,
AUTH_FAIL_MULTI = 3,
AUTH_FAIL_LOCK = 4,
AUTH_FAIL_LACKINFO = 5,
AUTH_FAIL_INPUT = 6,
AUTH_FAIL_OVER = 7,
AUTH_ERR = 8,
} auth_ret;
#define USER_AUTH_RET_ERROR_DISC \
{ \
{ AUTH_SUCCESS, "SUCCESS" },\
{ AUTH_FAIL_PASSWD, "ErrorUsernameOrPasswd" },\
{ AUTH_FAIL_VALID, "NotInValidTime" },\
{ AUTH_FAIL_MULTI, "OutMaxOnlineNum" },\
{ AUTH_FAIL_LOCK, "UserIsLocked" },\
{ AUTH_FAIL_LACKINFO, "LackConfigInfo" },\
{ AUTH_FAIL_INPUT, "InputError"},\
{ AUTH_FAIL_OVER, "OverMaxOnlineNum"},\
{ AUTH_ERR, "OtherErr"}\
}
typedef struct user_auth_list
{
time_t* fail_time; //循环队列存储认证失败时间点
int front; //循环队列头
int rear; //循环队列尾
int max_size; //循环队列的最大存储空间,锁定次数+1config_fail_num + 1
unsigned int online_num; //用户上线数量
time_t lock_time; //用户锁定时间
unsigned short group_id; //用户组id
//unsigned int fail_num; //用户认证失败次数
} USER_AUTH_LIST;
typedef struct user_auth_ret
{
auth_ret ret;
unsigned short user_id;
unsigned short group_id;
time_t remain_lock_time;
} USER_AUTH_RET;
/* 用户认证 */
void user_auth_login(char* username, char* password, USER_AUTH_RET* auth_result);
/* 用户在线数-1 */
void reduce_online_num(unsigned short user_id);
/* 用户在线节点重置-按用户id, num为user_ids数组长度 */
void reset_online_by_userid(int *user_ids, int num);
/* 用户在线节点重置-按用户组id */
void reset_online_by_groupid(int *group_ids);
#endif