Merge branch 'master' of git.komect.net:ISG/secogateway

This commit is contained in:
黄昕 2019-08-27 17:44:45 +08:00
commit 95bea78874
10 changed files with 23 additions and 19 deletions

View File

@ -4,6 +4,8 @@
#include "rpc_server.h" #include "rpc_server.h"
#include "rpc_client.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) ret_code log_rpc_exec(char* service_name, char* method_name, pointer input, int input_len, int last_lenth)
{ {
if ((input == NULL) if ((input == NULL)

View File

@ -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.1:514:RFC3164fmt
* *.=emerg;*.=alert;*.=crit;*.=err;*.=warn;*.=notice;*.=info @@1.1.1.2:514:RFC5424fmt */ * *.=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 *pos = NULL;
char *pos2 = 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) while ((getline(&line, &n, fp)) != -1)
{ {
memset(tmp_str, 0, sizeof(tmp_str)); 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)) if (NULL == strstr(line, tmp_str))
{ {
continue; continue;

View File

@ -16,7 +16,7 @@ int conf_file(cJSON *json_obj, int argc, char **argv)
log_file_t log_file_out = {0}; log_file_t log_file_out = {0};
int level = LOG_INFO; int level = LOG_INFO;
uint config_type = CM_CONFIG_SET; uint config_type = CM_CONFIG_SET;
cJSON *json_output = NULL; char *json_output = NULL;
log_file.is_compress = LOG_UNCOMPRESS; log_file.is_compress = LOG_UNCOMPRESS;

View File

@ -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) 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}; log_remote_host_x_t remote = {0};
cJSON *json_output = NULL; char *json_output = NULL;
int config_type = CM_CONFIG_SET; int config_type = CM_CONFIG_SET;
if (LOG_CONFIG_REMOTE_GET_HOST == config_id) 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 = {0};
log_remote_level_t log_level_out = {0}; log_remote_level_t log_level_out = {0};
uint config_type = CM_CONFIG_SET; uint config_type = CM_CONFIG_SET;
cJSON *json_output = NULL; char*json_output = NULL;
if (argc < 3) { if (argc < 3) {
ULOG_WARNING(g_log, "Not input log level"); ULOG_WARNING(g_log, "Not input log level");

View File

@ -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; int ret = -1;
char *output; 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; cJSON *json_obj = NULL;

View File

@ -13,15 +13,15 @@
extern ulog_t *g_log; extern ulog_t *g_log;
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 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);
#define CONF_TERMINAL(type, config_type, json_obj, str_level, on, module_name, conf_id) { \ #define CONF_TERMINAL(type, config_type, json_obj, str_level, on, module_name, conf_id) { \
type terminal = {0}; \ type terminal = {0}; \
type terminal_out = {0}; \ type terminal_out = {0}; \
int level; \ int level; \
cJSON *json_output = NULL; \ char *json_output = NULL; \
\ \
if ((level = log_str_to_level(str_level)) < 0) { \ if ((level = log_str_to_level(str_level)) < 0) { \
ULOG_WARNING(g_log, "Unknown log level:%s", str_level); \ ULOG_WARNING(g_log, "Unknown log level:%s", str_level); \

View File

@ -134,7 +134,7 @@ static int trace_recv_handle(struct pdelivnl_ctrl_data *ctrl,
case TRACE_CFG_POLICY_REPLY: case TRACE_CFG_POLICY_REPLY:
reply = (trace_reply_t *)NLMSG_DATA(n); reply = (trace_reply_t *)NLMSG_DATA(n);
if (sizeof(*reply) < (n->nlmsg_len - NLMSG_HDRLEN)) { 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 %ld, but fact length is %u",
sizeof(*reply), (n->nlmsg_len - NLMSG_HDRLEN)); sizeof(*reply), (n->nlmsg_len - NLMSG_HDRLEN));
break; 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 hdr: is_reply:%d, seq:%u, ver:%u", req.hdr.is_reply, req.hdr.seq, req.hdr.ver);
SYSLOG_DEBUG("Send policy:"); SYSLOG_DEBUG("Send policy:");
SYSLOG_DEBUG(" src family:%u, src ip:%02x, sport:%u", 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", 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); SYSLOG_DEBUG(" protocol:%u, app_type:%u", req.policy.protocol, req.policy.app_type);
/*发送组装好的netlink消息*/ /*发送组装好的netlink消息*/

View File

@ -15,7 +15,7 @@
#define REDIRECT_SEPERATE " " #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 ulog_t *g_log;
extern FILE *g_conf_fp; extern FILE *g_conf_fp;

View File

@ -347,7 +347,7 @@ static int __rpc_conf_log_remote(pointer input, const void *arg, char *str_err,
log_op_t op; log_op_t op;
memcpy(&op, arg, sizeof(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) { if (ret < 0) {
strncpy(str_err, "Configuring remote of log is faiure", str_len); strncpy(str_err, "Configuring remote of log is faiure", str_len);
} }

View File

@ -5,6 +5,8 @@
#include "log_common.h" #include "log_common.h"
#include "ulog_api.h" #include "ulog_api.h"
#include <unistd.h>
#define SEV_TIMEOUT 1 #define SEV_TIMEOUT 1
#define SEV_CMD "systemctl restart rsyslog" #define SEV_CMD "systemctl restart rsyslog"