From f7bbd461c8dd4c4194d664218e3a5494efd47003 Mon Sep 17 00:00:00 2001 From: zhanglianghy Date: Wed, 21 Aug 2019 09:46:58 +0800 Subject: [PATCH] =?UTF-8?q?MOD=20aaa-12=20config=5Ftype=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=8C=AA=E8=87=B3config=5Fmanager.h=E9=87=8C=E9=9D=A2=20SOL=20?= =?UTF-8?q?=20config=5Ftype=E5=AE=9A=E4=B9=89=E6=8C=AA=E8=87=B3config=5Fma?= =?UTF-8?q?nager.h=E9=87=8C=E9=9D=A2=20=E4=BF=AE=E6=94=B9=E4=BA=BA?= =?UTF-8?q?=EF=BC=9Azhangliang=20=E6=A3=80=E8=A7=86=E4=BA=BA=EF=BC=9Azhang?= =?UTF-8?q?liang?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Common/config_manager.h | 37 ++++++++++++++----- Platform/common/configm/configmapi.h | 6 --- .../user/configm/config-server/configserver.c | 7 ++-- .../netconfig/ipconfig/ipconfig.c | 7 +++- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/Common/config_manager.h b/Common/config_manager.h index 99878b6da..fcd26b98d 100755 --- a/Common/config_manager.h +++ b/Common/config_manager.h @@ -1,25 +1,34 @@ #ifndef _CONFIG_MANAGER_H #define _CONFIG_MANAGER_H -/* 类型定义 */ +/************************ 操作类型定义 ********************/ -/* IP CONFIG */ -#define NETCONFIG_MODULE 0x00000001 +#define CM_CONFIG_ADD 1 +#define CM_CONFIG_DEL 2 +#define CM_CONFIG_SET 3 +#define CM_CONFIG_GET 4 +#define CM_CONFIG_GET_ALL 5 + +/***********************操作类型定义结束 ********************/ + +/*************************** 模块定义 ************************/ +/* NET CONFIG */ +#define NETCONFIG_MODULE 0x00000001 /* USER MANAGER CONFIG */ -#define USER_MANAGER_CONFIG_MODULE 0x00000002 +#define USER_MANAGER_CONFIG_MODULE 0x00000002 /*PORTAL SERVER CONFIG */ -#define LOCALAUTH_CONFIG_MODULE 0x00000003 +#define LOCALAUTH_CONFIG_MODULE 0x00000003 -#define LOG_CONFIG_MODULE 0x00000004 +#define LOG_CONFIG_MODULE 0x00000004 /*nat config */ -#define NAT_CONFIG_MODULE 0x00000008 +#define NAT_CONFIG_MODULE 0x00000008 +/************************* 模块定义结束 **********************/ - -/* config id define*/ +/************************ config id定义 **********************/ #define IPCONFIG_V4 (uint64)((uint64)NETCONFIG_MODULE<<32|1) #define BR_CONFIG (uint64)((uint64)NETCONFIG_MODULE<<32|2) #define BRIF_CONFIG (uint64)((uint64)NETCONFIG_MODULE<<32|3) @@ -42,5 +51,13 @@ #define NAT4_CONFIG (uint64)((uint64)NAT_CONFIG_MODULE<<32|1) +/************************ config id定义 end**********************/ -#endif \ No newline at end of file + +/* error no, 32位,前16位为模块ID,后16位为模块错误码 */ + +/*0x00000000 ~ 0x0000ffff 为系统预留错误码,用于一般性系统错误,例如内存不够,输入错误等*/ + +/* NETCONFIG_MODULE */ +#define NETCONFIG_IPVALID (uint)((uint)NETCONFIG_MODULE<<16|1) +#endif diff --git a/Platform/common/configm/configmapi.h b/Platform/common/configm/configmapi.h index ccf8d7d54..94d09b86c 100755 --- a/Platform/common/configm/configmapi.h +++ b/Platform/common/configm/configmapi.h @@ -8,12 +8,6 @@ #define CONFIG_FROM_RECOVER1 0x01000000 #define CONFIG_FROM_RECOVER2 0x02000000 -#define CM_CONFIG_ADD 1 -#define CM_CONFIG_DEL 2 -#define CM_CONFIG_SET 3 -#define CM_CONFIG_GET 4 -#define CM_CONFIG_GET_ALL 5 - #define CM_BUFF_SIZE BUF_MAX_SIZE #define CONFIG_RECOVERY_DONE "/tmp/config_recovery" diff --git a/Platform/user/configm/config-server/configserver.c b/Platform/user/configm/config-server/configserver.c index 44df0603b..538411775 100644 --- a/Platform/user/configm/config-server/configserver.c +++ b/Platform/user/configm/config-server/configserver.c @@ -27,18 +27,20 @@ void cm_return(rpc_conn *conn, ret_code err_code, char* err_message) cJSON *res; char *ret_char = NULL; + rpc_log_dbg("result %d:%s\n", err_code, err_message); + res = cJSON_CreateObject(); if(res == NULL) { return; } - cJSON_AddStringToObject(res, "result", err_message); + cJSON_AddNumberToObject(res, "result", err_code); ret_char = cJSON_PrintUnformatted(res); cJSON_Delete(res); - rpc_return_error(conn, err_code, ret_char); + rpc_return(conn, ret_char, strlen(ret_char)+1); rpc_free(ret_char); return; @@ -408,7 +410,6 @@ int main(int argc, char **argv) /* 注册配置处理函数 */ rpc_server_regservice(server, "ConfigManger#0", "cm_config_process", cm_config_process); - //rpc_server_regservice(server, "ConfigManger#0", "test_big_data", test_big_data); for(;;) { diff --git a/Platform/user/configm/config-server/netconfig/ipconfig/ipconfig.c b/Platform/user/configm/config-server/netconfig/ipconfig/ipconfig.c index 28f433ba0..7e3e04e5a 100644 --- a/Platform/user/configm/config-server/netconfig/ipconfig/ipconfig.c +++ b/Platform/user/configm/config-server/netconfig/ipconfig/ipconfig.c @@ -93,8 +93,11 @@ ret_code ip_config_json_parse(pointer input, uint *conf_type, ip_config_t *confi 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; + + if(ip_config->config_type) + { + *conf_type = ip_config->config_type; + } s2j_delete_struct_obj(ip_config); cJSON_Delete(json_obj);