summaryrefslogtreecommitdiff
path: root/netcon
diff options
context:
space:
mode:
Diffstat (limited to 'netcon')
-rw-r--r--netcon/NetconEthernetTap.cpp48
-rw-r--r--netcon/NetconEthernetTap.hpp2
-rw-r--r--netcon/NetconUtilities.cpp71
-rw-r--r--netcon/NetconUtilities.hpp39
4 files changed, 41 insertions, 119 deletions
diff --git a/netcon/NetconEthernetTap.cpp b/netcon/NetconEthernetTap.cpp
index b722c682..da7a3d99 100644
--- a/netcon/NetconEthernetTap.cpp
+++ b/netcon/NetconEthernetTap.cpp
@@ -40,7 +40,6 @@
#include "Intercept.h"
#include "LWIPStack.hpp"
-#include "NetconUtilities.hpp"
#include "lwip/tcp_impl.h"
#include "netif/etharp.h"
@@ -59,6 +58,37 @@
namespace ZeroTier {
+// ---------------------------------------------------------------------------
+
+/*
+static void clearscreen(){
+ fprintf(stderr, "\033[2J");
+}
+static void gotoxy(int x,int y) {
+ fprintf(stderr, "%c[%d;%df",0x1B,y,x);
+}
+*/
+
+// Gets the process/path name associated with a pid
+static void get_path_from_pid(char* dest, int pid)
+{
+ char ppath[80];
+ sprintf(ppath, "/proc/%d/exe", pid);
+ if (readlink (ppath, dest, 80) != -1){
+ }
+}
+
+// Gets the process/path name associated with a fd
+/*
+static void get_path_from_fd(char* dest, int pid, int fd)
+{
+ char ppfd[80];
+ sprintf(ppfd, "/proc/%d/fd/%d", pid, fd);
+ if (readlink (ppfd, dest, 80) != -1){
+ }
+}
+*/
+
static err_t tapif_init(struct netif *netif)
{
// Actual init functionality is in addIp() of tap
@@ -137,6 +167,8 @@ public:
Larg(NetconEthernetTap *_tap, TcpConnection *conn) : tap(_tap), conn(conn) {}
};
+// ---------------------------------------------------------------------------
+
NetconEthernetTap::NetconEthernetTap(
const char *homePath,
const MAC &mac,
@@ -157,14 +189,15 @@ NetconEthernetTap::NetconEthernetTap(
_enabled(true),
_run(true)
{
+ char sockPath[4096],lwipPath[4096];
rpc_counter = -1;
- char sockPath[4096];
- Utils::snprintf(sockPath,sizeof(sockPath),"/tmp/.ztnc_%.16llx",(unsigned long long)nwid);
- _dev = sockPath;
+ Utils::snprintf(sockPath,sizeof(sockPath),"%s%snetcon_service_%.16llx",homePath,ZT_PATH_SEPARATOR_S,(unsigned long long)nwid);
+ _dev = sockPath; // in netcon mode, set device to be just the network ID
- lwipstack = new LWIPStack("ext/bin/lwip/liblwip.so"); // ext/bin/liblwip.so.debug for debug symbols
+ Utils::snprintf(lwipPath,sizeof(lwipPath),"%s%sliblwip.so",homePath,ZT_PATH_SEPARATOR_S);
+ lwipstack = new LWIPStack(lwipPath);
if(!lwipstack)
- throw std::runtime_error("unable to load lwip lib.");
+ throw std::runtime_error("unable to dynamically load a new instance of liblwip.so (searched ZeroTier home path)");
lwipstack->lwip_init();
_unixListenSocket = _phy.unixListen(sockPath,(void *)this);
@@ -290,7 +323,8 @@ void NetconEthernetTap::put(const MAC &from,const MAC &to,unsigned int etherType
}
}
-std::string NetconEthernetTap::deviceName() const {
+std::string NetconEthernetTap::deviceName() const
+{
return _dev;
}
diff --git a/netcon/NetconEthernetTap.hpp b/netcon/NetconEthernetTap.hpp
index 17d6ce4f..dd51a19d 100644
--- a/netcon/NetconEthernetTap.hpp
+++ b/netcon/NetconEthernetTap.hpp
@@ -44,8 +44,6 @@
#include "../osdep/Thread.hpp"
#include "../osdep/Phy.hpp"
-#include "NetconUtilities.hpp"
-
#include "netif/etharp.h"
struct tcp_pcb;
diff --git a/netcon/NetconUtilities.cpp b/netcon/NetconUtilities.cpp
deleted file mode 100644
index 9f8b902f..00000000
--- a/netcon/NetconUtilities.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-
-/*
- * ZeroTier One - Network Virtualization Everywhere
- * Copyright (C) 2011-2015 ZeroTier, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * --
- *
- * ZeroTier may be used and distributed under the terms of the GPLv3, which
- * are available at: http://www.gnu.org/licenses/gpl-3.0.html
- *
- * If you would like to embed ZeroTier into a commercial application or
- * redistribute it in a modified binary form, please contact ZeroTier Networks
- * LLC. Start here: http://www.zerotier.com/
- */
-
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <sys/socket.h>
-
-#include "lwip/ip.h"
-#include "lwip/ip_addr.h"
-#include "lwip/ip_frag.h"
-
-#ifndef _NETCON_UTILITIES_CPP
-#define _NETCON_UTILITIES_CPP
-
-namespace ZeroTier
-{
- void clearscreen(){
- fprintf(stderr, "\033[2J");
- }
- void gotoxy(int x,int y) {
- fprintf(stderr, "%c[%d;%df",0x1B,y,x);
- }
-
- // Gets the process/path name associated with a pid
- void get_path_from_pid(char* dest, int pid)
- {
- char ppath[80];
- sprintf(ppath, "/proc/%d/exe", pid);
- if (readlink (ppath, dest, 80) != -1){
- }
- }
-
- // Gets the process/path name associated with a fd
- void get_path_from_fd(char* dest, int pid, int fd)
- {
- char ppfd[80];
- sprintf(ppfd, "/proc/%d/fd/%d", pid, fd);
- if (readlink (ppfd, dest, 80) != -1){
- }
- }
-}
-
-#endif
diff --git a/netcon/NetconUtilities.hpp b/netcon/NetconUtilities.hpp
deleted file mode 100644
index 54550ba0..00000000
--- a/netcon/NetconUtilities.hpp
+++ /dev/null
@@ -1,39 +0,0 @@
-
-/*
- * ZeroTier One - Network Virtualization Everywhere
- * Copyright (C) 2011-2015 ZeroTier, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * --
- *
- * ZeroTier may be used and distributed under the terms of the GPLv3, which
- * are available at: http://www.gnu.org/licenses/gpl-3.0.html
- *
- * If you would like to embed ZeroTier into a commercial application or
- * redistribute it in a modified binary form, please contact ZeroTier Networks
- * LLC. Start here: http://www.zerotier.com/
- */
-
-#ifndef _NETCON_UTILITIES_H
-#define _NETCON_UTILITIES_H
-
-namespace ZeroTier
-{
- void clearscreen();
- void gotoxy(int x,int y);
- void get_path_from_pid(char* dest, int pid);
- void get_path_from_fd(char* dest, int pid, int fd);
-}
-#endif