git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updated InitRD to new usermode layout, cleanups in networking
[tpg/acess2.git]
/
Modules
/
IPStack
/
tcp.c
diff --git
a/Modules/IPStack/tcp.c
b/Modules/IPStack/tcp.c
index
e42e940
..
51f6ae4
100644
(file)
--- a/
Modules/IPStack/tcp.c
+++ b/
Modules/IPStack/tcp.c
@@
-84,7
+84,7
@@
void TCP_SendPacket( tTCPConnection *Conn, size_t Length, tTCPHeader *Data )
buf[2] = (htons(Length)<<16) | (6<<8) | 0;
Data->Checksum = 0;
memcpy( &buf[3], Data, Length );
buf[2] = (htons(Length)<<16) | (6<<8) | 0;
Data->Checksum = 0;
memcpy( &buf[3], Data, Length );
- Data->Checksum =
IPv4_Checksum( buf, buflen
);
+ Data->Checksum =
htons( IPv4_Checksum( buf, buflen )
);
free(buf);
IPv4_SendPacket(Conn->Interface, Conn->RemoteIP.v4, IP4PROT_TCP, 0, Length, Data);
break;
free(buf);
IPv4_SendPacket(Conn->Interface, Conn->RemoteIP.v4, IP4PROT_TCP, 0, Length, Data);
break;
@@
-282,14
+282,16
@@
void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head
tTCPStoredPacket *pkt;
int dataLen;
tTCPStoredPacket *pkt;
int dataLen;
+ // Syncronise sequence values
if(Header->Flags & TCP_FLAG_SYN) {
Connection->NextSequenceRcv = ntohl(Header->SequenceNumber) + 1;
}
if(Header->Flags & TCP_FLAG_SYN) {
Connection->NextSequenceRcv = ntohl(Header->SequenceNumber) + 1;
}
+ // Handle a server replying to our initial SYN
if( Connection->State == TCP_ST_SYN_SENT )
{
if( Connection->State == TCP_ST_SYN_SENT )
{
- if( (Header->Flags & (TCP_FLAG_SYN|TCP_FLAG_ACK)) == (TCP_FLAG_SYN|TCP_FLAG_ACK) )
{
-
+ if( (Header->Flags & (TCP_FLAG_SYN|TCP_FLAG_ACK)) == (TCP_FLAG_SYN|TCP_FLAG_ACK) )
+ {
Header->DestPort = Header->SourcePort;
Header->SourcePort = htons(Connection->LocalPort);
Header->AcknowlegementNumber = htonl(Connection->NextSequenceRcv);
Header->DestPort = Header->SourcePort;
Header->SourcePort = htons(Connection->LocalPort);
Header->AcknowlegementNumber = htonl(Connection->NextSequenceRcv);
@@
-303,6
+305,13
@@
void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head
}
}
}
}
+ // Handle a client confirming the connection
+ if( Connection->State == TCP_ST_HALFOPEN && (Header->Flags & TCP_FLAG_ACK) )
+ {
+ Connection->State = TCP_ST_OPEN;
+ Log_Log("TCP", "Connection fully opened");
+ }
+
// Get length of data
dataLen = Length - (Header->DataOffset>>4)*4;
Log_Log("TCP", "HandleConnectionPacket - dataLen = %i", dataLen);
// Get length of data
dataLen = Length - (Header->DataOffset>>4)*4;
Log_Log("TCP", "HandleConnectionPacket - dataLen = %i", dataLen);
@@
-330,6
+339,7
@@
void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head
}
}
}
}
+ // Check for an empty packet
if(dataLen == 0) {
Log_Log("TCP", "Empty Packet");
return ;
if(dataLen == 0) {
Log_Log("TCP", "Empty Packet");
return ;
UCC
git Repository :: git.ucc.asn.au