+// --- Server
+tVFS_Node *TCP_Server_Init(tInterface *Interface)
+{
+ return NULL;
+}
+
+char *TCP_Server_ReadDir(tVFS_Node *Node, int Pos)
+{
+ return NULL;
+}
+
+tVFS_Node *TCP_Server_FindDir(tVFS_Node *Node, char *Name)
+{
+ return NULL;
+}
+
+int TCP_Server_IOCtl(tVFS_Node *Node, int ID, void *Data)
+{
+ return 0;
+}
+
+// --- Client
+tVFS_Node *TCP_Client_Init(tInterface *Interface)
+{
+ tTCPConnection *conn = malloc( sizeof(tTCPConnection) );
+
+ conn->State = TCP_ST_CLOSED;
+ conn->Interface = Interface;
+ conn->LocalPort = 0;
+ conn->RemotePort = 0;
+ memset( &conn->RemoteIP, 0, sizeof(conn->RemoteIP) );
+
+ conn->Node.ImplPtr = conn;
+ conn->Node.NumACLs = 1;
+ conn->Node.ACLs = &gVFS_ACL_EveryoneRW;
+ conn->Node.Read = TCP_Client_Read;
+ conn->Node.Write = TCP_Client_Write;
+ conn->Node.IOCtl = TCP_Client_IOCtl;
+ conn->Node.Close = TCP_Client_Close;
+
+ return &conn->Node;
+}
+
+Uint64 TCP_Client_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+{
+ return 0;
+}
+
+Uint64 TCP_Client_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
+{
+ return 0;
+}
+
+int TCP_Client_IOCtl(tVFS_Node *Node, int ID, void *Data)
+{
+ tTCPConnection *conn = Node->ImplPtr;
+
+ switch(ID)
+ {
+ case 5: // Get/Set local port
+ if(!Data)
+ return conn->LocalPort;
+ if(conn->State != TCP_ST_CLOSED)
+ return -1;
+ if(!CheckMem(Data, sizeof(Uint16)))
+ return -1;
+
+ if(Threads_GetUID() != 0 && *(Uint16*)Data < 1024)
+ return -1;
+
+ conn->LocalPort = *(Uint16*)Data;
+ return 0;
+
+ case 6: // Get/Set remote port
+ if(!Data) return conn->RemotePort;
+ if(conn->State != TCP_ST_CLOSED) return -1;
+ if(!CheckMem(Data, sizeof(Uint16))) return -1;
+ conn->RemotePort = *(Uint16*)Data;
+ return 0;
+
+ case 7: // Set Remote IP
+ if( conn->State != TCP_ST_CLOSED )
+ return -1;
+ if( conn->Interface->Type == 4 )
+ {
+ if(!CheckMem(Data, sizeof(tIPv4))) return -1;
+ conn->RemoteIP.v4 = *(tIPv4*)Data;
+ }
+ else if( conn->Interface->Type == 6 )
+ {
+ if(!CheckMem(Data, sizeof(tIPv6))) return -1;
+ conn->RemoteIP.v6 = *(tIPv6*)Data;
+ }
+ return 0;
+
+ case 8: // Connect
+ if(conn->LocalPort == -1)
+ conn->LocalPort = TCP_GetUnusedPort();
+ if(conn->RemotePort == -1)
+ return 0;
+
+ TCP_StartConnection(conn);
+ return 1;
+ }
+
+ return 0;
+}
+
+void TCP_Client_Close(tVFS_Node *Node)
+{
+ free(Node->ImplPtr);
+}