TSG-6332 日志字段增加common_service_category

TSG-6438 策略优先级修复
This commit is contained in:
fengweihao
2021-05-28 10:51:22 +08:00
parent 91facad80a
commit 2ad0ddecbe
2 changed files with 43 additions and 14 deletions

View File

@@ -81,6 +81,34 @@ error_out:
return NULL;
}
static int pangu_log_get_fqdn_cat(struct tfe_cmsg *cmsg, char *fqdn_cat_buff)
{
int ret=0;
unsigned int i=0, category_id_num=0;
uint16_t opt_out_size;
unsigned int category_id_val[TFE_SYMBOL_MAX]={0};
char *p = fqdn_cat_buff;
ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_FQDN_CAT_ID_NUM, (unsigned char *)&category_id_num, sizeof(category_id_num), &opt_out_size);
if (ret != 0 || category_id_num == 0)
{
return -1;
}
ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_FQDN_CAT_ID_VAL, (unsigned char *)category_id_val, sizeof(category_id_val), &opt_out_size);
if (ret != 0)
{
return -1;
}
for (i = 0; i < category_id_num && i < 8; i++)
{
p += snprintf(p, sizeof(fqdn_cat_buff) - (p - fqdn_cat_buff), "%s%d", i>0 ? "," : "", category_id_val[i]);
}
return 0;
}
int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg)
{
const struct tfe_http_session* http=log_msg->http;
@@ -126,6 +154,7 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg)
cJSON_AddStringToObject(common_obj, "common_schema_type", "HTTP");
unsigned int common_direction=0;
char category_id_val[TFE_SYMBOL_MAX];
char opt_val[24] = { 0 }; uint16_t opt_out_size;
struct tfe_cmsg * cmsg = tfe_stream_get0_cmsg(log_msg->stream);
if (cmsg!=NULL)
@@ -140,6 +169,11 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg)
{
cJSON_AddNumberToObject(common_obj, "common_direction", common_direction); //0域内->域外1域外->域内描述的是CLIENT_IP信息
}
ret = pangu_log_get_fqdn_cat(cmsg, category_id_val);
if (ret==0)
{
cJSON_AddStringToObject(common_obj, "common_service_category", category_id_val);
}
}
if (http->req)