MOD aaa-12 增加配置管理服务端和api
SOL增加配置管理服务端和api 修改人:zhangliang 检视人:zhangliang
This commit is contained in:
parent
d32cc36fec
commit
f5696b556e
18
Makefile
18
Makefile
|
@ -28,9 +28,9 @@ MAKE_FLAGS += -j$(shell cat /proc/cpuinfo | grep processor | wc -l)
|
|||
endif
|
||||
endif
|
||||
|
||||
.PHONY : demo conntrack netlink trace openrpc
|
||||
.PHONY : demo conntrack netlink trace openrpc configm
|
||||
|
||||
all: demo conntrack netlink trace openrpc
|
||||
all: demo conntrack netlink trace openrpc configm
|
||||
|
||||
ifeq ($(OPT), install)
|
||||
#$(shell `find ../release -name "*.zip" -delete`)
|
||||
|
@ -120,3 +120,17 @@ else
|
|||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.openrpc.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=openrpc
|
||||
endif
|
||||
|
||||
configm:
|
||||
ifeq ($(OPT), clean)
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.configm.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=configm
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.configmapi.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=configm-api
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.configmtest.Makefile cleanall MLOG=$(MLOG) MAKE_TARGET=configmtest
|
||||
else ifeq ($(OPT), install)
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.configm.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=configm
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.configmapi.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=configm-api
|
||||
$(MLOG)make $(MAKE_FLAGS) -C Platform/build -f user.configmtest.Makefile install DIR=$(DIR) MLOG=$(MLOG) MAKE_TARGET=configmtest
|
||||
else
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.configm.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=configm
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.configmapi.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=configm-api
|
||||
$(MLOG)make all $(MAKE_FLAGS) -C Platform/build -f user.configmtest.Makefile MLOG=$(MLOG) DISABLE_WARRING=$(DIS_BUILD_WARRING) MAKE_TARGET=configmtest
|
||||
endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=test-trace
|
||||
TARGET_NAME=configm
|
||||
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
|
@ -21,7 +21,7 @@ DEBUG = TRUE
|
|||
PLAT_LINUX ?= TRUE
|
||||
PLAT_ARM64 ?= TRUE
|
||||
|
||||
VPATH = ../user/configm
|
||||
VPATH = ../user/configm/config-server
|
||||
|
||||
# source code
|
||||
|
||||
|
@ -34,28 +34,28 @@ PLAT_LINUX_SRCS = $(COMMON_SRCS)
|
|||
PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
||||
|
||||
# gcc CFLAGS
|
||||
PLAT_ARM64_CFLAGS := -I../user/configm/include -I../../Common -I../common/configm -I../common/rpc -I../common/rpc/hashtable
|
||||
PLAT_ARM64_CFLAGS := -I../user/configm/config-server/include -I../../Common -I../common/configm -I../common/rpc -I../common/rpc/hashtable
|
||||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_LINUX_LDFLAGS :=
|
||||
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := -lpthread -lpthread -lev -lm
|
||||
LINUX_LIBS := -lpthread -lpthread -lev -lm
|
||||
ARM64_LIBS := ../thirdparty/arm64/libev.so ./libopenrpc-arm64.so -lpthread -lm
|
||||
LINUX_LIBS := ../thirdparty/x86_64/libev.so ./libopenrpc-linux.so -lpthread -lm
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ./debug/libopenrpc.so
|
||||
USER_CLEAN_ITEMS += ./libopenrpc.so
|
||||
DEPEND_LIB += ../thirdparty/arm64/libev.so ./debug/libopenrpc-arm64.so
|
||||
USER_CLEAN_ITEMS += ./libopenrpc-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ./debug/libopenrpc.so
|
||||
USER_CLEAN_ITEMS += ./debug/libopenrpc.soo
|
||||
DEPEND_LIB += ../thirdparty/x86_64/libev.so ./debug/libopenrpc-linux.so
|
||||
USER_CLEAN_ITEMS += ./libopenrpc-linux.so
|
||||
endif
|
||||
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=libconfigmapi
|
||||
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = DLL
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
||||
PLAT_LINUX ?= TRUE
|
||||
PLAT_ARM64 ?= TRUE
|
||||
|
||||
VPATH = ../user/configm/config-api
|
||||
|
||||
# source code
|
||||
|
||||
# set the source file, don't used .o because of ...
|
||||
|
||||
COMMON_SRCS = configclient.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/configm -I../common/rpc -I../common/rpc/hashtable
|
||||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS := -fPIC -shared
|
||||
PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
||||
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := ../thirdparty/arm64/libev.so ./libopenrpc-arm64.so -lpthread -lm
|
||||
LINUX_LIBS := ../thirdparty/x86_64/libev.so ./libopenrpc-linux.so -lpthread -lm
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/arm64/libev.so ./debug/libopenrpc-arm64.so
|
||||
USER_CLEAN_ITEMS += ./libopenrpc-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/x86_64/libev.so ./debug/libopenrpc-linux.so
|
||||
USER_CLEAN_ITEMS += ./libopenrpc-linux.so
|
||||
endif
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
ifneq ($(MAKECMDGOALS), cleanall)
|
||||
ifneq ($(notdir $(DEPEND_LIB)), $(wildcard $(DEPEND_LIB)))
|
||||
$(shell $(CP) $(DEPEND_LIB) ./)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(MAKECMDGOALS), )
|
||||
$(shell find ./ -name "$(TARGET)-*.ko" -delete)
|
||||
else
|
||||
ifeq ($(MAKECMDGOALS), all)
|
||||
$(shell find ./ -name "$(TARGET)-*.ko" -delete)
|
||||
endif
|
||||
endif
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=configmtest
|
||||
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
# for application: EXE
|
||||
# for dynamic library: DLL
|
||||
TARGET_TYPE = EXE
|
||||
|
||||
# target object
|
||||
# for application: APP
|
||||
# for device driver: DRV
|
||||
TARGET_OBJ = APP
|
||||
|
||||
# custom install dir
|
||||
TARGET_BOX =
|
||||
|
||||
#debug mode or release mode
|
||||
DEBUG = TRUE
|
||||
|
||||
PLAT_LINUX ?= TRUE
|
||||
PLAT_ARM64 ?= TRUE
|
||||
|
||||
VPATH = ../user/configm/config-test
|
||||
|
||||
# source code
|
||||
|
||||
# set the source file, don't used .o because of ...
|
||||
|
||||
COMMON_SRCS = configtest.c
|
||||
|
||||
# MRS Board Source Files
|
||||
PLAT_LINUX_SRCS = $(COMMON_SRCS)
|
||||
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_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||
|
||||
|
||||
PLAT_ARM64_LDFLAGS :=
|
||||
PLAT_LINUX_LDFLAGS :=
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := ../thirdparty/arm64/libev.so ./libopenrpc-arm64.so ./libconfigmapi-arm64.so -lpthread -lm
|
||||
LINUX_LIBS := ../thirdparty/x86_64/libev.so ./libopenrpc-linux.so ./libconfigmapi-linux.so -lpthread -lm
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/arm64/libev.so ./debug/libopenrpc-arm64.so ./debug/libconfigmapi-arm64.so
|
||||
USER_CLEAN_ITEMS += ./libconfigmapi-arm64.so
|
||||
endif
|
||||
|
||||
ifeq ($(PLAT_LINUX), TRUE)
|
||||
DEPEND_LIB += ../thirdparty/x86_64/libev.so ./debug/libopenrpc-linux.so ./debug/libconfigmapi-linux.so
|
||||
USER_CLEAN_ITEMS += ./libconfigmapi-linux.so
|
||||
endif
|
||||
|
||||
|
||||
# this line must be at below of thus, because of...
|
||||
include ../../Common/common.Makefile
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
ifneq ($(MAKECMDGOALS), cleanall)
|
||||
ifneq ($(notdir $(DEPEND_LIB)), $(wildcard $(DEPEND_LIB)))
|
||||
$(shell $(CP) $(DEPEND_LIB) ./)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(MAKECMDGOALS), )
|
||||
$(shell find ./ -name "$(TARGET)-*.ko" -delete)
|
||||
else
|
||||
ifeq ($(MAKECMDGOALS), all)
|
||||
$(shell find ./ -name "$(TARGET)-*.ko" -delete)
|
||||
endif
|
||||
endif
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
# target name, the target name must have the same name of c source file
|
||||
TARGET_NAME=openrpc
|
||||
TARGET_NAME=libopenrpc
|
||||
|
||||
# target
|
||||
# for linux module driver: KO
|
||||
|
@ -43,11 +43,11 @@ PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
|||
|
||||
|
||||
#gcc libs
|
||||
ARM64_LIBS := -lpthread -lm
|
||||
LINUX_LIBS := -lpthread -lm
|
||||
ARM64_LIBS := ../thirdparty/arm64/libev.so -lpthread -lm
|
||||
LINUX_LIBS := ../thirdparty/x86_64/libev.so -lpthread -lm
|
||||
|
||||
ifeq ($(PLAT_ARM64), TRUE)
|
||||
DEPEND_LIB +=
|
||||
DEPEND_LIB += ../thirdparty/arm64/libev.so
|
||||
USER_CLEAN_ITEMS +=
|
||||
endif
|
||||
|
||||
|
|
|
@ -3,14 +3,9 @@
|
|||
|
||||
#include "rpc_common.h"
|
||||
#include "ipconfig.h"
|
||||
|
||||
#include "configmapi.h"
|
||||
/* 类型定义 */
|
||||
|
||||
#define CONFIG_FROM_WEB 0x00000001
|
||||
#define CONFIG_FROM_NETOPEER 0x00000010
|
||||
#define CONFIG_FROM_RECOVER1 0x01000000
|
||||
#define CONFIG_FROM_RECOVER2 0x02000000
|
||||
|
||||
/* IP CONFIG */
|
||||
#define IPCONFIG_MODULE 0x00000001
|
||||
|
||||
|
@ -52,10 +47,6 @@
|
|||
|
||||
#define CONFIG_RECOVERY_DONE "/tmp/config_recovery"
|
||||
|
||||
typedef struct _config_message config_msg_t;
|
||||
|
||||
typedef struct _config_service config_service_t;
|
||||
|
||||
typedef ret_code (*cm_config_chk)(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
|
@ -72,16 +63,6 @@ typedef ret_code (*cm_config_get_all)(uint source, uint64 config_id,
|
|||
pointer output, short *single_len,
|
||||
int *output_len);
|
||||
|
||||
/* 结构体定义 */
|
||||
|
||||
/* 配置消息 */
|
||||
struct _config_message {
|
||||
uint64 config_id; /*配置ID*/
|
||||
uint source; /*配置来源*/
|
||||
uint config_type; /*配置类型:add,del,set*/
|
||||
char config_buff[0]; /*配置数据缓存*/
|
||||
};
|
||||
|
||||
/* 配置注册 */
|
||||
struct _config_service {
|
||||
uint64 config_id; /* 配置ID,全局唯一,用于寻找对应的配置业务*/
|
||||
|
@ -94,15 +75,10 @@ struct _config_service {
|
|||
cm_config_get_all getall_callback; /* 获取所有配置接口 */
|
||||
};
|
||||
|
||||
/* 函数声明 */
|
||||
typedef struct _config_service config_service_t;
|
||||
|
||||
|
||||
ret_code web_config_exec_sync(uint config_type, uint64 config_id,
|
||||
char* config_data, int config_len,
|
||||
char**output, int *output_len);
|
||||
|
||||
ret_code web_config_exec_async(uint config_type, uint64 config_id,
|
||||
char* config_data, int config_len,
|
||||
rpc_callback callback, pointer data);
|
||||
|
||||
#endif /* RPC_COMMON_H_ */
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef CONFIGMAPI_H_
|
||||
#define CONFIGMAPI_H_
|
||||
|
||||
#include "rpc_common.h"
|
||||
|
||||
#define CONFIG_FROM_WEB 0x00000001
|
||||
#define CONFIG_FROM_NETOPEER 0x00000010
|
||||
#define CONFIG_FROM_RECOVER1 0x01000000
|
||||
#define CONFIG_FROM_RECOVER2 0x02000000
|
||||
|
||||
/* 结构体定义 */
|
||||
|
||||
/* 配置消息 */
|
||||
struct _config_message {
|
||||
uint64 config_id; /*配置ID*/
|
||||
uint source; /*配置来源*/
|
||||
uint config_type; /*配置类型:add,del,set*/
|
||||
char config_buff[0]; /*配置数据缓存*/
|
||||
};
|
||||
typedef struct _config_message config_msg_t;
|
||||
/* 函数声明 */
|
||||
|
||||
ret_code web_config_exec_sync(uint config_type, uint64 config_id,
|
||||
char* config_data, int config_len,
|
||||
char**output, int *output_len);
|
||||
|
||||
ret_code web_config_exec_async(uint config_type, uint64 config_id,
|
||||
char* config_data, int config_len,
|
||||
rpc_callback callback, pointer data);
|
||||
|
||||
#endif /* RPC_COMMON_H_ */
|
||||
|
Binary file not shown.
|
@ -0,0 +1,117 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "rpc.h"
|
||||
#include "configmapi.h"
|
||||
|
||||
|
||||
rpc_client *config_client = NULL;
|
||||
|
||||
rpc_client *config_client_get()
|
||||
{
|
||||
if(config_client == NULL)
|
||||
{
|
||||
config_client = rpc_client_connect_ex("ConfigManger#0");
|
||||
if(config_client == NULL)
|
||||
{
|
||||
rpc_log_error("connect ConfigManger#0 error\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return config_client;
|
||||
}
|
||||
|
||||
ret_code config_construct_msg(uint config_type, uint64 config_id,
|
||||
char* config_data, int config_len,
|
||||
config_msg_t **config_msg, int *msg_len)
|
||||
{
|
||||
config_msg_t *pconfig_msg;
|
||||
|
||||
if(config_data == NULL)
|
||||
{
|
||||
return RET_NULLP;
|
||||
}
|
||||
|
||||
*msg_len = sizeof(config_msg_t) + config_len;
|
||||
pconfig_msg= (config_msg_t *) malloc(*msg_len);
|
||||
if(pconfig_msg == NULL)
|
||||
{
|
||||
return RET_NOMEM;
|
||||
}
|
||||
|
||||
pconfig_msg->source = CONFIG_FROM_WEB;
|
||||
pconfig_msg->config_type = config_type;
|
||||
pconfig_msg->config_id = config_id;
|
||||
|
||||
memcpy(pconfig_msg->config_buff, config_data, config_len);
|
||||
*config_msg = pconfig_msg;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_code config_destroy_msg(config_msg_t *config_msg, int msg_len)
|
||||
{
|
||||
if(config_msg)
|
||||
{
|
||||
memset(config_msg, 0, msg_len);
|
||||
free(config_msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ret_code web_config_exec_sync(uint config_type, uint64 config_id,
|
||||
char* config_data, int config_len,
|
||||
char**output, int *output_len)
|
||||
{
|
||||
rpc_client * client = config_client_get();
|
||||
ret_code code = RET_OK ;
|
||||
config_msg_t *config_msg;
|
||||
int msg_len = 0;
|
||||
|
||||
if(client == NULL)
|
||||
{
|
||||
return RET_ERR;
|
||||
}
|
||||
|
||||
code = config_construct_msg(config_type, config_id, config_data,
|
||||
config_len, &config_msg, &msg_len);
|
||||
ASSERT_RET(code);
|
||||
|
||||
code = rpc_client_call(client, "ConfigManger#0", "cm_config_process",
|
||||
config_msg, msg_len, (pointer)output, output_len);
|
||||
ASSERT_RET_NO(code);
|
||||
|
||||
config_destroy_msg(config_msg, msg_len);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
ret_code web_config_exec_async(uint config_type, uint64 config_id,
|
||||
char* config_data, int config_len,
|
||||
rpc_callback callback, pointer data)
|
||||
{
|
||||
rpc_client * client = config_client_get();
|
||||
config_msg_t *config_msg;
|
||||
int msg_len = 0;
|
||||
|
||||
ret_code ret = RET_OK ;
|
||||
|
||||
if(client == NULL)
|
||||
{
|
||||
return RET_ERR;
|
||||
}
|
||||
|
||||
ret = config_construct_msg(config_type, config_id, config_data,
|
||||
config_len, &config_msg, &msg_len);
|
||||
ASSERT_RET(ret);
|
||||
|
||||
ret = rpc_client_call_async(client, "ConfigManger#0", "cm_config_process",
|
||||
config_msg, msg_len, callback, data);
|
||||
|
||||
config_destroy_msg(config_msg, msg_len);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
2
Platform/user/configm/configserver.c → Platform/user/configm/config-server/configserver.c
Executable file → Normal file
2
Platform/user/configm/configserver.c → Platform/user/configm/config-server/configserver.c
Executable file → Normal file
|
@ -79,7 +79,7 @@ ret_code cm_config_rec_done(char *input, short *input_len,char *output)
|
|||
free(input_len);
|
||||
free(output);
|
||||
|
||||
fd = open(CONFIG_RECOVERY_DONE, O_CREAT);
|
||||
fd = open(CONFIG_RECOVERY_DONE, O_CREAT, 0777);
|
||||
if(fd <= 0)
|
||||
{
|
||||
rpc_log_error("create recovery file error");
|
0
Platform/user/configm/include/ipconfig.h → Platform/user/configm/config-server/include/ipconfig.h
Executable file → Normal file
0
Platform/user/configm/include/ipconfig.h → Platform/user/configm/config-server/include/ipconfig.h
Executable file → Normal file
0
Platform/user/configm/include/parsefile.h → Platform/user/configm/config-server/include/parsefile.h
Executable file → Normal file
0
Platform/user/configm/include/parsefile.h → Platform/user/configm/config-server/include/parsefile.h
Executable file → Normal file
2
Platform/user/configm/ipconfig/ipconfig.c → Platform/user/configm/config-server/ipconfig/ipconfig.c
Executable file → Normal file
2
Platform/user/configm/ipconfig/ipconfig.c → Platform/user/configm/config-server/ipconfig/ipconfig.c
Executable file → Normal file
|
@ -162,7 +162,7 @@ ret_code if_get_prefix_all(ip_config_t *ip_conf, int *cnt, int *code)
|
|||
ip_conf[i].prefix = ((struct sockaddr_in *)&(ifreq[i].ifr_addr))->sin_addr;
|
||||
|
||||
memset(&netmask, 0, sizeof(netmask));
|
||||
strncpy(netmask.ifr_name, ifreq[i].ifr_name, INTERFACE_NAMSIZ);
|
||||
strncpy(netmask.ifr_name, ifreq[i].ifr_name, sizeof(netmask.ifr_name));
|
||||
|
||||
ret = if_ioctl(SIOCGIFNETMASK, (caddr_t)&netmask, &mask_ret);
|
||||
ASSERT_RET_NO(ret);
|
0
Platform/user/configm/ipconfig/parsefile.c → Platform/user/configm/config-server/ipconfig/parsefile.c
Executable file → Normal file
0
Platform/user/configm/ipconfig/parsefile.c → Platform/user/configm/config-server/ipconfig/parsefile.c
Executable file → Normal file
111
Platform/user/configm/configclient.c → Platform/user/configm/config-test/comfigtest.c
Executable file → Normal file
111
Platform/user/configm/configclient.c → Platform/user/configm/config-test/comfigtest.c
Executable file → Normal file
|
@ -4,116 +4,6 @@
|
|||
#include "configm.h"
|
||||
#include "ipconfig.h"
|
||||
|
||||
rpc_client *config_client = NULL;
|
||||
|
||||
rpc_client *config_client_get()
|
||||
{
|
||||
if(config_client == NULL)
|
||||
{
|
||||
config_client = rpc_client_connect_ex("ConfigManger#0");
|
||||
if(config_client == NULL)
|
||||
{
|
||||
rpc_log_error("connect ConfigManger#0 error\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return config_client;
|
||||
}
|
||||
|
||||
ret_code config_construct_msg(uint config_type, uint64 config_id,
|
||||
char* config_data, int config_len,
|
||||
config_msg_t **config_msg, int *msg_len)
|
||||
{
|
||||
config_msg_t *pconfig_msg;
|
||||
|
||||
if(config_data == NULL)
|
||||
{
|
||||
return RET_NULLP;
|
||||
}
|
||||
|
||||
*msg_len = sizeof(config_msg_t) + config_len;
|
||||
pconfig_msg= (config_msg_t *) malloc(*msg_len);
|
||||
if(pconfig_msg == NULL)
|
||||
{
|
||||
return RET_NOMEM;
|
||||
}
|
||||
|
||||
pconfig_msg->source = CONFIG_FROM_WEB;
|
||||
pconfig_msg->config_type = config_type;
|
||||
pconfig_msg->config_id = config_id;
|
||||
|
||||
memcpy(pconfig_msg->config_buff, config_data, config_len);
|
||||
*config_msg = pconfig_msg;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_code config_destroy_msg(config_msg_t *config_msg, int msg_len)
|
||||
{
|
||||
if(config_msg)
|
||||
{
|
||||
memset(config_msg, 0, msg_len);
|
||||
free(config_msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ret_code web_config_exec_sync(uint config_type, uint64 config_id,
|
||||
char* config_data, int config_len,
|
||||
char**output, int *output_len)
|
||||
{
|
||||
rpc_client * client = config_client_get();
|
||||
ret_code code = RET_OK ;
|
||||
config_msg_t *config_msg;
|
||||
int msg_len = 0;
|
||||
|
||||
if(client == NULL)
|
||||
{
|
||||
return RET_ERR;
|
||||
}
|
||||
|
||||
code = config_construct_msg(config_type, config_id, config_data,
|
||||
config_len, &config_msg, &msg_len);
|
||||
ASSERT_RET(code);
|
||||
|
||||
code = rpc_client_call(client, "ConfigManger#0", "cm_config_process",
|
||||
config_msg, msg_len, (pointer)output, output_len);
|
||||
ASSERT_RET_NO(code);
|
||||
|
||||
config_destroy_msg(config_msg, msg_len);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
ret_code web_config_exec_async(uint config_type, uint64 config_id,
|
||||
char* config_data, int config_len,
|
||||
rpc_callback callback, pointer data)
|
||||
{
|
||||
rpc_client * client = config_client_get();
|
||||
config_msg_t *config_msg;
|
||||
int msg_len = 0;
|
||||
|
||||
ret_code ret = RET_OK ;
|
||||
|
||||
if(client == NULL)
|
||||
{
|
||||
return RET_ERR;
|
||||
}
|
||||
|
||||
ret = config_construct_msg(config_type, config_id, config_data,
|
||||
config_len, &config_msg, &msg_len);
|
||||
ASSERT_RET(ret);
|
||||
|
||||
ret = rpc_client_call_async(client, "ConfigManger#0", "cm_config_process",
|
||||
config_msg, msg_len, callback, data);
|
||||
|
||||
config_destroy_msg(config_msg, msg_len);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//big data test
|
||||
//async
|
||||
//sync io
|
||||
|
@ -254,4 +144,3 @@ int main(int argc, char **argv)
|
|||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue