mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
Print path for user. Removed unused stub Phy methods
This commit is contained in:
parent
a73638b214
commit
1783867f96
3 changed files with 34 additions and 59 deletions
|
@ -54,12 +54,6 @@
|
||||||
#include "common.inc.c"
|
#include "common.inc.c"
|
||||||
#include "RPC.h"
|
#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 {
|
namespace ZeroTier {
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -104,32 +98,6 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p)
|
||||||
return ERR_OK;
|
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(
|
NetconEthernetTap::NetconEthernetTap(
|
||||||
|
@ -164,7 +132,7 @@ NetconEthernetTap::NetconEthernetTap(
|
||||||
lwipstack->lwip_init();
|
lwipstack->lwip_init();
|
||||||
|
|
||||||
_unixListenSocket = _phy.unixListen(sockPath,(void *)this);
|
_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)
|
if (!_unixListenSocket)
|
||||||
throw std::runtime_error(std::string("unable to bind to ")+sockPath);
|
throw std::runtime_error(std::string("unable to bind to ")+sockPath);
|
||||||
_thread = Thread::start(this);
|
_thread = Thread::start(this);
|
||||||
|
@ -457,14 +425,6 @@ void NetconEthernetTap::phyOnUnixClose(PhySocket *sock,void **uptr) {
|
||||||
closeConnection(sock);
|
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)
|
void NetconEthernetTap::phyOnUnixWritable(PhySocket *sock,void **uptr)
|
||||||
{
|
{
|
||||||
TcpConnection *conn = getConnection(sock);
|
TcpConnection *conn = getConnection(sock);
|
||||||
|
@ -571,13 +531,13 @@ void NetconEthernetTap::phyOnUnixData(PhySocket *sock,void **uptr,void *data,uns
|
||||||
data_start = padding_pos+PADDING_SZ;
|
data_start = padding_pos+PADDING_SZ;
|
||||||
memcpy((&conn->txbuf)+conn->txsz, buf+data_start, wlen);
|
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) {
|
if(len > CANARY_SZ+PADDING_SZ && canary_pos > 0 && canary_pos == len - CANARY_SZ+PADDING_SZ) {
|
||||||
wlen = len - CANARY_SZ+PADDING_SZ;
|
wlen = len - CANARY_SZ+PADDING_SZ;
|
||||||
data_start = 0;
|
data_start = 0;
|
||||||
memcpy((&conn->txbuf)+conn->txsz, buf+data_start, wlen);
|
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)) {
|
if(len > CANARY_SZ+PADDING_SZ && canary_pos > 0 && len > (canary_pos + CANARY_SZ+PADDING_SZ)) {
|
||||||
wlen = len - CANARY_SZ+PADDING_SZ;
|
wlen = len - CANARY_SZ+PADDING_SZ;
|
||||||
data_start = 0;
|
data_start = 0;
|
||||||
|
|
|
@ -56,15 +56,41 @@ struct connect_st;
|
||||||
struct getsockname_st;
|
struct getsockname_st;
|
||||||
struct accept_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 {
|
namespace ZeroTier {
|
||||||
|
|
||||||
class NetconEthernetTap;
|
class NetconEthernetTap;
|
||||||
class TcpConnection;
|
|
||||||
class Larg;
|
|
||||||
class LWIPStack;
|
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
|
* Network Containers instance -- emulates an Ethernet tap device as far as OneService knows
|
||||||
*/
|
*/
|
||||||
class NetconEthernetTap
|
class NetconEthernetTap
|
||||||
|
@ -365,11 +391,6 @@ private:
|
||||||
void phyOnTcpData(PhySocket *sock,void **uptr,void *data,unsigned long len);
|
void phyOnTcpData(PhySocket *sock,void **uptr,void *data,unsigned long len);
|
||||||
void phyOnTcpWritable(PhySocket *sock,void **uptr);
|
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
|
* Signals us to close the TcpConnection associated with this PhySocket
|
||||||
*/
|
*/
|
||||||
|
@ -384,12 +405,6 @@ private:
|
||||||
* Notifies us that we can write to an application's socket
|
* Notifies us that we can write to an application's socket
|
||||||
*/
|
*/
|
||||||
void phyOnUnixWritable(PhySocket *sock,void **uptr);
|
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
|
* Returns a pointer to a TcpConnection associated with a given PhySocket
|
||||||
|
|
|
@ -1013,7 +1013,7 @@ public:
|
||||||
sws.uptr = (void *)0;
|
sws.uptr = (void *)0;
|
||||||
memcpy(&(sws.saddr),&ss,sizeof(struct sockaddr_storage));
|
memcpy(&(sws.saddr),&ss,sizeof(struct sockaddr_storage));
|
||||||
try {
|
try {
|
||||||
_handler->phyOnUnixAccept((PhySocket *)&(*s),(PhySocket *)&(_socks.back()),&(s->uptr),&(sws.uptr));
|
//_handler->phyOnUnixAccept((PhySocket *)&(*s),(PhySocket *)&(_socks.back()),&(s->uptr),&(sws.uptr));
|
||||||
} catch ( ... ) {}
|
} catch ( ... ) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1027,7 +1027,7 @@ public:
|
||||||
const bool writable = ((FD_ISSET(sock,&wfds))&&(FD_ISSET(sock,&_writefds)));
|
const bool writable = ((FD_ISSET(sock,&wfds))&&(FD_ISSET(sock,&_writefds)));
|
||||||
if ((readable)||(writable)) {
|
if ((readable)||(writable)) {
|
||||||
try {
|
try {
|
||||||
_handler->phyOnFileDescriptorActivity((PhySocket *)&(*s),&(s->uptr),readable,writable);
|
//_handler->phyOnFileDescriptorActivity((PhySocket *)&(*s),&(s->uptr),readable,writable);
|
||||||
} catch ( ... ) {}
|
} catch ( ... ) {}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue