diff options
| author | Joseph Henry <joseph.henry@zerotier.com> | 2015-09-27 06:08:39 -0400 |
|---|---|---|
| committer | Joseph Henry <joseph.henry@zerotier.com> | 2015-09-27 06:08:39 -0400 |
| commit | 3bc9530db7050e8db19511a0888ffa4fc5b09641 (patch) | |
| tree | 26ad01ad3dcbabfb6b75b18174f0c43dfd0fad25 /netcon/NetconService.hpp | |
| parent | fe78eb77d4606ffb472e72b150d5b0a146f11084 (diff) | |
| download | infinitytier-3bc9530db7050e8db19511a0888ffa4fc5b09641.tar.gz infinitytier-3bc9530db7050e8db19511a0888ffa4fc5b09641.zip | |
Object-Model refactor: Removed notion of Client
Diffstat (limited to 'netcon/NetconService.hpp')
| -rw-r--r-- | netcon/NetconService.hpp | 90 |
1 files changed, 15 insertions, 75 deletions
diff --git a/netcon/NetconService.hpp b/netcon/NetconService.hpp index b7f80442..8f0d713f 100644 --- a/netcon/NetconService.hpp +++ b/netcon/NetconService.hpp @@ -41,101 +41,41 @@ using namespace std; namespace ZeroTier { - enum NetconConnectionType { RPC, TCP_DATA }; - class NetconEthernetTap; - /* - * A helper class for passing a reference to _phy to LWIP callbacks as a "state" - */ - class Larg - { - public: - NetconEthernetTap *tap; - PhySocket *sock; - Larg(NetconEthernetTap *_tap, PhySocket *_sock) : tap(_tap), sock(_sock) {} - }; - // prototypes - class NetconClient; - class NetconConnection; + class TcpConnection; /* - * A data connection, any number of these may be associated with a NetconClient + * */ - class NetconConnection + class TcpConnection { public: int perceived_fd; int their_fd; - unsigned char buf[DEFAULT_READ_BUFFER_SIZE]; - int idx; - NetconConnectionType type; + bool pending; + + PhySocket *rpcSock; + PhySocket *dataSock; struct tcp_pcb *pcb; - PhySocket *sock; - NetconClient *owner; - NetconConnection(NetconConnectionType type, PhySocket *sock) : type(type), sock(sock) {} + unsigned char buf[DEFAULT_READ_BUFFER_SIZE]; + int idx; }; /* - * A "harnessed" client with associated rpc and data connections. + * A helper class for passing a reference to _phy to LWIP callbacks as a "state" */ - class NetconClient + class Larg { public: - vector<NetconConnection*> connections; // TODO: Switch to storing the actual object here - - int tid; - bool waiting_for_retval; - NetconConnection *rpc; - NetconConnection* unmapped_conn; - - NetconConnection *addConnection(NetconConnectionType type, PhySocket *sock) - { - NetconConnection *new_conn = new NetconConnection(type, sock); - new_conn->owner = this; - return new_conn; - } - - // Check data and RPC connections - NetconConnection *getConnection(PhySocket *sock) - { - if(sock && sock == rpc->sock) { - return rpc; - } - for(size_t i=0; i<connections.size(); i++) { - if(sock == connections[i]->sock) return connections[i]; - } - return NULL; - } - - // - NetconConnection *getConnectionByTheirFD(int fd) - { - for(size_t i=0; i<connections.size(); i++) { - if(connections[i]->perceived_fd == fd) return connections[i]; - } - return NULL; - } + NetconEthernetTap *tap; + TcpConnection *conn; + Larg(NetconEthernetTap *_tap, TcpConnection *conn) : tap(_tap), conn(conn) {} + }; - // - NetconConnection *getConnectionByPCB(struct tcp_pcb *pcb) - { - for(size_t i=0; i<connections.size(); i++) { - if(connections[i]->pcb == pcb) return connections[i]; - } - return NULL; - } - NetconConnection *containsPCB(struct tcp_pcb *pcb) - { - for(size_t i=0; i<connections.size(); i++) { - if(connections[i]->pcb == pcb) return connections[i]; - } - return NULL; - } - }; } // namespace ZeroTier #endif |
