修改ip转换时笔误

This commit is contained in:
崔一鸣
2019-09-24 17:15:13 +08:00
parent 92436d0c1b
commit e65880ab16
2 changed files with 6 additions and 6 deletions

View File

@@ -352,8 +352,8 @@ static int log_generate(struct pme_info *pmeinfo, void *local_logger){
switch(addr->addrtype){ switch(addr->addrtype){
case ADDR_TYPE_IPV4: case ADDR_TYPE_IPV4:
cJSON_AddNumberToObject(log_obj, "addr_type", 4); cJSON_AddNumberToObject(log_obj, "addr_type", 4);
inet_ntop(AF_INET, &addr->tuple4_v4->saddr, client_ip_str, sizeof(client_ip_str)); inet_ntop(AF_INET, &(addr->tuple4_v4->saddr), client_ip_str, sizeof(client_ip_str));
inet_ntop(AF_INET, &addr->tuple4_v4->daddr, server_ip_str, sizeof(server_ip_str)); inet_ntop(AF_INET, &(addr->tuple4_v4->daddr), server_ip_str, sizeof(server_ip_str));
cJSON_AddStringToObject(log_obj, "client_ip", client_ip_str); cJSON_AddStringToObject(log_obj, "client_ip", client_ip_str);
cJSON_AddStringToObject(log_obj, "server_ip", server_ip_str); cJSON_AddStringToObject(log_obj, "server_ip", server_ip_str);
cJSON_AddNumberToObject(log_obj, "client_port", ntohs(addr->tuple4_v4->source)); cJSON_AddNumberToObject(log_obj, "client_port", ntohs(addr->tuple4_v4->source));
@@ -362,8 +362,8 @@ static int log_generate(struct pme_info *pmeinfo, void *local_logger){
break; break;
case ADDR_TYPE_IPV6: case ADDR_TYPE_IPV6:
cJSON_AddNumberToObject(log_obj, "addr_type", 6); cJSON_AddNumberToObject(log_obj, "addr_type", 6);
inet_ntop(AF_INET6, &addr->tuple4_v6->saddr, client_ip_str, sizeof(client_ip_str)); inet_ntop(AF_INET6, addr->tuple4_v6->saddr, client_ip_str, sizeof(client_ip_str));
inet_ntop(AF_INET6, &addr->tuple4_v6->daddr, server_ip_str, sizeof(server_ip_str)); inet_ntop(AF_INET6, addr->tuple4_v6->daddr, server_ip_str, sizeof(server_ip_str));
cJSON_AddStringToObject(log_obj, "client_ip", client_ip_str); cJSON_AddStringToObject(log_obj, "client_ip", client_ip_str);
cJSON_AddStringToObject(log_obj, "server_ip", server_ip_str); cJSON_AddStringToObject(log_obj, "server_ip", server_ip_str);
cJSON_AddNumberToObject(log_obj, "client_port", ntohs(addr->tuple4_v6->source)); cJSON_AddNumberToObject(log_obj, "client_port", ntohs(addr->tuple4_v6->source));

View File

@@ -310,8 +310,8 @@ enum kni_action intercept_policy_scan(struct kni_maat_handle* handle, struct ipa
scan_status_t scan_mid = NULL; scan_status_t scan_mid = NULL;
int scan_ret = 0, hit_policy_cnt = 0, enforced_policy_idx = 0; int scan_ret = 0, hit_policy_cnt = 0, enforced_policy_idx = 0;
//scan subscribe_id //scan subscribe_id
char sip[INET6_ADDRSTRLEN]; char sip[INET6_ADDRSTRLEN] = "";
char dip[INET6_ADDRSTRLEN]; char dip[INET6_ADDRSTRLEN] = "";
get_ip_from_ipaddr(addr, sip, 0); get_ip_from_ipaddr(addr, sip, 0);
get_ip_from_ipaddr(addr, dip, 1); get_ip_from_ipaddr(addr, dip, 1);
char* source_subscribe_id = NULL, *dest_subscribe_id = NULL; char* source_subscribe_id = NULL, *dest_subscribe_id = NULL;