Add support for compiling under MinGW + fix Windows compiling in general

This commit is contained in:
wuggy 2026-04-17 15:05:11 -07:00
commit a5cf494890
56 changed files with 243 additions and 76 deletions

View file

@ -43,9 +43,9 @@ public:
}
addr_ = buf;
is_vpn_ = (local_addr.interface.type & NR_INTERFACE_TYPE_VPN) != 0 ? 1 : 0;
estimated_speed_ = local_addr.interface.estimated_speed;
type_preference_ = GetNetworkTypePreference(local_addr.interface.type);
is_vpn_ = (local_addr.if_info.type & NR_INTERFACE_TYPE_VPN) != 0 ? 1 : 0;
estimated_speed_ = local_addr.if_info.estimated_speed;
type_preference_ = GetNetworkTypePreference(local_addr.if_info.type);
ip_version_ = local_addr.addr.ip_version;
return true;
}

View file

@ -1996,8 +1996,8 @@ class WebRtcIcePrioritizerTest : public StunTest {
std::string str_addr = "10.0.0." + num;
std::string ifname = "eth" + num;
nr_local_addr local_addr;
local_addr.interface.type = type;
local_addr.interface.estimated_speed = estimated_speed;
local_addr.if_info.type = type;
local_addr.if_info.estimated_speed = estimated_speed;
int r = nr_str_port_to_transport_addr(str_addr.c_str(), 0,
IPPROTO_UDP, &(local_addr.addr));

View file

@ -40,13 +40,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
int nr_local_addr_copy(nr_local_addr *to, nr_local_addr *from)
{
nr_transport_addr_copy(&(to->addr), &(from->addr));
to->interface = from->interface;
to->if_info = from->if_info;
return(0);
}
int nr_local_addr_fmt_info_string(nr_local_addr *addr, char *buf, int len)
{
int addr_type = addr->interface.type;
int addr_type = addr->if_info.type;
const char *vpn = (addr_type & NR_INTERFACE_TYPE_VPN) ? "VPN on " : "";
const char *type = (addr_type & NR_INTERFACE_TYPE_WIRED) ? "wired" :
@ -55,7 +55,7 @@ int nr_local_addr_fmt_info_string(nr_local_addr *addr, char *buf, int len)
"unknown";
snprintf(buf, len, "%s%s, estimated speed: %d kbps",
vpn, type, addr->interface.estimated_speed);
vpn, type, addr->if_info.estimated_speed);
buf[len - 1] = '\0';
return (0);
}

View file

@ -50,7 +50,7 @@ typedef struct nr_interface_ {
typedef struct nr_local_addr_ {
nr_transport_addr addr;
nr_interface interface;
nr_interface if_info;
} nr_local_addr;
int nr_local_addr_copy(nr_local_addr *to, nr_local_addr *from);

View file

@ -220,18 +220,18 @@ stun_get_win32_addrs(nr_local_addr addrs[], int maxaddrs, int *count)
strlcpy(addrs[n].addr.ifname, hex_hashed_ifname, sizeof(addrs[n].addr.ifname));
if (tmpAddress->IfType == IF_TYPE_ETHERNET_CSMACD) {
addrs[n].interface.type = NR_INTERFACE_TYPE_WIRED;
addrs[n].if_info.type = NR_INTERFACE_TYPE_WIRED;
} else if (tmpAddress->IfType == IF_TYPE_IEEE80211) {
/* Note: this only works for >= Win Vista */
addrs[n].interface.type = NR_INTERFACE_TYPE_WIFI;
addrs[n].if_info.type = NR_INTERFACE_TYPE_WIFI;
} else {
addrs[n].interface.type = NR_INTERFACE_TYPE_UNKNOWN;
addrs[n].if_info.type = NR_INTERFACE_TYPE_UNKNOWN;
}
#if (_WIN32_WINNT >= 0x0600)
/* Note: only >= Vista provide link speed information */
addrs[n].interface.estimated_speed = tmpAddress->TransmitLinkSpeed / 1000;
addrs[n].if_info.estimated_speed = tmpAddress->TransmitLinkSpeed / 1000;
#else
addrs[n].interface.estimated_speed = 0;
addrs[n].if_info.estimated_speed = 0;
#endif
if (++n >= maxaddrs)
goto done;
@ -300,11 +300,11 @@ stun_getifaddrs(nr_local_addr addrs[], int maxaddrs, int *count)
{
/* For wireless network, we won't get ethtool, it's a wired
* connection */
addrs[*count].interface.type = NR_INTERFACE_TYPE_WIRED;
addrs[*count].if_info.type = NR_INTERFACE_TYPE_WIRED;
#ifdef DONT_HAVE_ETHTOOL_SPEED_HI
addrs[*count].interface.estimated_speed = ecmd.speed;
addrs[*count].if_info.estimated_speed = ecmd.speed;
#else
addrs[*count].interface.estimated_speed = ((ecmd.speed_hi << 16) | ecmd.speed) * 1000;
addrs[*count].if_info.estimated_speed = ((ecmd.speed_hi << 16) | ecmd.speed) * 1000;
#endif
}
@ -312,20 +312,20 @@ stun_getifaddrs(nr_local_addr addrs[], int maxaddrs, int *count)
e = ioctl(s, SIOCGIWRATE, &wrq);
if (e == 0)
{
addrs[*count].interface.type = NR_INTERFACE_TYPE_WIFI;
addrs[*count].interface.estimated_speed = wrq.u.bitrate.value / 1000;
addrs[*count].if_info.type = NR_INTERFACE_TYPE_WIFI;
addrs[*count].if_info.estimated_speed = wrq.u.bitrate.value / 1000;
}
close(s);
if (if_addr->ifa_flags & IFF_POINTOPOINT)
{
addrs[*count].interface.type = NR_INTERFACE_TYPE_UNKNOWN | NR_INTERFACE_TYPE_VPN;
addrs[*count].if_info.type = NR_INTERFACE_TYPE_UNKNOWN | NR_INTERFACE_TYPE_VPN;
/* TODO (Bug 896913): find backend network type of this VPN */
}
#else
addrs[*count].interface.type = NR_INTERFACE_TYPE_UNKNOWN;
addrs[*count].interface.estimated_speed = 0;
addrs[*count].if_info.type = NR_INTERFACE_TYPE_UNKNOWN;
addrs[*count].if_info.estimated_speed = 0;
#endif
strlcpy(addrs[*count].addr.ifname, if_addr->ifa_name, sizeof(addrs[*count].addr.ifname));
++(*count);