summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Henry <josephjah@gmail.com>2016-01-17 15:13:32 -0800
committerJoseph Henry <josephjah@gmail.com>2016-01-17 15:13:32 -0800
commit1783867f9692a4eb5ad18fb534a397f23a9d95c5 (patch)
tree09528d228d23d59f32b35b606ec90bb83faa0016
parenta73638b214a49828c982d8780c1b7b6bee610722 (diff)
downloadinfinitytier-1783867f9692a4eb5ad18fb534a397f23a9d95c5.tar.gz
infinitytier-1783867f9692a4eb5ad18fb534a397f23a9d95c5.zip
Print path for user. Removed unused stub Phy methods
-rw-r--r--netcon/NetconEthernetTap.cpp46
-rw-r--r--netcon/NetconEthernetTap.hpp43
-rw-r--r--osdep/Phy.hpp4
3 files changed, 34 insertions, 59 deletions
diff --git a/netcon/NetconEthernetTap.cpp b/netcon/NetconEthernetTap.cpp
index c0691dbd..00c0f42a 100644
--- a/netcon/NetconEthernetTap.cpp
+++ b/netcon/NetconEthernetTap.cpp
@@ -54,12 +54,6 @@
#include "common.inc.c"
#include "RPC.h"
-#define APPLICATION_POLL_FREQ 50
-#define ZT_LWIP_TCP_TIMER_INTERVAL 5
-#define STATUS_TMR_INTERVAL 1000 // How often we check connection statuses (in ms)
-#define DEFAULT_BUF_SZ 1024 * 1024 * 2
-
-
namespace ZeroTier {
// ---------------------------------------------------------------------------
@@ -104,32 +98,6 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p)
return ERR_OK;
}
-/*
- * TCP connection administered by service
- */
-class TcpConnection
-{
-public:
- bool listening;
- int pid, txsz, rxsz;
- PhySocket *rpcSock, *sock;
- struct tcp_pcb *pcb;
- struct sockaddr_storage *addr;
- unsigned char txbuf[DEFAULT_BUF_SZ];
- unsigned char rxbuf[DEFAULT_BUF_SZ];
-};
-
-/*
- * A helper class for passing a reference to _phy to LWIP callbacks as a "state"
- */
-class Larg
-{
-public:
- NetconEthernetTap *tap;
- TcpConnection *conn;
- Larg(NetconEthernetTap *_tap, TcpConnection *conn) : tap(_tap), conn(conn) {}
-};
-
// ---------------------------------------------------------------------------
NetconEthernetTap::NetconEthernetTap(
@@ -164,7 +132,7 @@ NetconEthernetTap::NetconEthernetTap(
lwipstack->lwip_init();
_unixListenSocket = _phy.unixListen(sockPath,(void *)this);
- dwr(MSG_INFO," NetconEthernetTap initialized!\n", _phy.getDescriptor(_unixListenSocket));
+ fprintf(stderr," NetconEthernetTap initialized on: %s\n", sockPath);
if (!_unixListenSocket)
throw std::runtime_error(std::string("unable to bind to ")+sockPath);
_thread = Thread::start(this);
@@ -457,14 +425,6 @@ void NetconEthernetTap::phyOnUnixClose(PhySocket *sock,void **uptr) {
closeConnection(sock);
}
-void NetconEthernetTap::phyOnFileDescriptorActivity(PhySocket *sock,void **uptr,bool readable,bool writable) {
- // Currently unused since phyOnUnixData() handles everything now
-}
-
-void NetconEthernetTap::phyOnUnixAccept(PhySocket *sockL,PhySocket *sockN,void **uptrL,void **uptrN) {
- dwr(MSG_DEBUG,"\nphyOnUnixAccept(): new connection = %x\n", sockN);
-}
-
void NetconEthernetTap::phyOnUnixWritable(PhySocket *sock,void **uptr)
{
TcpConnection *conn = getConnection(sock);
@@ -571,13 +531,13 @@ void NetconEthernetTap::phyOnUnixData(PhySocket *sock,void **uptr,void *data,uns
data_start = padding_pos+PADDING_SZ;
memcpy((&conn->txbuf)+conn->txsz, buf+data_start, wlen);
}
- // [CANARY] + [TOKEN]
+ // [DATA] + [CANARY]
if(len > CANARY_SZ+PADDING_SZ && canary_pos > 0 && canary_pos == len - CANARY_SZ+PADDING_SZ) {
wlen = len - CANARY_SZ+PADDING_SZ;
data_start = 0;
memcpy((&conn->txbuf)+conn->txsz, buf+data_start, wlen);
}
- // [CANARY] + [TOKEN] + [DATA]
+ // [DATA] + [CANARY] + [DATA]
if(len > CANARY_SZ+PADDING_SZ && canary_pos > 0 && len > (canary_pos + CANARY_SZ+PADDING_SZ)) {
wlen = len - CANARY_SZ+PADDING_SZ;
data_start = 0;
diff --git a/netcon/NetconEthernetTap.hpp b/netcon/NetconEthernetTap.hpp
index 47f50e4c..673863b3 100644
--- a/netcon/NetconEthernetTap.hpp
+++ b/netcon/NetconEthernetTap.hpp
@@ -56,15 +56,41 @@ struct connect_st;
struct getsockname_st;
struct accept_st;
+#define APPLICATION_POLL_FREQ 50
+#define ZT_LWIP_TCP_TIMER_INTERVAL 5
+#define STATUS_TMR_INTERVAL 1000 // How often we check connection statuses (in ms)
+#define DEFAULT_BUF_SZ 1024 * 1024 * 2
namespace ZeroTier {
class NetconEthernetTap;
-class TcpConnection;
-class Larg;
class LWIPStack;
-/**
+/*
+ * TCP connection administered by service
+ */
+struct TcpConnection
+{
+ bool listening;
+ int pid, txsz, rxsz;
+ PhySocket *rpcSock, *sock;
+ struct tcp_pcb *pcb;
+ struct sockaddr_storage *addr;
+ unsigned char txbuf[DEFAULT_BUF_SZ];
+ unsigned char rxbuf[DEFAULT_BUF_SZ];
+};
+
+/*
+ * A helper for passing a reference to _phy to LWIP callbacks as a "state"
+ */
+struct Larg
+{
+ NetconEthernetTap *tap;
+ TcpConnection *conn;
+ Larg(NetconEthernetTap *_tap, TcpConnection *conn) : tap(_tap), conn(conn) {}
+};
+
+/*
* Network Containers instance -- emulates an Ethernet tap device as far as OneService knows
*/
class NetconEthernetTap
@@ -366,11 +392,6 @@ private:
void phyOnTcpWritable(PhySocket *sock,void **uptr);
/*
- * Add a new PhySocket for the client connections
- */
- void phyOnUnixAccept(PhySocket *sockL,PhySocket *sockN,void **uptrL,void **uptrN);
-
- /*
* Signals us to close the TcpConnection associated with this PhySocket
*/
void phyOnUnixClose(PhySocket *sock,void **uptr);
@@ -384,12 +405,6 @@ private:
* Notifies us that we can write to an application's socket
*/
void phyOnUnixWritable(PhySocket *sock,void **uptr);
-
- /*
- * Handles data on a application's data buffer. Data is sent to LWIP to be enqueued.
- * TODO: This is a candidate for removal now that phyOnUnixData() is used for everything
- */
- void phyOnFileDescriptorActivity(PhySocket *sock,void **uptr,bool readable,bool writable);
/*
* Returns a pointer to a TcpConnection associated with a given PhySocket
diff --git a/osdep/Phy.hpp b/osdep/Phy.hpp
index 7dc0b5dd..bdf20d13 100644
--- a/osdep/Phy.hpp
+++ b/osdep/Phy.hpp
@@ -1013,7 +1013,7 @@ public:
sws.uptr = (void *)0;
memcpy(&(sws.saddr),&ss,sizeof(struct sockaddr_storage));
try {
- _handler->phyOnUnixAccept((PhySocket *)&(*s),(PhySocket *)&(_socks.back()),&(s->uptr),&(sws.uptr));
+ //_handler->phyOnUnixAccept((PhySocket *)&(*s),(PhySocket *)&(_socks.back()),&(s->uptr),&(sws.uptr));
} catch ( ... ) {}
}
}
@@ -1027,7 +1027,7 @@ public:
const bool writable = ((FD_ISSET(sock,&wfds))&&(FD_ISSET(sock,&_writefds)));
if ((readable)||(writable)) {
try {
- _handler->phyOnFileDescriptorActivity((PhySocket *)&(*s),&(s->uptr),readable,writable);
+ //_handler->phyOnFileDescriptorActivity((PhySocket *)&(*s),&(s->uptr),readable,writable);
} catch ( ... ) {}
}
} break;