summaryrefslogtreecommitdiff
path: root/node/Node.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-07-06 15:51:04 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-07-06 15:51:04 -0700
commit235f4762b700174c795b28de7d4fe2f70cddbcd8 (patch)
tree2acca7f20487cf20eac76466debdfa60424128da /node/Node.cpp
parent79e9a8bcc26491a43577082ec7edb86020f7ec00 (diff)
downloadinfinitytier-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.cpp28
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;