Browse Source

Fix bug in returned interface address

pull/1123/head
Hamish Coleman 1 year ago
parent
commit
4f9a7d31d3
  1. 3
      include/edge_utils_win32.h
  2. 2
      src/edge_utils.c
  3. 4
      src/edge_utils_win32.c

3
include/edge_utils_win32.h

@ -43,8 +43,7 @@ struct tunread_arg {
}; };
extern HANDLE startTunReadThread (struct tunread_arg *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 */ #endif /* WIN32 */

2
src/edge_utils.c

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

4
src/edge_utils_win32.c

@ -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 interface_index = -1;
DWORD dwRetVal = 0; DWORD dwRetVal = 0;
PIP_ADAPTER_INFO pAdapterInfo = NULL, pAdapter = NULL; 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 Address: %s\n", pAdapter->IpAddressList.IpAddress.String);
traceEvent(TRACE_DEBUG, "IP Mask: %s\n", pAdapter->IpAddressList.IpMask.String); traceEvent(TRACE_DEBUG, "IP Mask: %s\n", pAdapter->IpAddressList.IpMask.String);
traceEvent(TRACE_DEBUG, "Gateway: %s\n", pAdapter->GatewayList.IpAddress.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 { } else {
traceEvent(TRACE_WARNING, "GetAdaptersInfo failed with error: %d\n", dwRetVal); traceEvent(TRACE_WARNING, "GetAdaptersInfo failed with error: %d\n", dwRetVal);

Loading…
Cancel
Save