From 0a38fdc3f68f08eb0e9e67bb8ed60b96374e811b Mon Sep 17 00:00:00 2001
From: A-star-ayush <myselfthebest@yahoo.com>
Date: Thu, 17 Aug 2017 12:29:56 +0530
Subject: [PATCH] tcp: rfc 7323: added PAWS timestamp check on Receive
---
src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp | 9 +++++++++
src/add-ons/kernel/network/protocols/tcp/tcp.cpp | 5 ++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp
index af2027b..64ffe5e 100644
a
|
b
|
TCPEndpoint::_SynchronizeSentReceive(tcp_segment_header &segment,
|
1551 | 1551 | int32 |
1552 | 1552 | TCPEndpoint::_Receive(tcp_segment_header& segment, net_buffer* buffer) |
1553 | 1553 | { |
| 1554 | // PAWS processing takes precedence over regular TCP acceptability check |
| 1555 | if ((fFlags & FLAG_OPTION_TIMESTAMP) != 0 && (segment.flags & TCP_FLAG_RESET) == 0) { |
| 1556 | if ((segment.options & TCP_HAS_TIMESTAMPS) == 0) |
| 1557 | return DROP; |
| 1558 | if ((int32)(fReceivedTimestamp - segment.timestamp_value) > 0 |
| 1559 | && (fReceivedTimestamp - segment.timestamp_value) <= INT32_MAX) |
| 1560 | return DROP | IMMEDIATE_ACKNOWLEDGE; |
| 1561 | } |
| 1562 | |
1554 | 1563 | uint32 advertisedWindow = (uint32)segment.advertised_window |
1555 | 1564 | << fSendWindowShift; |
1556 | 1565 | size_t segmentLength = buffer->size; |
diff --git a/src/add-ons/kernel/network/protocols/tcp/tcp.cpp b/src/add-ons/kernel/network/protocols/tcp/tcp.cpp
index 7c1dbb4..b14f662 100644
a
|
b
|
add_options(tcp_segment_header &segment, uint8 *buffer, size_t bufferSize)
|
117 | 117 | option->kind = TCP_OPTION_TIMESTAMP; |
118 | 118 | option->length = 10; |
119 | 119 | option->timestamp.value = htonl(segment.timestamp_value); |
120 | | // TSecr is opaque to us, we send it as we received it. |
121 | | option->timestamp.reply = segment.timestamp_reply; |
| 120 | option->timestamp.reply = htonl(segment.timestamp_reply); |
122 | 121 | bump_option(option, length); |
123 | 122 | } |
124 | 123 | |
… |
… |
process_options(tcp_segment_header &segment, net_buffer *buffer, size_t size)
|
210 | 209 | case TCP_OPTION_TIMESTAMP: |
211 | 210 | if (option->length == 10 && size >= 10) { |
212 | 211 | segment.options |= TCP_HAS_TIMESTAMPS; |
213 | | segment.timestamp_value = option->timestamp.value; |
| 212 | segment.timestamp_value = ntohl(option->timestamp.value); |
214 | 213 | segment.timestamp_reply = |
215 | 214 | ntohl(option->timestamp.reply); |
216 | 215 | } |