summaryrefslogtreecommitdiff
path: root/common/src/tfe_scan.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/tfe_scan.cpp')
-rw-r--r--common/src/tfe_scan.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/common/src/tfe_scan.cpp b/common/src/tfe_scan.cpp
index 5e7ec5b..b746a1b 100644
--- a/common/src/tfe_scan.cpp
+++ b/common/src/tfe_scan.cpp
@@ -67,6 +67,49 @@ int tfe_scan_subscribe_id(const struct tfe_stream *stream, struct Maat_rule_t *r
return hit_cnt_ip;
}
+int tfe_scan_fqdn_cat(const struct tfe_stream *stream, struct Maat_rule_t *result, scan_status_t *scan_mid,
+ int hit_cnt, unsigned int thread_id, void *logger, int table_id)
+{
+ int scan_ret = 0, i, fqdn_len =0;
+ uint16_t opt_out_size;
+ int category_num = 0, hit_cnt_fqdn = 0;
+ char category_id_num[24] = {0};
+ char category_id_val[TFE_SYMBOL_MAX] = {0};
+
+ struct tfe_cmsg *cmsg = tfe_stream_get0_cmsg(stream);
+ if (cmsg != NULL)
+ {
+ scan_ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_SRC_FQDN_ID, (unsigned char *)category_id_val, sizeof(category_id_val), &opt_out_size);
+ if (scan_ret != 0)
+ {
+ TFE_LOG_ERROR(logger, "fetch fqdn cat id from cmsg failed, ret: %d", scan_ret);
+ }
+ scan_ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_SRC_FQDN_NUM, (unsigned char *)category_id_num, sizeof(category_id_num), &opt_out_size);
+ if (scan_ret != 0)
+ {
+ TFE_LOG_ERROR(logger, "fetch fqdn cat id from cmsg failed, ret: %d", scan_ret);
+ }
+ category_num = atoll(category_id_num);
+ }
+
+ for(i = 0; i< category_num && i < 8; i++)
+ {
+ int fqdn_id =0;
+ char fqdn_val[16]={0};
+
+ snprintf(fqdn_val, sizeof(int), "%s", category_id_val + fqdn_len);
+ fqdn_id = atoi(fqdn_val);
+ scan_ret=Maat_scan_intval(tfe_bussiness_resouce_get(STATIC_MAAT), table_id, fqdn_id, result + hit_cnt + hit_cnt_fqdn,
+ MAX_SCAN_RESULT-hit_cnt-hit_cnt_fqdn, scan_mid, (int) thread_id);
+ if(scan_ret>0)
+ {
+ hit_cnt_fqdn+=scan_ret;
+ }
+ fqdn_len += sizeof(int);
+ }
+ return hit_cnt_fqdn;
+}
+
int tfe_scan_ip_location(const struct tfe_stream *stream, struct Maat_rule_t *result, scan_status_t *scan_mid,
int hit_cnt, unsigned int thread_id, void *logger, const char *addr, char **location_server, char **location_client)
{