History log of /haiku/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h
Revision Date Author Comments
# 4fec8175 29-Jan-2024 Augustin Cavalier <waddlesplash@gmail.com>

TCP: Refactor sending logic.

* Break segment setup out into its own method.

* Break the actual sending logic out into its own method.
- While at it, remove some old/obsolete comments and
rearrange some of the logic to match.

* Separate the send-pure-ACK and send-data methods.
- This way, the "force" parameters will act differently,
specifying "force" to SendAcknowledge() may generate
a duplicate ACK, while to SendQueued() it will either
send data smaller than a segment size, or do nothing.

Functional changes should be minor, and the code
meanwhile should be much easier to read.

Change-Id: I1e14b9a1e3b7c8b2d3bf8ae30f1369d8c9f662a4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7361
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 1029af17 01-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

Add missing includes following previous commit.

All these files were making use of headers included indirectly
through AutoLock.h that are now no longer following the previous commit.


# 81521280 21-Mar-2020 X512 <danger_mail@list.ru>

Fix clang warning "mismatched-tags"

Change-Id: I00f26e27d8ac24a46b528ea7ed47b92c2967ff2e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2390
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# bf1a86c1 04-Dec-2017 A-star-ayush <myselfthebest@yahoo.com>

TCP: Fixed RTO update and dup ACKs generation.

i) there was an integer promotion problem in updating the retransmission
timeout : a signed int was being divided by an unsigned int. This was causing
the values to overflow. Thus leading to huge values for timeout which
manifested in the perception of pause in data flow.

ii) for an ack to be recognised as a duplicate ack, the advertised window
must remain same. This was not taken care of in the code so I added it.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>

Helps with #13769 but does not fix it completely (upload gets
farther but still stalls.)


# 272e1a2f 09-Nov-2017 A-star-ayush <myselfthebest@yahoo.com>

tcp: fixed no response from window update, removed ideal timer

The reason for the erratic behavior was that the tcp implementation
silently drops window update messages after noting the update but without
triggering any data send event. Before the new TCP patches were applied,
the implementation relied on a retransmission timeout to trigger a send event
after a window update. One of the new patches dealing with the ideal timer
changed the semantic of the restransmit function call and caused the behavior
witnessed.

But a retransmission timeout is not the correct solution to window update. In
fact a retransmission is not a desired effect of window update. So in the patch
attached, I have changed the behavior of the implementation to immediately
acknowledge the window update (along with data from SendQueue) and thus solving
the problem of complete halt in data transmission.

The patch also has the changes re-implemented that were reverted back but had
nothing to do with the issue at hand. For the time being, I have also removed
the "ideal timer" part from the patch (although it wasn't creating any
conflict). I initially decided to implement the ideal timer using the same
timer used for retransmission to avoid adding an additional timer. But as I
have seen, it can be problematic. So I will be re-implementing the ideal timer
and thus it was not included in this patch.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
Fixes #13704.


# e736356c 12-Sep-2017 Augustin Cavalier <waddlesplash@gmail.com>

Revert "tcp: slow start@rfc5681 : updated rules for congestion window"

This reverts commit 05743f6a13319a9dc332603eb5d98ba4c5374b25
(and the portions of following commits that were layered on top of it.)


# 515cda72 18-Aug-2017 A-star-ayush <myselfthebest@yahoo.com>

tcp: rfc 6582: implemented NewReno modification

Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>


# 30982ed7 29-Jul-2017 A-star-ayush <myselfthebest@yahoo.com>

tcp: rfc 6298 & 7323: updated rto calculations and semantics

Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>


# ec63a329 14-Aug-2017 A-star-ayush <myselfthebest@yahoo.com>

tcp: rfc 5681: implemented fast retransmit and recovery

Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>


# 05743f6a 14-Aug-2017 A-star-ayush <myselfthebest@yahoo.com>

tcp: slow start@rfc5681 : updated rules for congestion window

Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>


# 89822930 02-Aug-2015 Michael Lotz <mmlr@mlotz.ch>

tcp: Whitespace cleanup, move a define to header and fix a typo.


# da8fbe0e 02-Aug-2015 Michael Lotz <mmlr@mlotz.ch>

tcp: Replace custom WaitList with ConditionVariable.

The WaitList implementation had a race condition between checking for
the condition and acquiering the semaphore. If a thread was rescheduled
at that point, the signal could be missed due to the use of
release_sem_etc() with the B_RELEASE_ALL flag while the thread was not
yet waiting for the semaphore. The transfer would subsequently stall.


# e572c323 10-Apr-2010 Axel Dörfler <axeld@pinc-software.de>

* When receiving an out of sequence FIN we must ignore it until its part of
our available buffer (we might want to move this into the BufferQueue class).
* Now, _AddData() remembers the flag (and its position), and will alter the
segment's flags field to reflect the current state.
* This fixes not being able to login into mmlr.dyndns.org.
* Fixed warnings when TCP_PROBE is defined.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36127 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5147963d 26-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

headers/private/kernel/util/OpenHashTable.h, Hugo's version, is a bit nicer than
Tracker's OpenHashTable.h which it should eventually replace. We've renamed the
class to BOpenHashTable and changed the interface slightly so that HashTableLink
became superfluous.
Adapted all the code that used it. Since the OpenHashTables no longer clash,
this should fix the GCC4 build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31791 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 11112327 07-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* Sockets now inherit from WeakReferenceable.
* This fixes the problem when a socket changes something with regards to its
parent.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30000 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 30a396ab 19-May-2008 Axel Dörfler <axeld@pinc-software.de>

* Made the endpoint manager wait on bind() if the existing connection is
local, and is about to close.
* This fixes several race conditions with the neon test suite that relied
on TCP sockets being gone after close, and their port being available again
(note, that is not what the TCP spec says, anyway, but it makes sense to
do so, since we already removed the time wait state for local connections).
* The endpoint manager is now using a mutex instead of a semaphore.
* TCPEndpoint::_Close() now notifies the senders/receivers instead of
_HandleReset().
* Besides ssl_closure(), all tests of the neon test suite seem to pass now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25564 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ec1f43f3 17-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
* Small style changes.
* Currently ifdef'ed out potentially correct changes, that break Neon
tests which otherwise succeed. Axel will investigate this further.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25530 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 03298f9d 02-May-2008 Axel Dörfler <axeld@pinc-software.de>

* The WaitList now always notifies all waiters.
* In SendData(), TCP will now split the buffer into smaller parts if it
can send data (ie. there is free space in the buffer queue left, but
not enough to send the whole buffer, and the free space is more than
the send low water mark of the socket).
* Both of these changes together let TCP now pass the "forwarding" test
of the OpenSSH suite.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25294 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8e0a418b 28-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Implemented sending of urgent data. Seems to work fine, but of course only
if the other end is not a Haiku host (retrieving of urgent data is still
missing).
* Resolved TODO: SendData() now sends a SIGPIPE when trying to send on a
closed connection.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25245 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 895d7215 29-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Added TCPEndpoint::GetOption(), currently only supports TCP_NODELAY, and
TCP_MAXSEG.
* Note, TCP_MAXSEG cannot be set yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25241 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 62895789 29-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25240 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0cadc931 29-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* TIME_WAIT endpoints must not send an acknowledgement for known data; this
fixes the "endless discussions" when closing a local connection - only
happened on a simultaneous close.
* A FIN in TIME_WAIT now updates the time-wait timer, as required by the
TCP specification.
* Entering TIME_WAIT now cancels all connection timers. We might want to
think about putting time wait connections into a separate hash, and delete
the socket early on.
* Added tracing support for send/receive, timers, and state changes.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25236 a95241bf-73f2-0310-859d-f6bbb57e9c96


# db4b6bc4 28-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Merged _Receive() and _SegmentReceived().
* Cleanup, shuffled methods around, renamed methods, etc. - no functional changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25223 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 05bc1e89 27-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Added _CancelConnectionTimers() that does what its name suggests, and is
now used from various places that previously did not cancel all timers
they should have.
* When a connection moves to the CLOSED state, it should cancel all timers;
this prevents from sending a reset at the end of a connection.
* If the persist/delayed acknowledge timers were canceled too late, they might
still have tried to send something (which would eventually cause a reset
sent to the peer).
* Follow RFC 1337 with respect to time wait assassination prevention (ie.
we now ignore resets from peers in time wait state).
* _SegmentReceived() must not check the sequence of a time wait connection;
it prevented sending a reset when that was due (a new connection request
would time out, instead of fail immediately).
* Also, that method must never be called in the LISTEN or SYNCHRONIZE_SENT
states, so we don't need to check for those.
* We don't have to wait in Close() until the connection is actually closed -
removed a TODO. TCP should handle this internally.
* Renamed _ShutdownEgress() to _Shutdown().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25219 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 05849428 17-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
* Added syscall restart support for connect(), accept(), send(), recv(),
which are implemented via ioctl()s. The actual restart support is done
in the net stack driver's ioctl() hook. Lower layers need to correctly
deal with socket timeouts, though, for which the stack module provides
support functions.
* TCPEndpoint::_WaitForEstablished() does abort now when an error
occurred earlier, so that trying to connect to an unused port fails
immediately, as it should.
* Fixed and refactored TCP connection reset handling. The new
TCPEndpoint::_HandleReset() does the job. Got rid of
TCPEndpoint::fError.
* Fixed sequence numbers for SYNC/FINI packets.
* The former two fix the problem that connections wouldn't be closed
correctly and could even be reused when trying to connect again (as
was reproducible with svnserve + svn).
* Some style cleanup in CPEndpoint.h.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23984 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5c3cf263 03-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Got rid of DeleteSocket().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23236 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1d0b34fa 23-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

* If a new buffer had its last part in common with an existing larger buffer,
BufferQueue::Add() tried to remove a negative amount of bytes. This could
bring a download to a complete halt (as could the other one due to the list
link mixup).
* While the RTT computation still seems to work not that good (with a drop quote
of 50% I would easily reach retransmit timeouts of 80 secs), TCP should now
work a lot better on a flaky connection.
* Renamed _GetMSS() to _MaxSegmentSize().
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22677 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 84052230 31-Jul-2007 Axel Dörfler <axeld@pinc-software.de>

axeld+bonefish: Got rid of the ParentType in the HashTableDefinition; it doesn't really
belong there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21766 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 34c53bac 26-May-2007 Hugo Santos <hugosantos@nowhere.fake>

tcp: fixed an issue where the socket could be waken from ReadData() even when no new data was added to the queue (due to lost packets). Also make sure we only break from the receive loop where there is at least a byte of data to be consumed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21248 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fe0ab286 23-May-2007 Hugo Santos <hugosantos@nowhere.fake>

tcp: no longer need recursive locking.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21216 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a0a553ca 08-May-2007 Hugo Santos <hugosantos@nowhere.fake>

tcp: allow TCP_NODELAY to be set


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21069 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 62a21143 04-May-2007 Hugo Santos <hugosantos@nowhere.fake>

fixed a race condition in TCP's WaitList Wait/Signal that was preventing Connect() from awake when it should. Reported by Francois Revol.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21024 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 785e7ef7 04-May-2007 Hugo Santos <hugosantos@nowhere.fake>

renamed TCP's TSval/TSecr


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21014 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 15945a11 29-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

added 'tcp_endpoints' and 'tcp_endpoint' debugger commands.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20909 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9cd3b980 27-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

fixed a long standing binding issue with spawned sockets and TCP. also fixed bind() address checking rules.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20866 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 342444bc 27-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

replaced TCP's Endpoint Manager manual handling of endpoint lists with MultiHashTable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20865 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4b55736d 27-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

added new helper ProtocolSocket. Moved some stuff together to achieve better inlining.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20848 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2586c25e 25-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

use Chaining in OpenHashTable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20822 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 66a4a428 25-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

added Recv-Q/Send-Q output to netstat.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20819 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 585195c2 25-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

introduced SocketAddress wrappers and use them in TCP.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20818 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 53f23f85 25-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

partially rewrote TCP's endpoint manager. Fixes #1173


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20814 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 39faeeba 20-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

when sending pure ACKs, use an artificial window of 0.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20778 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c70d3baf 20-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

more TCP fixes, we should now be able to send large amounts of data through congestioned links.

- fixed BufferQueue's RemoveUntil.
- reset SND.NXT on third duplicate ACK (fast retransmit).
- on retransmit reset SND.NXT to SND.UNA (it will be updated back when we get good ACKs).
- fixed effective window calculation.
- relaxed SWS checking a bit, don't send partial packets on retransmission as the window might have been reduced due to congestion.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20769 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2445c00e 19-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

some internal reorganization of getsockopt()/setsockopt() handling. TCP is now able to fully use the application requested sender/receiver buffer sizes for improved performance.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20764 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1d63ea33 18-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

some TCP performance improvements.

- support TCP fast retransmit/fast recovery.
- maintain the RTT average time and update the retransmit timeout accordingly.
- improvements to TCP Slow start / congestion avoidance.
- better handling of the retransmission timer.
- properly size segments taking the TCP options length into consideration.
- as an interim fix, update the SendQ/RecvQ sizes on Connect().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20748 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7d524fb7 16-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

implemented TCP's slow start and congestion avoidance.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20734 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f19e1f47 16-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

reorganized some of the TCP logic so we have common init paths for receive and send.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20731 a95241bf-73f2-0310-859d-f6bbb57e9c96


# aa077007 16-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

update Window Scaling variables when a simultaneous open is ACKed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20730 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 58bef2f4 16-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

support TCP Window Scale on sent segments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20729 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4ee08841 16-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

assorted TCP fixes.

- fixed the locking for spawned connections and accept()s.
- return EMSGSIZE if the user is trying to write more data than the send buffer can hold.
- fixed a crash when receiving a RST while the connection is being closed.
- don't wake up readers when the connection gets established.
- endpoint managers lock must be recursive to properly work with spawn'ed sockets.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20727 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ca1b900b 15-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

support RFC 1323's TCP Timestamps (we are still not updating our estimator though).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20719 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 03d7f17e 15-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

made TCP handle multiple domains.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20718 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fbaad6fd 15-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

fixed an issue where TCP would RST a connection when a peer trying to connect us re-sent their SYN.

- In fact our SYN/ACK reply is being lost due to ARP resolving as we are waiting in the device's receive path, thus we never get replies before timing out. This requires queueing during ARP resolving.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20706 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f73dd74e 10-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

even more TCP fixage.

- don't try to remove spawned sockets from Endpoints hashtable.
- return B_WOULD_BLOCK (EAGAIN) when we time out in acquire_sem().
- use B_RELEASE_IF_WAITING_ONLY in the TCP WaitList.
- fixed a off by one issue in ReadData() which could result in more than needed iterations (and waiting).
- implemented prepending new buffers to a net_buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20639 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7664bcb5 09-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

A couple more TCP fixes.

- ipv4_bind() was broken when binding to addresses not INADDR_ANY, as it wasn't copying the address to the socket, fixed.
- fixed a small issue in TCP's BindToEphemeral where the correct address might not have been bound to the socket.
- some assorted TCP wait lists fixes.
- fixed TCP's Connect() over the loopback interface, we might already be ESTABLISHED after _SendQueue() returns.
- fixed the amount of time we wait in TCP's Accept().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20629 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a7edede4 09-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

fixed multiple TCP issues.

- Moved FIN handling to after Segment Text handling, it matches the RFC and fixes a possible issue with a user missing some final segment data when receiving a FIN.
- Fixed the FIN handling to better terminate connections (no more senseless chatter in the end with RSTs etc).
- When Bind()ing, set the socket address so a call to getsockname() gets the allocated port correctly.
- After reaching the ESTABLISHED state, try to wake all pending threads (still needs work).
- Corrected the maximum amount of time we wait in SendData() to respect socket->send.timeout.
- Now ReadData() behaves correctly in all possible states.
- There was a missing handling of MSG_DONTWAIT, fixed.
- Better internal handling of PSH.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20624 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d86f48f3 05-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

tiny TCP cleanups, move the read notifications to _NotifyReader().

- Also fixed the buffer size check in UDP's SendData() since UDP's length field includes the size of the header we need to check that as well. IPv4 is correct since we check for the size after prepending the header (due to it being possibly already included).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20592 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52e75b62 03-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

TCP: initial shutdown() implementation and some general fixes

* set FLAG_NO_RECEIVE/FLAG_NO_SEND on shutdown() and send FIN on SHUT_WR
* if a send() is attempted with FLAG_NO_SEND set return EPIPE
* proper handling of recv timeout in ReadData(), using absolute timeout instead of relative
* if FLAG_NO_RECEIVE is set, don't attached more segments to the receive queue, drop them instead


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20542 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3537f096 03-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

fixed a bug in TCP where applications weren't properly signaled when the connection was terminated by the server and there was no more data to be read from the buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20534 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 868583b5 03-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

fixed a potential problem in TCP's accept() with the init'ing of new connections' MSS


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20527 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 442c0979 04-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

Renamed class TCPConnection to TCPEndpoint.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19418 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8982293017b132c73aff734fa8baa7afd261e125 02-Aug-2015 Michael Lotz <mmlr@mlotz.ch>

tcp: Whitespace cleanup, move a define to header and fix a typo.


# da8fbe0e5974bef73324b4297e7cc471b942b679 02-Aug-2015 Michael Lotz <mmlr@mlotz.ch>

tcp: Replace custom WaitList with ConditionVariable.

The WaitList implementation had a race condition between checking for
the condition and acquiering the semaphore. If a thread was rescheduled
at that point, the signal could be missed due to the use of
release_sem_etc() with the B_RELEASE_ALL flag while the thread was not
yet waiting for the semaphore. The transfer would subsequently stall.


# e572c3233547f29a65ef4e2108b62aaee82d825e 10-Apr-2010 Axel Dörfler <axeld@pinc-software.de>

* When receiving an out of sequence FIN we must ignore it until its part of
our available buffer (we might want to move this into the BufferQueue class).
* Now, _AddData() remembers the flag (and its position), and will alter the
segment's flags field to reflect the current state.
* This fixes not being able to login into mmlr.dyndns.org.
* Fixed warnings when TCP_PROBE is defined.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36127 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5147963dcd57fefa4f63c484eb88e9eaf4002976 26-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

headers/private/kernel/util/OpenHashTable.h, Hugo's version, is a bit nicer than
Tracker's OpenHashTable.h which it should eventually replace. We've renamed the
class to BOpenHashTable and changed the interface slightly so that HashTableLink
became superfluous.
Adapted all the code that used it. Since the OpenHashTables no longer clash,
this should fix the GCC4 build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31791 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1111232758bd76e4ce4e7f6daddd7334249db818 07-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* Sockets now inherit from WeakReferenceable.
* This fixes the problem when a socket changes something with regards to its
parent.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30000 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 30a396ab4211fe07b7d90e6c48a3eadd301a78db 19-May-2008 Axel Dörfler <axeld@pinc-software.de>

* Made the endpoint manager wait on bind() if the existing connection is
local, and is about to close.
* This fixes several race conditions with the neon test suite that relied
on TCP sockets being gone after close, and their port being available again
(note, that is not what the TCP spec says, anyway, but it makes sense to
do so, since we already removed the time wait state for local connections).
* The endpoint manager is now using a mutex instead of a semaphore.
* TCPEndpoint::_Close() now notifies the senders/receivers instead of
_HandleReset().
* Besides ssl_closure(), all tests of the neon test suite seem to pass now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25564 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ec1f43f30465ee4700c4a8a85dfb99ad6eaf8706 17-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
* Small style changes.
* Currently ifdef'ed out potentially correct changes, that break Neon
tests which otherwise succeed. Axel will investigate this further.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25530 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 03298f9d20fe782497471b9e3e131ee00d3fa526 02-May-2008 Axel Dörfler <axeld@pinc-software.de>

* The WaitList now always notifies all waiters.
* In SendData(), TCP will now split the buffer into smaller parts if it
can send data (ie. there is free space in the buffer queue left, but
not enough to send the whole buffer, and the free space is more than
the send low water mark of the socket).
* Both of these changes together let TCP now pass the "forwarding" test
of the OpenSSH suite.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25294 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8e0a418b70d2599c9eaf2a410af2f48afd5563f2 28-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Implemented sending of urgent data. Seems to work fine, but of course only
if the other end is not a Haiku host (retrieving of urgent data is still
missing).
* Resolved TODO: SendData() now sends a SIGPIPE when trying to send on a
closed connection.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25245 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 895d7215fbb32fc62277f028b21adcda9320fcd6 29-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Added TCPEndpoint::GetOption(), currently only supports TCP_NODELAY, and
TCP_MAXSEG.
* Note, TCP_MAXSEG cannot be set yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25241 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 62895789828ea068575fd2794a299325d618d5f6 29-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25240 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0cadc931d2bb80c7f5ee60883fc3d0a949a65a92 29-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* TIME_WAIT endpoints must not send an acknowledgement for known data; this
fixes the "endless discussions" when closing a local connection - only
happened on a simultaneous close.
* A FIN in TIME_WAIT now updates the time-wait timer, as required by the
TCP specification.
* Entering TIME_WAIT now cancels all connection timers. We might want to
think about putting time wait connections into a separate hash, and delete
the socket early on.
* Added tracing support for send/receive, timers, and state changes.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25236 a95241bf-73f2-0310-859d-f6bbb57e9c96


# db4b6bc46caaeb073a5e176a89ea695c0b52b70e 28-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Merged _Receive() and _SegmentReceived().
* Cleanup, shuffled methods around, renamed methods, etc. - no functional changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25223 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 05bc1e89735f8cdbfa314202fcbd88ce5bcdf047 27-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Added _CancelConnectionTimers() that does what its name suggests, and is
now used from various places that previously did not cancel all timers
they should have.
* When a connection moves to the CLOSED state, it should cancel all timers;
this prevents from sending a reset at the end of a connection.
* If the persist/delayed acknowledge timers were canceled too late, they might
still have tried to send something (which would eventually cause a reset
sent to the peer).
* Follow RFC 1337 with respect to time wait assassination prevention (ie.
we now ignore resets from peers in time wait state).
* _SegmentReceived() must not check the sequence of a time wait connection;
it prevented sending a reset when that was due (a new connection request
would time out, instead of fail immediately).
* Also, that method must never be called in the LISTEN or SYNCHRONIZE_SENT
states, so we don't need to check for those.
* We don't have to wait in Close() until the connection is actually closed -
removed a TODO. TCP should handle this internally.
* Renamed _ShutdownEgress() to _Shutdown().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25219 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 058494285aafd433af5618aeb52abd76a4b39c6a 17-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
* Added syscall restart support for connect(), accept(), send(), recv(),
which are implemented via ioctl()s. The actual restart support is done
in the net stack driver's ioctl() hook. Lower layers need to correctly
deal with socket timeouts, though, for which the stack module provides
support functions.
* TCPEndpoint::_WaitForEstablished() does abort now when an error
occurred earlier, so that trying to connect to an unused port fails
immediately, as it should.
* Fixed and refactored TCP connection reset handling. The new
TCPEndpoint::_HandleReset() does the job. Got rid of
TCPEndpoint::fError.
* Fixed sequence numbers for SYNC/FINI packets.
* The former two fix the problem that connections wouldn't be closed
correctly and could even be reused when trying to connect again (as
was reproducible with svnserve + svn).
* Some style cleanup in CPEndpoint.h.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23984 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5c3cf2631067f21d72880b245c0ec0e23c3791c7 03-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Got rid of DeleteSocket().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23236 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1d0b34faae63ccea578c5f8f51038afa16fb825a 23-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

* If a new buffer had its last part in common with an existing larger buffer,
BufferQueue::Add() tried to remove a negative amount of bytes. This could
bring a download to a complete halt (as could the other one due to the list
link mixup).
* While the RTT computation still seems to work not that good (with a drop quote
of 50% I would easily reach retransmit timeouts of 80 secs), TCP should now
work a lot better on a flaky connection.
* Renamed _GetMSS() to _MaxSegmentSize().
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22677 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 84052230379abf8e556e20e499d9a6040157f4a6 31-Jul-2007 Axel Dörfler <axeld@pinc-software.de>

axeld+bonefish: Got rid of the ParentType in the HashTableDefinition; it doesn't really
belong there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21766 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 34c53bacf49f84ef2b18ea80c0238d73ee2d56de 26-May-2007 Hugo Santos <hugosantos@nowhere.fake>

tcp: fixed an issue where the socket could be waken from ReadData() even when no new data was added to the queue (due to lost packets). Also make sure we only break from the receive loop where there is at least a byte of data to be consumed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21248 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fe0ab2867a7f7d03b8bdc231592807553aee72f3 23-May-2007 Hugo Santos <hugosantos@nowhere.fake>

tcp: no longer need recursive locking.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21216 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a0a553caa3d17608dcda994338aa3f8ca81cb674 08-May-2007 Hugo Santos <hugosantos@nowhere.fake>

tcp: allow TCP_NODELAY to be set


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21069 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 62a21143be0010e6f9681394cfa9e93960169dcb 04-May-2007 Hugo Santos <hugosantos@nowhere.fake>

fixed a race condition in TCP's WaitList Wait/Signal that was preventing Connect() from awake when it should. Reported by Francois Revol.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21024 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 785e7ef7dd751385821998a5cf513d14f2456b3e 04-May-2007 Hugo Santos <hugosantos@nowhere.fake>

renamed TCP's TSval/TSecr


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21014 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 15945a11c67002b10f04a6207eea5637e6c17b45 29-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

added 'tcp_endpoints' and 'tcp_endpoint' debugger commands.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20909 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9cd3b980fd431d2fc4cabfdae2b572b866686ee9 27-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

fixed a long standing binding issue with spawned sockets and TCP. also fixed bind() address checking rules.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20866 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 342444bc95a45142c5e6fa824c96ca1c1343c84f 27-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

replaced TCP's Endpoint Manager manual handling of endpoint lists with MultiHashTable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20865 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4b55736dde3c03e6732d2d550b53218b35c37e21 27-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

added new helper ProtocolSocket. Moved some stuff together to achieve better inlining.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20848 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2586c25e318e1f71ff45889b9b0d047ce03043d1 25-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

use Chaining in OpenHashTable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20822 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 66a4a428020db4e26cda68ffe4b3dd6f1bed88c2 25-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

added Recv-Q/Send-Q output to netstat.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20819 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 585195c28d3d06ee7726b04a420145dda0bd875a 25-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

introduced SocketAddress wrappers and use them in TCP.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20818 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 53f23f85a2725c8fc31c7a874256084c7c623d86 25-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

partially rewrote TCP's endpoint manager. Fixes #1173


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20814 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 39faeeba3871ea8cd6a41a043cf564ecd68c45e2 20-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

when sending pure ACKs, use an artificial window of 0.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20778 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c70d3bafd3ef8cb0b218d942531a2296576a8661 20-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

more TCP fixes, we should now be able to send large amounts of data through congestioned links.

- fixed BufferQueue's RemoveUntil.
- reset SND.NXT on third duplicate ACK (fast retransmit).
- on retransmit reset SND.NXT to SND.UNA (it will be updated back when we get good ACKs).
- fixed effective window calculation.
- relaxed SWS checking a bit, don't send partial packets on retransmission as the window might have been reduced due to congestion.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20769 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2445c00e6420e2b365cba47c758b66fc04e75f59 19-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

some internal reorganization of getsockopt()/setsockopt() handling. TCP is now able to fully use the application requested sender/receiver buffer sizes for improved performance.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20764 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1d63ea33723fa8f3afac5a98fdb36b5bfe6839ee 18-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

some TCP performance improvements.

- support TCP fast retransmit/fast recovery.
- maintain the RTT average time and update the retransmit timeout accordingly.
- improvements to TCP Slow start / congestion avoidance.
- better handling of the retransmission timer.
- properly size segments taking the TCP options length into consideration.
- as an interim fix, update the SendQ/RecvQ sizes on Connect().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20748 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7d524fb79bfb32d55883b36e8208a6f7f12d7034 16-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

implemented TCP's slow start and congestion avoidance.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20734 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f19e1f47daa90e34c9b363beb2e278b300505446 16-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

reorganized some of the TCP logic so we have common init paths for receive and send.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20731 a95241bf-73f2-0310-859d-f6bbb57e9c96


# aa0770079557f4401daf7dc7e18a253d5b70c688 16-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

update Window Scaling variables when a simultaneous open is ACKed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20730 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 58bef2f444947af261189df60c5231ab69a9601d 16-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

support TCP Window Scale on sent segments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20729 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4ee088419f8fdc733b6cb0606e2556b176316788 16-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

assorted TCP fixes.

- fixed the locking for spawned connections and accept()s.
- return EMSGSIZE if the user is trying to write more data than the send buffer can hold.
- fixed a crash when receiving a RST while the connection is being closed.
- don't wake up readers when the connection gets established.
- endpoint managers lock must be recursive to properly work with spawn'ed sockets.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20727 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ca1b900bdb8cd280418ade417a2f81b5b4b50a91 15-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

support RFC 1323's TCP Timestamps (we are still not updating our estimator though).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20719 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 03d7f17e07da19253587845073315010febc031a 15-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

made TCP handle multiple domains.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20718 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fbaad6fdb5fad8e2f37834712f333603ead96153 15-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

fixed an issue where TCP would RST a connection when a peer trying to connect us re-sent their SYN.

- In fact our SYN/ACK reply is being lost due to ARP resolving as we are waiting in the device's receive path, thus we never get replies before timing out. This requires queueing during ARP resolving.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20706 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f73dd74eb9660085e4db4c9f7597885bb04c1569 10-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

even more TCP fixage.

- don't try to remove spawned sockets from Endpoints hashtable.
- return B_WOULD_BLOCK (EAGAIN) when we time out in acquire_sem().
- use B_RELEASE_IF_WAITING_ONLY in the TCP WaitList.
- fixed a off by one issue in ReadData() which could result in more than needed iterations (and waiting).
- implemented prepending new buffers to a net_buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20639 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7664bcb5c42ce2e8b1324de100aeabba4cfac81f 09-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

A couple more TCP fixes.

- ipv4_bind() was broken when binding to addresses not INADDR_ANY, as it wasn't copying the address to the socket, fixed.
- fixed a small issue in TCP's BindToEphemeral where the correct address might not have been bound to the socket.
- some assorted TCP wait lists fixes.
- fixed TCP's Connect() over the loopback interface, we might already be ESTABLISHED after _SendQueue() returns.
- fixed the amount of time we wait in TCP's Accept().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20629 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a7edede46f377bf9b0f2710079a09f22df2771ca 09-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

fixed multiple TCP issues.

- Moved FIN handling to after Segment Text handling, it matches the RFC and fixes a possible issue with a user missing some final segment data when receiving a FIN.
- Fixed the FIN handling to better terminate connections (no more senseless chatter in the end with RSTs etc).
- When Bind()ing, set the socket address so a call to getsockname() gets the allocated port correctly.
- After reaching the ESTABLISHED state, try to wake all pending threads (still needs work).
- Corrected the maximum amount of time we wait in SendData() to respect socket->send.timeout.
- Now ReadData() behaves correctly in all possible states.
- There was a missing handling of MSG_DONTWAIT, fixed.
- Better internal handling of PSH.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20624 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d86f48f3f5a6ca5039ee8f2190c97906d976f2d1 05-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

tiny TCP cleanups, move the read notifications to _NotifyReader().

- Also fixed the buffer size check in UDP's SendData() since UDP's length field includes the size of the header we need to check that as well. IPv4 is correct since we check for the size after prepending the header (due to it being possibly already included).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20592 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52e75b62362812a53a8d7d9502feb7a9c91bad7f 03-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

TCP: initial shutdown() implementation and some general fixes

* set FLAG_NO_RECEIVE/FLAG_NO_SEND on shutdown() and send FIN on SHUT_WR
* if a send() is attempted with FLAG_NO_SEND set return EPIPE
* proper handling of recv timeout in ReadData(), using absolute timeout instead of relative
* if FLAG_NO_RECEIVE is set, don't attached more segments to the receive queue, drop them instead


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20542 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3537f0967f24705ec2ce6ac113c6cbada14a7571 03-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

fixed a bug in TCP where applications weren't properly signaled when the connection was terminated by the server and there was no more data to be read from the buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20534 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 868583b54a8fb3706b5e68c3ed5420d70f4d3d45 03-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

fixed a potential problem in TCP's accept() with the init'ing of new connections' MSS


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20527 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 442c0979467981e68c45820d6e5d931a13c2ad82 04-Dec-2006 Axel Dörfler <axeld@pinc-software.de>

Renamed class TCPConnection to TCPEndpoint.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19418 a95241bf-73f2-0310-859d-f6bbb57e9c96