diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-07-06 15:51:04 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-07-06 15:51:04 -0700 |
commit | 235f4762b700174c795b28de7d4fe2f70cddbcd8 (patch) | |
tree | 2acca7f20487cf20eac76466debdfa60424128da /node/Node.cpp | |
parent | 79e9a8bcc26491a43577082ec7edb86020f7ec00 (diff) | |
download | infinitytier-235f4762b700174c795b28de7d4fe2f70cddbcd8.tar.gz infinitytier-235f4762b700174c795b28de7d4fe2f70cddbcd8.zip |
Plumbing for local interface addresses -- GitHub issue #180
Diffstat (limited to 'node/Node.cpp')
-rw-r--r-- | node/Node.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/node/Node.cpp b/node/Node.cpp index 7c70db97..057dc285 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -426,6 +426,20 @@ void Node::freeQueryResult(void *qr) ::free(qr); } +void Node::addLocalInterfaceAddress(const struct sockaddr_storage *addr,int metric,ZT1_LocalInterfaceAddressTrust trust,int reliable) +{ + Mutex::Lock _l(_directPaths_m); + _directPaths.push_back(Path(*(reinterpret_cast<const InetAddress *>(addr)),metric,(Path::Trust)trust,reliable != 0)); + std::sort(_directPaths.begin(),_directPaths.end()); + _directPaths.erase(std::unique(_directPaths.begin(),_directPaths.end()),_directPaths.end()); +} + +void Node::clearLocalInterfaceAddresses() +{ + Mutex::Lock _l(_directPaths_m); + _directPaths.clear(); +} + void Node::setNetconfMaster(void *networkControllerInstance) { RR->localNetworkController = reinterpret_cast<NetworkController *>(networkControllerInstance); @@ -679,6 +693,20 @@ void ZT1_Node_setNetconfMaster(ZT1_Node *node,void *networkControllerInstance) } catch ( ... ) {} } +void ZT1_Node_addLocalInterfaceAddress(ZT1_Node *node,const struct sockaddr_storage *addr,int metric,ZT1_LocalInterfaceAddressTrust trust,int reliable) +{ + try { + reinterpret_cast<ZeroTier::Node *>(node)->addLocalInterfaceAddress(addr,metric,trust,reliable); + } catch ( ... ) {} +} + +void ZT1_Node_clearLocalInterfaceAddresses(ZT1_Node *node) +{ + try { + reinterpret_cast<ZeroTier::Node *>(node)->clearLocalInterfaceAddresses(); + } catch ( ... ) {} +} + void ZT1_version(int *major,int *minor,int *revision,unsigned long *featureFlags) { if (major) *major = ZEROTIER_ONE_VERSION_MAJOR; |