From e939f5705bc7115472582cfcd4115a33861fe6f0 Mon Sep 17 00:00:00 2001 From: zhangtaohz Date: Tue, 27 Aug 2019 16:20:19 +0800 Subject: [PATCH 01/11] =?UTF-8?q?Mod=20aaa-12=20modify=20remote=20format?= =?UTF-8?q?=20RCA=EF=BC=9A=20SOL=EF=BC=9A=20=E4=BF=AE=E6=94=B9=E4=BA=BA?= =?UTF-8?q?=EF=BC=9Azhangtao=20=E6=A3=80=E8=A7=86=E4=BA=BA=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/files/log/deal_logfiles.sh | 111 ++++++++++++++++++++++++++++++++ libs/files/log/rsyslog.conf | 64 ++++++++++++++++++ 2 files changed, 175 insertions(+) create mode 100755 libs/files/log/deal_logfiles.sh create mode 100755 libs/files/log/rsyslog.conf diff --git a/libs/files/log/deal_logfiles.sh b/libs/files/log/deal_logfiles.sh new file mode 100755 index 000000000..a2b04215c --- /dev/null +++ b/libs/files/log/deal_logfiles.sh @@ -0,0 +1,111 @@ +#!/bin/bash + +# 本脚本功能: +# 1. 从logrotate配置文件中取出日志文件的路径(所有日志文件均以logrotate配置文件中第一行指示的路径为前缀), +# 2. 从log_sched配置文件中取出日志文件大小上限 +# 3. 计算步骤1指示的日志文件的总大小,检测日志总大小是否超出上限,若超出则删除所有日志文件 + +function deal_logs () +{ + + # logrotate配置文件路径 + logrotate_log_file="/etc/logrotate.d/log-syslog" + + #log_sched配置文件路径 + log_sched_file="/etc/log-sched.conf" + + # 日志文件前缀 + prefix= + + # 日志大小上限 + size_max=0 + + echo "**********************************************************" + echo " logrotate_cfg: $logrotate_log_file" + echo " log_sched_cfg: $log_sched_file" + echo "**********************************************************" + echo "" + + # logrotate配置文件判空 + if [ ! -e $logrotate_log_file ] ; then + return + fi + + # 从logrotate配置文件中第一行有效行中读取出日志文件前缀 + while read line + do + if [ -z $line ] ; then + continue + fi + + prefix=$line; + echo "**********************************************************" + echo " get log-file-prefix: $prefix" + echo "**********************************************************" + echo "" + + break + done < $logrotate_log_file + + if [ -z $prefix ] ; then + echo "get log file failed" + return + fi + + + # log_sched配置文件判空 + if [ ! -e $log_sched_file ] ; then + return + fi + + #从log_sched配置文件中读取出日志大小上限值 + while read line + do + tmpkey="file.max_size=" + + if [[ $line = *$tmpkey* ]] ; then + if [[ $line = $tmpkey ]] ; then + echo "size_max is empty, do nothing and return" + return + fi + + size_max=${line#$tmpkey} + echo "**********************************************************" + echo " get size_max: $size_max" + echo "**********************************************************" + echo "" + + break + fi + done < $log_sched_file + + + if [ $size_max -eq 0 ] ; then + echo "size_max is 0, do nothing and return" + return + fi + + #定期检查日志总大小是否超限 + path=$prefix* + echo " get path: $path" + + folder_size=$(wc -c $path|grep total |awk '{print $1}') + if [ -z $folder_size ] ; then + folder_size=0 + fi + + echo "cursize: $folder_size" + echo "maxsize: $size_max" + + if [ $folder_size -gt $size_max ] ; then + echo "flush folder $path" + rm -rf $path + sync + fi +} + +deal_logs $@ + + + + diff --git a/libs/files/log/rsyslog.conf b/libs/files/log/rsyslog.conf new file mode 100755 index 000000000..30072be32 --- /dev/null +++ b/libs/files/log/rsyslog.conf @@ -0,0 +1,64 @@ +# /etc/rsyslog.conf Configuration file for rsyslog. +# +# For more information see +# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html +# +# Default logging rules can be found in /etc/rsyslog.d/50-default.conf + + +################# +#### MODULES #### +################# + +module(load="imuxsock") # provides support for local system logging +#module(load="immark") # provides --MARK-- message capability + +# provides UDP syslog reception +#module(load="imudp") +#input(type="imudp" port="514") + +# provides TCP syslog reception +#module(load="imtcp") +#input(type="imtcp" port="514") + +# provides kernel logging support and enable non-kernel klog messages +module(load="imklog" permitnonkernelfacility="on") + +########################### +#### GLOBAL DIRECTIVES #### +########################### + +# +# Use traditional timestamp format. +# To enable high precision timestamps, comment out the following line. +# + +template(name="RFC3164fmt" type="string" string="<%PRI%>%timestamp:::date-rfc3164% %hostname% %syslogtag%%msg%\n") +template(name="RFC5424fmt" type="string" string="<%PRI%>%protocol-version% %timestamp:::date-rfc3339% %hostname% %app-name% %procid% %structured-data% %msgid%%msg%\n") + + +$ActionFileDefaultTemplate RFC5424fmt + +# Filter duplicated messages +$RepeatedMsgReduction on + +# +# Set the default permissions for all log files. +# +$FileOwner syslog +$FileGroup adm +$FileCreateMode 0640 +$DirCreateMode 0755 +$Umask 0022 +$PrivDropToUser syslog +$PrivDropToGroup syslog + +# +# Where to place spool and state files +# +$WorkDirectory /var/spool/rsyslog + +# +# Include all config files in /etc/rsyslog.d/ +# +$IncludeConfig /etc/rsyslog.d/*.conf From 1d76282902773d0401ca5372437d6e88ad1b2c3e Mon Sep 17 00:00:00 2001 From: zhangtaohz Date: Tue, 27 Aug 2019 16:37:49 +0800 Subject: [PATCH 02/11] =?UTF-8?q?Mod=20aaa-12=20=20remove=20warning=20from?= =?UTF-8?q?=20log=5Fcommon.c=20RCA=EF=BC=9A=20SOL=EF=BC=9A=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=BA=EF=BC=9Azhangtao=20=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E4=BA=BA=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Platform/user/ulog/log-sched/log_common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Platform/user/ulog/log-sched/log_common.c b/Platform/user/ulog/log-sched/log_common.c index 73064ae5f..b201e1718 100755 --- a/Platform/user/ulog/log-sched/log_common.c +++ b/Platform/user/ulog/log-sched/log_common.c @@ -7,6 +7,7 @@ #include "ulog.h" #include "log_common.h" #include "ulog_in.h" +#include "sev_sched.h" #define FILTER_CONTENT ":msg,contains,\""MODULE_FMT"\"\n" #define DEFAULT_CONFIG_FILE_TMP "/etc/log-sched.conf.tmp" From 7a22c7fc29ccea0c9287fc2204d231fe0d2713fc Mon Sep 17 00:00:00 2001 From: liangxia Date: Tue, 27 Aug 2019 16:45:48 +0800 Subject: [PATCH 03/11] =?UTF-8?q?Mod=20aaa-12=20=20=E9=9B=86=E4=B8=AD?= =?UTF-8?q?=E6=B6=88=E9=99=A4log=E7=9B=B8=E5=85=B3=E5=B7=A5=E7=A8=8B?= =?UTF-8?q?=E4=B8=AD=E7=9A=84warning=20RCA=EF=BC=9A=20SOL=EF=BC=9A=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=BA=EF=BC=9Aliangxia=20=E6=A3=80?= =?UTF-8?q?=E8=A7=86=E4=BA=BA=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config-server/log_config/log_config_cm.c | 2 ++ .../config-server/log_config/log_config_remote.c | 4 ++-- Platform/user/logging/cmd_file.c | 2 +- Platform/user/logging/cmd_remote.c | 4 ++-- Platform/user/logging/logging_common.c | 4 ++-- Platform/user/logging/logging_common.h | 14 +++++++------- Platform/user/ulog/log-sched/log_common.h | 2 +- Platform/user/ulog/log-sched/log_remote.c | 2 +- Platform/user/ulog/log-sched/sev_sched.c | 2 ++ 9 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Platform/user/configm/config-server/log_config/log_config_cm.c b/Platform/user/configm/config-server/log_config/log_config_cm.c index ca1487e8d..cad81f0d1 100755 --- a/Platform/user/configm/config-server/log_config/log_config_cm.c +++ b/Platform/user/configm/config-server/log_config/log_config_cm.c @@ -4,6 +4,8 @@ #include "rpc_server.h" #include "rpc_client.h" +int access(const char *pathname, int mode); + ret_code log_rpc_exec(char* service_name, char* method_name, pointer input, int input_len, int last_lenth) { if ((input == NULL) diff --git a/Platform/user/configm/config-server/log_config/log_config_remote.c b/Platform/user/configm/config-server/log_config/log_config_remote.c index e17d859fa..6ca945a44 100755 --- a/Platform/user/configm/config-server/log_config/log_config_remote.c +++ b/Platform/user/configm/config-server/log_config/log_config_remote.c @@ -147,7 +147,7 @@ ret_code log_remote_level_config_getall(uint source, /* *.=emerg;*.=alert;*.=crit;*.=err;*.=warn;*.=notice;*.=info @1.1.1.1:514:RFC3164fmt * *.=emerg;*.=alert;*.=crit;*.=err;*.=warn;*.=notice;*.=info @@1.1.1.2:514:RFC5424fmt */ -static ret_code cm_log_prase_host_from_str(const char *input_str, log_remote_host_x_t *ret_host) +static ret_code cm_log_prase_host_from_str(char *const input_str, log_remote_host_x_t *ret_host) { char *pos = NULL; char *pos2 = NULL; @@ -336,7 +336,7 @@ static ret_code cm_log_get_host_from_file_by_addr(const char *file_str, const ch while ((getline(&line, &n, fp)) != -1) { memset(tmp_str, 0, sizeof(tmp_str)); - snprintf(tmp_str, "@%s:", addr_str); + sprintf(tmp_str, "@%s:", addr_str); if (NULL == strstr(line, tmp_str)) { continue; diff --git a/Platform/user/logging/cmd_file.c b/Platform/user/logging/cmd_file.c index db879fb1a..ac5fb38fc 100755 --- a/Platform/user/logging/cmd_file.c +++ b/Platform/user/logging/cmd_file.c @@ -16,7 +16,7 @@ int conf_file(cJSON *json_obj, int argc, char **argv) log_file_t log_file_out = {0}; int level = LOG_INFO; uint config_type = CM_CONFIG_SET; - cJSON *json_output = NULL; + char *json_output = NULL; log_file.is_compress = LOG_UNCOMPRESS; diff --git a/Platform/user/logging/cmd_remote.c b/Platform/user/logging/cmd_remote.c index 276ac8c89..d4ecf602a 100755 --- a/Platform/user/logging/cmd_remote.c +++ b/Platform/user/logging/cmd_remote.c @@ -28,7 +28,7 @@ static log_rfc_t get_rfc_by_name(const char *name) static int conf_remote_by_config_id(cJSON *json_obj, const char *host, const u16 port, const log_rfc_t rfc, uint64 config_id) { log_remote_host_x_t remote = {0}; - cJSON *json_output = NULL; + char *json_output = NULL; int config_type = CM_CONFIG_SET; if (LOG_CONFIG_REMOTE_GET_HOST == config_id) @@ -141,7 +141,7 @@ int conf_remote_level(cJSON *json_obj, int argc, char **argv) log_remote_level_t log_level = {0}; log_remote_level_t log_level_out = {0}; uint config_type = CM_CONFIG_SET; - cJSON *json_output = NULL; + char*json_output = NULL; if (argc < 3) { ULOG_WARNING(g_log, "Not input log level"); diff --git a/Platform/user/logging/logging_common.c b/Platform/user/logging/logging_common.c index 6d5e76183..1dfd8a9bf 100755 --- a/Platform/user/logging/logging_common.c +++ b/Platform/user/logging/logging_common.c @@ -7,7 +7,7 @@ -int set_log_conf(uint config_type, cJSON *json_obj, uint64 config_id, cJSON **json_output) +int set_log_conf(uint config_type, cJSON *json_obj, uint64 config_id, char **json_output) { int ret = -1; char *output; @@ -48,7 +48,7 @@ int set_log_conf(uint config_type, cJSON *json_obj, uint64 config_id, cJSON **js } -int logging_terminal_json_parse(pointer input, pointer config_buff, int conf_id) +int logging_terminal_json_parse(pointer input, pointer config_buff, uint64 conf_id) { cJSON *json_obj = NULL; diff --git a/Platform/user/logging/logging_common.h b/Platform/user/logging/logging_common.h index ea145c606..1054ef0f8 100755 --- a/Platform/user/logging/logging_common.h +++ b/Platform/user/logging/logging_common.h @@ -13,15 +13,15 @@ extern ulog_t *g_log; -int set_log_conf(uint config_type, cJSON *json_obj, uint64 config_id, cJSON **json_output); -int logging_terminal_json_parse(pointer input, pointer config_buff, int conf_id); +int set_log_conf(uint config_type, cJSON *json_obj, uint64 config_id, char **json_output); +int logging_terminal_json_parse(pointer input, pointer config_buff, uint64 conf_id); #define CONF_TERMINAL(type, config_type, json_obj, str_level, on, module_name, conf_id) { \ type terminal = {0}; \ type terminal_out = {0}; \ int level; \ - cJSON *json_output = NULL; \ + char *json_output = NULL; \ \ if ((level = log_str_to_level(str_level)) < 0) { \ ULOG_WARNING(g_log, "Unknown log level:%s", str_level); \ @@ -49,12 +49,12 @@ int logging_terminal_json_parse(pointer input, pointer config_buff, int conf_id) if (logging_terminal_json_parse(json_output, &terminal_out, conf_id) == 0) { \ if (LOG_ON == terminal_out.on) { \ ULOG_DEBUG(g_log, "Log %s get: level=%u, module=%s", \ - (conf_id == LOG_CONFIG_CONSOLE)?"console":"monitor", \ + (conf_id == LOG_CONFIG_CONSOLE)?"console":"monitor", \ terminal_out.level, \ - terminal_out.module); \ + terminal_out.module); \ } else { \ ULOG_DEBUG(g_log, "Log %s get: off", \ - (conf_id == LOG_CONFIG_CONSOLE)?"console":"monitor"); \ + (conf_id == LOG_CONFIG_CONSOLE)?"console":"monitor"); \ } \ } \ } \ @@ -64,7 +64,7 @@ int logging_terminal_json_parse(pointer input, pointer config_buff, int conf_id) #define CMD_PARSE_AND_CONFIG_TERMINAL(type, json_obj, argc, argv, conf_id) { \ log_sw_t on = LOG_ON; \ - char *str_level = DEFAULT_LOG_LEVEL; \ + char *str_level = DEFAULT_LOG_LEVEL; \ uint config_type = CM_CONFIG_SET; \ \ if (argc >= 3) { \ diff --git a/Platform/user/ulog/log-sched/log_common.h b/Platform/user/ulog/log-sched/log_common.h index a87e4a0e6..8f92a9cd0 100755 --- a/Platform/user/ulog/log-sched/log_common.h +++ b/Platform/user/ulog/log-sched/log_common.h @@ -15,7 +15,7 @@ #define REDIRECT_SEPERATE " " -typedef int (*rpc_cb)(pointer *input, const void *arg, char *str_err, int str_len); +typedef int (*rpc_cb)(pointer input, const void *arg, char *str_err, int str_len); extern ulog_t *g_log; extern FILE *g_conf_fp; diff --git a/Platform/user/ulog/log-sched/log_remote.c b/Platform/user/ulog/log-sched/log_remote.c index 31da25c7e..b9ceb935a 100755 --- a/Platform/user/ulog/log-sched/log_remote.c +++ b/Platform/user/ulog/log-sched/log_remote.c @@ -347,7 +347,7 @@ static int __rpc_conf_log_remote(pointer input, const void *arg, char *str_err, log_op_t op; memcpy(&op, arg, sizeof(op)); - int ret = config_log_remote_host(op, (const log_remote_level_t *)input); + int ret = config_log_remote_host(op, (const log_remote_host_t *)input); if (ret < 0) { strncpy(str_err, "Configuring remote of log is faiure", str_len); } diff --git a/Platform/user/ulog/log-sched/sev_sched.c b/Platform/user/ulog/log-sched/sev_sched.c index 6847553c6..63db2589d 100755 --- a/Platform/user/ulog/log-sched/sev_sched.c +++ b/Platform/user/ulog/log-sched/sev_sched.c @@ -5,6 +5,8 @@ #include "log_common.h" #include "ulog_api.h" +#include + #define SEV_TIMEOUT 1 #define SEV_CMD "systemctl restart rsyslog" From 043330c7f27f923cc6a5335b558e5ff104fdd695 Mon Sep 17 00:00:00 2001 From: zhangtaohz Date: Tue, 27 Aug 2019 17:20:50 +0800 Subject: [PATCH 04/11] =?UTF-8?q?Mod=20aaa-12=20=20remove=20warning=20from?= =?UTF-8?q?=20trace=5Fapi=20RCA=EF=BC=9A=20SOL=EF=BC=9A=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=BA=EF=BC=9Azhangtao=20=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E4=BA=BA=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Platform/user/trace/trace-api/trace_api.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Platform/user/trace/trace-api/trace_api.c b/Platform/user/trace/trace-api/trace_api.c index 32a24e97d..1c9c216db 100755 --- a/Platform/user/trace/trace-api/trace_api.c +++ b/Platform/user/trace/trace-api/trace_api.c @@ -134,7 +134,7 @@ static int trace_recv_handle(struct pdelivnl_ctrl_data *ctrl, case TRACE_CFG_POLICY_REPLY: reply = (trace_reply_t *)NLMSG_DATA(n); if (sizeof(*reply) < (n->nlmsg_len - NLMSG_HDRLEN)) { - SYSLOG_WARN("The length of the reply message is required to be %u, but fact length is %u", + SYSLOG_WARN("The length of the reply message is required to be %d, but fact length is %u", sizeof(*reply), (n->nlmsg_len - NLMSG_HDRLEN)); break; } @@ -187,9 +187,9 @@ static trace_ret_t cfg_channel_send(const uint32_t seq, const trace_policy_t *p SYSLOG_DEBUG("Send hdr: is_reply:%d, seq:%u, ver:%u", req.hdr.is_reply, req.hdr.seq, req.hdr.ver); SYSLOG_DEBUG("Send policy:"); SYSLOG_DEBUG(" src family:%u, src ip:%02x, sport:%u", - req.policy.src.family, req.policy.src.addr.ip4, req.policy.sport); + req.policy.src.family, req.policy.src.addr.ip4.s_addr, req.policy.sport); SYSLOG_DEBUG(" dst family:%u, dst ip:%02x, dport:%u", - req.policy.dst.family, req.policy.dst.addr.ip4, req.policy.dport); + req.policy.dst.family, req.policy.dst.addr.ip4.s_addr, req.policy.dport); SYSLOG_DEBUG(" protocol:%u, app_type:%u", req.policy.protocol, req.policy.app_type); /*发送组装好的netlink消息*/ From d01d8d1e1960ae160235c3e6930c3455a23e2363 Mon Sep 17 00:00:00 2001 From: zhangtaohz Date: Tue, 27 Aug 2019 17:28:38 +0800 Subject: [PATCH 05/11] =?UTF-8?q?Mod=20aaa-12=20=20remove=20warning=20from?= =?UTF-8?q?=20trace=5Fapi=20RCA=EF=BC=9A=20SOL=EF=BC=9A=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=BA=EF=BC=9Azhangtao=20=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E4=BA=BA=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Platform/user/trace/trace-api/trace_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Platform/user/trace/trace-api/trace_api.c b/Platform/user/trace/trace-api/trace_api.c index 1c9c216db..6a64c31ba 100755 --- a/Platform/user/trace/trace-api/trace_api.c +++ b/Platform/user/trace/trace-api/trace_api.c @@ -134,7 +134,7 @@ static int trace_recv_handle(struct pdelivnl_ctrl_data *ctrl, case TRACE_CFG_POLICY_REPLY: reply = (trace_reply_t *)NLMSG_DATA(n); if (sizeof(*reply) < (n->nlmsg_len - NLMSG_HDRLEN)) { - SYSLOG_WARN("The length of the reply message is required to be %d, but fact length is %u", + SYSLOG_WARN("The length of the reply message is required to be %u, but fact length is %lu", sizeof(*reply), (n->nlmsg_len - NLMSG_HDRLEN)); break; } From d3bc2158c5d8bc835719350ce885b130f486e627 Mon Sep 17 00:00:00 2001 From: zhangtaohz Date: Tue, 27 Aug 2019 17:31:28 +0800 Subject: [PATCH 06/11] =?UTF-8?q?Mod=20aaa-12=20=20remove=20warning=20from?= =?UTF-8?q?=20trace=5Fapi=20RCA=EF=BC=9A=20SOL=EF=BC=9A=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=BA=EF=BC=9Azhangtao=20=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E4=BA=BA=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Platform/user/trace/trace-api/trace_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Platform/user/trace/trace-api/trace_api.c b/Platform/user/trace/trace-api/trace_api.c index 6a64c31ba..52fe85ddf 100755 --- a/Platform/user/trace/trace-api/trace_api.c +++ b/Platform/user/trace/trace-api/trace_api.c @@ -134,7 +134,7 @@ static int trace_recv_handle(struct pdelivnl_ctrl_data *ctrl, case TRACE_CFG_POLICY_REPLY: reply = (trace_reply_t *)NLMSG_DATA(n); if (sizeof(*reply) < (n->nlmsg_len - NLMSG_HDRLEN)) { - SYSLOG_WARN("The length of the reply message is required to be %u, but fact length is %lu", + SYSLOG_WARN("The length of the reply message is required to be %ld, but fact length is %u", sizeof(*reply), (n->nlmsg_len - NLMSG_HDRLEN)); break; } From efc55b65600a9bf37b823903de2a0c7cb72156e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=95?= Date: Tue, 27 Aug 2019 17:44:34 +0800 Subject: [PATCH 07/11] =?UTF-8?q?Mod=20=20aaa-12=20=E6=9B=B4=E6=96=B0CMake?= =?UTF-8?q?=E4=BA=A4=E5=8F=89=E7=BC=96=E8=AF=91=E9=85=8D=E7=BD=AE=20RCA?= =?UTF-8?q?=EF=BC=9A=20SOL=EF=BC=9A=20=E4=BF=AE=E6=94=B9=E4=BA=BA=EF=BC=9A?= =?UTF-8?q?huangxin=20=E6=A3=80=E8=A7=86=E4=BA=BA=EF=BC=9Ahuangxin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- patchs/cJSON/CMakeLists.txt | 51 ++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/patchs/cJSON/CMakeLists.txt b/patchs/cJSON/CMakeLists.txt index 43f73fb93..aeceab5e4 100644 --- a/patchs/cJSON/CMakeLists.txt +++ b/patchs/cJSON/CMakeLists.txt @@ -12,30 +12,33 @@ set(CJSON_VERSION_SO 1) set(CJSON_UTILS_VERSION_SO 1) set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") -if(PLAT_ARM64) - # this one is important - SET(CMAKE_SYSTEM_NAME Linux) - #this one not so much - SET(CMAKE_SYSTEM_VERSION 1) - - # specify the cross compiler - SET(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) - SET(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) - SET(CMAKE_STRIP aarch64-fsl-linux-strip) - - # specify the cross compile and link flags - # set(CMAKE_C_FLAGS "--sysroot=$ENV{SDKTARGETSYSROOT}") - # set(CMAKE_SHARED_LINKER_FLAGS "--sysroot=$ENV{SDKTARGETSYSROOT}") - - # where is the target environment - SET(CMAKE_FIND_ROOT_PATH ${SDKTARGETSYSROOT}) - - # search for programs in the build host directories - SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) - # for libraries and headers in the target directories - SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) - SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -endif() +if(PLAT_ARM64) + # this one is important + SET(CMAKE_SYSTEM_NAME Linux) + #this one not so much + SET(CMAKE_SYSTEM_VERSION 1) + # this is install root directory + SET(CMAKE_INSTALL_PREFIX /usr) + + # specify the cross compiler + SET(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) + SET(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) + SET(CMAKE_STRIP aarch64-linux-gnu-strip) + + # specify the cross compile and link flags + set(CMAKE_C_FLAGS "--sysroot=$ENV{SDKTARGETSYSROOT}") + set(CMAKE_SHARED_LINKER_FLAGS "--sysroot=$ENV{SDKTARGETSYSROOT}") + SET(CMAKE_LIBRARY_PATH $ENV{SDKTARGETSYSROOT}/usr/lib) + + # where is the target environment + SET(CMAKE_FIND_ROOT_PATH ${SDKTARGETSYSROOT}) + + # search for programs in the build host directories + SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + # for libraries and headers in the target directories + SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() set(custom_compiler_flags) From 48d6b17da27627c50bd524630d092f5687ba685f Mon Sep 17 00:00:00 2001 From: ChenLing Date: Tue, 27 Aug 2019 18:36:49 +0800 Subject: [PATCH 08/11] =?UTF-8?q?Mod=20=20aaa-12=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=AE=A4=E8=AF=81=E9=85=8D=E7=BD=AE=E6=81=A2?= =?UTF-8?q?=E5=A4=8D=E3=80=81=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=20RCA=EF=BC=9A=20RCA=EF=BC=9A=20SOL=EF=BC=9A?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E4=BA=BA=EF=BC=9Achenling=20=E6=A3=80?= =?UTF-8?q?=E8=A7=86=E4=BA=BA=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Common/config_manager.h | 5 +- Platform/build/user.configm.Makefile | 2 +- .../configm/config-server/include/configm.h | 534 +++++++++--------- .../web_config/auth_recover_config.c | 321 +++++++++++ .../web_config/auth_recover_config.h | 41 ++ .../web_config/config-adm/user_authfree.c | 47 +- .../web_config/config-adm/user_authpara.c | 20 +- .../web_config/include/auth_common.h | 9 + .../web_config/include/user_authfree.h | 1 - .../web_config/include/user_authpara.h | 1 - 10 files changed, 686 insertions(+), 295 deletions(-) create mode 100644 Platform/user/configm/config-server/web_config/auth_recover_config.c create mode 100644 Platform/user/configm/config-server/web_config/auth_recover_config.h create mode 100644 Platform/user/configm/config-server/web_config/include/auth_common.h diff --git a/Common/config_manager.h b/Common/config_manager.h index dcbf0869e..c07b5c42f 100755 --- a/Common/config_manager.h +++ b/Common/config_manager.h @@ -45,8 +45,9 @@ #define USER_MANAGER_CONFIG_USER (uint64)((uint64)USER_MANAGER_CONFIG_MODULE<<32|2) #define USER_MANAGER_CONFIG_RECOVER (uint64)((uint64)USER_MANAGER_CONFIG_MODULE<<32|3) -#define AUTHFREE_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|1) -#define FREEPARAMETERS_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|2) +#define AUTHFREE_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|1) +#define FREEPARAMETERS_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|2) +#define AUTH_CONFIG_RECOVER (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|3) #define LOG_CONFIG_CONSOLE (uint64)((uint64)LOG_CONFIG_MODULE<<32|1) diff --git a/Platform/build/user.configm.Makefile b/Platform/build/user.configm.Makefile index b38b6a0f8..cea8c2a28 100755 --- a/Platform/build/user.configm.Makefile +++ b/Platform/build/user.configm.Makefile @@ -33,7 +33,7 @@ COMMON_SRCS = configserver.c \ netconfig/bridge/libbridge/libbridge_if.c netconfig/bridge/libbridge/libbridge_init.c netconfig/bridge/libbridge/libbridge_devif.c\ web_config/config-adm/user_authpara.c \ web_config/config-adm/user_authfree.c \ - web_config/authfree.c web_config/auth_parameters.c\ + web_config/authfree.c web_config/auth_parameters.c web_config/auth_recover_config.c \ user_manager_config/user_recover_config.c user_manager_config/user_group_config.c user_manager_config/user_account_config.c user_manager_config/usermanager-server/array_index.c \ user_manager_config/usermanager-server/user_group.c user_manager_config/usermanager-server/user_mod.c user_manager_config/usermanager-server/user.c \ log_config/log_config_console.c log_config/log_config_init.c log_config/log_config_cm.c log_config/log_config_monitor.c log_config/log_config_remote.c log_config/log_config_file.c \ diff --git a/Platform/user/configm/config-server/include/configm.h b/Platform/user/configm/config-server/include/configm.h index 49c3913ac..e6c97eac7 100755 --- a/Platform/user/configm/config-server/include/configm.h +++ b/Platform/user/configm/config-server/include/configm.h @@ -1,262 +1,272 @@ -#ifndef CONFIGM_H_ -#define CONFIGM_H_ -#include "config_manager.h" -#include "s2j/s2j.h" -#include "../../../../common/rpc/rpc_common.h" -#include "../../../../../Common/commuapinl.h" -#include "../user_manager_config/user_group_config.h" -#include "../user_manager_config/user_account_config.h" -#include "../user_manager_config/user_recover_config.h" -#include "netconfig.h" -#include "log_config.h" -#include "../web_config/authfree.h" -#include "../web_config/auth_parameters.h" -#include "natconfig.h" -#include "vlan_config.h" - -#define RET_CODE_LEN 16 -#define RET_MSG_LEN 128 - -#define CONFIG_INIT_ARRAY \ -{\ - { \ - NETCONFIG_MODULE, \ - net_main \ - }, \ - { \ - LOG_CONFIG_MODULE, \ - log_config_init \ - }, \ - { \ - VLAN_CONFIG_MODULE, \ - vlan_config_init \ - } \ -} - -/* - 1、配置ID,全局唯一,用于寻找对应的配置业务 - 2、配置源检查,全局唯一,用于寻找对应的配置业务, - 从低位到高位,第一位表示WEB,后续配置扩展 - 3、是否配置恢复 - 4、是否是多实例 - 5、配置校验回调函数 - 6、配置处理接口 - 7、配置获取接口 - 8、配置全部获取接口 -*/ -#define CONFIG_SERVICE_ARRAY \ -{ \ - {\ - IPCONFIG_V4, \ - CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \ - FALSE, \ - ip_config_chk, \ - ip_config_proc, \ - ip_config_get, \ - ip_config_get_all \ - },\ - {\ - BR_CONFIG, \ - CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \ - FALSE, \ - br_config_chk, \ - br_config_proc, \ - NULL, \ - NULL \ - },\ - {\ - BRIF_CONFIG, \ - CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \ - FALSE, \ - br_if_config_chk, \ - br_if_config_proc, \ - br_if_config_get, \ - br_if_config_get_all \ - },\ - {\ - BRFDB_CONFIG, \ - CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \ - FALSE, \ - br_fdb_config_chk, \ - NULL, \ - br_fdb_config_get, \ - NULL \ - },\ - {\ - USER_MANAGER_CONFIG_GROUP, \ - CONFIG_FROM_WEB, \ - FALSE, \ - usergroup_config_chk, \ - usergroup_config_proc, \ - usergroup_config_get, \ - usergroup_config_get_all \ - },\ - {\ - USER_MANAGER_CONFIG_RECOVER, \ - CONFIG_FROM_RECOVER1, \ - TRUE, \ - userecover_config_chk, \ - userecover_config_proc, \ - userecover_config_get, \ - userecover_config_get_all \ - },\ - { \ - AUTHFREE_CONFIG, \ - CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \ - FALSE, \ - freeauth_config_chk, \ - freeauth_config_proc, \ - NULL, \ - NULL \ - },\ - {\ - FREEPARAMETERS_CONFIG, \ - CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \ - FALSE, \ - authpara_config_chk, \ - authpara_config_proc, \ - NULL, \ - NULL \ - },\ - {\ - USER_MANAGER_CONFIG_USER, \ - CONFIG_FROM_WEB, \ - FALSE, \ - user_config_chk, \ - user_config_proc, \ - user_config_get, \ - user_config_get_all \ - },\ - {\ - LOG_CONFIG_CONSOLE, \ - CONFIG_FROM_WEB, \ - FALSE, \ - log_console_config_chk, \ - log_console_config_proc, \ - log_console_config_get, \ - log_console_config_getall \ - },\ - {\ - LOG_CONFIG_MONITOR, \ - CONFIG_FROM_WEB, \ - FALSE, \ - log_monitor_config_chk, \ - log_monitor_config_proc, \ - log_monitor_config_get, \ - log_monitor_config_getall \ - },\ - {\ - LOG_CONFIG_REMOTE_ADD_HOST, \ - CONFIG_FROM_WEB, \ - FALSE, \ - log_remote_host_config_chk, \ - log_remote_add_host_config_proc, \ - NULL, \ - NULL \ - },\ - {\ - LOG_CONFIG_REMOTE_DEL_HOST, \ - CONFIG_FROM_WEB, \ - FALSE, \ - log_remote_host_config_chk, \ - log_remote_del_host_config_proc, \ - NULL, \ - NULL \ - },\ - {\ - LOG_CONFIG_REMOTE_LEVEL, \ - CONFIG_FROM_WEB, \ - FALSE, \ - log_remote_level_config_chk, \ - log_remote_level_config_proc, \ - log_remote_level_config_get, \ - log_remote_level_config_getall \ - },\ - {\ - LOG_CONFIG_FILE, \ - CONFIG_FROM_WEB, \ - FALSE, \ - log_file_config_chk, \ - log_file_config_proc, \ - log_file_config_get, \ - log_file_config_getall \ - },\ - {\ - LOG_CONFIG_REMOTE_GET_HOST, \ - CONFIG_FROM_WEB, \ - FALSE, \ - log_remote_host_x_config_chk, \ - NULL, \ - log_remote_host_x_config_get, \ - log_remote_host_x_config_getall \ - },\ - {\ - NAT4_CONFIG, \ - CONFIG_FROM_WEB, \ - FALSE, \ - nat_config_chk, \ - nat_config_proc, \ - NULL, \ - nat_config_get_all \ - },\ - {\ - VLAN_CONFIG, \ - CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \ - FALSE, \ - vlan_config_chk, \ - vlan_config_proc, \ - vlan_config_get, \ - vlan_config_get_all \ - }\ -} - -typedef ret_code (*cm_config_init)(); - -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, - pointer input, int input_len, - pointer output, int *output_len); - -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, - pointer output, int *output_len); - -/* 配置注册 */ -struct _config_init { - uint config_mudlue; - cm_config_init init_callback; -}; -typedef struct _config_init config_init_t; - - -/* 配置注册 */ -struct _config_service { - uint64 config_id; /* 配置ID,全局唯一,用于寻找对应的配置业务*/ - uint config_src; /* 配置源检查,全局唯一,用于寻找对应的配置业务,从低位到高位,第一位表示web,后续配置扩展 */ - boolean recovery; /* 配置恢复处理函数,如果为FALSE则不进行配置恢复 */ - cm_config_chk chk_callback; /* 配置校验回调函数 */ - cm_config_proc proc_callback; /* 配置接口 */ - cm_config_get get_callback; /* 获取配置接口 */ - cm_config_get_all getall_callback; /* 获取所有配置接口 */ -}; - -typedef struct _config_service config_service_t; - -struct _config_result { - char resultCode[RET_CODE_LEN]; - char *message; - char *data; -}; - -typedef struct _config_result config_result_t; - -int cm_format_data(ret_code ret_code, cJSON *json_obj, char *output); - -#endif /* RPC_COMMON_H_ */ - +#ifndef CONFIGM_H_ +#define CONFIGM_H_ +#include "config_manager.h" +#include "s2j/s2j.h" +#include "../../../../common/rpc/rpc_common.h" +#include "../../../../../Common/commuapinl.h" +#include "../user_manager_config/user_group_config.h" +#include "../user_manager_config/user_account_config.h" +#include "../user_manager_config/user_recover_config.h" +#include "netconfig.h" +#include "log_config.h" +#include "../web_config/authfree.h" +#include "../web_config/auth_parameters.h" +#include "../web_config/auth_recover_config.h" +#include "natconfig.h" +#include "vlan_config.h" + +#define RET_CODE_LEN 16 +#define RET_MSG_LEN 128 + +#define CONFIG_INIT_ARRAY \ +{\ + { \ + NETCONFIG_MODULE, \ + net_main \ + }, \ + { \ + LOG_CONFIG_MODULE, \ + log_config_init \ + }, \ + { \ + VLAN_CONFIG_MODULE, \ + vlan_config_init \ + } \ +} + +/* + 1、配置ID,全局唯一,用于寻找对应的配置业务 + 2、配置源检查,全局唯一,用于寻找对应的配置业务, + 从低位到高位,第一位表示WEB,后续配置扩展 + 3、是否配置恢复 + 4、是否是多实例 + 5、配置校验回调函数 + 6、配置处理接口 + 7、配置获取接口 + 8、配置全部获取接口 +*/ +#define CONFIG_SERVICE_ARRAY \ +{ \ + {\ + IPCONFIG_V4, \ + CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \ + FALSE, \ + ip_config_chk, \ + ip_config_proc, \ + ip_config_get, \ + ip_config_get_all \ + },\ + {\ + BR_CONFIG, \ + CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \ + FALSE, \ + br_config_chk, \ + br_config_proc, \ + NULL, \ + NULL \ + },\ + {\ + BRIF_CONFIG, \ + CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \ + FALSE, \ + br_if_config_chk, \ + br_if_config_proc, \ + br_if_config_get, \ + br_if_config_get_all \ + },\ + {\ + BRFDB_CONFIG, \ + CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \ + FALSE, \ + br_fdb_config_chk, \ + NULL, \ + br_fdb_config_get, \ + NULL \ + },\ + {\ + USER_MANAGER_CONFIG_GROUP, \ + CONFIG_FROM_WEB, \ + FALSE, \ + usergroup_config_chk, \ + usergroup_config_proc, \ + usergroup_config_get, \ + usergroup_config_get_all \ + },\ + {\ + USER_MANAGER_CONFIG_RECOVER, \ + CONFIG_FROM_RECOVER1, \ + TRUE, \ + userecover_config_chk, \ + userecover_config_proc, \ + userecover_config_get, \ + userecover_config_get_all \ + },\ + { \ + AUTHFREE_CONFIG, \ + CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \ + FALSE, \ + freeauth_config_chk, \ + freeauth_config_proc, \ + NULL, \ + NULL \ + },\ + {\ + FREEPARAMETERS_CONFIG, \ + CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \ + FALSE, \ + authpara_config_chk, \ + authpara_config_proc, \ + NULL, \ + NULL \ + },\ + {\ + AUTH_CONFIG_RECOVER, \ + CONFIG_FROM_RECOVER1, \ + TRUE, \ + auth_recover_chk, \ + auth_recover_proc, \ + auth_recover_get, \ + auth_recover_get_all \ + },\ + {\ + USER_MANAGER_CONFIG_USER, \ + CONFIG_FROM_WEB, \ + FALSE, \ + user_config_chk, \ + user_config_proc, \ + user_config_get, \ + user_config_get_all \ + },\ + {\ + LOG_CONFIG_CONSOLE, \ + CONFIG_FROM_WEB, \ + FALSE, \ + log_console_config_chk, \ + log_console_config_proc, \ + log_console_config_get, \ + log_console_config_getall \ + },\ + {\ + LOG_CONFIG_MONITOR, \ + CONFIG_FROM_WEB, \ + FALSE, \ + log_monitor_config_chk, \ + log_monitor_config_proc, \ + log_monitor_config_get, \ + log_monitor_config_getall \ + },\ + {\ + LOG_CONFIG_REMOTE_ADD_HOST, \ + CONFIG_FROM_WEB, \ + FALSE, \ + log_remote_host_config_chk, \ + log_remote_add_host_config_proc, \ + NULL, \ + NULL \ + },\ + {\ + LOG_CONFIG_REMOTE_DEL_HOST, \ + CONFIG_FROM_WEB, \ + FALSE, \ + log_remote_host_config_chk, \ + log_remote_del_host_config_proc, \ + NULL, \ + NULL \ + },\ + {\ + LOG_CONFIG_REMOTE_LEVEL, \ + CONFIG_FROM_WEB, \ + FALSE, \ + log_remote_level_config_chk, \ + log_remote_level_config_proc, \ + log_remote_level_config_get, \ + log_remote_level_config_getall \ + },\ + {\ + LOG_CONFIG_FILE, \ + CONFIG_FROM_WEB, \ + FALSE, \ + log_file_config_chk, \ + log_file_config_proc, \ + log_file_config_get, \ + log_file_config_getall \ + },\ + {\ + LOG_CONFIG_REMOTE_GET_HOST, \ + CONFIG_FROM_WEB, \ + FALSE, \ + log_remote_host_x_config_chk, \ + NULL, \ + log_remote_host_x_config_get, \ + log_remote_host_x_config_getall \ + },\ + {\ + NAT4_CONFIG, \ + CONFIG_FROM_WEB, \ + FALSE, \ + nat_config_chk, \ + nat_config_proc, \ + NULL, \ + nat_config_get_all \ + },\ + {\ + VLAN_CONFIG, \ + CONFIG_FROM_WEB|CONFIG_FROM_NETOPEER, \ + FALSE, \ + vlan_config_chk, \ + vlan_config_proc, \ + vlan_config_get, \ + vlan_config_get_all \ + }\ +} + +typedef ret_code (*cm_config_init)(); + +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, + pointer input, int input_len, + pointer output, int *output_len); + +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, + pointer output, int *output_len); + +/* 配置注册 */ +struct _config_init { + uint config_mudlue; + cm_config_init init_callback; +}; +typedef struct _config_init config_init_t; + + +/* 配置注册 */ +struct _config_service { + uint64 config_id; /* 配置ID,全局唯一,用于寻找对应的配置业务*/ + uint config_src; /* 配置源检查,全局唯一,用于寻找对应的配置业务,从低位到高位,第一位表示web,后续配置扩展 */ + boolean recovery; /* 配置恢复处理函数,如果为FALSE则不进行配置恢复 */ + cm_config_chk chk_callback; /* 配置校验回调函数 */ + cm_config_proc proc_callback; /* 配置接口 */ + cm_config_get get_callback; /* 获取配置接口 */ + cm_config_get_all getall_callback; /* 获取所有配置接口 */ +}; + +typedef struct _config_service config_service_t; + +struct _config_result { + char resultCode[RET_CODE_LEN]; + char *message; + char *data; +}; + +typedef struct _config_result config_result_t; + +int cm_format_data(ret_code ret_code, cJSON *json_obj, char *output); + +#endif /* RPC_COMMON_H_ */ + diff --git a/Platform/user/configm/config-server/web_config/auth_recover_config.c b/Platform/user/configm/config-server/web_config/auth_recover_config.c new file mode 100644 index 000000000..53f147647 --- /dev/null +++ b/Platform/user/configm/config-server/web_config/auth_recover_config.c @@ -0,0 +1,321 @@ +#include "auth_recover_config.h" +#include +#include "../include/parsefile.h" +#include "../include/configm.h" +#include "rpc.h" +#include "s2j/s2j.h" +#include "commuapinl.h" +#include "../Platform/common/database/database.h" +#include "config_manager.h" +#include "authfree.h" +#include "auth_parameters.h" +#include "include/user_authfree.h" +#include "include/user_authpara.h" +#include "include/auth_common.h" + +void * auth_hdbc = NULL; //认证数据库连接句柄 +extern freeauth_configure_t freeauth_array[]; +extern auth_parameters_t *auth_para; + + +/*数据库重连*/ +void db_connect() +{ + if(NULL == auth_hdbc) + { + auth_hdbc = connect_database(AUTHRECOVER_DATABASE_ID); + } +} + + +/* 查询未认证权限恢复 */ +void auth_getrule_db(char ** rule_db) +{ + int num = 0; + int size = 0; + char *ret_authrule = NULL; + + /*数据库重连*/ + db_connect(); + if(NULL == auth_hdbc) + { + return; + } + + char *select_sql = "SELECT rule_priority, name, sip, dip, dport, flag FROM `authfree`"; + ret_authrule = select_datebase_by_number(AUTHRECOVER_DATABASE_ID, auth_hdbc, "authfree", select_sql, 1, 0, &num, 0); + + if(0 == num || NULL == ret_authrule) + { + return; + } + + size = strlen(ret_authrule)+1; + char * point = (char*)malloc(size); + if(NULL == point) + { + return; + } + memset(point, 0, size); + memcpy(point, ret_authrule, size); + *rule_db = point; //在函数外面释放 + + return; +} + +/* 查询认证参数恢复 */ +void auth_getpara_db(char ** parameters_db) +{ + int num = 0; + int size = 0; + char *ret_parameters = NULL; + + /*数据库重连*/ + db_connect(); + if(NULL == auth_hdbc) + { + return; + } + + char *select_sql = "SELECT port, timehorizon, failcount, dip, locktime, aging_time FROM `authparas`"; + ret_parameters = select_datebase_by_number(AUTHRECOVER_DATABASE_ID, auth_hdbc, "authparas", select_sql, 1, 0, &num, 0); + + if(0 == num || NULL == ret_parameters) + { + return; + } + + size = strlen(ret_parameters)+1; + char * point = (char*)malloc(size); + if(NULL == point) + { + return; + } + memset(point, 0, size); + memcpy(point, ret_parameters, size); + *parameters_db = point; //在函数外面释放 + + return; +} + + +ret_code auth_recover_chk(uint source, uint *config_type, + pointer input, int *input_len, + pointer output, int *output_len) +{ + ret_code ret = RET_OK; + return ret; +} + +ret_code auth_recover_proc(uint source, uint config_type, + pointer input, int input_len, + pointer output, int *output_len) +{ + ret_code ret = RET_OK; + return ret; +} + +ret_code auth_recover_get(uint source, + pointer input, int input_len, + pointer output, int *output_len) +{ + ret_code ret = RET_OK; + return ret; +} + +/*配置恢复未认证权限、认证参数*/ +ret_code auth_recover_get_all(uint source, + pointer output, int *output_len) +{ + ret_code ret = RET_OK; + char *rule_db = NULL; + char *parameters_db = NULL; + + if(CONFIG_FROM_RECOVER1 != source) + { + return ret; + } + + auth_hdbc = connect_database(AUTHRECOVER_DATABASE_ID); + + if(NULL == auth_hdbc) + { + return RET_SYSERR; + } + + /*初始化认证参数结构体指针*/ + authparInit(); + + auth_getrule_db(&rule_db); + if(NULL != rule_db) + { + /*输出参数为json字符串*/ + cJSON * cjson = cJSON_Parse(rule_db); + if(NULL == cjson) + { + free(rule_db); + ret = RET_ERR; + return ret; + } + + cJSON * data = cJSON_GetObjectItem(cjson, "data"); + if(NULL == data) + { + free(rule_db); + cJSON_Delete(cjson); + return RET_ERR; + } + + int mun_rule = cJSON_GetArraySize(data); + if(0 == mun_rule) + { + free(rule_db); + cJSON_Delete(cjson); + return RET_ERR; + } + + /*创建freeauth_configure_t结构体对象 */ + s2j_create_struct_obj(freeauth_buff, freeauth_configure_t); + + if(freeauth_buff == NULL) { + cJSON_Delete(cjson); + return RET_NOMEM; + } + + for (int i = 0; i < mun_rule; i++) + { + cJSON *pArrayItem = cJSON_GetArrayItem(data, i); + + if(pArrayItem) { + /*获取未认证权限优先级键值对*/ + cJSON *rule_priority = cJSON_GetObjectItem(pArrayItem, "rule_priority"); + + if(rule_priority) { + freeauth_buff->rule_priority = rule_priority->valueint; + } + + /*未认证权限名称*/ + cJSON *name = cJSON_GetObjectItem(pArrayItem, "name"); + + if(name) { + strncpy(freeauth_buff->name, name->valuestring, 31); + } + + /*源IP地址*/ + cJSON *sip = cJSON_GetObjectItem(pArrayItem, "sip"); + + if(sip) { + freeauth_buff->sip = sip->valueint; + } + + /*目的IP地址*/ + cJSON *dip = cJSON_GetObjectItem(pArrayItem, "dip"); + + if(dip) { + freeauth_buff->dip = dip->valueint; + } + + /*目的端口号*/ + cJSON *dport = cJSON_GetObjectItem(pArrayItem, "dport"); + + if(dport) { + freeauth_buff->dport = dport->valueint; + } + + /*状态标志位*/ + cJSON *flag = cJSON_GetObjectItem(pArrayItem, "flag"); + + if(flag) { + freeauth_buff->flag = flag->valueint; + } + + printf("freeauth_buff->name = %p %s\n", &freeauth_buff->name, freeauth_buff->name); + + /*把数据库的内容读出来 然后加到全局变量里边去*/ + for(i = 0; i < RULE_MAX_NUM; i++) { + printf("the name is :%s\n", freeauth_array[i].name); + /*两个字符串相等 strcmp值为0*/ + int a = strlen(freeauth_array[i].name); + printf("%d\n", a); + + if(0 == strlen(freeauth_array[i].name)) { + printf("%s(%d) freeauth_array[%d] = %p\n", __FUNCTION__, __LINE__, i, &freeauth_array[i]); + memset(&freeauth_array[i], 0, sizeof(freeauth_configure_t)); + freeauth_array[i].rule_priority = freeauth_buff->rule_priority; + strncpy(freeauth_array[i].name, freeauth_buff->name, 32); + freeauth_array[i].sip = freeauth_buff->sip; + freeauth_array[i].dip = freeauth_buff->dip; + freeauth_array[i].dport = freeauth_buff->dport; + freeauth_array[i].flag = freeauth_buff->flag; + printf("[%d %s %d %d %d %d %d]\n", freeauth_array[i].rule_priority, freeauth_array[i].name, freeauth_array[i].sip, + freeauth_array[i].dip, freeauth_array[i].dport, freeauth_array[i].dport, i); + break; + } + + } + + freeauth_buff++; + } + } + + s2j_delete_struct_obj(freeauth_buff); + free(rule_db); + + return RET_OK; + } + + + auth_getpara_db(¶meters_db); + if(NULL != parameters_db) + { + /*输出参数为json字符串*/ + cJSON * cjson_para = cJSON_Parse(parameters_db); + if(NULL == cjson_para) + { + free(parameters_db); + ret = RET_ERR; + return ret; + } + + cJSON * data_para = cJSON_GetObjectItem(cjson_para, "data"); + if(NULL == data_para) + { + free(parameters_db); + cJSON_Delete(cjson_para); + return RET_ERR; + } + + /*创建freeauth_configure_t结构体对象 */ + s2j_create_struct_obj(auth_parameters, auth_parameters_t); + + if(auth_parameters == NULL) { + cJSON_Delete(cjson_para); + return RET_NOMEM; + } + + /*反序列化数据到freeauth_configure_t结构体对象 */ + s2j_struct_get_basic_element(auth_parameters, data_para, int, port); + s2j_struct_get_basic_element(auth_parameters, data_para, int, timehorizon); + s2j_struct_get_basic_element(auth_parameters, data_para, int, failcount); + s2j_struct_get_basic_element(auth_parameters, data_para, int, locktime); + s2j_struct_get_basic_element(auth_parameters, data_para, int, aging_time); + + /*将数据存入全局结构体指针*/ + if(auth_para) { + auth_para->port = auth_parameters->port; + auth_para->timehorizon = auth_parameters->timehorizon; + auth_para->failcount = auth_parameters->failcount; + auth_para->locktime = auth_parameters->locktime; + auth_para->aging_time = auth_parameters->aging_time; + } + + s2j_delete_struct_obj(auth_parameters); + cJSON_Delete(cjson_para); + } + + return RET_OK; +} + + + + diff --git a/Platform/user/configm/config-server/web_config/auth_recover_config.h b/Platform/user/configm/config-server/web_config/auth_recover_config.h new file mode 100644 index 000000000..abef11537 --- /dev/null +++ b/Platform/user/configm/config-server/web_config/auth_recover_config.h @@ -0,0 +1,41 @@ +#ifndef AUTH_RECOVER_H_ +#define AUTH_RECOVER_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "rpc_common.h" + +/*数据库重连*/ +void db_connect(); + +/* 查询未认证权限恢复 */ +void auth_getrule_db(char ** rule_db); + +/* 查询认证参数恢复 */ +void auth_getpara_db(char ** parameters_db); + +ret_code auth_recover_chk(uint source, uint *config_type, + pointer input, int *input_len, + pointer output, int *output_len); + +ret_code auth_recover_proc(uint source, uint config_type, + pointer input, int input_len, + pointer output, int *output_len); + +ret_code auth_recover_get(uint source, + pointer input, int input_len, + pointer output, int *output_len); + +/*配置恢复未认证权限、认证参数*/ +ret_code auth_recover_get_all(uint source, + pointer output, int *output_len); + + + +#endif \ No newline at end of file diff --git a/Platform/user/configm/config-server/web_config/config-adm/user_authfree.c b/Platform/user/configm/config-server/web_config/config-adm/user_authfree.c index 4ce0b9fed..dbc0e6842 100644 --- a/Platform/user/configm/config-server/web_config/config-adm/user_authfree.c +++ b/Platform/user/configm/config-server/web_config/config-adm/user_authfree.c @@ -3,11 +3,10 @@ #include "../Platform/common/database/database.h" #include "../include/user_authfree.h" #include "string.h" - -#define AUTHFREE_DATABASE_ID (16) -#define AUTHFREE_TABLE "authfree" +#include "../include/auth_common.h" extern freeauth_configure_t freeauth_array[]; +extern void * auth_hdbc; static char *authfreemes[] = {"addrule success", "addrule fail", "rule existed", "modrule success", "modrule failure", "rule not found", "delrule success", "delrule fail", "rulenum exceed maxnum", @@ -37,7 +36,7 @@ static int is_rule_full(void) /*增加未认证权限规则*/ void add_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int dport, int flag, authfree_result_t *authfree_result) { - void *authfree_hdbc; + //void *authfree_hdbc; char *ret_sql = NULL; int ret_add; int ret; @@ -54,10 +53,9 @@ void add_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int authfree_result->message = get_sql_ret_message(authfree_result->resultcode); return; } - - printf("开始连接数据库\n"); /* 连接数据库 */ + #if 0 authfree_hdbc = connect_database(AUTHFREE_DATABASE_ID); if(NULL == authfree_hdbc) { @@ -67,7 +65,10 @@ void add_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int /*长整型bigint 浮点型double 字符串character(10)*/ printf("authfree_hdbc = %p\n", authfree_hdbc); - ret = create_database_table(AUTHFREE_DATABASE_ID, authfree_hdbc, "authfree", "create table authfree(rule_priority bigint, name character(32), sip bigint, dip bigint, dport bigint, flag bigint)"); + #endif + + /*建表*/ + ret = create_database_table(AUTHRECOVER_DATABASE_ID, auth_hdbc, "authfree", "create table authfree(rule_priority bigint, name character(32), sip bigint, dip bigint, dport bigint, flag bigint)"); printf("%d \n", ret); #if 0 @@ -89,7 +90,7 @@ void add_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int /* 根据指定信息查询数据库的获取的结果的条目数 条目数大于10 则不能再添加 */ char *select_num = "SELECT rule_priority, name, sip, dip, dport, flag FROM `authfree`"; - ret = get_select_datebase_number(AUTHFREE_DATABASE_ID, authfree_hdbc, "authfree", select_num, &num_sql, 6, + ret = get_select_datebase_number(AUTHRECOVER_DATABASE_ID, auth_hdbc, "authfree", select_num, &num_sql, 6, DB_DATA_INT_TYPE, sizeof(rule_priority), rule_priority, DB_DATA_STRING_TYPE, strlen(name) + 1, name, DB_DATA_INT_TYPE, sizeof(sip), sip, @@ -109,7 +110,7 @@ void add_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int /* 向authfree表中添加:未认证权限名称、内部源IP地址、目的IP地址、目的端口号 */ char *addfree_sql = "INSERT INTO `authfree` SET rule_priority = ?, name = ?, sip = ?, dip = ?, dport = ?, flag = ?"; - ret_add = update_database(AUTHFREE_DATABASE_ID, authfree_hdbc, DB_OP_INSERT, AUTHFREE_TABLE, addfree_sql, 6, + ret_add = update_database(AUTHRECOVER_DATABASE_ID, auth_hdbc, DB_OP_INSERT, AUTHFREE_TABLE, addfree_sql, 6, DB_DATA_INT_TYPE, sizeof(rule_priority), rule_priority, DB_DATA_STRING_TYPE, strlen(name) + 1, name, DB_DATA_INT_TYPE, sizeof(sip), sip, @@ -167,7 +168,7 @@ void add_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int /*修改未认证权限*/ void mod_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int dport, int flag, authfree_result_t *authfree_result) { - void *authfree_hdbc; + //void *authfree_hdbc; char *ret_sql = NULL; int ret_mod; int ret; @@ -179,9 +180,10 @@ void mod_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int } printf("开始连接数据库\n"); - + + #if 0 /* 连接数据库 */ - authfree_hdbc = connect_database(AUTHFREE_DATABASE_ID); + authfree_hdbc = connect_database(AUTHRECOVER_DATABASE_ID); if(NULL == authfree_hdbc) { printf("connetc failure\n"); @@ -190,7 +192,10 @@ void mod_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int /*长整型bigint 浮点型double 字符串character(10)*/ printf("authfree_hdbc = %p\n", authfree_hdbc); - ret = create_database_table(AUTHFREE_DATABASE_ID, authfree_hdbc, "authfree", "create table authfree(name character(32), sip bigint, dip bigint, dport bigint)"); + #endif + + /*建表*/ + ret = create_database_table(AUTHRECOVER_DATABASE_ID, auth_hdbc, "authfree", "create table authfree(name character(32), sip bigint, dip bigint, dport bigint)"); printf("%d \n", ret); #if 0 @@ -211,7 +216,7 @@ void mod_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int /*修改authfree表中内部源IP地址、目的IP地址、目的端口号 未认证权限名称不能修改 */ char *modfree_sql = "UPDATE `authfree` SET rule_priority = ?, sip = ?, dip = ?, dport = ? ,flag = ? WHERE name = ?"; - ret_mod = update_database(AUTHFREE_DATABASE_ID, authfree_hdbc, DB_OP_UPDATE, AUTHFREE_TABLE, modfree_sql, 6, + ret_mod = update_database(AUTHRECOVER_DATABASE_ID, auth_hdbc, DB_OP_UPDATE, AUTHFREE_TABLE, modfree_sql, 6, DB_DATA_INT_TYPE, sizeof(rule_priority), rule_priority, DB_DATA_INT_TYPE, sizeof(sip), sip, DB_DATA_INT_TYPE, sizeof(dip), dip, @@ -262,7 +267,7 @@ void mod_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int /*删除未认证权限*/ void del_authfree(char *name, authfree_result_t *authfree_result) { - void *authfree_hdbc; + //void *authfree_hdbc; char *ret_sql = NULL; int ret_del; int ret; @@ -272,9 +277,8 @@ void del_authfree(char *name, authfree_result_t *authfree_result) if(NULL == authfree_result) { return; } - - printf("开始连接数据库\n"); - + + #if 0 /* 连接数据库 */ authfree_hdbc = connect_database(AUTHFREE_DATABASE_ID); @@ -285,7 +289,10 @@ void del_authfree(char *name, authfree_result_t *authfree_result) /*长整型bigint 浮点型double 字符串character(10)*/ printf("authfree_hdbc = %p\n", authfree_hdbc); - ret = create_database_table(AUTHFREE_DATABASE_ID, authfree_hdbc, "authfree", "create table authfree(name character(32), sip bigint, dip bigint, dport bigint)"); + #endif + + /*建表*/ + ret = create_database_table(AUTHRECOVER_DATABASE_ID, auth_hdbc, "authfree", "create table authfree(name character(32), sip bigint, dip bigint, dport bigint)"); printf("%d \n", ret); @@ -308,7 +315,7 @@ void del_authfree(char *name, authfree_result_t *authfree_result) /*删除authfree表中未认证权限名称、内部源IP地址、目的IP地址、目的端口号 */ char *delfree_sql = "DELETE FROM authfree WHERE name = ?"; - ret_del = update_database(AUTHFREE_DATABASE_ID, authfree_hdbc, DB_OP_DEL, AUTHFREE_TABLE, delfree_sql, 1, + ret_del = update_database(AUTHRECOVER_DATABASE_ID, auth_hdbc, DB_OP_DEL, AUTHFREE_TABLE, delfree_sql, 1, DB_DATA_STRING_TYPE, strlen(name) + 1, name); printf("the value of ret:%d\n", ret_del); diff --git a/Platform/user/configm/config-server/web_config/config-adm/user_authpara.c b/Platform/user/configm/config-server/web_config/config-adm/user_authpara.c index be2138df9..86e0ebb2b 100644 --- a/Platform/user/configm/config-server/web_config/config-adm/user_authpara.c +++ b/Platform/user/configm/config-server/web_config/config-adm/user_authpara.c @@ -8,11 +8,11 @@ #include "../../../../../Common/commuapinl.h" #include "../auth_parameters.h" #include "../Platform/common/database/database.h" - -#define AUTHPARA_DATABASE_ID 15 -#define AUTHPARA_TABLE "authparas" +#include "../include/user_authpara.h" +#include "../include/auth_common.h" extern auth_parameters_t *auth_para; +extern void * auth_hdbc; char * mes[]={"mod success", "mod failure"}; @@ -20,7 +20,7 @@ char * mes[]={"mod success", "mod failure"}; void mod_authpara(int port, int timehorizon, int failcount, int locktime, int aging_time, configure_result_t *configure_result) { authparInit(); - void * authpara_hdbc; + //void * authpara_hdbc; char * ret_sql = NULL; int ret; int num; @@ -31,6 +31,7 @@ void mod_authpara(int port, int timehorizon, int failcount, int locktime, int ag return; } + #if 0 printf("开始连接数据库\n"); /* 连接数据库 */ @@ -43,15 +44,18 @@ void mod_authpara(int port, int timehorizon, int failcount, int locktime, int ag /*长整型bigint 浮点型double 字符串character(10)*/ printf("authpara_hdbc = %p\n", authpara_hdbc); - ret = create_database_table(AUTHPARA_DATABASE_ID, authpara_hdbc, "authparas", "create table authparas(port bigint, timehorizon bigint, failcount bigint, locktime bigint, aging_time bigint)"); + #endif + + /*建表*/ + ret = create_database_table(AUTHRECOVER_DATABASE_ID, auth_hdbc, "authparas", "create table authparas(port bigint, timehorizon bigint, failcount bigint, locktime bigint, aging_time bigint)"); printf("%d \n",ret); /* 存authpara表 默认值 */ char *user1_authpara = "INSERT INTO `authparas` SET port = 8080, timehorizon = 1, failcount = 5, locktime = 10, aging_time = 10"; - int ret_addauthpara = update_database(AUTHPARA_DATABASE_ID, authpara_hdbc, DB_OP_INSERT, AUTHPARA_TABLE, user1_authpara, 0); + int ret_addauthpara = update_database(AUTHRECOVER_DATABASE_ID, auth_hdbc, DB_OP_INSERT, AUTHPARA_TABLE, user1_authpara, 0); if(0 != ret_addauthpara) { - disconnect_database(AUTHPARA_DATABASE_ID , authpara_hdbc); // ret_release记录日志 + disconnect_database(AUTHRECOVER_DATABASE_ID , auth_hdbc); // ret_release记录日志 configure_result->resultcode = 1; configure_result->message = mes[configure_result->resultcode]; return; @@ -59,7 +63,7 @@ void mod_authpara(int port, int timehorizon, int failcount, int locktime, int ag char *user_authpara = "UPDATE `authparas` SET port = ?, timehorizon = ?, failcount = ?, locktime = ?, aging_time = ?"; - ret = update_database(AUTHPARA_DATABASE_ID, authpara_hdbc, DB_OP_UPDATE, AUTHPARA_TABLE, user_authpara, 5, + ret = update_database(AUTHRECOVER_DATABASE_ID, auth_hdbc, DB_OP_UPDATE, AUTHPARA_TABLE, user_authpara, 5, DB_DATA_INT_TYPE, sizeof(port), port, DB_DATA_INT_TYPE, sizeof(timehorizon), timehorizon, DB_DATA_INT_TYPE, sizeof(failcount), failcount, diff --git a/Platform/user/configm/config-server/web_config/include/auth_common.h b/Platform/user/configm/config-server/web_config/include/auth_common.h new file mode 100644 index 000000000..2587b3656 --- /dev/null +++ b/Platform/user/configm/config-server/web_config/include/auth_common.h @@ -0,0 +1,9 @@ +#ifndef AUTH_COMMON_H_ +#define AUTH_COMMON_H_ + +#define AUTHPARA_TABLE "authparas" +#define AUTHFREE_TABLE "authfree" + +#define AUTHRECOVER_DATABASE_ID (15) + +#endif \ No newline at end of file diff --git a/Platform/user/configm/config-server/web_config/include/user_authfree.h b/Platform/user/configm/config-server/web_config/include/user_authfree.h index 4c3496268..a62356a9e 100644 --- a/Platform/user/configm/config-server/web_config/include/user_authfree.h +++ b/Platform/user/configm/config-server/web_config/include/user_authfree.h @@ -11,7 +11,6 @@ #define DELAUTHFREE_FAIL_DATABASE (7) //删除未认证权限失败 #define RULENUM_EXCEED (8) //未认证权限数量超过最大值 - typedef enum { ADD_RULE_OK = 0, ADD_RULE_ERR = 1, diff --git a/Platform/user/configm/config-server/web_config/include/user_authpara.h b/Platform/user/configm/config-server/web_config/include/user_authpara.h index c5df56948..4fc142033 100644 --- a/Platform/user/configm/config-server/web_config/include/user_authpara.h +++ b/Platform/user/configm/config-server/web_config/include/user_authpara.h @@ -4,7 +4,6 @@ #include #include "../Platform/user/configm/config-server/web_config/auth_parameters.h" - #define ADDUSER_FAIL_NAMEDUP 4 //用户名重名 #define MODAUTHPARA_SUCCESS 0 //修改认证信息成功 From f6536d140974a10048dc6b3d600bddc3161b0449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=95?= Date: Tue, 27 Aug 2019 18:49:05 +0800 Subject: [PATCH 09/11] =?UTF-8?q?Mod=20=20aaa-12=20=E6=9B=B4=E6=96=B0Makef?= =?UTF-8?q?ile=E6=94=AF=E6=8C=81SDKTARGETSYSROOT=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F=20RCA=EF=BC=9A=20SOL=EF=BC=9A=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=BA=EF=BC=9Ahuangxin=20=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E4=BA=BA=EF=BC=9Ahuangxin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Common/common.Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/common.Makefile b/Common/common.Makefile index 5102fb7d8..f53fb2e86 100755 --- a/Common/common.Makefile +++ b/Common/common.Makefile @@ -119,8 +119,8 @@ LINUX_KERNEL := $(HUACHENG_LINUX_KERNEL) endif # 设置 ARM64 平台 SDK 头文件和库文件路径 -ARM64_SDK_INCLUDE := $(SDKTARGETSYSROOT)/include -ARM64_SDK_LIBDIR := $(SDKTARGETSYSROOT) +ARM64_SDK_INCLUDE := $(SDKTARGETSYSROOT)/usr/include +ARM64_SDK_LIBDIR := $(SDKTARGETSYSROOT)/usr/lib # 设置平台安装子目录 CPU_ARM64_DIR := ARM64 From bb44ab5b158ce12484a439e893cadb26abf0850f Mon Sep 17 00:00:00 2001 From: yinbin Date: Tue, 27 Aug 2019 04:08:10 -0700 Subject: [PATCH 10/11] =?UTF-8?q?Add=20aaa-12=20=E4=BF=AE=E6=94=B9vlan=5Fg?= =?UTF-8?q?et=5Fchk=E4=BB=A5=E5=8F=8A=E5=9C=A8webserver=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E4=B8=AD=E6=96=B0=E5=A2=9Evlan=E5=9B=9E=E8=B0=83=20SOL=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9vlan=5Fget=5Fchk=E4=BB=A5=E5=8F=8A=E5=9C=A8we?= =?UTF-8?q?bserver=E6=A1=86=E6=9E=B6=E4=B8=AD=E6=96=B0=E5=A2=9Evlan?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=20=E4=BF=AE=E6=94=B9=E4=BA=BA=EF=BC=9Ayinbin?= =?UTF-8?q?=20=E6=A3=80=E8=A7=86=E4=BA=BA=EF=BC=9Ayinbin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yinbin --- .../config-server/vlan_config/vlan_config.c | 21 ++++++++++++------- libs/src/lighttpd-1.4.51/src/mod_webm.c | 16 ++++++++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/Platform/user/configm/config-server/vlan_config/vlan_config.c b/Platform/user/configm/config-server/vlan_config/vlan_config.c index ca2e8ab2d..ac7d9ad33 100644 --- a/Platform/user/configm/config-server/vlan_config/vlan_config.c +++ b/Platform/user/configm/config-server/vlan_config/vlan_config.c @@ -1824,6 +1824,7 @@ ret_code vid_value_chk(int vid) ret_code vid_num_chk(char *if_name, operation_type op_type, int num) { int ifnode = -1; + int total = 0; if(!if_name){ printf("[vlan]vid_num_chk: if_name is null.\n"); return RET_NULLP; @@ -1831,13 +1832,15 @@ ret_code vid_num_chk(char *if_name, operation_type op_type, int num) printf("[vlan]vid_num_chk: if_name=%s, op_type=%d, num=%d\n", if_name, op_type, num); ifnode = get_ifnode_from_global(if_name); if(ifnode == -1){ - printf("[vlan]vid_num_chk: get ifnode empty, return\n"); - return RET_OK; + total = num; + printf("[vlan]vid_num_chk: get ifnode empty, total = %d\n", total); } - if(op_type == OP_ADD && - g_if_vlan_info[ifnode].vidcnt + num > EACH_PORT_MAX_VLAN_NUM){ - printf("[vlan]vid_num_chk: ADD operation's vid num(%d+%d=%d) > EACH_PORT_MAX_VLAN_NUM\n", - g_if_vlan_info[ifnode].vidcnt, num, g_if_vlan_info[ifnode].vidcnt + num); + else{ + total = g_if_vlan_info[ifnode].vidcnt + num; + printf("[vlan]vid_num_chk: total = %d + %d = %d\n", g_if_vlan_info[ifnode].vidcnt, num, total); + } + if(op_type == OP_ADD && total > EACH_PORT_MAX_VLAN_NUM){ + printf("[vlan]vid_num_chk: ADD operation's total vid num > EACH_PORT_MAX_VLAN_NUM\n"); return RET_INPUTERR; } @@ -2105,12 +2108,16 @@ ret_code vlan_config_get_chk(uint source, pointer input) printf("[vlan]vlan_config_get_chk: get json parse failed(%d).\n", ret); return ret; } +#if 0 for(i = 0; i < MAX_INTERFACES; i++){ if(interface[i] == 1){ + printf("[vlan]find a node[%d]\n", i); return RET_OK; } } return RET_INPUTERR; +#endif + return RET_OK; } /************************************************************ @@ -2148,7 +2155,7 @@ ret_code vlan_config_chk(uint source,uint *config_type, if(ret != RET_OK){ goto out; } - *config_type = oper_type; + //*config_type = oper_type; printf("[vlan]vlan_config_chk: operate_type=%d\n", oper_type); if(oper_type == CM_CONFIG_SET){ printf("[vlan]vlan_config_chk: SET chk\n"); diff --git a/libs/src/lighttpd-1.4.51/src/mod_webm.c b/libs/src/lighttpd-1.4.51/src/mod_webm.c index f5473f59f..e62a09694 100644 --- a/libs/src/lighttpd-1.4.51/src/mod_webm.c +++ b/libs/src/lighttpd-1.4.51/src/mod_webm.c @@ -38,6 +38,8 @@ typedef enum { WEBM_HANDLE_INVALID_INDEX = -1, WEBM_HANDLE_CONFIG_UUID_USER, WEBM_HANDLE_CONFIG_DETAIL_USER, WEBM_HANDLE_CONFIG_IPV4, + WEBM_HANDLE_CONFIG_VLAN_SET, + WEBM_HANDLE_CONFIG_VLAN_GET, WEBM_HANDLE_MAX } webm_handle_index; @@ -169,6 +171,20 @@ extern int webm_config_send_proc(server *srv, uint32_t config_type, uint64 confg CM_CONFIG_SET, \ IPCONFIG_V4, \ webm_config_send_proc \ + }, \ + {\ + WEBM_HANDLE_CONFIG_VLAN_SET, \ + "/FSG-CF/setvlan", \ + CM_CONFIG_SET, \ + VLAN_CONFIG, \ + webm_config_send_proc \ + }, \ + {\ + WEBM_HANDLE_CONFIG_VLAN_GET, \ + "/FSG-GF/getvlan", \ + CM_CONFIG_GET, \ + VLAN_CONFIG, \ + webm_config_send_proc \ } \ \ } From 86c714344f2caa7d78d077cc8dab547d3718549a Mon Sep 17 00:00:00 2001 From: dongxiancun Date: Tue, 27 Aug 2019 19:15:10 +0800 Subject: [PATCH 11/11] =?UTF-8?q?Mod=20aaa-12=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96cpu=E3=80=81=E5=86=85?= =?UTF-8?q?=E5=AD=98=E7=9A=84bug=E3=80=82=20RCA=EF=BC=9A=20SOL=EF=BC=9A=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=BA=EF=BC=9Adongxiancun=20=E6=A3=80?= =?UTF-8?q?=E8=A7=86=E4=BA=BA=EF=BC=9Adongxiancun?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/yang/device-status.yang | 4 +- .../huawei/impl/HuaweiDriverProvider.java | 7 +- .../huawei/impl/HuaweiNetconfSpeaker.java | 84 +++++++++++-------- .../opendaylight/blueprint/impl-blueprint.xml | 3 + 4 files changed, 58 insertions(+), 40 deletions(-) diff --git a/ControlPlatform/driver-layer/adaptation-layer/src/main/yang/device-status.yang b/ControlPlatform/driver-layer/adaptation-layer/src/main/yang/device-status.yang index 03f8ad40b..2ae2220d9 100644 --- a/ControlPlatform/driver-layer/adaptation-layer/src/main/yang/device-status.yang +++ b/ControlPlatform/driver-layer/adaptation-layer/src/main/yang/device-status.yang @@ -26,9 +26,7 @@ module device-status { container memory-infos { description "内存的状态信息"; leaf memory-total { - type int16 { - range "0..100"; - } + type int64 ; } leaf usage-rate { type int16 { diff --git a/ControlPlatform/driver-layer/drivers/huawei/src/main/java/com/cmcc/cmhi/huawei/impl/HuaweiDriverProvider.java b/ControlPlatform/driver-layer/drivers/huawei/src/main/java/com/cmcc/cmhi/huawei/impl/HuaweiDriverProvider.java index 6f00cfb99..dd5c37807 100644 --- a/ControlPlatform/driver-layer/drivers/huawei/src/main/java/com/cmcc/cmhi/huawei/impl/HuaweiDriverProvider.java +++ b/ControlPlatform/driver-layer/drivers/huawei/src/main/java/com/cmcc/cmhi/huawei/impl/HuaweiDriverProvider.java @@ -8,6 +8,7 @@ package com.cmcc.cmhi.huawei.impl; import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.MountPointService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -16,13 +17,15 @@ public class HuaweiDriverProvider { private static final Logger LOG = LoggerFactory.getLogger(HuaweiDriverProvider.class); private final DataBroker dataBroker; + private final MountPointService mountService; private HuaweiDriverRegister register = null; private HuaweiNetconfSpeaker netconfSpeaker = null; - public HuaweiDriverProvider(final DataBroker dataBroker) { + public HuaweiDriverProvider(final DataBroker dataBroker, final MountPointService mountService) { this.dataBroker = dataBroker; + this.mountService = mountService; this.register = new HuaweiDriverRegister(this.dataBroker); - this.netconfSpeaker = new HuaweiNetconfSpeaker(this.dataBroker); + this.netconfSpeaker = new HuaweiNetconfSpeaker(this.dataBroker, this.mountService); } /** diff --git a/ControlPlatform/driver-layer/drivers/huawei/src/main/java/com/cmcc/cmhi/huawei/impl/HuaweiNetconfSpeaker.java b/ControlPlatform/driver-layer/drivers/huawei/src/main/java/com/cmcc/cmhi/huawei/impl/HuaweiNetconfSpeaker.java index 55146d1fe..18735c1da 100644 --- a/ControlPlatform/driver-layer/drivers/huawei/src/main/java/com/cmcc/cmhi/huawei/impl/HuaweiNetconfSpeaker.java +++ b/ControlPlatform/driver-layer/drivers/huawei/src/main/java/com/cmcc/cmhi/huawei/impl/HuaweiNetconfSpeaker.java @@ -52,12 +52,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev15 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; @@ -75,7 +77,7 @@ import static org.opendaylight.controller.md.sal.binding.api.DataObjectModificat public class HuaweiNetconfSpeaker implements DataTreeChangeListener, - BindingAwareProvider, AutoCloseable { + AutoCloseable { private final ListenerRegistration configurationReg; private MountPointService mountService; @@ -93,8 +95,9 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener connectPath = InstanceIdentifier.create(ConnectorInfo.class); final DataTreeIdentifier dataTreeIdentifier = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, connectPath); configurationReg = dataBroker.registerDataTreeChangeListener(dataTreeIdentifier, this); @@ -131,7 +134,7 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener() { @@ -143,7 +146,7 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener - * The skeleton for this method was generated with the MD-SAL application - * archetype. - * - * @param session Reference to the established MD-SAL session - */ - @Override - public void onSessionInitiated(BindingAwareBroker.ProviderContext session) { - LOG.info("HuaweiNetconfSpeaker Session Initiated"); - this.mountService = session.getSALService(MountPointService.class); - } +// /** +// * A method called when the session to MD-SAL is established. It initializes +// * references to MD-SAL services needed throughout the lifetime of the +// * huawei netconf application and registers its RPC implementation and Data change +// * Listener with the MD-SAL +// *

+// * The skeleton for this method was generated with the MD-SAL application +// * archetype. +// * +// * @param session Reference to the established MD-SAL session +// */ +// @Override +// public void onSessionInitiated(BindingAwareBroker.ProviderContext session) { +// LOG.info("HuaweiNetconfSpeaker Session Initiated"); +// this.mountService = session.getSALService(MountPointService.class); +// } @Override @@ -213,7 +216,7 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener { + oldEntry.getRemoteDevices().forEach(d -> { disConnectDevice(d.getId().getValue()); }); @@ -261,15 +264,19 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener { - readInfoFromDevice(nodeId); - }, 0, 10000, TimeUnit.MILLISECONDS); + try { + readInfoFromDevice(nodeId); + } catch (Exception e) { + LOG.error("捕获一个异常:{}", e); + } + }, 180000, 10000, TimeUnit.MILLISECONDS); if (Objects.nonNull(threads.get(nodeId))) { LOG.info("remove exist pool in thread map"); if (!threads.get(nodeId).isShutdown()) { threads.get(nodeId).shutdownNow(); } } - LOG.info("put pool in thread map with key {}",nodeId); + LOG.info("put pool in thread map with key {}", nodeId); threads.put(nodeId, pool); } @@ -285,13 +292,15 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener hwNodeOptional = mountService.getMountPoint(NETCONF_TOPO_IID .child(Node.class, new NodeKey(new NodeId(nodeId)))); - + LOG.info("开始向华为设备获取cpu信息2!"); Preconditions.checkArgument(hwNodeOptional.isPresent(), "Unable to locate mountpoint: %s, not mounted yet or not configured", nodeId); final MountPoint hwNode = hwNodeOptional.get(); + LOG.info("Get the DataBroker for the mounted node !"); // Get the DataBroker for the mounted node final DataBroker hwNodeBroker = hwNode.getService(DataBroker.class).get(); @@ -308,7 +317,7 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener iid = InstanceIdentifier.create(Devm.class).child(CpuInfos.class); Optional cupInfos; - LOG.info("开始向华为设备获取cpu信息!"); + LOG.info("开始向华为设备读取cupInfos!"); try { // Read from a transaction is asynchronous, but a simple // get/checkedGet makes the call synchronous @@ -331,9 +340,10 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener cpuIid = NETCONF_TOPO_IID.child(Node.class). - augmentation(NodeCpu.class). - child(org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.cpu.status.CpuInfos.class); + InstanceIdentifier cpuIid = NETCONF_TOPO_IID + .child(Node.class, new NodeKey(new NodeId(nodeId))) + .augmentation(NodeCpu.class) + .child(org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.cpu.status.CpuInfos.class); for (int i = 0; i < ifcList.size(); i++) { final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); writeTransaction.put(LogicalDatastoreType.OPERATIONAL, cpuIid, ifcList.get(i)); @@ -369,7 +379,8 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener customMemoryIID = NETCONF_TOPO_IID.child(Node.class). - augmentation(NodeMemory.class). - child(org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.mem.status.MemoryInfos.class); + InstanceIdentifier customMemoryIID = NETCONF_TOPO_IID + .child(Node.class, new NodeKey(new NodeId(nodeId))) + .augmentation(NodeMemory.class) + .child(org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.mem.status.MemoryInfos.class); for (int i = 0; i < memoryList.size(); i++) { final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); writeTransaction.put(LogicalDatastoreType.OPERATIONAL, customMemoryIID, memoryList.get(i)); @@ -433,9 +445,11 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener tpinfosIID = NETCONF_TOPO_IID.child(Node.class). - child(TerminationPoint.class).augmentation(TpExt.class).child(TpInfos.class); for (int i = 0; i < tpInfosList.size(); i++) { + InstanceIdentifier tpinfosIID = NETCONF_TOPO_IID + .child(Node.class, new NodeKey(new NodeId(nodeId))) + .child(TerminationPoint.class, new TerminationPointKey(new TpId(tpInfosList.get(i).getTpName()))) + .augmentation(TpExt.class).child(TpInfos.class); final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); writeTransaction.put(LogicalDatastoreType.OPERATIONAL, tpinfosIID, tpInfosList.get(i)); Futures.addCallback(writeTransaction.submit(), new FutureCallback() { diff --git a/ControlPlatform/driver-layer/drivers/huawei/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/ControlPlatform/driver-layer/drivers/huawei/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml index 66dc04a06..212ba5b7b 100644 --- a/ControlPlatform/driver-layer/drivers/huawei/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml +++ b/ControlPlatform/driver-layer/drivers/huawei/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml @@ -14,11 +14,14 @@ and is available at http://www.eclipse.org/legal/epl-v10.html + +