+void TCP_int_SendRSTTo(tInterface *Interface, void *Address, size_t Length, const tTCPHeader *Header)
+{
+ tTCPHeader out_hdr = {0};
+
+ out_hdr.DataOffset = (sizeof(out_hdr)/4) << 4;
+ out_hdr.DestPort = Header->SourcePort;
+ out_hdr.SourcePort = Header->DestPort;
+
+ size_t data_len = Length - (Header->DataOffset>>4)*4;
+ out_hdr.AcknowlegementNumber = htonl( ntohl(Header->SequenceNumber) + data_len );
+ if( Header->Flags & TCP_FLAG_ACK ) {
+ out_hdr.Flags = TCP_FLAG_RST;
+ out_hdr.SequenceNumber = Header->AcknowlegementNumber;
+ }
+ else {
+ out_hdr.Flags = TCP_FLAG_RST|TCP_FLAG_ACK;
+ out_hdr.SequenceNumber = 0;
+ }
+ TCP_int_SendPacket(Interface, Address, &out_hdr, 0, NULL);
+}
+