✨ feat(TSG-15641): Packet IO控制报文字段调整
This commit is contained in:
@@ -86,14 +86,8 @@ enum tfe_cmsg_tlv_type
|
|||||||
TFE_CMSG_DST_ASN, // string max size 64
|
TFE_CMSG_DST_ASN, // string max size 64
|
||||||
TFE_CMSG_SRC_ORGANIZATION, // string max size 256
|
TFE_CMSG_SRC_ORGANIZATION, // string max size 256
|
||||||
TFE_CMSG_DST_ORGANIZATION, // string max size 256
|
TFE_CMSG_DST_ORGANIZATION, // string max size 256
|
||||||
TFE_CMSG_SRC_IP_LOCATION_COUNTRY, // string max size 256
|
TFE_CMSG_SRC_IP_LOCATION, // string max size 256 * 4
|
||||||
TFE_CMSG_DST_IP_LOCATION_COUNTRY, // string max size 256
|
TFE_CMSG_DST_IP_LOCATION, // string max size 256 * 4
|
||||||
TFE_CMSG_SRC_IP_LOCATION_PROVINE, // string max size 256
|
|
||||||
TFE_CMSG_DST_IP_LOCATION_PROVINE, // string max size 256
|
|
||||||
TFE_CMSG_SRC_IP_LOCATION_CITY, // string max size 256
|
|
||||||
TFE_CMSG_DST_IP_LOCATION_CITY, // string max size 256
|
|
||||||
TFE_CMSG_SRC_IP_LOCATION_SUBDIVISION,
|
|
||||||
TFE_CMSG_DST_IP_LOCATION_SUBDIVISION,
|
|
||||||
|
|
||||||
/* SSL ja3 fingerprint */
|
/* SSL ja3 fingerprint */
|
||||||
TFE_CMSG_SSL_CLIENT_JA3_FINGERPRINT, // string max size 32
|
TFE_CMSG_SSL_CLIENT_JA3_FINGERPRINT, // string max size 32
|
||||||
|
|||||||
@@ -63,23 +63,17 @@ struct mpack_mmap_id2type
|
|||||||
{.id = 19, .type = TFE_CMSG_DST_ASN, .str_name = "TFE_CMSG_DST_ASN", .size = 64, .array_index = MPACK_ARRAY_INIT},
|
{.id = 19, .type = TFE_CMSG_DST_ASN, .str_name = "TFE_CMSG_DST_ASN", .size = 64, .array_index = MPACK_ARRAY_INIT},
|
||||||
{.id = 20, .type = TFE_CMSG_SRC_ORGANIZATION, .str_name = "TFE_CMSG_SRC_ORGANIZATION", .size = 256, .array_index = MPACK_ARRAY_INIT},
|
{.id = 20, .type = TFE_CMSG_SRC_ORGANIZATION, .str_name = "TFE_CMSG_SRC_ORGANIZATION", .size = 256, .array_index = MPACK_ARRAY_INIT},
|
||||||
{.id = 21, .type = TFE_CMSG_DST_ORGANIZATION, .str_name = "TFE_CMSG_DST_ORGANIZATION", .size = 256, .array_index = MPACK_ARRAY_INIT},
|
{.id = 21, .type = TFE_CMSG_DST_ORGANIZATION, .str_name = "TFE_CMSG_DST_ORGANIZATION", .size = 256, .array_index = MPACK_ARRAY_INIT},
|
||||||
{.id = 22, .type = TFE_CMSG_SRC_IP_LOCATION_COUNTRY, .str_name = "TFE_CMSG_SRC_IP_LOCATION_COUNTRY", .size = 256, .array_index = MPACK_ARRAY_INIT},
|
{.id = 22, .type = TFE_CMSG_SRC_IP_LOCATION, .str_name = "TFE_CMSG_SRC_IP_LOCATION", .size = 1024, .array_index = MPACK_ARRAY_INIT},
|
||||||
{.id = 23, .type = TFE_CMSG_DST_IP_LOCATION_COUNTRY, .str_name = "TFE_CMSG_DST_IP_LOCATION_COUNTRY", .size = 256, .array_index = MPACK_ARRAY_INIT},
|
{.id = 23, .type = TFE_CMSG_DST_IP_LOCATION, .str_name = "TFE_CMSG_DST_IP_LOCATION", .size = 1024, .array_index = MPACK_ARRAY_INIT},
|
||||||
{.id = 24, .type = TFE_CMSG_SRC_IP_LOCATION_PROVINE, .str_name = "TFE_CMSG_SRC_IP_LOCATION_PROVINE", .size = 256, .array_index = MPACK_ARRAY_INIT},
|
{.id = 24, .type = TFE_CMSG_SSL_CLIENT_JA3_FINGERPRINT, .str_name = "TFE_CMSG_SSL_CLIENT_JA3_FINGERPRINT", .size = 32, .array_index = MPACK_ARRAY_INIT},
|
||||||
{.id = 25, .type = TFE_CMSG_DST_IP_LOCATION_PROVINE, .str_name = "TFE_CMSG_DST_IP_LOCATION_PROVINE", .size = 256, .array_index = MPACK_ARRAY_INIT},
|
{.id = 25, .type = TFE_CMSG_FQDN_CAT_ID_VAL, .str_name = "TFE_CMSG_FQDN_CAT_ID_VAL", .size = 4, .array_index = MPACK_ARRAY_FQDN_IDS},
|
||||||
{.id = 26, .type = TFE_CMSG_SRC_IP_LOCATION_CITY, .str_name = "TFE_CMSG_SRC_IP_LOCATION_CITY", .size = 256, .array_index = MPACK_ARRAY_INIT},
|
{.id = 26, .type = TFE_CMSG_TLV_NR_MAX, .str_name = "TFE_SEQ_SIDS", .size = 2, .array_index = MPACK_ARRAY_SEQ_SIDS},
|
||||||
{.id = 27, .type = TFE_CMSG_DST_IP_LOCATION_CITY, .str_name = "TFE_CMSG_DST_IP_LOCATION_CITY", .size = 256, .array_index = MPACK_ARRAY_INIT},
|
{.id = 27, .type = TFE_CMSG_TLV_NR_MAX, .str_name = "TFE_ACK_SIDS", .size = 2, .array_index = MPACK_ARRAY_ACK_SIDS},
|
||||||
{.id = 28, .type = TFE_CMSG_SRC_IP_LOCATION_SUBDIVISION, .str_name = "TFE_CMSG_SRC_IP_LOCATION_SUBDIVISION", .size = 256, .array_index = MPACK_ARRAY_INIT},
|
{.id = 28, .type = TFE_CMSG_TLV_NR_MAX, .str_name = "TFE_SEQ_ROUTE_CTX", .size = 1, .array_index = MPACK_ARRAY_SEQ_ROUTE_CTX},
|
||||||
{.id = 29, .type = TFE_CMSG_DST_IP_LOCATION_SUBDIVISION, .str_name = "TFE_CMSG_DST_IP_LOCATION_SUBDIVISION", .size = 256, .array_index = MPACK_ARRAY_INIT},
|
{.id = 29, .type = TFE_CMSG_TLV_NR_MAX, .str_name = "TFE_ACK_ROUTE_CTX", .size = 1, .array_index = MPACK_ARRAY_ACK_ROUTE_CTX},
|
||||||
{.id = 30, .type = TFE_CMSG_SSL_CLIENT_JA3_FINGERPRINT, .str_name = "TFE_CMSG_SSL_CLIENT_JA3_FINGERPRINT", .size = 32, .array_index = MPACK_ARRAY_INIT},
|
{.id = 30, .type = TFE_CMSG_TLV_NR_MAX, .str_name = "TFE_SEQ_PKG_HEADER", .size = 1, .array_index = MPACK_ARRAY_SEQ_PKG_HEADER},
|
||||||
{.id = 31, .type = TFE_CMSG_FQDN_CAT_ID_VAL, .str_name = "TFE_CMSG_FQDN_CAT_ID_VAL", .size = 4, .array_index = MPACK_ARRAY_FQDN_IDS},
|
{.id = 31, .type = TFE_CMSG_TLV_NR_MAX, .str_name = "TFE_ACK_PKG_HEADER", .size = 1, .array_index = MPACK_ARRAY_ACK_PKG_HEADER},
|
||||||
{.id = 32, .type = TFE_CMSG_TLV_NR_MAX, .str_name = "TFE_SEQ_SIDS", .size = 2, .array_index = MPACK_ARRAY_SEQ_SIDS},
|
{.id = 32, .type = TFE_CMSG_TLV_NR_MAX, .str_name = "TFE_FLAG", .size = 1, .array_index = MPACK_ARRAY_INIT}
|
||||||
{.id = 33, .type = TFE_CMSG_TLV_NR_MAX, .str_name = "TFE_ACK_SIDS", .size = 2, .array_index = MPACK_ARRAY_ACK_SIDS},
|
|
||||||
{.id = 34, .type = TFE_CMSG_TLV_NR_MAX, .str_name = "TFE_SEQ_ROUTE_CTX", .size = 1, .array_index = MPACK_ARRAY_SEQ_ROUTE_CTX},
|
|
||||||
{.id = 35, .type = TFE_CMSG_TLV_NR_MAX, .str_name = "TFE_ACK_ROUTE_CTX", .size = 1, .array_index = MPACK_ARRAY_ACK_ROUTE_CTX},
|
|
||||||
{.id = 36, .type = TFE_CMSG_TLV_NR_MAX, .str_name = "TFE_SEQ_PKG_HEADER", .size = 1, .array_index = MPACK_ARRAY_SEQ_PKG_HEADER},
|
|
||||||
{.id = 37, .type = TFE_CMSG_TLV_NR_MAX, .str_name = "TFE_ACK_PKG_HEADER", .size = 1, .array_index = MPACK_ARRAY_ACK_PKG_HEADER},
|
|
||||||
{.id = 38, .type = TFE_CMSG_TLV_NR_MAX, .str_name = "TFE_FLAG", .size = 1, .array_index = MPACK_ARRAY_INIT}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void * g_packet_io_logger;
|
extern void * g_packet_io_logger;
|
||||||
@@ -156,7 +150,7 @@ static int proxy_parse_messagepack(mpack_node_t node, void *ctx, void *logger)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
uint64_t value = 0;
|
uint64_t value = 0;
|
||||||
char empty_str[4] = {0};
|
char empty_str[4] = {0};
|
||||||
char cmsg_str[256] = {0};
|
char cmsg_str[1024] = {0};
|
||||||
struct ctrl_pkt_parser *handler = (struct ctrl_pkt_parser *)ctx;
|
struct ctrl_pkt_parser *handler = (struct ctrl_pkt_parser *)ctx;
|
||||||
|
|
||||||
if (mpack_node_is_nil(mpack_node_map_cstr(node, "rule_ids")))
|
if (mpack_node_is_nil(mpack_node_map_cstr(node, "rule_ids")))
|
||||||
@@ -480,14 +474,8 @@ void tfe_cmsg_enum_to_string()
|
|||||||
tfe_cmsg_tlv_type_to_string[TFE_CMSG_DST_ASN] = "TFE_CMSG_DST_ASN";
|
tfe_cmsg_tlv_type_to_string[TFE_CMSG_DST_ASN] = "TFE_CMSG_DST_ASN";
|
||||||
tfe_cmsg_tlv_type_to_string[TFE_CMSG_SRC_ORGANIZATION] = "TFE_CMSG_SRC_ORGANIZATION";
|
tfe_cmsg_tlv_type_to_string[TFE_CMSG_SRC_ORGANIZATION] = "TFE_CMSG_SRC_ORGANIZATION";
|
||||||
tfe_cmsg_tlv_type_to_string[TFE_CMSG_DST_ORGANIZATION] = "TFE_CMSG_DST_ORGANIZATION";
|
tfe_cmsg_tlv_type_to_string[TFE_CMSG_DST_ORGANIZATION] = "TFE_CMSG_DST_ORGANIZATION";
|
||||||
tfe_cmsg_tlv_type_to_string[TFE_CMSG_SRC_IP_LOCATION_COUNTRY] = "TFE_CMSG_SRC_IP_LOCATION_COUNTRY";
|
tfe_cmsg_tlv_type_to_string[TFE_CMSG_SRC_IP_LOCATION] = "TFE_CMSG_SRC_IP_LOCATION";
|
||||||
tfe_cmsg_tlv_type_to_string[TFE_CMSG_DST_IP_LOCATION_COUNTRY] = "TFE_CMSG_DST_IP_LOCATION_COUNTRY";
|
tfe_cmsg_tlv_type_to_string[TFE_CMSG_DST_IP_LOCATION] = "TFE_CMSG_DST_IP_LOCATION";
|
||||||
tfe_cmsg_tlv_type_to_string[TFE_CMSG_SRC_IP_LOCATION_PROVINE] = "TFE_CMSG_SRC_IP_LOCATION_PROVINE";
|
|
||||||
tfe_cmsg_tlv_type_to_string[TFE_CMSG_DST_IP_LOCATION_PROVINE] = "TFE_CMSG_DST_IP_LOCATION_PROVINE";
|
|
||||||
tfe_cmsg_tlv_type_to_string[TFE_CMSG_SRC_IP_LOCATION_CITY] = "TFE_CMSG_SRC_IP_LOCATION_CITY";
|
|
||||||
tfe_cmsg_tlv_type_to_string[TFE_CMSG_DST_IP_LOCATION_CITY] = "TFE_CMSG_DST_IP_LOCATION_CITY";
|
|
||||||
tfe_cmsg_tlv_type_to_string[TFE_CMSG_SRC_IP_LOCATION_SUBDIVISION] = "TFE_CMSG_SRC_IP_LOCATION_SUBDIVISION";
|
|
||||||
tfe_cmsg_tlv_type_to_string[TFE_CMSG_DST_IP_LOCATION_SUBDIVISION] = "TFE_CMSG_DST_IP_LOCATION_SUBDIVISION";
|
|
||||||
|
|
||||||
tfe_cmsg_tlv_type_to_string[TFE_CMSG_SSL_CLIENT_JA3_FINGERPRINT] = "TFE_CMSG_SSL_CLIENT_JA3_FINGERPRINT";
|
tfe_cmsg_tlv_type_to_string[TFE_CMSG_SSL_CLIENT_JA3_FINGERPRINT] = "TFE_CMSG_SSL_CLIENT_JA3_FINGERPRINT";
|
||||||
tfe_cmsg_tlv_type_to_string[TFE_CMSG_FQDN_CAT_ID_NUM] = "TFE_CMSG_FQDN_CAT_ID_NUM";
|
tfe_cmsg_tlv_type_to_string[TFE_CMSG_FQDN_CAT_ID_NUM] = "TFE_CMSG_FQDN_CAT_ID_NUM";
|
||||||
|
|||||||
@@ -126,123 +126,64 @@ int tfe_scan_ip_location(const struct tfe_stream *stream, long long *result, str
|
|||||||
{
|
{
|
||||||
int scan_ret = 0;
|
int scan_ret = 0;
|
||||||
int hit_cnt_ip = 0;
|
int hit_cnt_ip = 0;
|
||||||
size_t n_hit_result = 0;
|
size_t n_hit_result = 0;
|
||||||
uint16_t opt_out_size;
|
uint16_t opt_out_size;
|
||||||
char buff[TFE_STRING_MAX * 5] = {0};
|
char src_ip_location[TFE_STRING_MAX * 5] = {0};
|
||||||
char src_city[TFE_STRING_MAX] = {0};
|
char dst_ip_location[TFE_STRING_MAX * 5] = {0};
|
||||||
char dst_city[TFE_STRING_MAX] = {0};
|
|
||||||
char src_provine[TFE_STRING_MAX] = {0};
|
|
||||||
char dst_provine[TFE_STRING_MAX] = {0};
|
|
||||||
char src_country[TFE_STRING_MAX] = {0};
|
|
||||||
char dst_country[TFE_STRING_MAX] = {0};
|
|
||||||
char src_subdivsion[TFE_STRING_MAX] = {0};
|
|
||||||
char dst_subdivsion[TFE_STRING_MAX] = {0};
|
|
||||||
struct tfe_cmsg *cmsg = tfe_stream_get0_cmsg(stream);
|
struct tfe_cmsg *cmsg = tfe_stream_get0_cmsg(stream);
|
||||||
if (cmsg != NULL)
|
if (cmsg != NULL)
|
||||||
{
|
{
|
||||||
scan_ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_SRC_IP_LOCATION_COUNTRY, (unsigned char *)src_country, sizeof(src_country), &opt_out_size);
|
scan_ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_SRC_IP_LOCATION, (unsigned char *)src_ip_location, sizeof(src_ip_location), &opt_out_size);
|
||||||
if (scan_ret != 0)
|
if (scan_ret != 0)
|
||||||
{
|
{
|
||||||
TFE_LOG_ERROR(logger, "fetch src country from cmsg failed, ret: %d addr: %s", scan_ret, stream->str_stream_info);
|
TFE_LOG_ERROR(logger, "fetch src country from cmsg failed, ret: %d addr: %s", scan_ret, stream->str_stream_info);
|
||||||
}
|
}
|
||||||
scan_ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_DST_IP_LOCATION_COUNTRY, (unsigned char *)dst_country, sizeof(dst_country), &opt_out_size);
|
scan_ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_DST_IP_LOCATION, (unsigned char *)dst_ip_location, sizeof(dst_ip_location), &opt_out_size);
|
||||||
if (scan_ret != 0)
|
if (scan_ret != 0)
|
||||||
{
|
{
|
||||||
TFE_LOG_ERROR(logger, "fetch dst country from cmsg failed, ret: %d addr: %s", scan_ret, stream->str_stream_info);
|
TFE_LOG_ERROR(logger, "fetch dst country from cmsg failed, ret: %d addr: %s", scan_ret, stream->str_stream_info);
|
||||||
}
|
}
|
||||||
scan_ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_SRC_IP_LOCATION_PROVINE, (unsigned char *)src_provine, sizeof(src_provine), &opt_out_size);
|
|
||||||
if (scan_ret != 0)
|
|
||||||
{
|
|
||||||
TFE_LOG_ERROR(logger, "fetch src provine from cmsg failed, ret: %d addr: %s", scan_ret, stream->str_stream_info);
|
|
||||||
}
|
|
||||||
scan_ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_DST_IP_LOCATION_PROVINE, (unsigned char *)dst_provine, sizeof(dst_provine), &opt_out_size);
|
|
||||||
if (scan_ret != 0)
|
|
||||||
{
|
|
||||||
TFE_LOG_ERROR(logger, "fetch dst provine from cmsg failed, ret: %d addr: %s", scan_ret, stream->str_stream_info);
|
|
||||||
}
|
|
||||||
scan_ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_SRC_IP_LOCATION_CITY, (unsigned char *)src_city, sizeof(src_city), &opt_out_size);
|
|
||||||
if (scan_ret != 0)
|
|
||||||
{
|
|
||||||
TFE_LOG_ERROR(logger, "fetch src city from cmsg failed, ret: %d addr: %s", scan_ret, stream->str_stream_info);
|
|
||||||
}
|
|
||||||
scan_ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_DST_IP_LOCATION_CITY, (unsigned char *)dst_city, sizeof(dst_city), &opt_out_size);
|
|
||||||
if (scan_ret != 0)
|
|
||||||
{
|
|
||||||
TFE_LOG_ERROR(logger, "fetch dst city from cmsg failed, ret: %d addr: %s", scan_ret, stream->str_stream_info);
|
|
||||||
}
|
|
||||||
scan_ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_SRC_IP_LOCATION_SUBDIVISION, (unsigned char *)src_subdivsion, sizeof(src_subdivsion), &opt_out_size);
|
|
||||||
if (scan_ret != 0)
|
|
||||||
{
|
|
||||||
TFE_LOG_ERROR(logger, "fetch src subdivsion from cmsg failed, ret: %d addr: %s", scan_ret, stream->str_stream_info);
|
|
||||||
}
|
|
||||||
scan_ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_DST_IP_LOCATION_SUBDIVISION, (unsigned char *)dst_subdivsion, sizeof(dst_subdivsion), &opt_out_size);
|
|
||||||
if (scan_ret != 0)
|
|
||||||
{
|
|
||||||
TFE_LOG_ERROR(logger, "fetch dst subdivsion from cmsg failed, ret: %d addr: %s", scan_ret, stream->str_stream_info);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
TFE_LOG_DEBUG(logger, "fetch src country:%s provine:%s city:%s; subdivsion:%s, dst country:%s provine:%s city:%s subdivsion:%s addr: %s", src_country, src_provine, src_city, src_subdivsion, dst_country, dst_provine, dst_city, dst_subdivsion, stream->str_stream_info);
|
TFE_LOG_DEBUG(logger, "fetch src ip location: %s dst ip location: %s addr: %s", src_ip_location, dst_ip_location, stream->str_stream_info);
|
||||||
|
|
||||||
if (strlen(dst_country) || strlen(dst_city))
|
if (strlen(dst_ip_location))
|
||||||
{
|
{
|
||||||
memset(buff, 0, sizeof(buff));
|
|
||||||
|
|
||||||
snprintf(buff, sizeof(buff),"%s.%s.%s.%s.", dst_country, dst_provine, dst_city, dst_subdivsion);
|
|
||||||
scan_ret = maat_scan_string((struct maat *)tfe_bussiness_resouce_get(STATIC_MAAT), tfe_bussiness_tableid_get(TABLE_SECURITY_DESTINATION_LOCATION),
|
scan_ret = maat_scan_string((struct maat *)tfe_bussiness_resouce_get(STATIC_MAAT), tfe_bussiness_tableid_get(TABLE_SECURITY_DESTINATION_LOCATION),
|
||||||
buff, strlen(buff), result + hit_cnt + hit_cnt_ip,MAX_SCAN_RESULT - hit_cnt - hit_cnt_ip,
|
dst_ip_location, strlen(dst_ip_location), result + hit_cnt + hit_cnt_ip, MAX_SCAN_RESULT - hit_cnt - hit_cnt_ip,
|
||||||
&n_hit_result, scan_mid);
|
&n_hit_result, scan_mid);
|
||||||
if (scan_ret == MAAT_SCAN_HIT)
|
if (scan_ret == MAAT_SCAN_HIT)
|
||||||
{
|
{
|
||||||
TFE_LOG_INFO(logger, "Scan TSG_SECURITY_DESTINATION_LOCATION, Hit location: %s scan ret: %d policy_id: %lld addr: %s",
|
TFE_LOG_INFO(logger, "Scan TSG_SECURITY_DESTINATION_LOCATION, Hit location: %s scan ret: %d policy_id: %lld addr: %s",
|
||||||
buff, scan_ret, result[hit_cnt + hit_cnt_ip], stream->str_stream_info);
|
dst_ip_location, scan_ret, result[hit_cnt + hit_cnt_ip], stream->str_stream_info);
|
||||||
hit_cnt_ip += n_hit_result;
|
hit_cnt_ip += n_hit_result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TFE_LOG_INFO(logger, "Scan TSG_SECURITY_DESTINATION_LOCATION, NO hit location: %s scan ret: %d addr: %s",
|
TFE_LOG_INFO(logger, "Scan TSG_SECURITY_DESTINATION_LOCATION, NO hit location: %s scan ret: %d addr: %s",
|
||||||
buff, scan_ret, stream->str_stream_info);
|
dst_ip_location, scan_ret, stream->str_stream_info);
|
||||||
}
|
}
|
||||||
memset(buff, 0, sizeof(buff));
|
*location_server = (char *)ALLOC(char, strlen(dst_ip_location));
|
||||||
if(strlen(dst_subdivsion))
|
memcpy(*location_server,dst_ip_location,strlen(dst_ip_location)-1);
|
||||||
{
|
|
||||||
snprintf(buff, sizeof(buff), "%s.%s.%s.%s", dst_country, dst_provine, dst_city, dst_subdivsion);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf(buff, sizeof(buff), "%s.%s.%s", dst_country, dst_provine, dst_city);
|
|
||||||
}
|
|
||||||
*location_server = tfe_strdup(buff);
|
|
||||||
}
|
}
|
||||||
if (strlen(src_country) || strlen(src_city))
|
if (strlen(src_ip_location))
|
||||||
{
|
{
|
||||||
memset(buff, 0, sizeof(buff));
|
|
||||||
|
|
||||||
snprintf(buff, sizeof(buff), "%s.%s.%s.%s.", src_country, src_provine, src_city, src_subdivsion);
|
|
||||||
scan_ret = maat_scan_string((struct maat *)tfe_bussiness_resouce_get(STATIC_MAAT), tfe_bussiness_tableid_get(TABLE_SECURITY_SOURCE_LOCATION),
|
scan_ret = maat_scan_string((struct maat *)tfe_bussiness_resouce_get(STATIC_MAAT), tfe_bussiness_tableid_get(TABLE_SECURITY_SOURCE_LOCATION),
|
||||||
buff, strlen(buff),result + hit_cnt + hit_cnt_ip, MAX_SCAN_RESULT - hit_cnt - hit_cnt_ip,
|
src_ip_location, strlen(src_ip_location), result + hit_cnt + hit_cnt_ip, MAX_SCAN_RESULT - hit_cnt - hit_cnt_ip,
|
||||||
&n_hit_result, scan_mid);
|
&n_hit_result, scan_mid);
|
||||||
if (scan_ret == MAAT_SCAN_HIT)
|
if (scan_ret == MAAT_SCAN_HIT)
|
||||||
{
|
{
|
||||||
TFE_LOG_INFO(logger, "Scan TSG_SECURITY_SOURCE_LOCATION, Hit location: %s scan ret: %d policy_id: %lld addr: %s",
|
TFE_LOG_INFO(logger, "Scan TSG_SECURITY_SOURCE_LOCATION, Hit location: %s scan ret: %d policy_id: %lld addr: %s",
|
||||||
buff, scan_ret, result[hit_cnt + hit_cnt_ip], stream->str_stream_info);
|
src_ip_location, scan_ret, result[hit_cnt + hit_cnt_ip], stream->str_stream_info);
|
||||||
hit_cnt_ip += n_hit_result;
|
hit_cnt_ip += n_hit_result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TFE_LOG_INFO(logger, "Scan TSG_SECURITY_SOURCE_LOCATION, NO hit location: %s scan ret: %d addr: %s",
|
TFE_LOG_INFO(logger, "Scan TSG_SECURITY_SOURCE_LOCATION, NO hit location: %s scan ret: %d addr: %s",
|
||||||
buff, scan_ret, stream->str_stream_info);
|
src_ip_location, scan_ret, stream->str_stream_info);
|
||||||
}
|
}
|
||||||
|
*location_client = (char *)ALLOC(char, strlen(src_ip_location));
|
||||||
memset(buff, 0, sizeof(buff));
|
memcpy(*location_client,src_ip_location, strlen(src_ip_location)-1);
|
||||||
if(strlen(src_subdivsion))
|
|
||||||
{
|
|
||||||
snprintf(buff, sizeof(buff), "%s.%s.%s.%s", src_country, src_provine, src_city, src_subdivsion);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf(buff, sizeof(buff), "%s.%s.%s", src_country, src_provine, src_city);
|
|
||||||
}
|
|
||||||
*location_client = tfe_strdup(buff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return hit_cnt_ip;
|
return hit_cnt_ip;
|
||||||
|
|||||||
Reference in New Issue
Block a user