Merge branch 'master' of http://git.komect.net/ISG/secogateway
This commit is contained in:
commit
f632f68eab
|
@ -1,11 +1,11 @@
|
|||
/* This file is auto generated,for sGATE version info */
|
||||
/* Used readelf to get this information form driver of application */
|
||||
/* "readelf --debug-dump=macro <filename>" */
|
||||
#define sGATE_COMPILE_DATE "2019-07-04"
|
||||
#define sGATE_COMPILE_TIME "16:24:06"
|
||||
#define sGATE_COMPILE_MAJOR "20190704"
|
||||
#define sGATE_COMPILE_SUB "162406"
|
||||
#define sGATE_COMPILE_BY "zza"
|
||||
#define sGATE_COMPILE_DATE "2019-07-08"
|
||||
#define sGATE_COMPILE_TIME "16:43:21"
|
||||
#define sGATE_COMPILE_MAJOR "20190708"
|
||||
#define sGATE_COMPILE_SUB "164321"
|
||||
#define sGATE_COMPILE_BY "cl"
|
||||
#define sGATE_COMPILE_HOST "esgwdev01"
|
||||
#define sGATE_GIT_TAGS "8ab4e9178-dev"
|
||||
#define sGATE_GIT_VERS "8ab4e9178e1bfa02cef1e2de1991daf1c7593b86"
|
||||
#define sGATE_GIT_TAGS "422ab40d7-dev"
|
||||
#define sGATE_GIT_VERS "422ab40d72986d1bba93e7eba5379cd61f5d9c24"
|
||||
|
|
7
Makefile
7
Makefile
|
@ -125,11 +125,11 @@ endif
|
|||
|
||||
usermanager:
|
||||
ifeq ($(OPT), clean)
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Product/build -f user.usermanager.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=usermanager
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Product/build -f user.usermanager-test.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=usermanager-test
|
||||
else ifeq ($(OPT), install)
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Product/build -f user.usermanager.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=usermanager
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Product/build -f user.usermanager-test.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=usermanager-test
|
||||
else
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Product/build -f user.usermanager.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=usermanager
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Product/build -f user.usermanager-test.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=usermanager-test
|
||||
endif
|
||||
|
||||
configm:
|
||||
|
@ -156,3 +156,4 @@ else ifeq ($(OPT), install)
|
|||
else
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.redismq.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=redismq
|
||||
endif
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=authfree
|
||||
TARGET_NAME=userlock
|
||||
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
|
@ -22,13 +22,13 @@ DEBUG = TRUE
|
|||
PLAT_LINUX ?= TRUE
|
||||
PLAT_ARM64 ?= FALSE
|
||||
|
||||
VPATH = ../user/configm/config-server/authfree_config/
|
||||
VPATH = ../user/configm/config-server/userlock_config/
|
||||
|
||||
# source code
|
||||
|
||||
# set the source file, don't used .o because of ...
|
||||
|
||||
COMMON_SRCS = authfree.c
|
||||
COMMON_SRCS = userlock.c
|
||||
|
||||
# MRS Board Source Files
|
||||
PLAT_LINUX_SRCS = $(COMMON_SRCS)
|
||||
|
@ -36,6 +36,7 @@ PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
|||
|
||||
# gcc CFLAGS
|
||||
PLAT_ARM64_CFLAGS := -I../user/configm/config-server/include -I../../Common -I../common/configm -I../common/rpc -I../common/rpc/hashtable
|
||||
PLAT_ARM64_CFLAGS += -I../include/
|
||||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||
|
||||
|
||||
|
|
|
@ -21,13 +21,14 @@ DEBUG = TRUE
|
|||
PLAT_LINUX ?= TRUE
|
||||
PLAT_ARM64 ?= TRUE
|
||||
|
||||
VPATH = ../user/configm/config-server
|
||||
|
||||
VPATH = ../user/configm/config-server ../user/configm/config-server/user_manager_config
|
||||
# source code
|
||||
|
||||
# set the source file, don't used .o because of ...
|
||||
|
||||
COMMON_SRCS = configserver.c ipconfig/ipconfig.c ipconfig/parsefile.c authfree_config/authfree.c localportal_config/localportal.c userlock_config/userlock.c jumppage_config/jumppage.c user_manager_config/user_group_config.c agingtime_config/agingtime.c
|
||||
COMMON_SRCS = configserver.c ipconfig/ipconfig.c ipconfig/parsefile.c \
|
||||
authfree_config/authfree.c localportal_config/localportal.c userlock_config/userlock.c jumppage_config/jumppage.c agingtime_config/agingtime.c \
|
||||
user_group_config.c user_account_config.c usermanager-server/array_index.c usermanager-server/user_group.c usermanager-server/user_mod.c usermanager-server/user.c
|
||||
|
||||
# MRS Board Source Files
|
||||
PLAT_LINUX_SRCS = $(COMMON_SRCS)
|
||||
|
@ -42,8 +43,8 @@ PLAT_ARM64_LDFLAGS :=
|
|||
PLAT_LINUX_LDFLAGS :=
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := -lcjson ../thirdparty/arm64/libev-arm64.so ./libopenrpc-arm64.so ./libnetlinku-arm64.so ../../Product/build/debug/usermanager-arm64.so -lpthread -lm
|
||||
LINUX_LIBS := -lcjson ../thirdparty/x86_64/libev-linux.so ./libopenrpc-linux.so ./libnetlinku-linux.so ../../Product/build/debug/usermanager-linux.so -lpthread -lm
|
||||
ARM64_LIBS := -lcjson ../thirdparty/arm64/libev-arm64.so ./libopenrpc-arm64.so ./libnetlinku-arm64.so -lpthread -lm
|
||||
LINUX_LIBS := -lcjson ../thirdparty/x86_64/libev-linux.so ./libopenrpc-linux.so ./libnetlinku-linux.so -lpthread -lm
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/arm64/libev-arm64.so ./debug/libopenrpc-arm64.so ./debug/libnetlinku-arm64.so
|
||||
|
|
|
@ -91,8 +91,8 @@ return 0;
|
|||
|
||||
/*判断配置的老化时间是否有效,老化时间大于0 */
|
||||
/*input格式 '{\"type\":0, \"time\":24}' */
|
||||
ret_code agingtime_config_chk(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
ret_code agingtime_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
|
@ -101,7 +101,6 @@ ret_code agingtime_config_chk(uint source, uint config_type,
|
|||
char * ret_char = NULL;
|
||||
int * ret_int = NULL;
|
||||
|
||||
|
||||
/*JSON字符串到JSON格式 */
|
||||
cjson = cJSON_Parse(input);
|
||||
if(!cjson)
|
||||
|
@ -128,23 +127,9 @@ ret_code agingtime_config_chk(uint source, uint config_type,
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*创建json对象 */
|
||||
res = cJSON_CreateObject();
|
||||
if(!res)
|
||||
{
|
||||
ret = RET_ERR;
|
||||
cJSON_Delete(cjson);
|
||||
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
cJSON_AddNumberToObject(res, "time", time->valueint);
|
||||
|
||||
/*将json对象转换成json字符串 */
|
||||
ret_char = cJSON_PrintUnformatted(res);
|
||||
ret_int = (int*)ret_char;
|
||||
memcpy(output, ret_int, sizeof(ret_int)+1);
|
||||
|
||||
cJSON_Delete(res);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
@ -229,6 +214,8 @@ ret_code agingtime_config_proc(uint source, uint config_type,
|
|||
ret_int =(int*)ret_char;
|
||||
memcpy(output, ret_int, sizeof(ret_int)+1);
|
||||
|
||||
free(ret_char);
|
||||
cJSON_Delete(cjson);
|
||||
cJSON_Delete(res);
|
||||
|
||||
/*把免认证规则的配置信息存入全局变量 */
|
||||
|
@ -244,9 +231,8 @@ ret_code agingtime_config_get(uint source,
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret_code agingtime_config_get_all(uint source, uint64 config_id,
|
||||
pointer output, short *single_len,
|
||||
int *cnt)
|
||||
ret_code agingtime_config_get_all(uint source,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
return ret;
|
||||
|
|
|
@ -52,7 +52,6 @@ int isIpV4Addr(const char *ipAddr)
|
|||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/*下发配置到内核态 */
|
||||
int set_freeauthcfg_waitack(freeauth_configure_t *struct_freeauth)
|
||||
{
|
||||
|
@ -136,17 +135,39 @@ return 0;
|
|||
|
||||
|
||||
/*判断免认证规则源IP地址、目的IP地址是否有效,判断端口号是否有效 */
|
||||
ret_code freeauth_config_chk(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
/*input格式 "{\"type\":0, \"dport\":24, \"name\":\"armink\", \"sip\":1027824, \"dip\":103427824}";*/
|
||||
ret_code freeauth_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
freeauth_configure_t *struct_freeauth;
|
||||
struct_freeauth = (freeauth_configure_t *)input;
|
||||
cJSON *cjson, *res;
|
||||
|
||||
if(input_len < sizeof(freeauth_configure_t) )
|
||||
/*JSON字符串到JSON格式 */
|
||||
cjson = cJSON_Parse(input);
|
||||
if(!cjson)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*创建freeauth_configure_t结构体对象 */
|
||||
s2j_create_struct_obj(struct_freeauth, freeauth_configure_t);
|
||||
|
||||
/*反序列化数据到freeauth_configure_t结构体对象 */
|
||||
s2j_struct_get_basic_element(struct_freeauth, cjson, string, name);
|
||||
s2j_struct_get_basic_element(struct_freeauth, cjson, int, sip);
|
||||
s2j_struct_get_basic_element(struct_freeauth, cjson, int, dip);
|
||||
s2j_struct_get_basic_element(struct_freeauth, cjson, int, dport);
|
||||
printf("freeauth configure: name: %s sip: %d dip: %d dport: %d\n",
|
||||
struct_freeauth->name,struct_freeauth->sip, struct_freeauth->dip, struct_freeauth->dport);
|
||||
|
||||
if(*input_len < sizeof(freeauth_configure_t) )
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char str[32];
|
||||
|
@ -155,6 +176,8 @@ ret_code freeauth_config_chk(uint source, uint config_type,
|
|||
if( isIpV4Addr(sip_addr) < 0 )
|
||||
{
|
||||
ret = RET_IPINVALID;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char dtr[32];
|
||||
|
@ -163,14 +186,16 @@ ret_code freeauth_config_chk(uint source, uint config_type,
|
|||
if( isIpV4Addr(dip_addr) < 0 )
|
||||
{
|
||||
ret = RET_IPINVALID;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ( (struct_freeauth->dport < DPORT_MIN_NUM) && (struct_freeauth->dport > DPORT_MAX_NUM ))
|
||||
{
|
||||
ret = RET_IPINVALID; /*先用IPVAILD表示,后面加PORTVAILD */
|
||||
}
|
||||
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
@ -182,10 +207,27 @@ ret_code freeauth_config_proc(uint source, uint config_type,
|
|||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
int code;
|
||||
freeauth_configure_t *struct_freeauth;
|
||||
cJSON *cjson, *res;
|
||||
char * ret_char = NULL;
|
||||
int * ret_int = NULL;
|
||||
|
||||
struct_freeauth = (freeauth_configure_t *)input;
|
||||
/*JSON字符串到JSON格式 */
|
||||
cjson = cJSON_Parse(input);
|
||||
if(!cjson)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*创建freeauth_configure_t结构体对象 */
|
||||
s2j_create_struct_obj(struct_freeauth, freeauth_configure_t);
|
||||
|
||||
/*反序列化数据到freeauth_configure_t结构体对象 */
|
||||
s2j_struct_get_basic_element(struct_freeauth, cjson, string, name);
|
||||
s2j_struct_get_basic_element(struct_freeauth, cjson, int, sip);
|
||||
s2j_struct_get_basic_element(struct_freeauth, cjson, int, dip);
|
||||
s2j_struct_get_basic_element(struct_freeauth, cjson, int, dport);
|
||||
|
||||
char str[32];
|
||||
inet_ntop(AF_INET, (void *)&struct_freeauth->sip, str, 32);
|
||||
|
@ -197,20 +239,20 @@ ret_code freeauth_config_proc(uint source, uint config_type,
|
|||
struct_freeauth->name,sip_addr, dip_addr, struct_freeauth->dport);
|
||||
|
||||
/*用户态下发到内核态auth_hook */
|
||||
int ret1 = -1;
|
||||
int r = -1;
|
||||
printf("cfgchannel main begin:\r\n");
|
||||
|
||||
/*创建通道 */
|
||||
ret1 = commcfgnl_open();
|
||||
if(ret1 < 0)
|
||||
r = commcfgnl_open();
|
||||
if(r < 0)
|
||||
{
|
||||
printf(" pdlivnl_open fail, exit.\r\n");
|
||||
return RET_ERR;
|
||||
}
|
||||
|
||||
/*下发配置到内核态 */
|
||||
ret1 = set_freeauthcfg_waitack(struct_freeauth);
|
||||
if(ret1 < 0)
|
||||
r = set_freeauthcfg_waitack(struct_freeauth);
|
||||
if(r < 0)
|
||||
{
|
||||
printf("set_cfg_debug_waitack failed.\r\n");
|
||||
return RET_ERR;
|
||||
|
@ -218,9 +260,27 @@ ret_code freeauth_config_proc(uint source, uint config_type,
|
|||
|
||||
/*关闭netlink通道 */
|
||||
commcfgnl_close();
|
||||
|
||||
printf("cfgchannel main exit!\r\n");
|
||||
|
||||
/*创建json对象 */
|
||||
res = cJSON_CreateObject();
|
||||
if(!res)
|
||||
{
|
||||
ret = RET_ERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
cJSON_AddNumberToObject(res, "result", r);
|
||||
|
||||
/*将json对象转换成json字符串 */
|
||||
ret_char = cJSON_PrintUnformatted(res);
|
||||
ret_int = (int*)ret_char;
|
||||
memcpy(output, ret_int, sizeof(ret_int)+1);
|
||||
|
||||
free(ret_char);
|
||||
cJSON_Delete(res);
|
||||
|
||||
/*把免认证规则的配置信息存入全局变量 */
|
||||
localuser = struct_freeauth;
|
||||
return RET_OK;
|
||||
|
@ -229,3 +289,6 @@ ret_code freeauth_config_proc(uint source, uint config_type,
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,27 @@ void test_big_data(rpc_conn *conn, pointer input, int input_len, void* data) {
|
|||
rpc_return_null(conn);
|
||||
}
|
||||
|
||||
void cm_return(rpc_conn *conn, ret_code err_code, char* err_message)
|
||||
{
|
||||
cJSON *res;
|
||||
char *ret_char = NULL;
|
||||
|
||||
res = cJSON_CreateObject();
|
||||
if(res == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cJSON_AddStringToObject(res, "result", err_message);
|
||||
ret_char = cJSON_PrintUnformatted(res);
|
||||
|
||||
cJSON_Delete(res);
|
||||
|
||||
rpc_return_error(conn, err_code, ret_char);
|
||||
rpc_free(ret_char);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
config_service_t *cm_config_service_get(uint64 config_id)
|
||||
{
|
||||
|
@ -38,8 +59,7 @@ config_service_t *cm_config_service_get(uint64 config_id)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ret_code cm_config_rec_pre(char **input, short **input_len,
|
||||
char **output, int *output_len)
|
||||
ret_code cm_config_rec_pre(char **input, int *input_len, char **output, int *output_len)
|
||||
{
|
||||
/*if((access(CONFIG_RECOVERY_DONE, F_OK))!=-1)
|
||||
{
|
||||
|
@ -47,19 +67,17 @@ ret_code cm_config_rec_pre(char **input, short **input_len,
|
|||
} */
|
||||
|
||||
*input = rpc_new(char, CM_BUFF_SIZE);
|
||||
*input_len = rpc_new(short, CM_BUFF_SIZE);
|
||||
*output = rpc_new(char, CM_BUFF_SIZE);
|
||||
*input_len = CM_BUFF_SIZE;
|
||||
*output_len = CM_BUFF_SIZE;
|
||||
|
||||
if(*input == NULL
|
||||
|| *input_len == NULL
|
||||
|| *output == NULL)
|
||||
{
|
||||
return RET_NOMEM;
|
||||
}
|
||||
|
||||
memset(*input, 0, CM_BUFF_SIZE);
|
||||
memset(*input_len, 0, CM_BUFF_SIZE * sizeof(short));
|
||||
memset(*output, 0, CM_BUFF_SIZE);
|
||||
|
||||
rpc_log_info("==>config revocery start\n");
|
||||
|
@ -67,16 +85,14 @@ ret_code cm_config_rec_pre(char **input, short **input_len,
|
|||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_code cm_config_rec_done(char *input, short *input_len,char *output)
|
||||
ret_code cm_config_rec_done(char *input, char *output)
|
||||
{
|
||||
int fd;
|
||||
|
||||
memset(input, 0, CM_BUFF_SIZE);
|
||||
memset(input_len, 0, CM_BUFF_SIZE * sizeof(short));
|
||||
memset(output, 0, CM_BUFF_SIZE);
|
||||
|
||||
free(input);
|
||||
free(input_len);
|
||||
free(output);
|
||||
|
||||
fd = open(CONFIG_RECOVERY_DONE, O_CREAT, 0777);
|
||||
|
@ -96,17 +112,13 @@ ret_code cm_config_rec_done(char *input, short *input_len,char *output)
|
|||
|
||||
ret_code cm_config_get_allconfig(uint source,
|
||||
config_service_t *config_svr,
|
||||
char *input_array,
|
||||
short *len_array,
|
||||
int *cnt)
|
||||
char *input, int *intput_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
|
||||
memset(input_array, 0, CM_BUFF_SIZE);
|
||||
memset(len_array, 0, CM_BUFF_SIZE*sizeof(short));
|
||||
memset(input, 0, CM_BUFF_SIZE);
|
||||
|
||||
ret = config_svr->getall_callback(source, config_svr->config_id,
|
||||
input_array, len_array, cnt);
|
||||
ret = config_svr->getall_callback(source, input, intput_len);
|
||||
ASSERT_RET(ret);
|
||||
|
||||
return ret;
|
||||
|
@ -114,27 +126,66 @@ ret_code cm_config_get_allconfig(uint source,
|
|||
|
||||
ret_code cm_config_config_rec(uint source,
|
||||
config_service_t *config_svr,
|
||||
char *input_array, short *len_array,
|
||||
int cnt, char *output, int *output_len)
|
||||
char *input, int input_len,
|
||||
char *output, int *output_len)
|
||||
{
|
||||
uint config_type = CM_CONFIG_SET;
|
||||
int config_type = CM_CONFIG_SET;
|
||||
ret_code ret = RET_OK;
|
||||
int idx = 0;
|
||||
cJSON *json_obj;
|
||||
cJSON* pArrayItem;
|
||||
char *json_str;
|
||||
char *config_buff;
|
||||
int config_len;
|
||||
int iCount = 0;
|
||||
int i = 0;
|
||||
|
||||
if(config_svr->multi_inst == TRUE)
|
||||
json_obj = cJSON_Parse(input);
|
||||
if(!json_obj)
|
||||
{
|
||||
config_type = CM_CONFIG_ADD;
|
||||
return RET_INPUTERR;
|
||||
}
|
||||
|
||||
for(idx = 0; idx < cnt; idx++)
|
||||
config_buff = rpc_new(char, CM_BUFF_SIZE);
|
||||
if(!config_buff)
|
||||
{
|
||||
config_svr->proc_callback(source, config_type,
|
||||
input_array, len_array[idx],
|
||||
cJSON_Delete(json_obj);
|
||||
return RET_NOMEM;
|
||||
}
|
||||
|
||||
rpc_log_info("config recover: %s \n", cJSON_Print(json_obj));
|
||||
|
||||
iCount = cJSON_GetArraySize(json_obj); /*获取数组长度*/
|
||||
|
||||
for(i = 0; i < iCount; i++)
|
||||
{
|
||||
pArrayItem = cJSON_GetArrayItem(json_obj, i);
|
||||
if(pArrayItem)
|
||||
{
|
||||
json_str = cJSON_PrintUnformatted(pArrayItem);
|
||||
config_len = strlen(json_str) + 1;
|
||||
|
||||
memset(config_buff, 0, CM_BUFF_SIZE);
|
||||
strncpy(config_buff, json_str, CM_BUFF_SIZE);
|
||||
|
||||
free(json_str);
|
||||
|
||||
ret = config_svr->chk_callback(source, &config_type,
|
||||
config_buff, &config_len,
|
||||
output, output_len);
|
||||
|
||||
input_array = input_array + len_array[idx];
|
||||
if(ret != RET_OK)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
config_svr->proc_callback(source, config_type,
|
||||
config_buff, config_len,
|
||||
output, output_len);
|
||||
}
|
||||
}
|
||||
|
||||
rpc_free(config_buff);
|
||||
cJSON_Delete(json_obj);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
@ -144,17 +195,15 @@ void cm_config_recovery()
|
|||
{
|
||||
int len = sizeof(g_config_service) / sizeof(config_service_t);
|
||||
config_service_t *config_svr;
|
||||
char *input_array = NULL;
|
||||
short *len_array = NULL;
|
||||
int input_len = 0;
|
||||
int output_len = 0;
|
||||
char *input = NULL;
|
||||
char *output = NULL;
|
||||
int output_len;
|
||||
|
||||
int count = 0;
|
||||
ret_code ret = RET_OK;
|
||||
int config_idx;
|
||||
int recover_idx = 1,recover_phase;
|
||||
|
||||
ret = cm_config_rec_pre(&input_array, &len_array, &output, &output_len);
|
||||
ret = cm_config_rec_pre(&input, &input_len, &output, &output_len);
|
||||
ASSERT_RET_VOID(ret);
|
||||
|
||||
while(recover_idx <= 2)
|
||||
|
@ -181,19 +230,24 @@ void cm_config_recovery()
|
|||
continue;
|
||||
}
|
||||
|
||||
cm_config_get_allconfig(recover_phase,
|
||||
config_svr, input_array,
|
||||
len_array, &count);
|
||||
if(config_svr->chk_callback == NULL
|
||||
|| config_svr->proc_callback == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
cm_config_get_allconfig(recover_phase, config_svr,
|
||||
input, &input_len);
|
||||
|
||||
cm_config_config_rec(recover_phase, config_svr,
|
||||
input_array, len_array, count,
|
||||
input, input_len,
|
||||
output, &output_len);
|
||||
}
|
||||
|
||||
recover_idx++;
|
||||
}
|
||||
|
||||
cm_config_rec_done(input_array, len_array, output);
|
||||
cm_config_rec_done(input, output);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -204,22 +258,21 @@ void cm_config_process(rpc_conn *conn, pointer input, int input_len, void* data)
|
|||
config_service_t *config_svr;
|
||||
config_msg_t *config_msg;
|
||||
char *cm_get_buff = NULL;
|
||||
char *cm_set_buff = NULL;
|
||||
ret_code ret = RET_OK;
|
||||
int config_len = 0;
|
||||
short* single_len = NULL;
|
||||
int buff_len = CM_BUFF_SIZE;
|
||||
int index = 0, cnt = 0;
|
||||
|
||||
if(conn == NULL || input == NULL)
|
||||
{
|
||||
rpc_return_error(conn, RET_NULLP, "NULL pointer");
|
||||
cm_return(conn, RET_NULLP, "NULL pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
/*parse message*/
|
||||
if(input_len < sizeof(config_msg_t))
|
||||
{
|
||||
rpc_return_error(conn, RET_NOMEM, "not enough memery");
|
||||
cm_return(conn, RET_NOMEM, "not enough memery");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -233,38 +286,42 @@ void cm_config_process(rpc_conn *conn, pointer input, int input_len, void* data)
|
|||
config_svr = cm_config_service_get(config_msg->config_id);
|
||||
if(config_svr == NULL)
|
||||
{
|
||||
rpc_return_error(conn, RET_NULLP, "NULL pointer");
|
||||
cm_return(conn, RET_NULLP, "NULL pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
/*source check*/
|
||||
if(!(config_svr->config_src & config_msg->source))
|
||||
{
|
||||
rpc_return_error(conn, RET_CHKERR, "source check error!\r\n");
|
||||
cm_return(conn, RET_CHKERR, "source check error!\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
cm_set_buff = rpc_new(char, buff_len);
|
||||
cm_get_buff = rpc_new(char, buff_len);
|
||||
if(cm_get_buff == NULL)
|
||||
if(cm_get_buff == NULL || cm_set_buff == NULL)
|
||||
{
|
||||
rpc_return_error(conn, RET_NOMEM, "not enough memery");
|
||||
cm_return(conn, RET_NOMEM, "not enough memery");
|
||||
return;
|
||||
}
|
||||
|
||||
memset(cm_set_buff, 0, buff_len);
|
||||
memset(cm_get_buff, 0, buff_len);
|
||||
|
||||
memcpy(cm_set_buff, config_msg->config_buff, config_len);
|
||||
|
||||
/*config check*/
|
||||
if(config_svr->chk_callback)
|
||||
{
|
||||
ret = config_svr->chk_callback(config_msg->source,
|
||||
config_msg->config_type,
|
||||
config_msg->config_buff,
|
||||
config_len,
|
||||
&(config_msg->config_type),
|
||||
cm_set_buff,
|
||||
&config_len,
|
||||
cm_get_buff,
|
||||
&buff_len);
|
||||
if(ret != RET_OK)
|
||||
{
|
||||
rpc_return_error(conn, ret, cm_get_buff);
|
||||
cm_return(conn, ret, cm_get_buff);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
@ -276,7 +333,7 @@ void cm_config_process(rpc_conn *conn, pointer input, int input_len, void* data)
|
|||
if(config_svr->get_callback)
|
||||
{
|
||||
ret = config_svr->get_callback(config_msg->source,
|
||||
config_msg->config_buff,
|
||||
cm_set_buff,
|
||||
config_len,
|
||||
cm_get_buff,
|
||||
&buff_len);
|
||||
|
@ -286,24 +343,10 @@ void cm_config_process(rpc_conn *conn, pointer input, int input_len, void* data)
|
|||
case CM_CONFIG_GET_ALL:
|
||||
if(config_svr->getall_callback)
|
||||
{
|
||||
single_len = rpc_new(short, CM_BUFF_SIZE);
|
||||
if(single_len == NULL)
|
||||
{
|
||||
rpc_return_error(conn, RET_NOMEM, "not enough memery");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ret = config_svr->getall_callback(config_msg->source,
|
||||
config_svr->config_id,
|
||||
cm_get_buff,
|
||||
single_len,
|
||||
&cnt);
|
||||
|
||||
buff_len = 0;
|
||||
for(index = 0 ; index < cnt; index++)
|
||||
{
|
||||
buff_len = buff_len + single_len[index];
|
||||
}
|
||||
&buff_len);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -312,7 +355,7 @@ void cm_config_process(rpc_conn *conn, pointer input, int input_len, void* data)
|
|||
{
|
||||
ret = config_svr->proc_callback(config_msg->source,
|
||||
config_msg->config_type,
|
||||
config_msg->config_buff,
|
||||
cm_set_buff,
|
||||
config_len,
|
||||
cm_get_buff,
|
||||
&buff_len);
|
||||
|
@ -327,20 +370,16 @@ void cm_config_process(rpc_conn *conn, pointer input, int input_len, void* data)
|
|||
|
||||
if(ret != RET_OK)
|
||||
{
|
||||
rpc_return_error(conn, ret, cm_get_buff);
|
||||
cm_return(conn, ret, cm_get_buff);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
rpc_return(conn, cm_get_buff, buff_len);
|
||||
|
||||
exit:
|
||||
rpc_free(cm_set_buff);
|
||||
rpc_free(cm_get_buff);
|
||||
|
||||
if(single_len != NULL)
|
||||
{
|
||||
rpc_free(single_len);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
|
||||
/*判断配置的老化时间是否有效,老化时间大于0 */
|
||||
ret_code agingtime_config_chk(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
ret_code agingtime_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
/*系统管理模块将配置的用户老化时间通过netlink下发到内核态 */
|
||||
|
@ -28,8 +28,7 @@ ret_code agingtime_config_get(uint source,
|
|||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
ret_code agingtime_config_get_all(uint source, uint64 config_id,
|
||||
pointer output, short *single_len,
|
||||
int *cnt);
|
||||
ret_code agingtime_config_get_all(uint source,
|
||||
pointer output, int *output_len);
|
||||
|
||||
#endif
|
|
@ -37,11 +37,13 @@ int isIpV4Addr(const char *ipAddr);
|
|||
int set_freeauthcfg_waitack(freeauth_configure_t *struct_freeauth);
|
||||
|
||||
/*判断免认证规则源IP地址、目的IP地址是否有效,判断端口号是否有效 */
|
||||
ret_code freeauth_config_chk(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
/*input格式 "{\"type\":0, \"dport\":24, \"name\":\"armink\", \"sip\":1027824, \"dip\":103427824}";*/
|
||||
ret_code freeauth_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
|
||||
|
||||
/*免认证规则有效,将免认证规则通过netlink下发到内核态 */
|
||||
ret_code freeauth_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
|
|
Binary file not shown.
|
@ -1,10 +1,12 @@
|
|||
#ifndef CONFIGM_H_
|
||||
#define CONFIGM_H_
|
||||
|
||||
#include "s2j/s2j.h"
|
||||
#include "../../../../common/rpc/rpc_common.h"
|
||||
#include "ipconfig.h"
|
||||
#include "../../../../../Common/commuapinl.h"
|
||||
#include "user_group_config.h"
|
||||
#include "../user_manager_config/user_group_config.h"
|
||||
#include "../user_manager_config/user_account_config.h"
|
||||
#include "authfree.h"
|
||||
#include "localportal.h"
|
||||
#include "jumppage.h"
|
||||
|
@ -118,12 +120,21 @@
|
|||
agingtime_config_proc, \
|
||||
agingtime_config_get, \
|
||||
agingtime_config_get_all \
|
||||
}, \
|
||||
{\
|
||||
USER_MANAGER_CONFIG_USER, \
|
||||
CONFIG_FROM_WEB, \
|
||||
FALSE, \
|
||||
FALSE, \
|
||||
user_config_chk, \
|
||||
user_config_proc, \
|
||||
user_config_get, \
|
||||
user_config_get_all \
|
||||
}\
|
||||
\
|
||||
}
|
||||
|
||||
typedef ret_code (*cm_config_chk)(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
typedef ret_code (*cm_config_chk)(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
typedef ret_code (*cm_config_proc)(uint source, uint config_type,
|
||||
|
@ -134,9 +145,8 @@ typedef ret_code (*cm_config_get)(uint source,
|
|||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
typedef ret_code (*cm_config_get_all)(uint source, uint64 config_id,
|
||||
pointer output, short *single_len,
|
||||
int *cnt);
|
||||
typedef ret_code (*cm_config_get_all)(uint source,
|
||||
pointer output, int *output_len);
|
||||
|
||||
/* 配置注册 */
|
||||
struct _config_service {
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include <net/if.h>
|
||||
|
||||
#define MAX_IF_NUM 32
|
||||
#define DOT_IP_STR 32
|
||||
|
||||
#define INTERFACE_NAMSIZ 20
|
||||
/* Max bit/byte length of IPv4 address. */
|
||||
#define IPV4_MAX_BYTELEN 4
|
||||
|
@ -66,13 +68,22 @@ struct _ip_config_str {
|
|||
struct in_addr prefix __attribute__((aligned(8)));
|
||||
};
|
||||
|
||||
struct _ip_config_string {
|
||||
int config_type;
|
||||
char ifname[INTERFACE_NAMSIZ];
|
||||
int family;
|
||||
char ipaddr[DOT_IP_STR];
|
||||
int prefixlen;
|
||||
};
|
||||
|
||||
typedef struct _ip_config_str ip_config_t;
|
||||
typedef struct _ip_config_string ip_config_string_t;
|
||||
|
||||
/* 业务模块函数声明 */
|
||||
|
||||
/* ip config */
|
||||
ret_code ip_config_chk(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
ret_code ip_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
ret_code ip_config_proc(uint source, uint config_type,
|
||||
|
@ -83,9 +94,8 @@ ret_code ip_config_get(uint source,
|
|||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
ret_code ip_config_get_all(uint source, uint64 config_id,
|
||||
pointer output, short *single_len,
|
||||
int *output_len);
|
||||
ret_code ip_config_get_all(uint source,
|
||||
pointer output, int *output_len);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ int _valid_ipv4_port(const char *str, int port);
|
|||
|
||||
|
||||
/*判断配置本地Portal服务器的IP地址是否有效,端口号是否被占用 */
|
||||
ret_code portalserver_config_chk(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
ret_code portalserver_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ int Init(userlock_configure_t *userlock);
|
|||
|
||||
|
||||
/*判断锁定配置信息是否有效,时间范围大于0,失败的次数大于0,锁定时间大于0 */
|
||||
ret_code userlock_config_chk(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
ret_code userlock_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
|
||||
|
|
|
@ -94,6 +94,203 @@ ret_code if_ioctl(unsigned long request, caddr_t ifreq, int *ret)
|
|||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
ret_code ip_config_json_parse(pointer input, uint *conf_type, ip_config_t *config_buff)
|
||||
{
|
||||
//ip_config_string_t *ip_config;
|
||||
cJSON *json_obj;
|
||||
|
||||
json_obj = cJSON_Parse(input);
|
||||
if(!json_obj)
|
||||
{
|
||||
return RET_INPUTERR;
|
||||
}
|
||||
|
||||
rpc_log_info("json input:\n %s \n", cJSON_Print(json_obj));
|
||||
|
||||
s2j_create_struct_obj(ip_config, ip_config_string_t);
|
||||
|
||||
if(ip_config == NULL)
|
||||
{
|
||||
cJSON_Delete(json_obj);
|
||||
return RET_NOMEM;
|
||||
}
|
||||
|
||||
s2j_struct_get_basic_element(ip_config, json_obj, int, config_type);
|
||||
s2j_struct_get_basic_element(ip_config, json_obj, string, ifname);
|
||||
s2j_struct_get_basic_element(ip_config, json_obj, int, family);
|
||||
s2j_struct_get_basic_element(ip_config, json_obj, string, ipaddr);
|
||||
s2j_struct_get_basic_element(ip_config, json_obj, int, prefixlen);
|
||||
|
||||
strncpy(config_buff->ifname, ip_config->ifname, INTERFACE_NAMSIZ);
|
||||
|
||||
config_buff->family = (uchar)ip_config->family;
|
||||
config_buff->prefixlen = (uchar)ip_config->prefixlen;
|
||||
config_buff->prefix.s_addr = inet_addr(ip_config->ipaddr);
|
||||
|
||||
*conf_type = ip_config->config_type;
|
||||
|
||||
s2j_delete_struct_obj(ip_config);
|
||||
cJSON_Delete(json_obj);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_code ip_config_json_parse_array(pointer input, uint *conf_type,
|
||||
ip_config_t *config_buff, int *cnt)
|
||||
{
|
||||
//ip_config_string_t *ip_config;
|
||||
cJSON *json_obj;
|
||||
cJSON* pArrayItem;
|
||||
int iCount = 0, i = 0;
|
||||
|
||||
json_obj = cJSON_Parse(input);
|
||||
if(!json_obj)
|
||||
{
|
||||
return RET_INPUTERR;
|
||||
}
|
||||
|
||||
rpc_log_info("json input %s \n", cJSON_Print(json_obj));
|
||||
|
||||
iCount = cJSON_GetArraySize(json_obj); /*»ñÈ¡Êý×鳤¶È*/
|
||||
|
||||
config_buff = rpc_new(ip_config_t, iCount);
|
||||
conf_type = rpc_new(uint, iCount);
|
||||
if(!config_buff || !conf_type)
|
||||
{
|
||||
return RET_NOMEM;
|
||||
}
|
||||
|
||||
s2j_create_struct_obj(ip_config, ip_config_string_t);
|
||||
if(ip_config == NULL)
|
||||
{
|
||||
cJSON_Delete(json_obj);
|
||||
rpc_free(config_buff);
|
||||
return RET_NOMEM;
|
||||
}
|
||||
|
||||
*cnt = 0;
|
||||
for(i = 0; i < iCount; i++)
|
||||
{
|
||||
pArrayItem = cJSON_GetArrayItem(json_obj, i);
|
||||
if(pArrayItem)
|
||||
{
|
||||
memset(ip_config, 0, sizeof(ip_config_string_t));
|
||||
|
||||
s2j_struct_get_basic_element(ip_config, json_obj, int, config_type);
|
||||
s2j_struct_get_basic_element(ip_config, json_obj, string, ifname);
|
||||
s2j_struct_get_basic_element(ip_config, json_obj, int, family);
|
||||
s2j_struct_get_basic_element(ip_config, json_obj, string, ipaddr);
|
||||
s2j_struct_get_basic_element(ip_config, json_obj, int, prefixlen);
|
||||
|
||||
strncpy(config_buff[*cnt].ifname, ip_config->ifname, INTERFACE_NAMSIZ);
|
||||
config_buff[*cnt].family = (uchar)ip_config->family;
|
||||
config_buff[*cnt].prefixlen = (uchar)ip_config->prefixlen;
|
||||
config_buff[*cnt].prefix.s_addr = inet_addr(ip_config->ipaddr);
|
||||
conf_type[*cnt] = ip_config->config_type;
|
||||
|
||||
(*cnt)++;
|
||||
}
|
||||
}
|
||||
|
||||
s2j_delete_struct_obj(ip_config);
|
||||
cJSON_Delete(json_obj);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
ret_code ip_config_format_json(int config_type, ip_config_t *config_buff,
|
||||
pointer output, int *outlen)
|
||||
{
|
||||
ip_config_string_t tem_buff = {0};
|
||||
ip_config_string_t *ip_config = &tem_buff;
|
||||
//cJSON *json_obj = NULL;
|
||||
char *json_ip;
|
||||
|
||||
ip_config->config_type = config_type;
|
||||
ip_config->family = AF_INET;
|
||||
ip_config->prefixlen = config_buff->prefixlen;
|
||||
|
||||
strncpy(ip_config->ifname, config_buff->ifname, INTERFACE_NAMSIZ);
|
||||
strncpy(ip_config->ipaddr, inet_ntoa(config_buff->prefix), DOT_IP_STR);
|
||||
|
||||
/* create Student JSON object */
|
||||
s2j_create_json_obj(json_obj);
|
||||
if(json_obj == NULL)
|
||||
{
|
||||
return RET_NOMEM;
|
||||
}
|
||||
|
||||
s2j_json_set_basic_element(json_obj, ip_config, int, config_type);
|
||||
s2j_json_set_basic_element(json_obj, ip_config, string, ifname);
|
||||
s2j_json_set_basic_element(json_obj, ip_config, int, family);
|
||||
s2j_json_set_basic_element(json_obj, ip_config, string, ipaddr);
|
||||
s2j_json_set_basic_element(json_obj, ip_config, int, prefixlen);
|
||||
|
||||
json_ip = cJSON_PrintUnformatted(json_obj);
|
||||
*outlen = strlen(json_ip) + 1;
|
||||
memcpy(output, json_ip, *outlen);
|
||||
|
||||
free(json_ip);
|
||||
cJSON_Delete(json_obj);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_code ip_config_format_json_array(int config_type, ip_config_t *config_buff,
|
||||
int count, pointer output, int *outlen)
|
||||
{
|
||||
ip_config_string_t tem_buff = {0};
|
||||
ip_config_string_t *ip_config = &tem_buff;
|
||||
cJSON *json_array = NULL;
|
||||
//cJSON *json_obj = NULL;
|
||||
char *json_ip;
|
||||
int i;
|
||||
|
||||
json_array = cJSON_CreateArray();
|
||||
if(json_array == NULL)
|
||||
{
|
||||
return RET_NOMEM;
|
||||
}
|
||||
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
memset(ip_config, 0, sizeof(ip_config_string_t));
|
||||
|
||||
ip_config->config_type = config_type;
|
||||
ip_config->family = AF_INET;
|
||||
ip_config->prefixlen = config_buff[i].prefixlen;
|
||||
strncpy(ip_config->ifname, config_buff[i].ifname, INTERFACE_NAMSIZ);
|
||||
strncpy(ip_config->ipaddr, inet_ntoa(config_buff[i].prefix), DOT_IP_STR);
|
||||
|
||||
/* create Student JSON object */
|
||||
s2j_create_json_obj(json_obj);
|
||||
if(json_obj == NULL)
|
||||
{
|
||||
return RET_NOMEM;
|
||||
}
|
||||
|
||||
cJSON_AddItemToArray(json_array, json_obj);
|
||||
|
||||
s2j_json_set_basic_element(json_obj, ip_config, int, config_type);
|
||||
s2j_json_set_basic_element(json_obj, ip_config, string, ifname);
|
||||
s2j_json_set_basic_element(json_obj, ip_config, int, family);
|
||||
s2j_json_set_basic_element(json_obj, ip_config, string, ipaddr);
|
||||
s2j_json_set_basic_element(json_obj, ip_config, int, prefixlen);
|
||||
}
|
||||
|
||||
json_ip = cJSON_PrintUnformatted(json_array);
|
||||
*outlen = strlen(json_ip) + 1;
|
||||
memcpy(output, json_ip, *outlen);
|
||||
|
||||
free(json_ip);
|
||||
cJSON_Delete(json_array);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
ret_code if_set_prefix(ip_config_t *ip_conf, int *code)
|
||||
{
|
||||
ret_code ret;
|
||||
|
@ -123,11 +320,12 @@ ret_code if_set_prefix(ip_config_t *ip_conf, int *code)
|
|||
return 0;
|
||||
}
|
||||
|
||||
ret_code if_get_prefix_all(ip_config_t *ip_conf, short *single_len, int *cnt, int *code)
|
||||
ret_code if_get_prefix_all(pointer output, int *output_len, int *code)
|
||||
{
|
||||
struct ifreq ifreq[MAX_IF_NUM];
|
||||
struct sockaddr_in *addr;
|
||||
struct ifreq netmask;
|
||||
ip_config_t *ip_conf;
|
||||
struct ifconf ifc;
|
||||
int if_count = 0;
|
||||
ret_code ret;
|
||||
|
@ -147,13 +345,20 @@ ret_code if_get_prefix_all(ip_config_t *ip_conf, short *single_len, int *cnt, in
|
|||
|
||||
rpc_log_info("if num is %d\n", if_count);
|
||||
|
||||
if(if_count * sizeof(ip_config_t) > CM_BUFF_SIZE)
|
||||
if((if_count * sizeof(ip_config_t) > CM_BUFF_SIZE)
|
||||
|| (if_count == 0))
|
||||
{
|
||||
ret = RET_NOMEM;
|
||||
ASSERT_RET(ret);
|
||||
}
|
||||
|
||||
*cnt = 0;
|
||||
ip_conf = rpc_new(ip_config_t, MAX_IF_NUM);
|
||||
if(ip_conf == NULL)
|
||||
{
|
||||
return RET_NOMEM;
|
||||
}
|
||||
memset(ip_conf, 0, MAX_IF_NUM * sizeof(ip_config_t));
|
||||
|
||||
for(i = 0; i < if_count; i++)
|
||||
{
|
||||
rpc_log_info("get interface %s info\n", ifreq[i].ifr_name);
|
||||
|
@ -169,12 +374,11 @@ ret_code if_get_prefix_all(ip_config_t *ip_conf, short *single_len, int *cnt, in
|
|||
|
||||
addr = ( struct sockaddr_in * )&(netmask.ifr_netmask );
|
||||
ip_conf[i].prefixlen = ip_masklen(addr->sin_addr);
|
||||
|
||||
single_len[i] = sizeof(ip_config_t);
|
||||
|
||||
(*cnt)++;
|
||||
}
|
||||
|
||||
ip_config_format_json_array(CM_CONFIG_GET, ip_conf, if_count, output, output_len);
|
||||
|
||||
rpc_free(ip_conf);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
@ -282,37 +486,56 @@ ret_code ip_config_getall_chk(uint source,uint config_type,
|
|||
}
|
||||
|
||||
|
||||
ret_code ip_config_chk(uint source,uint config_type,
|
||||
pointer input, int input_len,
|
||||
ret_code ip_config_chk(uint source,uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len)
|
||||
|
||||
{
|
||||
int config_len = sizeof(ip_config_t);
|
||||
uint conf_type = CM_CONFIG_GET;
|
||||
ip_config_t ip_config = {0};
|
||||
ret_code ret = RET_OK;
|
||||
int code = 0;
|
||||
|
||||
switch (config_type)
|
||||
ip_config_json_parse(input, &conf_type, &ip_config);
|
||||
|
||||
switch (conf_type)
|
||||
{
|
||||
case CM_CONFIG_SET:
|
||||
case CM_CONFIG_DEL:
|
||||
ret = ip_config_set_chk(source, config_type,
|
||||
input, input_len,
|
||||
ret = ip_config_set_chk(source, conf_type,
|
||||
&ip_config, config_len,
|
||||
output, output_len);
|
||||
break;
|
||||
case CM_CONFIG_GET:
|
||||
ret = ip_config_get_chk(source, config_type,
|
||||
input, input_len,
|
||||
ret = ip_config_get_chk(source, conf_type,
|
||||
&ip_config, config_len,
|
||||
output, output_len);
|
||||
break;
|
||||
case CM_CONFIG_GET_ALL:
|
||||
ret = ip_config_getall_chk(source, config_type,
|
||||
input, input_len,
|
||||
ret = ip_config_getall_chk(source, conf_type,
|
||||
&ip_config, config_len,
|
||||
output, output_len);
|
||||
break;
|
||||
default:
|
||||
ret = RET_NOTSUPPORT;
|
||||
}
|
||||
|
||||
/* å°†ä¼ å…¥çš„jsonæ•°æ<C2B0>®è½¬æ<C2AC>¢æˆ<C3A6>结构体,便于å<C5BD>Žç»å¤„ç<E2809E>† */
|
||||
if(config_len <= CM_BUFF_SIZE)
|
||||
{
|
||||
memset(input, 0, *input_len);
|
||||
memcpy(input, &ip_config, config_len);
|
||||
*config_type = conf_type;
|
||||
*input_len = config_len;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = RET_NOMEM;
|
||||
}
|
||||
|
||||
RET_ERR_FORMART(ret, code, output, *output_len);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -320,20 +543,22 @@ ret_code ip_config_proc(uint source, uint config_type,
|
|||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ip_config_t *ip_conf;
|
||||
uint conf_type = CM_CONFIG_SET;
|
||||
ip_config_t conf_buff = {0};
|
||||
ip_config_t *ip_conf = &conf_buff;
|
||||
ret_code ret = RET_OK;
|
||||
int code;
|
||||
|
||||
ip_conf = (ip_config_t *)input;
|
||||
|
||||
if(config_type == CM_CONFIG_DEL)
|
||||
if(conf_type == CM_CONFIG_DEL)
|
||||
{
|
||||
ip_conf->prefix.s_addr = 0;
|
||||
ip_conf->prefixlen = IPV4_DEFAULT_PREFIXLEN;
|
||||
}
|
||||
|
||||
rpc_log_info("config type is %d, if %s ip %s prefixlen %d\n",
|
||||
config_type, ip_conf->ifname,
|
||||
conf_type, ip_conf->ifname,
|
||||
inet_ntoa(ip_conf->prefix),
|
||||
ip_conf->prefixlen);
|
||||
|
||||
|
@ -342,7 +567,7 @@ ret_code ip_config_proc(uint source, uint config_type,
|
|||
RET_ERR_FORMART(ret, code, output, *output_len);
|
||||
ASSERT_RET(ret);
|
||||
|
||||
ip_save_file(ip_conf, config_type);
|
||||
ip_save_file(ip_conf, conf_type);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
@ -353,7 +578,7 @@ ret_code ip_config_get(uint source,
|
|||
{
|
||||
ip_config_t *ip_conf;
|
||||
ret_code ret = RET_OK;
|
||||
int code;
|
||||
int code, conf_type;
|
||||
|
||||
ip_conf = (ip_config_t *)input;
|
||||
|
||||
|
@ -362,25 +587,22 @@ ret_code ip_config_get(uint source,
|
|||
RET_ERR_FORMART(ret, code, output, *output_len);
|
||||
ASSERT_RET(ret);
|
||||
|
||||
memcpy(output, ip_conf, sizeof(ip_config_t));
|
||||
*output_len = sizeof(ip_config_t);
|
||||
ip_config_format_json(CM_CONFIG_GET, ip_conf, output, output_len);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret_code ip_config_get_all(uint source, uint64 config_id,
|
||||
pointer output, short *single_len,
|
||||
int *count)
|
||||
ret_code ip_config_get_all(uint source, pointer output, int *output_len)
|
||||
{
|
||||
int output_len = 0;
|
||||
ret_code ret = RET_OK;
|
||||
int code = 0;
|
||||
|
||||
rpc_log_info("ip_config_get_all\r\n");
|
||||
*output_len = 0;
|
||||
ret = if_get_prefix_all(output, output_len, &code);
|
||||
|
||||
ret = if_get_prefix_all((ip_config_t *)output, single_len, count, &code);
|
||||
rpc_log_info("ip_config_get_all: %s\n", output);
|
||||
|
||||
RET_ERR_FORMART(ret, code, output, output_len);
|
||||
RET_ERR_FORMART(ret, code, output, *output_len);
|
||||
ASSERT_RET(ret);
|
||||
|
||||
return RET_OK;
|
||||
|
|
|
@ -42,8 +42,8 @@ ret_code jumppage_config_proc(uint source, uint config_type,
|
|||
|
||||
rpc_log_info("jumppage configure: url %s\n", url->valuestring);
|
||||
|
||||
char i = url->valuestring;
|
||||
jump_url = &i;
|
||||
jump_url = url->valuestring;
|
||||
// jump_url = &i;
|
||||
cJSON_Delete(cjson);
|
||||
|
||||
/*将配置信息发送到web server 发送结果int表示,0表示发送成功,-1表示发送失败*/
|
||||
|
@ -65,6 +65,9 @@ ret_code jumppage_config_proc(uint source, uint config_type,
|
|||
ret_char = cJSON_PrintUnformatted(res);
|
||||
memcpy(output, ret_char, sizeof(ret_char)+1);
|
||||
|
||||
//cJSON_Delete(ret_char);
|
||||
free(ret_char);
|
||||
ret_char = NULL;
|
||||
cJSON_Delete(res);
|
||||
return RET_OK;
|
||||
|
||||
|
|
|
@ -31,9 +31,9 @@ int _valid_ipv4_port(const char *str, int port)
|
|||
int i;
|
||||
volatile int local_errno;
|
||||
struct sockaddr_in addr;
|
||||
fd = socket(AF_INET,SOCK_STREAM,0); //初始化socket
|
||||
fd = socket(AF_INET,SOCK_STREAM,0); /*初始化*/
|
||||
|
||||
if(fd ==-1) //检查是否正常初始化socket
|
||||
if(fd ==-1) /*检查是否正常初始化socket */
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -47,8 +47,8 @@ int _valid_ipv4_port(const char *str, int port)
|
|||
{
|
||||
fprintf(stderr, "\"%s\" is a vaild IPv4 address\n", str);
|
||||
|
||||
addr.sin_family = AF_INET; //地址结构的协议簇
|
||||
addr.sin_port=htons(port); //地址结构的端口地址,网络字节序
|
||||
addr.sin_family = AF_INET; /*地址结构的协议簇 */
|
||||
addr.sin_port=htons(port); /*地址结构的端口地址,网络字节序 */
|
||||
printf("the value of str:%s\n", str);
|
||||
i = (bind(fd, (struct sockaddr*)&addr, sizeof(struct sockaddr)));
|
||||
printf("the value of i:%d\n", i);
|
||||
|
@ -79,15 +79,33 @@ int _valid_ipv4_port(const char *str, int port)
|
|||
|
||||
|
||||
/*判断配置本地Portal服务器的IP地址是否有效,端口号是否被占用 */
|
||||
ret_code portalserver_config_chk(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
/*input格式 "{\"type\":0, \"ip\":1027824, \"port\":1010}"*/
|
||||
ret_code portalserver_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
localportal_configure_t *struct_portal;
|
||||
struct_portal = (localportal_configure_t *)input;
|
||||
cJSON *cjson, *res;
|
||||
|
||||
if(input_len < sizeof(localportal_configure_t) )
|
||||
/*JSON字符串到JSON格式 */
|
||||
cjson = cJSON_Parse(input);
|
||||
if(!cjson)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*创建freeauth_configure_t结构体对象 */
|
||||
s2j_create_struct_obj(struct_portal, localportal_configure_t);
|
||||
|
||||
/*反序列化数据到freeauth_configure_t结构体对象 */
|
||||
s2j_struct_get_basic_element(struct_portal, cjson, int, ip);
|
||||
s2j_struct_get_basic_element(struct_portal, cjson, int, port);
|
||||
rpc_log_info("localport configure: ip: %d port: %d\n",
|
||||
struct_portal->ip,struct_portal->port);
|
||||
|
||||
if(*input_len < sizeof(localportal_configure_t) )
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
}
|
||||
|
@ -112,9 +130,25 @@ ret_code portalserver_config_proc(uint source, uint config_type,
|
|||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
int code;
|
||||
localportal_configure_t *struct_portal;
|
||||
struct_portal = (localportal_configure_t *)input;
|
||||
cJSON *cjson, *res;
|
||||
char * ret_char = NULL;
|
||||
int * ret_int = NULL;
|
||||
|
||||
/*JSON字符串到JSON格式 */
|
||||
cjson = cJSON_Parse(input);
|
||||
if(!cjson)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*创建freeauth_configure_t结构体对象 */
|
||||
s2j_create_struct_obj(struct_portal, localportal_configure_t);
|
||||
|
||||
/*反序列化数据到freeauth_configure_t结构体对象 */
|
||||
s2j_struct_get_basic_element(struct_portal, cjson, int, ip);
|
||||
s2j_struct_get_basic_element(struct_portal, cjson, int, port);
|
||||
|
||||
char str[32];
|
||||
inet_ntop(AF_INET, (void *)&struct_portal->ip, str, 32);
|
||||
|
@ -122,13 +156,31 @@ ret_code portalserver_config_proc(uint source, uint config_type,
|
|||
rpc_log_info("portalserver configure: ip: %s port: %d\n",
|
||||
ip_addr, struct_portal->port);
|
||||
|
||||
/*将配置信息发送到web server */
|
||||
/*将配置信息发送到web server,发送结果int类型表示,0表示发送成功,-1表示发送失败 */
|
||||
int r;
|
||||
|
||||
/*创建json对象 */
|
||||
res = cJSON_CreateObject();
|
||||
if(!res)
|
||||
{
|
||||
ret = RET_ERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
cJSON_AddNumberToObject(res, "result", r);
|
||||
|
||||
/*将json对象转换成json字符串 */
|
||||
ret_char = cJSON_PrintUnformatted(res);
|
||||
ret_int = (int*)ret_char;
|
||||
memcpy(output, ret_int, sizeof(ret_int)+1);
|
||||
|
||||
free(ret_char);
|
||||
cJSON_Delete(res);
|
||||
|
||||
/*把本地Portal server的配置信息存入全局变量 */
|
||||
localportal = struct_portal;
|
||||
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,332 @@
|
|||
#include <cjson/cJSON.h>
|
||||
#include "configm.h"
|
||||
#include "user_account_config.h"
|
||||
#include "rpc.h"
|
||||
#include "parsefile.h"
|
||||
#include "usermanager-server/include/common_user.h"
|
||||
#include "usermanager-server/include/user.h"
|
||||
#include "usermanager-server/include/user_mod.h"
|
||||
#include "s2j/s2j.h"
|
||||
|
||||
|
||||
|
||||
/* user account config */
|
||||
ret_code user_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* 新增用户-处理
|
||||
* iuput格式:{"type": 0,"data": {"uname": "xxx","gname": "xxx"}}
|
||||
* output格式:{"result": 0,"user_id": 2}
|
||||
* 0:成功
|
||||
* 1/2/3/4/5:失败,1:用户组名不存在,2:用户名长度不符合,3:用户名中包含特殊字符,4:用户名重名,5:用户数已达到最大
|
||||
* 备注:当新增失败时,用户id为0
|
||||
*/
|
||||
static ret_code user_config_add_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
cJSON *root, *data, *uname, *gname, *res;
|
||||
USERADD *add_user_ret;
|
||||
char *ret_char = NULL;
|
||||
|
||||
/* 解析json串 */
|
||||
root = cJSON_Parse(input);
|
||||
data = cJSON_GetObjectItem(root, "data");
|
||||
if(!data)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
cJSON_Delete(root);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uname = cJSON_GetObjectItem(data, "uname");
|
||||
if(!uname)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
cJSON_Delete(root);
|
||||
return ret;
|
||||
}
|
||||
|
||||
gname = cJSON_GetObjectItem(data, "gname");
|
||||
if(!gname)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
cJSON_Delete(root);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 执行操作 */
|
||||
add_user_ret = (USERADD*)malloc(sizeof(USERADD));
|
||||
if (NULL == add_user_ret)
|
||||
{
|
||||
// 记录日志
|
||||
ret = RET_ERR;
|
||||
ASSERT_RET(ret);
|
||||
cJSON_Delete(root);
|
||||
return ret;
|
||||
}
|
||||
usermanager_add_user(uname->valuestring, gname->valuestring, add_user_ret); //新增用户
|
||||
|
||||
/* 处理返回结果 */
|
||||
res = cJSON_CreateObject();
|
||||
if(!res)
|
||||
{
|
||||
ret = RET_ERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
cJSON_AddNumberToObject(res, "result", add_user_ret->result);
|
||||
cJSON_AddNumberToObject(res, "user_id", add_user_ret->userID);
|
||||
ret_char = cJSON_PrintUnformatted(res);
|
||||
memcpy(output, ret_char, strlen(ret_char)+1);
|
||||
|
||||
/* 释放内存 */
|
||||
cJSON_Delete(root);
|
||||
cJSON_Delete(res);
|
||||
UCHAR_FREE(add_user_ret);
|
||||
UCHAR_FREE(ret_char);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* 修改用户-web-处理
|
||||
* iuput格式:
|
||||
* {
|
||||
* "type": 2,
|
||||
* "data": {
|
||||
* "ID": 2,
|
||||
* "GID": 3,
|
||||
* "uname": "xxx",
|
||||
* "gname": "xxx",
|
||||
* "passwd": "xxx",
|
||||
* "udescription": "xxx",
|
||||
* "multi": 0,
|
||||
* "valid": 0,
|
||||
* "valid_begin_time": "2013-07-04 15:04:23",
|
||||
* "valid_end_time": "2020-07-04 15:04:23"
|
||||
* }
|
||||
* }
|
||||
* multi, 0:允许多用户登陆、1:只允许单个用户登陆
|
||||
* valid, 0:永久有效、1:在有效期内有效
|
||||
*
|
||||
* output格式:{"result":true}
|
||||
* true:成功
|
||||
* false:失败
|
||||
*/
|
||||
static ret_code user_config_mod_web_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
cJSON *root, *data, *ret_json;
|
||||
bool ret_mod_web;
|
||||
char *ret_char = NULL;
|
||||
|
||||
|
||||
/* 解析json串 */
|
||||
root = cJSON_Parse(input);
|
||||
data = cJSON_GetObjectItem(root, "data");
|
||||
if(!data)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
cJSON_Delete(root);
|
||||
return ret;
|
||||
}
|
||||
s2j_create_struct_obj(input_data, USERLIST);
|
||||
s2j_struct_get_basic_element(input_data, data, int, ID);
|
||||
s2j_struct_get_basic_element(input_data, data, int, GID);
|
||||
s2j_struct_get_basic_element(input_data, data, string, uname);
|
||||
s2j_struct_get_basic_element(input_data, data, string, gname);
|
||||
s2j_struct_get_basic_element(input_data, data, string, passwd);
|
||||
s2j_struct_get_basic_element(input_data, data, string, udescription);
|
||||
s2j_struct_get_basic_element(input_data, data, int, multi);
|
||||
s2j_struct_get_basic_element(input_data, data, int, valid);
|
||||
s2j_struct_get_basic_element(input_data, data, string, valid_begin_time);
|
||||
s2j_struct_get_basic_element(input_data, data, string, valid_end_time);
|
||||
|
||||
/* 执行操作 */
|
||||
ret_mod_web = mod_user_web(input_data);
|
||||
|
||||
/* 处理返回结果 */
|
||||
ret_json = cJSON_CreateObject();
|
||||
if(!ret_json)
|
||||
{
|
||||
ret = RET_ERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
cJSON_AddBoolToObject(ret_json, "result", ret_mod_web);
|
||||
ret_char = cJSON_PrintUnformatted(ret_json);
|
||||
memcpy(output, ret_char, strlen(ret_char)+1);
|
||||
|
||||
/* 释放内存 */
|
||||
cJSON_Delete(root);
|
||||
cJSON_Delete(ret_json);
|
||||
UCHAR_FREE(input_data);
|
||||
UCHAR_FREE(ret_char);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* 修改用户-命令行-处理
|
||||
* iuput格式:
|
||||
* {
|
||||
* "type": 2,
|
||||
* "data": {
|
||||
* "uname": "xxx",
|
||||
* "attr_type": 3,
|
||||
* "attr_data": "xxx"
|
||||
* }
|
||||
* }
|
||||
* attr_type:指定修改的属性,值为0/1/2/3/4/5/6
|
||||
* 其中,0:描述、1:所属组名、2:登陆密码、3:公用账号、4:永久有效、5:有效期开始时间、6:有效期结束时间
|
||||
*
|
||||
* output格式:{"result":true}
|
||||
* true:成功
|
||||
* false:失败
|
||||
*/
|
||||
static ret_code user_config_mod_line_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
bool ret_mod_line;
|
||||
cJSON *root, *data, *uname, *attr_type, *attr_data, *ret_json;
|
||||
char *ret_char = NULL;
|
||||
|
||||
/* 解析json串 */
|
||||
root = cJSON_Parse(input);
|
||||
data = cJSON_GetObjectItem(root, "data");
|
||||
if(!data)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
cJSON_Delete(root);
|
||||
return ret;
|
||||
}
|
||||
uname = cJSON_GetObjectItem(data, "uname");
|
||||
if(!uname)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
cJSON_Delete(root);
|
||||
return ret;
|
||||
}
|
||||
attr_type = cJSON_GetObjectItem(data, "attr_type");
|
||||
if(!attr_type)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
cJSON_Delete(root);
|
||||
return ret;
|
||||
}
|
||||
attr_data = cJSON_GetObjectItem(data, "attr_data");
|
||||
if(!attr_data)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
cJSON_Delete(root);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 执行操作 */
|
||||
ret_mod_line = mod_user_line(uname->valuestring, attr_type->valueint, attr_data->valuestring);
|
||||
|
||||
/* 处理返回结果 */
|
||||
ret_json = cJSON_CreateObject();
|
||||
if(!ret_json)
|
||||
{
|
||||
ret = RET_ERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
cJSON_AddBoolToObject(ret_json, "result", ret_mod_line);
|
||||
ret_char = cJSON_PrintUnformatted(ret_json);
|
||||
memcpy(output, ret_char, strlen(ret_char)+1);
|
||||
|
||||
/* 释放内存 */
|
||||
cJSON_Delete(root);
|
||||
cJSON_Delete(ret_json);
|
||||
UCHAR_FREE(ret_char);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* 处理函数接口,这里的config_type只设置为3:CM_CONFIG_SET,具体的函数类型设置在input的json中
|
||||
* iuput格式:{"type": 0,"data": {xxx}}
|
||||
*/
|
||||
ret_code user_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
int fun_type;
|
||||
|
||||
if(NULL == input)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 获取对应的函数type */
|
||||
FUNCTYPE_GET(input, fun_type);
|
||||
|
||||
if(ERR_FUNC_TYPE == fun_type)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch(fun_type)
|
||||
{
|
||||
case USER_CONFIG_ADD:
|
||||
ret = user_config_add_proc(source, config_type,
|
||||
input, input_len,
|
||||
output, output_len);
|
||||
break;
|
||||
case USER_CONFIG_MOD_WEB:
|
||||
ret = user_config_mod_web_proc(source, config_type,
|
||||
input, input_len,
|
||||
output, output_len);
|
||||
break;
|
||||
case USER_CONFIG_MOD_LINE:
|
||||
ret = user_config_mod_line_proc(source, config_type,
|
||||
input, input_len,
|
||||
output, output_len);
|
||||
break;
|
||||
default:
|
||||
ret = RET_NOTSUPPORT;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
ret_code user_config_get(uint source,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret_code user_config_get_all(uint source,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
return ret;
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
#ifndef USER_ACCOUNT_CONFIG_H_
|
||||
#define USER_ACCOUNT_CONFIG_H_
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include <cjson/cJSON.h>
|
||||
|
||||
|
||||
#include "configmapi.h"
|
||||
#include "rpc_common.h"
|
||||
|
||||
#define USER_CONFIG_ADD 0
|
||||
#define USER_CONFIG_DEL 1
|
||||
#define USER_CONFIG_MOD_WEB 2
|
||||
#define USER_CONFIG_GET 3
|
||||
#define USER_CONFIG_GET_ALL 4
|
||||
#define USER_CONFIG_MOD_LINE 5
|
||||
#define USER_CONFIG_MOD_GROUP 6
|
||||
|
||||
|
||||
/* user account config */
|
||||
ret_code user_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
ret_code user_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
ret_code user_config_get(uint source,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
ret_code user_config_get_all(uint source,
|
||||
pointer output, int *output_len);
|
||||
|
||||
#endif
|
|
@ -1,70 +1,29 @@
|
|||
#include <cjson/cJSON.h>
|
||||
#include "configm.h"
|
||||
#include "user_group_config.h"
|
||||
#include "usermanager-server/include/user_group.h"
|
||||
#include "usermanager-server/include/common_user.h"
|
||||
#include "rpc.h"
|
||||
#include "parsefile.h"
|
||||
|
||||
/* 用户组处理函数数组 */
|
||||
static usergroup_config gs_usergroup_fun_table[] = {
|
||||
usergroup_config_add_proc
|
||||
};
|
||||
|
||||
/* check暂时不做操作,所有的检查在业务接口中完成 */
|
||||
ret_code usergroup_config_chk(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
ret_code usergroup_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
int code = 0;
|
||||
cJSON *root;
|
||||
cJSON *name, *description;
|
||||
|
||||
switch(config_type)
|
||||
{
|
||||
case CM_CONFIG_ADD:
|
||||
// root = cJSON_Parse(input);
|
||||
// if(!root)
|
||||
// {
|
||||
// ret = RET_INPUTERR;
|
||||
// ASSERT_RET(ret);
|
||||
// return ret;
|
||||
// }
|
||||
// name = cJSON_GetObjectItem(root, "gname");
|
||||
// if(!name)
|
||||
// {
|
||||
// cJSON_Delete(root);
|
||||
// ret = RET_INPUTERR;
|
||||
// ASSERT_RET(ret);
|
||||
// return ret;
|
||||
// }
|
||||
// description = cJSON_GetObjectItem(root, "gdescription");
|
||||
// if(!description)
|
||||
// {
|
||||
// cJSON_Delete(root);
|
||||
// ret = RET_INPUTERR;
|
||||
// ASSERT_RET(ret);
|
||||
// return ret;
|
||||
// }
|
||||
//cJSON_Delete(root);
|
||||
break;
|
||||
case CM_CONFIG_DEL:
|
||||
break;
|
||||
case CM_CONFIG_GET:
|
||||
break;
|
||||
case CM_CONFIG_GET_ALL:
|
||||
break;
|
||||
default:
|
||||
ret = RET_NOTSUPPORT;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* 新增用户组-处理
|
||||
* input格式:{"type": 0,"data": {"gname": "xxx","gdescription": "xxx"}}
|
||||
* output格式:{"result":0}
|
||||
* 0:成功
|
||||
* 1/2/3/4:失败,1:用户组满了、2:用户组名或描述长度不符合要求、3:用户组名中包含特殊字符、4:用户组名重名
|
||||
*/
|
||||
ret_code usergroup_config_add_proc(uint source, uint config_type,
|
||||
static ret_code usergroup_config_add_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
|
@ -83,7 +42,6 @@ ret_code usergroup_config_add_proc(uint source, uint config_type,
|
|||
cJSON_Delete(root);
|
||||
return ret;
|
||||
}
|
||||
|
||||
name = cJSON_GetObjectItem(data, "gname");
|
||||
if(!name)
|
||||
{
|
||||
|
@ -92,7 +50,6 @@ ret_code usergroup_config_add_proc(uint source, uint config_type,
|
|||
cJSON_Delete(root);
|
||||
return ret;
|
||||
}
|
||||
|
||||
description = cJSON_GetObjectItem(data, "gdescription");
|
||||
if(description)
|
||||
{
|
||||
|
@ -100,7 +57,6 @@ ret_code usergroup_config_add_proc(uint source, uint config_type,
|
|||
}
|
||||
|
||||
result = add_group(name->valuestring, des); //增加用户组
|
||||
cJSON_Delete(root);
|
||||
|
||||
res = cJSON_CreateObject();
|
||||
if(!res)
|
||||
|
@ -109,11 +65,14 @@ ret_code usergroup_config_add_proc(uint source, uint config_type,
|
|||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
cJSON_AddNumberToObject(res, "result", result);
|
||||
ret_char = cJSON_PrintUnformatted(res);
|
||||
memcpy(output, ret_char, strlen(ret_char)+1);
|
||||
|
||||
cJSON_Delete(root);
|
||||
cJSON_Delete(res);
|
||||
UCHAR_FREE(des);
|
||||
UCHAR_FREE(ret_char);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -128,43 +87,34 @@ ret_code usergroup_config_proc(uint source, uint config_type,
|
|||
{
|
||||
ret_code ret = RET_OK;
|
||||
int fun_type;
|
||||
int usergroup_fun_table_len;
|
||||
cJSON *root, *type, *data;
|
||||
|
||||
//获取函数数组的长度
|
||||
usergroup_fun_table_len = sizeof(gs_usergroup_fun_table)/sizeof(gs_usergroup_fun_table[0]);
|
||||
|
||||
//解析input,获取type
|
||||
root = cJSON_Parse(input);
|
||||
if(!root)
|
||||
if(NULL == input)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
type = cJSON_GetObjectItem(root, "type");
|
||||
if(!type)
|
||||
/* 获取对应的函数type */
|
||||
FUNCTYPE_GET(input, fun_type);
|
||||
|
||||
if(ERR_FUNC_TYPE == fun_type)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
cJSON_Delete(root);
|
||||
return ret;
|
||||
}
|
||||
fun_type = type->valueint;
|
||||
|
||||
//type在数组长度的范围内,执行数组内的函数,否则 ret = RET_NOTSUPPORT;
|
||||
if(fun_type < 0 || fun_type >= usergroup_fun_table_len)
|
||||
switch(fun_type)
|
||||
{
|
||||
ret = RET_NOTSUPPORT;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = gs_usergroup_fun_table[fun_type](source, config_type,
|
||||
case USERGROUP_CONFIG_ADD:
|
||||
ret = usergroup_config_add_proc(source, config_type,
|
||||
input, input_len,
|
||||
output, output_len);
|
||||
|
||||
break;
|
||||
default:
|
||||
ret = RET_NOTSUPPORT;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -177,9 +127,8 @@ ret_code usergroup_config_get(uint source,
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret_code usergroup_config_get_all(uint source, uint64 config_id,
|
||||
pointer output, short *single_len,
|
||||
int *output_len)
|
||||
ret_code usergroup_config_get_all(uint source,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
return ret;
|
||||
|
|
|
@ -16,21 +16,16 @@
|
|||
|
||||
#include "configmapi.h"
|
||||
#include "rpc_common.h"
|
||||
#include "sg/user/user_manager/user_group.h"
|
||||
|
||||
typedef ret_code (*usergroup_config)(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
|
||||
/* 新增用户组 */
|
||||
ret_code usergroup_config_add_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
#define USERGROUP_CONFIG_ADD 0
|
||||
#define USERGROUP_CONFIG_DEL 1
|
||||
#define USERGROUP_CONFIG_MOD 2
|
||||
#define USERGROUP_CONFIG_GET 3
|
||||
#define USERGROUP_CONFIG_GET_ALL 4
|
||||
|
||||
/* user group config */
|
||||
ret_code usergroup_config_chk(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
ret_code usergroup_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
ret_code usergroup_config_proc(uint source, uint config_type,
|
||||
|
@ -41,8 +36,7 @@ ret_code usergroup_config_get(uint source,
|
|||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
ret_code usergroup_config_get_all(uint source, uint64 config_id,
|
||||
pointer output, short *single_len,
|
||||
int *output_len);
|
||||
ret_code usergroup_config_get_all(uint source,
|
||||
pointer output, int *output_len);
|
||||
|
||||
#endif
|
|
@ -1,8 +1,8 @@
|
|||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<stdbool.h>
|
||||
#include "array_index.h"
|
||||
#include "common_user.h"
|
||||
#include "./include/array_index.h"
|
||||
#include "./include/common_user.h"
|
||||
|
||||
ARRAY g_user_index_head = { 0 };
|
||||
ARRAY g_group_index_head = { 0 };
|
|
@ -0,0 +1,53 @@
|
|||
#ifndef COMMON_USER_H_
|
||||
#define COMMON_USER_H_
|
||||
|
||||
#define SPECHAR(element) (strpbrk((element), "~!@#$%^&*()_+{}|:\"<>?\\,./;\'[]-=`")) //校验特殊字符
|
||||
#define GETID(ID, NAME1, NAME2) ((((ID) != 0) && (strcmp((NAME1), (NAME2)) == 0)) ? (ID) : 0) //根据name查询ID
|
||||
#define CHECKOUTARG(element) ((NULL == (element) || "" == (element) || SPECHAR(element)) ? true : false) //校验参数
|
||||
#define INVALID_INDEX (0)
|
||||
#define INIT_FAIL -1
|
||||
#define INIT_SUCCESS 0
|
||||
|
||||
#define TIME_T2STRING(time_int, time_char) (strftime((time_char), 20, "%Y-%m-%d %H:%M:%S", (localtime(&time_int))))
|
||||
#define STRING2TIME_T(time_char,time_int) \
|
||||
do { \
|
||||
struct tm tm_time; \
|
||||
int res = sscanf(time_char, "%4d-%2d-%2d %2d:%2d:%2d", \
|
||||
&tm_time.tm_year, &tm_time.tm_mon, &tm_time.tm_mday, \
|
||||
&tm_time.tm_hour, &tm_time.tm_min, &tm_time.tm_sec); \
|
||||
tm_time.tm_year -= 1900; \
|
||||
tm_time.tm_mon--; \
|
||||
tm_time.tm_isdst = -1; \
|
||||
time_int = mktime(&tm_time); \
|
||||
} while (0)
|
||||
|
||||
#define MULTI_MASK 0x0002
|
||||
#define VALID_MASK 0x0001
|
||||
|
||||
#define MULTI_GET(element) ((element) >> 1)
|
||||
#define MULTI_SET(element, value) (((element) & VALID_MASK) | (((value) << 1) & MULTI_MASK))
|
||||
#define VALID_GET(element) ((element) & VALID_MASK)
|
||||
#define VALID_SET(element, value) (((element) & MULTI_MASK) | ((value) & VALID_MASK))
|
||||
|
||||
#define FUNCTYPE_GET(input,fun_type) \
|
||||
do { \
|
||||
fun_type = -1; \
|
||||
cJSON *root, *type; \
|
||||
root = cJSON_Parse(input); \
|
||||
if(root) { \
|
||||
type = cJSON_GetObjectItem(root, "type"); \
|
||||
if(type) { \
|
||||
fun_type = type->valueint; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define ERR_FUNC_TYPE -1
|
||||
|
||||
#define UCHAR_FREE(element) \
|
||||
do { \
|
||||
free(element); \
|
||||
element = NULL; \
|
||||
} while (0)
|
||||
|
||||
#endif
|
|
@ -2,11 +2,11 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "common_user.h"
|
||||
#include "array_index.h"
|
||||
#include "user_mod.h"
|
||||
#include "sg/user/user_manager/user_group.h"
|
||||
#include "sg/user/user_manager/user.h"
|
||||
#include "./include/common_user.h"
|
||||
#include "./include/array_index.h"
|
||||
#include "./include/user_mod.h"
|
||||
#include "./include/user_group.h"
|
||||
#include "./include/user.h"
|
||||
|
||||
extern ARRAY g_user_index_head;
|
||||
extern USERGROUP g_group_table[];
|
||||
|
@ -218,6 +218,8 @@ bool mod_user_web(USERLIST* ulist)
|
|||
/* 下线用户,return */
|
||||
}
|
||||
}
|
||||
free(temp_user);
|
||||
temp_user = NULL;
|
||||
|
||||
return true;
|
||||
}
|
|
@ -2,9 +2,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "array_index.h"
|
||||
#include "sg/user/user_manager/user_group.h"
|
||||
#include "common_user.h"
|
||||
#include "./include/array_index.h"
|
||||
#include "./include/user_group.h"
|
||||
#include "./include/common_user.h"
|
||||
|
||||
extern ARRAY g_group_index_head;
|
||||
USERGROUP g_group_table[GROUP_INDEX_MAX];
|
|
@ -1,11 +1,11 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "user_mod.h"
|
||||
#include "sg/user/user_manager/user_group.h"
|
||||
#include "sg/user/user_manager/user.h"
|
||||
#include "array_index.h"
|
||||
#include "common_user.h"
|
||||
#include "./include/user_mod.h"
|
||||
#include "./include/user_group.h"
|
||||
#include "./include/user.h"
|
||||
#include "./include/array_index.h"
|
||||
#include "./include/common_user.h"
|
||||
|
||||
/* 修改用户函数数组 */
|
||||
exce_mod_user g_user_modfunc_table[USER_ATTRIBUTE_NUM] = {mod_user_des,
|
|
@ -26,23 +26,50 @@ int Init(userlock_configure_t *userlock)
|
|||
|
||||
|
||||
/*判断锁定配置信息是否有效,时间范围大于0,失败的次数大于0,锁定时间大于0 */
|
||||
ret_code userlock_config_chk(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
/*input格式 "{\"type\":0, \"failcount\":10, \"locktime\":30, \"timehorizon\":30, \"logintime\":3213250}"*/
|
||||
ret_code userlock_config_chk(uint source, uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
userlock_configure_t *struct_userlock;
|
||||
struct_userlock = (userlock_configure_t *)input;
|
||||
cJSON *cjson, *res;
|
||||
|
||||
if(input_len < sizeof(userlock_configure_t) )
|
||||
/*JSON字符串到JSON格式 */
|
||||
cjson = cJSON_Parse(input);
|
||||
if(!cjson)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*创建freeauth_configure_t结构体对象 */
|
||||
s2j_create_struct_obj(struct_userlock, userlock_configure_t);
|
||||
|
||||
/*反序列化数据到freeauth_configure_t结构体对象 */
|
||||
s2j_struct_get_basic_element(struct_userlock, cjson, int, failcount);
|
||||
s2j_struct_get_basic_element(struct_userlock, cjson, int, locktime);
|
||||
s2j_struct_get_basic_element(struct_userlock, cjson, int, timehorizon);
|
||||
s2j_struct_get_basic_element(struct_userlock, cjson, int, logintime);
|
||||
|
||||
|
||||
rpc_log_info("userlock configure: 登录时间: %d 用户认证失败次数: %d 用户认证的时间范围: %d 用户锁定时间: %ld\n",
|
||||
struct_userlock->logintime, struct_userlock->failcount,
|
||||
struct_userlock->timehorizon, struct_userlock->locktime);
|
||||
|
||||
if(*input_len < sizeof(userlock_configure_t))
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*配置的用户失败次数如果小于0,则配置错误 */
|
||||
if(struct_userlock->failcount < FAIL_MIN_NUM )
|
||||
{
|
||||
ret = RET_ERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
printf("userlock configure error\n");
|
||||
}
|
||||
|
||||
|
@ -50,6 +77,8 @@ ret_code userlock_config_chk(uint source, uint config_type,
|
|||
if(struct_userlock->locktime < LOCK_MIN_TIME )
|
||||
{
|
||||
ret = RET_ERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
printf("locktime configure error\n");
|
||||
}
|
||||
|
||||
|
@ -57,6 +86,8 @@ ret_code userlock_config_chk(uint source, uint config_type,
|
|||
if(struct_userlock->timehorizon < HORIZON_MIN_VALUE )
|
||||
{
|
||||
ret = RET_ERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
printf("timehorizon configure error\n");
|
||||
}
|
||||
|
||||
|
@ -72,15 +103,54 @@ ret_code userlock_config_proc(uint source, uint config_type,
|
|||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
userlock_configure_t *struct_userlock;
|
||||
struct_userlock = (userlock_configure_t *)input;
|
||||
cJSON *cjson, *res;
|
||||
char *ret_char = NULL;
|
||||
int *ret_int = NULL;
|
||||
|
||||
/*JSON字符串到JSON格式 */
|
||||
cjson = cJSON_Parse(input);
|
||||
if(!cjson)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*创建freeauth_configure_t结构体对象 */
|
||||
s2j_create_struct_obj(struct_userlock, userlock_configure_t);
|
||||
|
||||
/*反序列化数据到freeauth_configure_t结构体对象 */
|
||||
s2j_struct_get_basic_element(struct_userlock, cjson, int, failcount);
|
||||
s2j_struct_get_basic_element(struct_userlock, cjson, int, locktime);
|
||||
s2j_struct_get_basic_element(struct_userlock, cjson, int, timehorizon);
|
||||
s2j_struct_get_basic_element(struct_userlock, cjson, int, logintime);
|
||||
|
||||
rpc_log_info("userlock configure: 登录时间: %d 用户认证失败次数: %d 用户认证的时间范围: %d 用户锁定时间: %ld\n",
|
||||
struct_userlock->logintime, struct_userlock->failcount,
|
||||
struct_userlock->timehorizon, struct_userlock->locktime);
|
||||
|
||||
|
||||
/*将配置信息struct_userlock发送到数据库 */
|
||||
/*将配置信息struct_userlock发送到数据库 发送结果int类型表示,0表示发送成功,-1表示发送失败 */
|
||||
int r;
|
||||
|
||||
/*创建json对象 */
|
||||
res = cJSON_CreateObject();
|
||||
if(!res)
|
||||
{
|
||||
ret = RET_ERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
cJSON_AddNumberToObject(res, "result", r);
|
||||
|
||||
/*将json对象转换成json字符串 */
|
||||
ret_char = cJSON_PrintUnformatted(res);
|
||||
ret_int = (int*)ret_char;
|
||||
memcpy(output, ret_int, sizeof(ret_int)+1);
|
||||
|
||||
free(ret_char);
|
||||
cJSON_Delete(res);
|
||||
|
||||
/*把本地Portal server的配置信息存入全局变量 */
|
||||
userlock = struct_userlock;
|
||||
|
@ -89,4 +159,3 @@ ret_code userlock_config_proc(uint source, uint config_type,
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -4,258 +4,36 @@
|
|||
#include "configm.h"
|
||||
#include "ipconfig.h"
|
||||
|
||||
//big data test
|
||||
//async
|
||||
//sync io
|
||||
|
||||
static char* test_data = "给李彦宏先生的一封信 (2011-03-26 04:33:37)转载"
|
||||
"标签: 杂谈 "
|
||||
"您好,李彦宏先生。"
|
||||
"上周我和出版社的朋友沈浩波先生去山东的纸厂销毁已经印刷完毕的一百多万册《独唱团》第二期,三百多吨的纸和工业垃圾一起进了化浆炉。"
|
||||
"几百万的损失对您来说可能是个小数目,但是对一个出版公司来说几乎等于一年白干了,那还得是国内数得上数的大出版公司。"
|
||||
"这个行业就是这么可怜的,一个一百多人的企业一年的利润还不如在上海炒一套公寓,而且分分钟要背上“黑心书商”的骂名。"
|
||||
"但是沈浩波一直很高兴,因为他说和百度的谈判终于有眉目了,百度答应派人来商量百度文库的事情,李承鹏,慕容雪村,路金波,彭浩翔,"
|
||||
"都是文化行业里数一数二的畅销书作家,导演和出版商,大家都很激动,准备了好几个晚上各种资料。"
|
||||
"于是昨天开始谈判了,您派来几个高傲的中层,始终不承认百度文库有任何的侵权行为。"
|
||||
"你们不认为那包含了几乎全中国所有最新最旧图书的279万份文档是侵权,而是网民自己上传给大家共享的。"
|
||||
"你这里只是一个平台。我觉得其实我们不用讨论平台不平台,侵权不侵权这个问题了,您其实什么都心知肚明。"
|
||||
"您在美国有那么长时间的生活经历,现在您的妻子和女儿也都在美国,您一定知道如果百度开了一个叫百度美国的搜索引擎,"
|
||||
"然后把全美国所有的作家的书和所有音乐人的音乐都放在百度美国上面免费共享会是什么样的一个结果。"
|
||||
"您不会这么做,您也不会和美国人去谈什么这只是一个平台,和我没关系,都是网民自己干的,互联网的精神是共享。"
|
||||
"因为您知道这事儿只有在现在的中国才能成立。而且您也知道谁能欺负,谁不能欺负,您看,您就没有做一个百度影剧院,让大家共享共享最新的电影电视剧。"
|
||||
"您也许不太了解出版行业,我可以简单的给您介绍一下。1999年,十二年前,我的书卖18元一本,2011年,卖25元一本,很多读者还都嫌贵。"
|
||||
"您知道这十二年间,纸张,人工,物流都涨了多少倍,但出版商一直不敢提太多价,因为怕被骂,文化人脸皮都薄。"
|
||||
"一本25元的书,一般作者的版税是百分之8,可以赚2块钱,其中还要交三毛钱左右的税,也就是可以赚一块七。"
|
||||
"一本书如果卖两万本,已经算是畅销,一个作家两年能写一本,一本可以赚三万四,一年赚一万七,如果他光写书,"
|
||||
"他得不吃不喝写一百年才够在大城市的城郊买套像样的两居室。假设一本书卖10元,里面的构成是这样的,作家赚1元,印刷成本2元多,"
|
||||
"出版社赚1元多,书店赚5元。有点名气的作家出去签售做宣传,住的都是三星的酒店,来回能坐上飞机已经算不错了。"
|
||||
"出行标准一定还不如你们的低级别员工。最近几年我已经不出席任何宣传签售活动了,但是在2004年前,"
|
||||
"我至少做过几十场各个城市的宣传活动,而在那个时候,我已经是行业里的畅销书作家,我从没住到过一次300以上的酒店,"
|
||||
"有的时候和出版社陪同的几个人得在机场等好几个小时,因为打折的那班飞机得傍晚起飞,而多住半天酒店得加钱。"
|
||||
"这个行业就是这么窘迫的。这个行业里最顶尖的企业家,年收入就几百万。出版业和互联网业,本是两个级别相当的行业,"
|
||||
"你们是用几百亿身价和私人飞机豪华游艇来算企业家身价的,我们这个行业里的企业家们,我几乎没见过一个出行坐头等舱的。"
|
||||
"我们倒不是眼红你们有钱,我们只是觉得,你们都那么富有了,为何还要一分钱都不肯花从我们这个行业里强行获得免费的知识版权。"
|
||||
"音乐人还可以靠商演赚钱,而你让作家和出版行业如何生存。也许你说,传统出版会始终消亡,但那不代表出版行业就该如此的不体面。"
|
||||
"而且文艺作品和出版行业是不会消亡的,只是换了一个介质,一开始它们被画在墙上,后来刻在竹子上,现在有书,未来也许有别的科技,"
|
||||
"但版权是永远存在的。我写这些并不是代表这个行业向你们哭穷,"
|
||||
"但这的确中国唯一一个拥有很多的资源与生活息息相关却没有什么财富可言的行业。尤其在盗版和侵权的伤害之下。"
|
||||
"我们也不是要求你们把百度文库关了,我们只是希望百度文库可以主动对版权进行保护,等未来数字阅读成熟以后,"
|
||||
"说不定百度文库还能成为中国作家生活保障的来源,而不是现在这样,成为行业公敌众矢之的。因为没有永远的敌人,也没有永远的利益。"
|
||||
"我在2006年还和磨铁图书的沈浩波先生打过笔仗,为了现代诗互相骂的不可开交,而现在却是朋友和合作伙伴。"
|
||||
"百度文库完全可以成为造福作家的基地,而不是埋葬作家的墓地。"
|
||||
"在我们这个行业里,我算是生活得好的。李彦宏先生,也许我们一样,虽不畏惧,但并不喜欢这些是非恩怨,我喜欢晒晒太阳玩泥巴,"
|
||||
"你喜欢晒晒太阳种种花。无论你怎么共享我的知识版权,至少咱俩还能一起晒晒太阳,毕竟我赛车还能养活自己和家庭,"
|
||||
"但对于大部分作家来说,他们理应靠着传统的出版和数字出版过着体面的生活。也许他们未必能够有自己的院子晒太阳。"
|
||||
"您的产品会把他们赶回阴暗的小屋里为了生活不停的写,而您头上的太阳也并不会因此大一些。"
|
||||
"中国那么多的写作者被迫为百度无偿的提供了无数的知识版权和流量,他们不光没有来找过百度麻烦或者要求百度分点红,"
|
||||
"甚至还要承受百度拥趸们的侮辱以及百度员工谈判时的蔑视。您现在是中国排名第一的企业家,作为企业家的表率,"
|
||||
"您必须对百度文库给出版行业带来的伤害有所表态。倘若百度文库始终不肯退一步,那我可以多走几步,也许在不远的某天,"
|
||||
"在您北京的办公室里往楼下望去,您可以看见我。"
|
||||
" 祝 您的女儿为她的父亲感到骄傲"
|
||||
" 韩寒"
|
||||
"2011年 3月26日"
|
||||
"end";
|
||||
|
||||
void ip_set_callback(ret_code code, pointer output,
|
||||
int output_len, pointer data)
|
||||
{
|
||||
int i;
|
||||
|
||||
//rpc_log_info("call %s i is %d len is %d", rpc_code_format(code), *(int *)data, output_len);
|
||||
|
||||
|
||||
if(code != RET_OK)
|
||||
{
|
||||
rpc_log_info("ERROR: %s", (char *)output);
|
||||
}
|
||||
}
|
||||
|
||||
int parse_config_type(char *str)
|
||||
{
|
||||
if(strcasecmp(str, "SET") == 0)
|
||||
{
|
||||
return CM_CONFIG_SET;
|
||||
}
|
||||
else if(strcasecmp(str, "DEL") == 0)
|
||||
{
|
||||
return CM_CONFIG_DEL;
|
||||
}
|
||||
else if(strcasecmp(str, "GET") == 0)
|
||||
{
|
||||
return CM_CONFIG_GET;
|
||||
}
|
||||
else if(strcasecmp(str, "GET_ALL") == 0)
|
||||
{
|
||||
return CM_CONFIG_GET_ALL;
|
||||
}
|
||||
else if(strcasecmp(str, "ADD") == 0)
|
||||
{
|
||||
return CM_CONFIG_ADD;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
ret_code parse_input_str(int argc, char **argv, int *config_type, ip_config_t *ip_conf)
|
||||
{
|
||||
int intput_cnt = argc;
|
||||
int idx = 1;
|
||||
|
||||
intput_cnt--;
|
||||
|
||||
memset(ip_conf, 0, sizeof(ip_config_t));
|
||||
|
||||
/* 第一个参数是动作 */
|
||||
*config_type = parse_config_type(argv[idx]);
|
||||
|
||||
if(*config_type == CM_CONFIG_GET_ALL
|
||||
|| *config_type == 0)
|
||||
{
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
if(intput_cnt < 2)
|
||||
{
|
||||
printf("input error:<type> <if>\n");
|
||||
return RET_INPUTERR;
|
||||
}
|
||||
|
||||
idx++;
|
||||
|
||||
/* 第二个参数是接口名 */
|
||||
strcpy(ip_conf->ifname, argv[idx]);
|
||||
if(*config_type == CM_CONFIG_GET)
|
||||
{
|
||||
ip_conf->family = AF_INET;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
if(argc < 4)
|
||||
{
|
||||
printf("input error:<type> <if> <ip> <mask>\n");
|
||||
return RET_INPUTERR;
|
||||
}
|
||||
|
||||
printf("if %s\n",ip_conf->ifname);
|
||||
idx++;
|
||||
|
||||
/* 第三个参数是IP */
|
||||
ip_conf->prefix.s_addr = inet_addr(argv[idx]);
|
||||
ip_conf->family = AF_INET;
|
||||
printf("ip is %s\n", inet_ntoa(ip_conf->prefix));
|
||||
|
||||
idx++;
|
||||
/* 第四个参数是掩码长度 */
|
||||
ip_conf->prefixlen = atoi(argv[idx]);
|
||||
printf("prefix len is %d\n", ip_conf->prefixlen);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
ip_config_t ip_conf;
|
||||
ip_config_t *pip_conf;
|
||||
int config_type = 0;
|
||||
int i = 0, result;
|
||||
ret_code code;
|
||||
FILE *f = fopen("configtest","r+");
|
||||
char config_linebuf[512];
|
||||
char* output = NULL;
|
||||
int output_len;
|
||||
ret_code code;
|
||||
|
||||
if(parse_input_str(argc, argv, &config_type, &ip_conf) != RET_OK)
|
||||
if(f == NULL)
|
||||
{
|
||||
printf("OPEN CONFIG test file FALID\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
printf("=============================\n");
|
||||
|
||||
code = web_config_exec_sync(config_type, IPCONFIG_V4,
|
||||
(pointer)&ip_conf, sizeof(ip_conf), &output, &output_len);
|
||||
|
||||
printf("call config type %d: %s-%s\n", config_type, rpc_code_format(code), output);
|
||||
|
||||
if(config_type == CM_CONFIG_GET_ALL)
|
||||
memset(config_linebuf, 0, sizeof(config_linebuf));
|
||||
while(fgets(config_linebuf, 512, f) != NULL)
|
||||
{
|
||||
for(i = 0; i < output_len / sizeof(ip_config_t); i++)
|
||||
{
|
||||
pip_conf = (ip_config_t *)output;
|
||||
printf("ifname is %s\n",pip_conf[i].ifname);
|
||||
printf("family is %d\n", pip_conf[i].family);
|
||||
printf("ip is %s\n", inet_ntoa(pip_conf[i].prefix));
|
||||
printf("prefix len is %d\n", pip_conf[i].prefixlen);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(config_type == CM_CONFIG_GET)
|
||||
{
|
||||
pip_conf = (ip_config_t *)output;
|
||||
printf("ifname is %s\n",pip_conf[i].ifname);
|
||||
printf("family is %d\n", pip_conf[i].family);
|
||||
printf("ip is %s\n", inet_ntoa(pip_conf[i].prefix));
|
||||
printf("prefix len is %d\n", pip_conf[i].prefixlen);
|
||||
}
|
||||
|
||||
|
||||
/*strcpy(ip_conf.ifname, "ens39");
|
||||
ip_conf.prefix.s_addr = inet_addr("192.168.80.1");
|
||||
ip_conf.family = AF_INET;
|
||||
ip_conf.prefixlen = 24;*/
|
||||
|
||||
/*code = rpc_client_call(client, "ConfigManger#0", "test_big_data", test_data,
|
||||
strlen(test_data), NULL, NULL);
|
||||
ASSERT_RET_NO(code);
|
||||
|
||||
code = web_config_exec_sync(CM_CONFIG_ADD, IPCONFIG_V4,
|
||||
(pointer)&ip_conf, sizeof(ip_conf), &output, &output_len);
|
||||
|
||||
rpc_log_info("call CM_CONFIG_ADD %s: %s\n", rpc_code_format(code), output);
|
||||
|
||||
code = web_config_exec_sync(CM_CONFIG_DEL, IPCONFIG_V4,
|
||||
(pointer)&ip_conf, sizeof(ip_conf), &output, &output_len);
|
||||
rpc_log_info("call CM_CONFIG_DEL %s: %s\n", rpc_code_format(code), output);
|
||||
|
||||
code = web_config_exec_sync(CM_CONFIG_SET, IPCONFIG_V4,
|
||||
(pointer)&ip_conf, sizeof(ip_conf), &output, &output_len);
|
||||
rpc_log_info("call CM_CONFIG_SET %s: %s\n", rpc_code_format(code), output);
|
||||
|
||||
code = web_config_exec_sync(CM_CONFIG_GET_ALL, IPCONFIG_V4,
|
||||
(pointer)&ip_conf, sizeof(ip_conf), &output, &output_len);
|
||||
|
||||
rpc_log_info("call CM_CONFIG_GET_ALL %s: %s\n", rpc_code_format(code), output);
|
||||
|
||||
for(i = 0; i < output_len / sizeof(ip_config_t); i++)
|
||||
{
|
||||
pip_conf = (ip_config_t *)output;
|
||||
printf("ifname is %s\n",pip_conf[i].ifname);
|
||||
printf("family is %d\n", pip_conf[i].family);
|
||||
printf("ip is %s\n", inet_ntoa(pip_conf[i].prefix));
|
||||
printf("prefix len is %d\n", pip_conf[i].prefixlen);
|
||||
}
|
||||
printf("configure: %s\n", config_linebuf);
|
||||
|
||||
code = web_config_exec_sync(CM_CONFIG_GET, IPCONFIG_V4,
|
||||
(pointer)&ip_conf, sizeof(ip_conf), &output, &output_len);
|
||||
rpc_log_info("call %s: %s\n", rpc_code_format(code), output);
|
||||
config_linebuf, strlen(config_linebuf) + 1, &output, &output_len);
|
||||
|
||||
code = web_config_exec_async(CM_CONFIG_ADD, IPCONFIG_V4, (pointer)&ip_conf, sizeof(ip_conf), ip_set_callback, &i);
|
||||
rpc_log_info("call CM_CONFIG_ADD: %s\n", rpc_code_format(code));
|
||||
printf("call config type retturn:%s,result:%s\n", rpc_code_format(code), output);
|
||||
|
||||
code = web_config_exec_async(CM_CONFIG_DEL, IPCONFIG_V4, (pointer)&ip_conf, sizeof(ip_conf), ip_set_callback, &i);
|
||||
rpc_log_info("call CM_CONFIG_DEL: %s\n", rpc_code_format(code));
|
||||
memset(config_linebuf, 0, sizeof(config_linebuf));
|
||||
}
|
||||
|
||||
code = web_config_exec_async(CM_CONFIG_SET, IPCONFIG_V4, (pointer)&ip_conf, sizeof(ip_conf), ip_set_callback, &i);
|
||||
rpc_log_info("call CM_CONFIG_SET: %s\n", rpc_code_format(code));
|
||||
|
||||
code = web_config_exec_async(CM_CONFIG_GET, IPCONFIG_V4, (pointer)&ip_conf, sizeof(ip_conf), ip_set_callback, &i);
|
||||
rpc_log_info("call CM_CONFIG_GET: %s\n", rpc_code_format(code));
|
||||
|
||||
code = web_config_exec_async(CM_CONFIG_GET_ALL, IPCONFIG_V4, (pointer)&ip_conf, sizeof(ip_conf), ip_set_callback, &i);
|
||||
rpc_log_info("call CM_CONFIG_GET_ALL: %s\n", rpc_code_format(code));*/
|
||||
|
||||
printf("test ok\n");
|
||||
fclose(f);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=usermanager
|
||||
TARGET_NAME=usermanager-test
|
||||
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = DLL
|
||||
TARGET_TYPE = EXE
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
|
@ -19,27 +19,41 @@ TARGET_BOX =
|
|||
DEBUG = TRUE
|
||||
|
||||
PLAT_LINUX ?= TRUE
|
||||
PLAT_ARM64 ?= TRUE
|
||||
PLAT_ARM64 ?= FALSE
|
||||
|
||||
VPATH = ../user/user_manager/
|
||||
VPATH = ../user/user_manager/usermanager-test/ ../../Platform/user/configm/config-server/user_manager_config/usermanager-server/
|
||||
|
||||
# source code
|
||||
|
||||
# set the source file, don't used .o because of ...
|
||||
|
||||
COMMON_SRCS = array_index.c user_group.c user.c user_mod.c
|
||||
COMMON_SRCS = test_usermanager.c array_index.c user_group.c user_mod.c user.c
|
||||
|
||||
# MRS Board Source Files
|
||||
PLAT_LINUX_SRCS = $(COMMON_SRCS)
|
||||
PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
||||
|
||||
# gcc CFLAGS
|
||||
PLAT_ARM64_CFLAGS := -fPIC -I../../Common -I../common
|
||||
PLAT_LINUX_CFLAGS := -fPIC -I../../Common -I../common
|
||||
PLAT_ARM64_CFLAGS := -I../../Platform/user/configm/config-server/user_manager_config/usermanager-server/include -I../../Common -I../common
|
||||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||
|
||||
PLAT_ARM64_LDFLAGS := -fPIC -shared -lpthread
|
||||
PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
||||
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_LINUX_LDFLAGS :=
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := -lcjson -lpthread -lm
|
||||
LINUX_LIBS := -lcjson -lpthread -lm
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ./debug/usermanager-arm64.so
|
||||
USER_CLEAN_ITEMS += ./usermanager-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ./debug/usermanager-linux.so
|
||||
USER_CLEAN_ITEMS += ./usermanager-linux.so
|
||||
endif
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
|
@ -0,0 +1,351 @@
|
|||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <cjson/cJSON.h>
|
||||
#include "common_user.h"
|
||||
#include "array_index.h"
|
||||
#include "user_group.h"
|
||||
#include "user.h"
|
||||
|
||||
|
||||
|
||||
|
||||
extern USERGROUP g_group_table[GROUP_INDEX_MAX];
|
||||
extern USERACCOUNT g_user_table[USER_INDEX_MAX];
|
||||
|
||||
|
||||
int main1()
|
||||
{
|
||||
int a[2] = {1,2};
|
||||
printf("%d", sizeof(a)/sizeof(a[0]));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usergroup_config_add_proc(int source, int config_type,
|
||||
void* input, int input_len,
|
||||
void* output, int *output_len)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned short result;
|
||||
cJSON *root, *data, *name, *description, *res;
|
||||
char *des = NULL;
|
||||
char *ret_char = NULL;
|
||||
|
||||
root = cJSON_Parse(input);
|
||||
data = cJSON_GetObjectItem(root, "data");
|
||||
if(!data)
|
||||
{
|
||||
ret = -1;
|
||||
//ASSERT_RET(ret);
|
||||
cJSON_Delete(root);
|
||||
return ret;
|
||||
}
|
||||
|
||||
name = cJSON_GetObjectItem(data, "gname");
|
||||
if(!name)
|
||||
{
|
||||
ret = -1;
|
||||
//ASSERT_RET(ret);
|
||||
cJSON_Delete(root);
|
||||
return ret;
|
||||
}
|
||||
|
||||
description = cJSON_GetObjectItem(data, "gdescription");
|
||||
if(description)
|
||||
{
|
||||
des = description->valuestring;
|
||||
}
|
||||
|
||||
result = add_group(name->valuestring, des); //增加用户组
|
||||
cJSON_Delete(root);
|
||||
|
||||
res = cJSON_CreateObject();
|
||||
if(!res)
|
||||
{
|
||||
ret = -1;
|
||||
//ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
cJSON_AddNumberToObject(res, "result", result);
|
||||
ret_char = cJSON_PrintUnformatted(res);
|
||||
memcpy(output, ret_char, strlen(ret_char)+1);
|
||||
cJSON_Delete(res);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
printf("初始化用户组:%d\n", init_group());
|
||||
|
||||
printf("增加一个用户组:%d\n", add_group("", ""));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa01", "描述02"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa03", "描述03"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa,", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa04", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa07", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa08", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa09", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa10", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa11", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa12", "描述04"));
|
||||
|
||||
char *out_put;
|
||||
out_put = malloc(sizeof(char) * 200);
|
||||
if (NULL == out_put)
|
||||
{
|
||||
printf("*****\n");
|
||||
}
|
||||
char* input = "{\"type\": 0,\"data\": {\"gname\": \"xxx\",\"gdescription\": \"xxx\"}}";
|
||||
|
||||
printf("ttttt增加一个用户组:%d\n", usergroup_config_add_proc(1, 1, input, 100, out_put, 200));
|
||||
printf("result: %s", out_put);
|
||||
|
||||
//USERGROUP U[22] = { 0 };
|
||||
int gsize = get_group_count();
|
||||
|
||||
USERGROUP* U;
|
||||
U = (USERGROUP*)malloc(sizeof(USERGROUP) * gsize);
|
||||
if (NULL == U)
|
||||
{
|
||||
printf("shibaile");
|
||||
}
|
||||
|
||||
show_group_list(U);
|
||||
for (int i = 0; i < gsize; i++)
|
||||
{
|
||||
printf("第 %d 用户组 ID : %d, NAME: %s, 描述:%s \n", i, U[i].ID, U[i].gname, U[i].gdescription);
|
||||
}
|
||||
|
||||
char* name1 = { "aaa18" };
|
||||
printf("删除一个组:%s, %d\n", name1, del_group_by_name(name1));
|
||||
printf("删除一个组:%s, %d\n", "aaa03", del_group_by_name("aaa03"));
|
||||
printf("删除一个组:%s, %d\n", "aaaa03", del_group_by_name("aaaa03"));
|
||||
|
||||
printf("增加一个用户组:%d\n", add_group("aaa30", "就爱看九分阿道夫就卡了阿道夫阿道夫就"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa31", "描述31"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa32", "描述31"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa13", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa14", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa15", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa16", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa17", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa18", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa18", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa20", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa21", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa22", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa23", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa20", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa20", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa24", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa25", "描述04"));
|
||||
printf("增加一个用户组:%d\n", add_group("aaa26", "描述04"));
|
||||
|
||||
|
||||
gsize = get_group_count();
|
||||
|
||||
USERGROUP* U1;
|
||||
U1 = (USERGROUP*)malloc(sizeof(USERGROUP) * gsize);
|
||||
if (NULL == U1)
|
||||
{
|
||||
printf("shibaile");
|
||||
}
|
||||
|
||||
show_group_list(U1);
|
||||
for (int i = 0; i < gsize; i++)
|
||||
{
|
||||
printf("第 %d 用户组 ID : %d, NAME: %s, 描述:%s \n", i, U1[i].ID, U1[i].gname, U1[i].gdescription);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
char* name2 = { "aaa10" };
|
||||
USERGROUP* U2;
|
||||
U2 = (USERGROUP*)malloc(sizeof(USERGROUP));
|
||||
if (NULL == U2)
|
||||
{
|
||||
printf("shibaile");
|
||||
}
|
||||
find_group_by_name(name2, U2);
|
||||
if (NULL != U2)
|
||||
{
|
||||
printf("%s, %d, %s, %s \n", name2, U2->ID, U2->gname, U2->gdescription);
|
||||
}
|
||||
|
||||
printf("*************************************\n");
|
||||
|
||||
|
||||
printf("初始化用户:%d\n", init_user());
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
printf("初始化后的第 %d 个用户,ID:%d, PWD:%s \n", i, g_user_table[i].ID, g_user_table[i].passwd);
|
||||
}
|
||||
|
||||
USERADD* addUserResullt;
|
||||
addUserResullt = (USERADD*)malloc(sizeof(USERADD));
|
||||
if (NULL == addUserResullt)
|
||||
{
|
||||
printf("shibaile");
|
||||
}
|
||||
|
||||
usermanager_add_user("用户01", "aaa04", addUserResullt);
|
||||
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
||||
//addUserResullt = AddUser("用户02", "aaa04", NULL);
|
||||
//printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
||||
usermanager_add_user(NULL, "aaa04", addUserResullt);
|
||||
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
||||
usermanager_add_user("", "aaa04", addUserResullt);
|
||||
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
||||
usermanager_add_user("用户04,", "aaa04", addUserResullt);
|
||||
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
||||
usermanager_add_user("用户05", "aCaa04", addUserResullt);
|
||||
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
||||
usermanager_add_user("用户01", "aaa04", addUserResullt);
|
||||
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
||||
usermanager_add_user("用户04", "aaa07", addUserResullt);
|
||||
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
||||
usermanager_add_user("用户05", "aaa07", addUserResullt);
|
||||
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
||||
usermanager_add_user("用户06", "aaa07", addUserResullt);
|
||||
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
||||
usermanager_add_user("用户07", "aaa07", addUserResullt);
|
||||
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
||||
usermanager_add_user("用户08", "aaa07", addUserResullt);
|
||||
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
||||
usermanager_add_user("用户09", "aaa07", addUserResullt);
|
||||
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
||||
|
||||
for (int i = 0; i < USER_INDEX_MAX; i++)
|
||||
{
|
||||
if (g_user_table[i].ID != 0)
|
||||
{
|
||||
printf("tianjia后的第 %d 个用户, ID:%d, GID:%d, 用户名:%s, PWD:%s \n", i, g_user_table[i].ID, g_user_table[i].GID, g_user_table[i].uname, g_user_table[i].passwd);
|
||||
}
|
||||
}
|
||||
|
||||
printf("*****************************************************\n");
|
||||
|
||||
USERLIST* ulist;
|
||||
ulist = (USERLIST*)malloc(sizeof(USERLIST));
|
||||
if (NULL == ulist)
|
||||
{
|
||||
printf("ulist fail");
|
||||
}
|
||||
|
||||
unsigned short id1 = 2;
|
||||
get_user_by_id(id1, ulist);
|
||||
printf("查找id为:%d, 用户名:%s, 用户组ID:%d,用户组名:%s,描述:%s", id1, ulist->uname, ulist->GID, ulist->gname, ulist->udescription);
|
||||
printf(" ,多用户登陆:%d, 永久性:%d, 开始时间:%s, 结束时间:%s", ulist->multi, ulist->valid, ulist->valid_begin_time, ulist->valid_end_time);
|
||||
printf("密码:%s\n", ulist->passwd);
|
||||
|
||||
USERLIST* ulist2;
|
||||
ulist2 = (USERLIST*)malloc(sizeof(USERLIST));
|
||||
if (NULL == ulist2)
|
||||
{
|
||||
printf("ulist fail");
|
||||
}
|
||||
|
||||
ulist2->ID = 2;
|
||||
ulist2->GID = 4;
|
||||
strcpy(ulist2->udescription, "修改用");
|
||||
strcpy(ulist2->passwd, "zhelishimima123");
|
||||
ulist2->multi = 1;
|
||||
ulist2->valid = 1;
|
||||
strcpy(ulist2->valid_begin_time, "2013-07-04 15:04:23");
|
||||
strcpy(ulist2->valid_end_time, "2019-07-04 15:04:23");
|
||||
|
||||
|
||||
printf("%d\n", mod_user_web(ulist2));
|
||||
|
||||
USERLIST* ulist22;
|
||||
ulist22 = (USERLIST*)malloc(sizeof(USERLIST));
|
||||
if (NULL == ulist22)
|
||||
{
|
||||
printf("ulist fail");
|
||||
}
|
||||
get_user_by_id(id1, ulist22);
|
||||
printf("查找id为:%d, 用户名:%s, 用户组ID:%d,用户组名:%s,描述:%s", id1, ulist22->uname, ulist22->GID, ulist22->gname, ulist22->udescription);
|
||||
printf(" ,多用户登陆:%d, 永久性:%d, 开始时间:%s, 结束时间:%s", ulist22->multi, ulist22->valid, ulist22->valid_begin_time, ulist22->valid_end_time);
|
||||
printf("密码:%s\n", ulist22->passwd);
|
||||
|
||||
//printf("内存表中的时间:%lld,%lld, mul_avil:%d", g_user_table[2].valid_begin_time, g_user_table[2].valid_end_time, g_user_table[2].multi_valid);
|
||||
|
||||
|
||||
mod_user_line("用户05", 0, "zhelishimiaoshu");
|
||||
mod_user_line("用户05", 1, "aaa12");
|
||||
mod_user_line("用户05", 2, "zhelishidenglumima");
|
||||
//mod_user_line("用户05", 3, "1");
|
||||
mod_user_line("用户05", 4, "1");
|
||||
mod_user_line("用户05", 5, "2013-03-03 15:04:23");
|
||||
mod_user_line("用户05", 6, "2018-03-03 15:04:23");
|
||||
//mod_user_line("用户05", 7, "2020-03-03 15:04:23");
|
||||
|
||||
unsigned short id2 = 3;
|
||||
get_user_by_id(id2, ulist22);
|
||||
printf("查找id为:%d, 用户名:%s, 用户组ID:%d,用户组名:%s,描述:%s", id2, ulist22->uname, ulist22->GID, ulist22->gname, ulist22->udescription);
|
||||
printf(" ,多用户登陆:%d, 永久性:%d, 开始时间:%s, 结束时间:%s", ulist22->multi, ulist22->valid, ulist22->valid_begin_time, ulist22->valid_end_time);
|
||||
printf("密码:%s\n", ulist22->passwd);
|
||||
|
||||
printf("*********************************************************************************\n");
|
||||
|
||||
|
||||
|
||||
// USER_AUTH_RET* aret;
|
||||
// aret = (USER_AUTH_RET*)malloc(sizeof(USER_AUTH_RET));
|
||||
// if (NULL == aret)
|
||||
// {
|
||||
// printf("111111111111");
|
||||
// }
|
||||
// time_t t1 = time(NULL);
|
||||
|
||||
// aret = user_auth("用户05", "zhelishidenglumima", t1, aret);
|
||||
// printf("%d,%d,%d\n", aret->ret, aret->user_id, aret->group_id);
|
||||
|
||||
// Sleep(1000);
|
||||
// t1 = time(NULL);
|
||||
// aret = user_auth("用户05", "zhelishidenglumima", t1, aret);
|
||||
// printf("%d,%d,%d\n", aret->ret, aret->user_id, aret->group_id);
|
||||
|
||||
// Sleep(1000);
|
||||
// t1 = time(NULL);
|
||||
// aret = user_auth("用户05", "zhelishidenglumima", t1, aret);
|
||||
// printf("%d,%d,%d\n",aret->ret,aret->user_id,aret->group_id);
|
||||
|
||||
// Sleep(1000);
|
||||
// t1 = time(NULL);
|
||||
// aret = user_auth("用户05", "zhelishidenglumima", t1, aret);
|
||||
// printf("%d,%d,%d\n", aret->ret, aret->user_id, aret->group_id);
|
||||
|
||||
// Sleep(1000);
|
||||
// t1 = time(NULL);
|
||||
// aret = user_auth("用户05", "zhelishidenglumima", t1, aret);
|
||||
// printf("%d,%d,%d\n", aret->ret, aret->user_id, aret->group_id);
|
||||
|
||||
// Sleep(1000);
|
||||
// t1 = time(NULL);
|
||||
// aret = user_auth("用户05", "zhelishidenglumima", t1, aret);
|
||||
// printf("%d,%d,%d\n", aret->ret, aret->user_id, aret->group_id);
|
||||
|
||||
// mod_user_line("用户05", 6, "2020-03-03 15:04:23");
|
||||
// Sleep(4000);
|
||||
// t1 = time(NULL);
|
||||
// aret = user_auth("用户05", "zhelishidenglumima", t1, aret);
|
||||
// printf("%d,%d,%d\n", aret->ret, aret->user_id, aret->group_id);
|
||||
|
||||
|
||||
///extern USER_AUTH_LIST g_user_auth_ret_table[USER_INDEX_MAX];
|
||||
|
||||
//printf("%lld,%lld,%lld",g_user_auth_ret_table[3].fail_time[0], g_user_auth_ret_table[3].fail_time[1], g_user_auth_ret_table[3].fail_time[2]);
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@
|
|||
};
|
||||
|
||||
&ifc {
|
||||
status = "okay";
|
||||
status = "disable";
|
||||
#address-cells = <2>;
|
||||
#size-cells = <1>;
|
||||
/* NOR, NAND Flashes and FPGA on board */
|
||||
|
|
Loading…
Reference in New Issue