secgateway/Product/user/user_manager/usermanager-auth/user_auth.h

58 lines
1.5 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 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, time_t login_time, USER_AUTH_RET* auth_result);
/* 用户下线数-1 */
void reduce_online_num(unsigned short user_id);
#endif