mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-05-28 13:04:29 +00:00
compiles, technically
This commit is contained in:
parent
20beafedc5
commit
e4dc46741f
@ -253,6 +253,20 @@ void NetconEthernetTap::threadMain()
|
||||
// TODO: cleanup -- destroy LWIP state, kill any clients, unload .so, etc.
|
||||
}
|
||||
|
||||
|
||||
void NetconEthernetTap::phyOnSocketPairEndpointClose(PhySocket *sock, void **uptr)
|
||||
{
|
||||
|
||||
}
|
||||
void NetconEthernetTap::phyOnSocketPairEndpointData(PhySocket *sock, void **uptr, void *buf, unsigned long n)
|
||||
{
|
||||
|
||||
}
|
||||
void NetconEthernetTap::phyOnSocketPairEndpointWritable(PhySocket *sock, void **uptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Unused -- no UDP or TCP from this thread/Phy<>
|
||||
void NetconEthernetTap::phyOnDatagram(PhySocket *sock,void **uptr,const struct sockaddr *from,void *data,unsigned long len) {}
|
||||
|
||||
@ -364,7 +378,20 @@ int NetconEthernetTap::send_return_value(NetconClient *client, int retval)
|
||||
--------------------------------- LWIP callbacks -------------------------------
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
err_t NetconEthernetTap::nc_poll(void* arg, struct tcp_pcb *tpcb)
|
||||
{
|
||||
Larg *l = (Larg*)arg;
|
||||
NetconConnection *c = l->tap->getConnectionByPCB(tpcb);
|
||||
NetconEthernetTap *tap = l->tap;
|
||||
if(c)
|
||||
tap->handle_write(c);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
err_t NetconEthernetTap::nc_accept(void *arg, struct tcp_pcb *newpcb, err_t err)
|
||||
{
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
err_t NetconEthernetTap::nc_recved(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
|
||||
{
|
||||
@ -465,6 +492,8 @@ err_t NetconEthernetTap::nc_connected(void *arg, struct tcp_pcb *tpcb, err_t err
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
----------------------------- RPC Handler functions ----------------------------
|
||||
------------------------------------------------------------------------------*/
|
||||
@ -543,7 +572,7 @@ void NetconEthernetTap::handle_socket(NetconClient *client, struct socket_st* so
|
||||
{
|
||||
struct tcp_pcb *pcb = lwipstack->tcp_new();
|
||||
if(pcb != NULL) {
|
||||
int *their_fd;
|
||||
int *their_fd = NULL;
|
||||
NetconConnection *new_conn = client->addConnection(BUFFER, _phy.createSocketPair(*their_fd, client));
|
||||
new_conn->their_fd = *their_fd;
|
||||
new_conn->pcb = pcb;
|
||||
@ -562,10 +591,11 @@ void NetconEthernetTap::handle_connect(NetconClient *client, struct connect_st*
|
||||
connaddr = (struct sockaddr_in *) &connect_rpc->__addr;
|
||||
int conn_port = lwipstack->ntohs(connaddr->sin_port);
|
||||
ip_addr_t conn_addr = convert_ip((struct sockaddr_in *)&connect_rpc->__addr);
|
||||
|
||||
NetconConnection *c = client->getConnectionByTheirFD(connect_rpc->__fd);
|
||||
|
||||
if(c!= NULL) {
|
||||
lwipstack->tcp_sent(c->pcb, nc_sent); // FIXME: Move?
|
||||
lwipstack->tcp_sent(c->pcb, NetconEthernetTap::nc_sent); // FIXME: Move?
|
||||
lwipstack->tcp_recv(c->pcb, nc_recved);
|
||||
lwipstack->tcp_err(c->pcb, nc_err);
|
||||
lwipstack->tcp_poll(c->pcb, nc_poll, APPLICATION_POLL_FREQ);
|
||||
|
@ -86,6 +86,15 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
static err_t nc_poll(void* arg, struct tcp_pcb *tpcb);
|
||||
static err_t nc_accept(void *arg, struct tcp_pcb *newpcb, err_t err);
|
||||
static err_t nc_recved(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err);
|
||||
static void nc_err(void *arg, err_t err);
|
||||
static void nc_close(struct tcp_pcb *tpcb);
|
||||
static err_t nc_send(struct tcp_pcb *tpcb);
|
||||
static err_t nc_sent(void *arg, struct tcp_pcb *tpcb, u16_t len);
|
||||
static err_t nc_connected(void *arg, struct tcp_pcb *tpcb, err_t err);
|
||||
|
||||
// RPC handlers (from NetconIntercept)
|
||||
void handle_bind(NetconClient *client, struct bind_st *bind_rpc);
|
||||
void handle_listen(NetconClient *client, struct listen_st *listen_rpc);
|
||||
@ -105,34 +114,25 @@ private:
|
||||
void phyOnUnixData(PhySocket *sock,void **uptr,void *data,unsigned long len);
|
||||
void phyOnUnixWritable(PhySocket *sock,void **uptr);
|
||||
|
||||
void phyOnSocketPairEndpointClose(void *sock, void **uptr);
|
||||
void phyOnSocketPairEndpointClose(PhySocket *sock, void **uptr);
|
||||
void phyOnSocketPairEndpointData(PhySocket *sock, void **uptr, void *buf, unsigned long n);
|
||||
void phyOnSocketPairEndpointWritable(PhySocket *sock, void **uptr);
|
||||
|
||||
|
||||
|
||||
int send_return_value(NetconClient *client, int retval);
|
||||
|
||||
// For LWIP Callbacks
|
||||
static err_t nc_poll(void* arg, struct tcp_pcb *tpcb)
|
||||
ip_addr_t convert_ip(struct sockaddr_in * addr)
|
||||
{
|
||||
Larg *l = (Larg*)arg;
|
||||
NetconConnection *c = l->tap->getConnectionByPCB(tpcb);
|
||||
NetconEthernetTap *tap = l->tap;
|
||||
if(c)
|
||||
tap->handle_write(c);
|
||||
return ERR_OK;
|
||||
ip_addr_t conn_addr;
|
||||
struct sockaddr_in *ipv4 = addr;
|
||||
short a = ip4_addr1(&(ipv4->sin_addr));
|
||||
short b = ip4_addr2(&(ipv4->sin_addr));
|
||||
short c = ip4_addr3(&(ipv4->sin_addr));
|
||||
short d = ip4_addr4(&(ipv4->sin_addr));
|
||||
IP4_ADDR(&conn_addr, a,b,c,d);
|
||||
return conn_addr;
|
||||
}
|
||||
|
||||
|
||||
static err_t nc_accept(void *arg, struct tcp_pcb *newpcb, err_t err);
|
||||
static err_t nc_recved(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err);
|
||||
static void nc_err(void *arg, err_t err);
|
||||
static void nc_close(struct tcp_pcb *tpcb);
|
||||
static err_t nc_send(struct tcp_pcb *tpcb);
|
||||
static err_t nc_sent(void *arg, struct tcp_pcb *tpcb, u16_t len);
|
||||
static err_t nc_connected(void *arg, struct tcp_pcb *tpcb, err_t err);
|
||||
|
||||
|
||||
|
||||
void (*_handler)(void *,uint64_t,const MAC &,const MAC &,unsigned int,unsigned int,const void *,unsigned int);
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
namespace ZeroTier
|
||||
{
|
||||
/*
|
||||
ip_addr_t convert_ip(struct sockaddr_in * addr)
|
||||
{
|
||||
ip_addr_t conn_addr;
|
||||
@ -20,7 +21,7 @@ namespace ZeroTier
|
||||
IP4_ADDR(&conn_addr, a,b,c,d);
|
||||
return conn_addr;
|
||||
}
|
||||
|
||||
*/
|
||||
ip_addr_t ip_addr_sin(register struct sockaddr_in *sin) {
|
||||
ip_addr_t ip;
|
||||
*((struct sockaddr_in*) &ip) = *sin;
|
||||
@ -29,9 +30,6 @@ namespace ZeroTier
|
||||
|
||||
// Functions used to pass file descriptors between processes
|
||||
|
||||
ssize_t sock_fd_write(int sock, int fd);
|
||||
ssize_t sock_fd_read(int sock, void *buf, ssize_t bufsize, int *fd);
|
||||
|
||||
ssize_t sock_fd_write(int sock, int fd)
|
||||
{
|
||||
ssize_t size;
|
||||
|
@ -4,10 +4,12 @@
|
||||
|
||||
namespace ZeroTier
|
||||
{
|
||||
ip_addr_t convert_ip(struct sockaddr_in * addr);
|
||||
|
||||
//ip_addr_t convert_ip(struct sockaddr_in * addr);
|
||||
ip_addr_t ip_addr_sin(register struct sockaddr_in *sin);
|
||||
|
||||
ssize_t sock_fd_write(int sock, int fd);
|
||||
ssize_t sock_fd_read(int sock, void *buf, ssize_t bufsize, int *fd);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user