Fix bug in returned interface address

This commit is contained in:
Hamish Coleman 2023-06-21 18:23:34 +01:00
parent 7b77950352
commit 4f9a7d31d3
3 changed files with 4 additions and 5 deletions

View File

@ -43,8 +43,7 @@ struct tunread_arg {
};
extern HANDLE startTunReadThread (struct tunread_arg *arg);
int get_best_interface_ip (n2n_edge_t * eee, dec_ip_str_t ip_addr);
int get_best_interface_ip (n2n_edge_t * eee, dec_ip_str_t *ip_addr);
#endif /* WIN32 */

View File

@ -1184,7 +1184,7 @@ static void check_join_multicast_group (n2n_edge_t *eee) {
mreq.imr_multiaddr.s_addr = inet_addr(N2N_MULTICAST_GROUP);
#ifdef WIN32
dec_ip_str_t ip_addr;
get_best_interface_ip(eee, ip_addr);
get_best_interface_ip(eee, &ip_addr);
mreq.imr_interface.s_addr = inet_addr(ip_addr);
#else
mreq.imr_interface.s_addr = htonl(INADDR_ANY);

View File

@ -51,7 +51,7 @@ HANDLE startTunReadThread (struct tunread_arg *arg) {
int get_best_interface_ip (n2n_edge_t * eee, dec_ip_str_t ip_addr){
int get_best_interface_ip (n2n_edge_t * eee, dec_ip_str_t *ip_addr){
DWORD interface_index = -1;
DWORD dwRetVal = 0;
PIP_ADAPTER_INFO pAdapterInfo = NULL, pAdapter = NULL;
@ -94,7 +94,7 @@ int get_best_interface_ip (n2n_edge_t * eee, dec_ip_str_t ip_addr){
traceEvent(TRACE_DEBUG, "IP Address: %s\n", pAdapter->IpAddressList.IpAddress.String);
traceEvent(TRACE_DEBUG, "IP Mask: %s\n", pAdapter->IpAddressList.IpMask.String);
traceEvent(TRACE_DEBUG, "Gateway: %s\n", pAdapter->GatewayList.IpAddress.String);
strncpy(ip_addr, pAdapter->IpAddressList.IpAddress.String, sizeof(dec_ip_str_t)-1);
strncpy(ip_addr, pAdapter->IpAddressList.IpAddress.String, sizeof(*ip_addr));
}
} else {
traceEvent(TRACE_WARNING, "GetAdaptersInfo failed with error: %d\n", dwRetVal);