Improved multipath link monitoring
This commit is contained in:
parent
0797adf223
commit
bc521504ca
9 changed files with 232 additions and 255 deletions
|
@ -66,6 +66,9 @@
|
|||
// Max number of bindings
|
||||
#define ZT_BINDER_MAX_BINDINGS 256
|
||||
|
||||
// Maximum physical interface name length. This number is gigantic because of Windows.
|
||||
#define ZT_MAX_PHYSIFNAME 256
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
/**
|
||||
|
@ -88,6 +91,7 @@ class Binder {
|
|||
PhySocket* udpSock;
|
||||
PhySocket* tcpListenSock;
|
||||
InetAddress address;
|
||||
char ifname[256] = {};
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -443,7 +447,7 @@ class Binder {
|
|||
_bindings[_bindingCount].udpSock = udps;
|
||||
_bindings[_bindingCount].tcpListenSock = tcps;
|
||||
_bindings[_bindingCount].address = ii->first;
|
||||
phy.setIfName(udps, (char*)ii->second.c_str(), (int)ii->second.length());
|
||||
memcpy(_bindings[_bindingCount].ifname, (char*)ii->second.c_str(), (int)ii->second.length());
|
||||
++_bindingCount;
|
||||
}
|
||||
}
|
||||
|
@ -514,6 +518,22 @@ class Binder {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param s Socket object
|
||||
* @param nameBuf Buffer to store name of interface which this Socket object is bound to
|
||||
* @param buflen Length of buffer to copy name into
|
||||
*/
|
||||
void getIfName(PhySocket* s, char* nameBuf, int buflen) const
|
||||
{
|
||||
Mutex::Lock _l(_lock);
|
||||
for (unsigned int b = 0, c = _bindingCount; b < c; ++b) {
|
||||
if (_bindings[b].udpSock == s) {
|
||||
memcpy(nameBuf, _bindings[b].ifname, buflen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
_Binding _bindings[ZT_BINDER_MAX_BINDINGS];
|
||||
std::atomic<unsigned int> _bindingCount;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue