* Acess2 IP Stack
* - TCP Handling
*/
-#define DEBUG 1
+#define DEBUG 0
#include "ipstack.h"
#include "ipv4.h"
#include "ipv6.h"
int TCP_DeallocatePort(Uint16 Port);
// --- Server
tVFS_Node *TCP_Server_Init(tInterface *Interface);
-char *TCP_Server_ReadDir(tVFS_Node *Node, int Pos);
+ int TCP_Server_ReadDir(tVFS_Node *Node, int Pos, char Name[FILENAME_MAX]);
tVFS_Node *TCP_Server_FindDir(tVFS_Node *Node, const char *Name);
int TCP_Server_IOCtl(tVFS_Node *Node, int ID, void *Data);
void TCP_Server_Close(tVFS_Node *Node);
IPStack_Buffer_AppendSubBuffer(buffer, Length, 0, Data, NULL, NULL);
IPStack_Buffer_AppendSubBuffer(buffer, sizeof(*Header), 0, Header, NULL, NULL);
- Log_Debug("TCP", "Sending %i+%i to %s:%i", sizeof(*Header), Length,
+ LOG("Sending %i+%i to %s:%i", sizeof(*Header), Length,
IPStack_PrintAddress(Conn->Interface->Type, &Conn->RemoteIP),
Conn->RemotePort
);
tTCPListener *srv;
tTCPConnection *conn;
- Log_Log("TCP", "TCP_GetPacket: <Local>:%i from [%s]:%i, Flags= %s%s%s%s%s%s%s%s",
+ Log_Log("TCP", "TCP_GetPacket: <Local>:%i from [%s]:%i, Flags = %s%s%s%s%s%s%s%s",
ntohs(hdr->DestPort),
IPStack_PrintAddress(Interface->Type, Address),
ntohs(hdr->SourcePort),
if( Length > (hdr->DataOffset >> 4)*4 )
{
- Log_Log("TCP", "TCP_GetPacket: SequenceNumber = 0x%x", ntohl(hdr->SequenceNumber));
+ LOG("SequenceNumber = 0x%x", ntohl(hdr->SequenceNumber));
#if HEXDUMP_INCOMING
Debug_HexDump(
"TCP_GetPacket: Packet Data = ",
// Ackowledge a sent packet
if(Header->Flags & TCP_FLAG_ACK) {
// TODO: Process an ACKed Packet
- Log_Log("TCP", "Conn %p, Sent packet 0x%x ACKed", Connection, Header->AcknowlegementNumber);
+ LOG("Conn %p, Sent packet 0x%x ACKed", Connection, Header->AcknowlegementNumber);
}
// Get length of data
dataLen = Length - (Header->DataOffset>>4)*4;
- Log_Log("TCP", "HandleConnectionPacket - dataLen = %i", dataLen);
+ LOG("dataLen = %i", dataLen);
//
// State Machine
sequence_num = ntohl(Header->SequenceNumber);
- Log_Log("TCP", "0x%08x <= 0x%08x < 0x%08x",
+ LOG("TCP", "0x%08x <= 0x%08x < 0x%08x",
Connection->NextSequenceRcv,
ntohl(Header->SequenceNumber),
Connection->NextSequenceRcv + TCP_WINDOW_SIZE
if(rv != 0) {
break;
}
- Log_Log("TCP", "0x%08x += %i", Connection->NextSequenceRcv, dataLen);
+ LOG("0x%08x += %i", Connection->NextSequenceRcv, dataLen);
Connection->NextSequenceRcv += dataLen;
// TODO: This should be moved out of the watcher thread,
TCP_INT_UpdateRecievedFromFuture(Connection);
// ACK Packet
+ // TODO: Implement delayed ACK sending
Header->DestPort = Header->SourcePort;
Header->SourcePort = htons(Connection->LocalPort);
Header->AcknowlegementNumber = htonl(Connection->NextSequenceRcv);
Header->WindowSize = htons(TCP_WINDOW_SIZE);
Header->Flags &= TCP_FLAG_SYN; // Eliminate all flags save for SYN
Header->Flags |= TCP_FLAG_ACK; // Add ACK
- Log_Log("TCP", "Sending ACK for 0x%08x", Connection->NextSequenceRcv);
+ LOG("TCP", "Sending ACK for 0x%08x", Connection->NextSequenceRcv);
TCP_SendPacket( Connection, Header, 0, NULL );
//Connection->NextSequenceSend ++;
}
* \param Node Server node
* \param Pos Position (ignored)
*/
-char *TCP_Server_ReadDir(tVFS_Node *Node, int Pos)
+int TCP_Server_ReadDir(tVFS_Node *Node, int Pos, char Dest[FILENAME_MAX])
{
tTCPListener *srv = Node->ImplPtr;
tTCPConnection *conn;
- char *ret;
ENTER("pNode iPos", Node, Pos);
LOG("srv->NewConnections = %p", srv->NewConnections);
LOG("srv->ConnectionsTail = %p", srv->ConnectionsTail);
- ret = malloc(9);
- itoa(ret, conn->Node.ImplInt, 16, 8, '0');
- Log_Log("TCP", "Thread %i got '%s'", Threads_GetTID(), ret);
- LEAVE('s', ret);
- return ret;
+ itoa(Dest, conn->Node.ImplInt, 16, 8, '0');
+ Log_Log("TCP", "Thread %i got connection '%s'", Threads_GetTID(), Dest);
+ LEAVE('i', 0);
+ return 0;
}
/**