diff options
Diffstat (limited to 'plugin/business/doh/src/logger.cpp')
| -rw-r--r-- | plugin/business/doh/src/logger.cpp | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/plugin/business/doh/src/logger.cpp b/plugin/business/doh/src/logger.cpp index 50e2648..ca68bc3 100644 --- a/plugin/business/doh/src/logger.cpp +++ b/plugin/business/doh/src/logger.cpp @@ -285,7 +285,7 @@ int doh_get_format_host(cJSON *common_obj, const char *req_spec_host) char *format_host=ALLOC(char, strlen(req_spec_host)+1); sscanf(req_spec_host, "%[^:]:%u", format_host, &port); cJSON_AddStringToObject(common_obj, "doh_host", format_host); - cJSON_AddStringToObject(common_obj, "server_fqdn", format_host); + cJSON_AddStringToObject(common_obj, "destination_fqdn", format_host); FREE(&format_host); return 0; } @@ -321,6 +321,36 @@ int doh_get_string_by_cmsg(cJSON *common_obj, struct tfe_cmsg * cmsg, enum tfe_ return 0; } +int doh_get_uuid_by_cmsg(cJSON *common_obj, struct tfe_cmsg * cmsg, enum tfe_cmsg_tlv_type type, const char *keyword) +{ + uuid_t opt_val; + char session_uuid[UUID_STRING_SIZE]={0}; + uint16_t opt_out_size = 0; + + int ret=tfe_cmsg_get_value(cmsg, type, (unsigned char *)opt_val, sizeof(opt_val), &opt_out_size); + if (ret == 0 && opt_out_size > 0) + { + uuid_unparse(opt_val,session_uuid); + cJSON_AddStringToObject(common_obj, keyword, session_uuid); + } + return 0; +} + + +#ifdef __x86_64__ +#include "uuid_v4_x86.h" +#else +#include "uuid_v4_arm.h" +#endif + +void doh_uuidv4_generate(char *uuid) +{ + UUIDv4::UUIDGenerator<std::mt19937_64> uuidGenerator; + UUIDv4::UUID uid = uuidGenerator.getUUID(); + uid.str(uuid); + return; +} + int doh_send_log(struct doh_conf *handle, const struct tfe_http_session *http, const struct tfe_stream *stream, struct doh_ctx *ctx) { struct doh_maat_rule_t *result = ctx->result; @@ -348,6 +378,9 @@ int doh_send_log(struct doh_conf *handle, const struct tfe_http_session *http, c return 0; } + char log_uuid[40] = {0}; + doh_uuidv4_generate(log_uuid); + common_obj = cJSON_CreateObject(); gettimeofday(&cur_time, NULL); @@ -355,11 +388,12 @@ int doh_send_log(struct doh_conf *handle, const struct tfe_http_session *http, c cJSON_AddNumberToObject(common_obj, "end_timestamp_ms", get_time_ms(cur_time)); cJSON_AddStringToObject(common_obj, "doh_version", app_proto[http->major_version]); cJSON_AddStringToObject(common_obj, "decoded_as", "DoH"); + cJSON_AddStringToObject(common_obj, "log_uuid", log_uuid); struct tfe_cmsg *cmsg = tfe_stream_get0_cmsg(stream); if (cmsg != NULL) { - doh_get_string_by_cmsg(common_obj, cmsg, TFE_CMSG_STREAM_TRACE_ID, "session_id"); + doh_get_uuid_by_cmsg(common_obj, cmsg, TFE_CMSG_STREAM_TRACE_ID, "session_uuid"); doh_get_string_by_cmsg(common_obj, cmsg, TFE_CMSG_SRC_SUB_ID, "subscriber_id"); doh_get_string_by_cmsg(common_obj, cmsg, TFE_CMSG_SRC_IMSI_STR, "imsi"); |
