mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-07-05 12:36:14 -07:00
Port multipath improvements to newer version
This commit is contained in:
parent
024649c175
commit
2e6cda38f6
9 changed files with 120 additions and 47 deletions
|
@ -146,6 +146,7 @@ private:
|
|||
PhySocketType type;
|
||||
ZT_PHY_SOCKFD_TYPE sock;
|
||||
void *uptr; // user-settable pointer
|
||||
uint16_t localPort;
|
||||
ZT_PHY_SOCKADDR_STORAGE_TYPE saddr; // remote for TCP_OUT and TCP_IN, local for TCP_LISTEN, RAW, and UDP
|
||||
};
|
||||
|
||||
|
@ -244,6 +245,18 @@ public:
|
|||
return &(reinterpret_cast<PhySocketImpl*>(s)->uptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the local port corresponding to this PhySocket
|
||||
*
|
||||
* @param s Socket object
|
||||
*
|
||||
* @return Local port corresponding to this PhySocket
|
||||
*/
|
||||
static inline uint16_t getLocalPort(PhySocket* s) throw()
|
||||
{
|
||||
return reinterpret_cast<PhySocketImpl*>(s)->localPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cause poll() to stop waiting immediately
|
||||
*
|
||||
|
@ -417,6 +430,11 @@ public:
|
|||
sws.type = ZT_PHY_SOCKET_UDP;
|
||||
sws.sock = s;
|
||||
sws.uptr = uptr;
|
||||
|
||||
#ifdef __UNIX_LIKE__
|
||||
struct sockaddr_in *sin = (struct sockaddr_in *)localAddress;
|
||||
sws.localPort = htons(sin->sin_port);
|
||||
#endif
|
||||
memset(&(sws.saddr),0,sizeof(struct sockaddr_storage));
|
||||
memcpy(&(sws.saddr),localAddress,(localAddress->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue