mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
More Windows tweaks and a compile fix.
This commit is contained in:
parent
d3cb063d13
commit
b6f6ed35fc
2 changed files with 65 additions and 57 deletions
|
@ -2299,7 +2299,7 @@ http_parse_host_char(enum http_host_state s, const char ch) {
|
||||||
|
|
||||||
static int
|
static int
|
||||||
http_parse_host(const char * buf, struct http_parser_url *u, int found_at) {
|
http_parse_host(const char * buf, struct http_parser_url *u, int found_at) {
|
||||||
assert(u->field_set & (1 << UF_HOST));
|
//assert(u->field_set & (1 << UF_HOST));
|
||||||
enum http_host_state s;
|
enum http_host_state s;
|
||||||
|
|
||||||
const char *p;
|
const char *p;
|
||||||
|
|
|
@ -695,7 +695,8 @@ bool WindowsEthernetTap::removeIp(const InetAddress &ip)
|
||||||
try {
|
try {
|
||||||
MIB_UNICASTIPADDRESS_TABLE *ipt = (MIB_UNICASTIPADDRESS_TABLE *)0;
|
MIB_UNICASTIPADDRESS_TABLE *ipt = (MIB_UNICASTIPADDRESS_TABLE *)0;
|
||||||
if (GetUnicastIpAddressTable(AF_UNSPEC,&ipt) == NO_ERROR) {
|
if (GetUnicastIpAddressTable(AF_UNSPEC,&ipt) == NO_ERROR) {
|
||||||
for(DWORD i=0;i<ipt->NumEntries;++i) {
|
if ((ipt)&&(ipt->NumEntries > 0)) {
|
||||||
|
for(DWORD i=0;i<(DWORD)ipt->NumEntries;++i) {
|
||||||
if (ipt->Table[i].InterfaceLuid.Value == _deviceLuid.Value) {
|
if (ipt->Table[i].InterfaceLuid.Value == _deviceLuid.Value) {
|
||||||
InetAddress addr;
|
InetAddress addr;
|
||||||
switch(ipt->Table[i].Address.si_family) {
|
switch(ipt->Table[i].Address.si_family) {
|
||||||
|
@ -729,6 +730,7 @@ bool WindowsEthernetTap::removeIp(const InetAddress &ip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
FreeMibTable((PVOID)ipt);
|
FreeMibTable((PVOID)ipt);
|
||||||
}
|
}
|
||||||
} catch ( ... ) {}
|
} catch ( ... ) {}
|
||||||
|
@ -746,7 +748,8 @@ std::vector<InetAddress> WindowsEthernetTap::ips() const
|
||||||
try {
|
try {
|
||||||
MIB_UNICASTIPADDRESS_TABLE *ipt = (MIB_UNICASTIPADDRESS_TABLE *)0;
|
MIB_UNICASTIPADDRESS_TABLE *ipt = (MIB_UNICASTIPADDRESS_TABLE *)0;
|
||||||
if (GetUnicastIpAddressTable(AF_UNSPEC,&ipt) == NO_ERROR) {
|
if (GetUnicastIpAddressTable(AF_UNSPEC,&ipt) == NO_ERROR) {
|
||||||
for(DWORD i=0;i<ipt->NumEntries;++i) {
|
if ((ipt)&&(ipt->NumEntries > 0)) {
|
||||||
|
for(DWORD i=0;i<(DWORD)ipt->NumEntries;++i) {
|
||||||
if (ipt->Table[i].InterfaceLuid.Value == _deviceLuid.Value) {
|
if (ipt->Table[i].InterfaceLuid.Value == _deviceLuid.Value) {
|
||||||
switch(ipt->Table[i].Address.si_family) {
|
switch(ipt->Table[i].Address.si_family) {
|
||||||
case AF_INET: {
|
case AF_INET: {
|
||||||
|
@ -762,12 +765,13 @@ std::vector<InetAddress> WindowsEthernetTap::ips() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
FreeMibTable(ipt);
|
FreeMibTable(ipt);
|
||||||
}
|
}
|
||||||
} catch ( ... ) {} // sanity check, shouldn't happen unless out of memory
|
} catch ( ... ) {} // sanity check, shouldn't happen unless out of memory
|
||||||
|
|
||||||
std::sort(addrs.begin(),addrs.end());
|
std::sort(addrs.begin(),addrs.end());
|
||||||
std::unique(addrs.begin(),addrs.end());
|
addrs.erase(std::unique(addrs.begin(),addrs.end()),addrs.end());
|
||||||
|
|
||||||
return addrs;
|
return addrs;
|
||||||
}
|
}
|
||||||
|
@ -824,6 +828,7 @@ void WindowsEthernetTap::scanMulticastGroups(std::vector<MulticastGroup> &added,
|
||||||
unsigned char mcastbuf[TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS_OUTPUT_BUF_SIZE];
|
unsigned char mcastbuf[TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS_OUTPUT_BUF_SIZE];
|
||||||
DWORD bytesReturned = 0;
|
DWORD bytesReturned = 0;
|
||||||
if (DeviceIoControl(t,TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS,(LPVOID)0,0,(LPVOID)mcastbuf,sizeof(mcastbuf),&bytesReturned,NULL)) {
|
if (DeviceIoControl(t,TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS,(LPVOID)0,0,(LPVOID)mcastbuf,sizeof(mcastbuf),&bytesReturned,NULL)) {
|
||||||
|
if ((bytesReturned > 0)&&(bytesReturned <= TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS_OUTPUT_BUF_SIZE)) { // sanity check
|
||||||
MAC mac;
|
MAC mac;
|
||||||
DWORD i = 0;
|
DWORD i = 0;
|
||||||
while ((i + 6) <= bytesReturned) {
|
while ((i + 6) <= bytesReturned) {
|
||||||
|
@ -835,13 +840,14 @@ void WindowsEthernetTap::scanMulticastGroups(std::vector<MulticastGroup> &added,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<InetAddress> allIps(ips());
|
std::vector<InetAddress> allIps(ips());
|
||||||
for(std::vector<InetAddress>::iterator ip(allIps.begin());ip!=allIps.end();++ip)
|
for(std::vector<InetAddress>::iterator ip(allIps.begin());ip!=allIps.end();++ip)
|
||||||
newGroups.push_back(MulticastGroup::deriveMulticastGroupForAddressResolution(*ip));
|
newGroups.push_back(MulticastGroup::deriveMulticastGroupForAddressResolution(*ip));
|
||||||
|
|
||||||
std::sort(newGroups.begin(),newGroups.end());
|
std::sort(newGroups.begin(),newGroups.end());
|
||||||
std::unique(newGroups.begin(),newGroups.end());
|
newGroups.erase(std::unique(newGroups.begin(),newGroups.end()),newGroups.end());
|
||||||
|
|
||||||
for(std::vector<MulticastGroup>::iterator m(newGroups.begin());m!=newGroups.end();++m) {
|
for(std::vector<MulticastGroup>::iterator m(newGroups.begin());m!=newGroups.end();++m) {
|
||||||
if (!std::binary_search(_multicastGroups.begin(),_multicastGroups.end(),*m))
|
if (!std::binary_search(_multicastGroups.begin(),_multicastGroups.end(),*m))
|
||||||
|
@ -1077,6 +1083,7 @@ NET_IFINDEX WindowsEthernetTap::_getDeviceIndex()
|
||||||
if (GetIfTable2Ex(MibIfTableRaw,&ift) != NO_ERROR)
|
if (GetIfTable2Ex(MibIfTableRaw,&ift) != NO_ERROR)
|
||||||
throw std::runtime_error("GetIfTable2Ex() failed");
|
throw std::runtime_error("GetIfTable2Ex() failed");
|
||||||
|
|
||||||
|
if (ift->NumEntries > 0) {
|
||||||
for(ULONG i=0;i<ift->NumEntries;++i) {
|
for(ULONG i=0;i<ift->NumEntries;++i) {
|
||||||
if (ift->Table[i].InterfaceLuid.Value == _deviceLuid.Value) {
|
if (ift->Table[i].InterfaceLuid.Value == _deviceLuid.Value) {
|
||||||
NET_IFINDEX idx = ift->Table[i].InterfaceIndex;
|
NET_IFINDEX idx = ift->Table[i].InterfaceIndex;
|
||||||
|
@ -1084,6 +1091,7 @@ NET_IFINDEX WindowsEthernetTap::_getDeviceIndex()
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FreeMibTable(&ift);
|
FreeMibTable(&ift);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue