aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/ndpi_main.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index 39443bec7..781fc1e29 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -2770,7 +2770,7 @@ static int ndpi_add_host_ip_subprotocol(struct ndpi_detection_module_struct *ndp
}
memset(&hints, 0, sizeof(struct addrinfo));
- hints.ai_family = is_ipv6 ? AF_INET6 : AF_INET;
+ hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_CANONNAME;
@@ -2793,6 +2793,7 @@ static int ndpi_add_host_ip_subprotocol(struct ndpi_detection_module_struct *ndp
memcpy(&pin, &(addr->sin_addr), sizeof(struct in_addr));
value_ready = true;
+ bits = 32;
break;
}
}
@@ -2819,6 +2820,7 @@ static int ndpi_add_host_ip_subprotocol(struct ndpi_detection_module_struct *ndp
memcpy(&pin6, &(addr->sin6_addr), sizeof(struct in6_addr));
value_ready = true;
+ bits = 128;
break;
}
}
@@ -3058,6 +3060,12 @@ struct ndpi_detection_module_struct *ndpi_init_detection_module(ndpi_init_prefs
return(NULL);
}
+#ifdef WIN32
+ /* Required to use getaddrinfo on Windows */
+ WSADATA wsaData;
+ WSAStartup(MAKEWORD(2, 2), &wsaData);
+#endif
+
memset(ndpi_str, 0, sizeof(struct ndpi_detection_module_struct));
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
@@ -3943,6 +3951,10 @@ void ndpi_exit_detection_module(struct ndpi_detection_module_struct *ndpi_str) {
ndpi_free(ndpi_str->callback_buffer_tcp_payload);
ndpi_free(ndpi_str);
}
+
+#ifdef WIN32
+ WSACleanup();
+#endif
}
/* ****************************************************** */