summaryrefslogtreecommitdiff
path: root/tests/test-pseudotcp.c
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2014-07-17 16:44:45 +0100
committerOlivier Crête <olivier.crete@collabora.com>2014-08-21 14:33:11 -0400
commit5adf7f97dc0c18c95828e53fc4ea86f366e2f9af (patch)
tree9980262fa95888bc2174ced2d3af44d2178df631 /tests/test-pseudotcp.c
parent480725bd92a50a47cab0b8725944263c6bf1d18f (diff)
downloadlibnice-5adf7f97dc0c18c95828e53fc4ea86f366e2f9af.tar.gz
pseudotcp: Add optional FIN–ACK and RST support
In order to detect cases where the peer closes its connection without an explicit in-band close message (e.g. in protocols such as Telnet where there is none), pseudo-TCP needs to grow support for a shutdown handshake, following the TCP FIN–ACK specification. Arguably it should have had this all along, but Jingle apparently doesn’t need it. This adds support for FIN–ACK to the pseudo-TCP implementation. It is backwards-compatible, only being used if the TCP_OPT_FIN_ACK option is specified in the SYN segment. If enabled, full-duplex closes are supported, and the standard method for notifying a peer of the other end closing its connection (returning 0 from recv()) is used. Also allow rapidly tearing down a connection, discarding unsent and unreceived data, by sending an RST segment. This preserves the ability to do a forced socket closure with pseudo_tcp_socket_close(sock, TRUE). It also permits graceful socket shutdown in the case where the final ACK is lost, and one peer gets stuck in the LAST-ACK state: that peer will eventually re-transmit its FIN segment. The other peer, in the CLOSED state, will respond with a RST segment, and the first peer will then reach CLOSED. References (most useful first): • http://tools.ietf.org/html/rfc793#section-3.5 • http://tools.ietf.org/html/rfc1122#page-87 • http://vincent.bernat.im/en/blog/2014-tcp-time-wait-state-linux.html • http://tools.ietf.org/html/rfc675 Diagram: • http://en.wikipedia.org/wiki/Transmission_Control_Protocol#mediaviewer/File:TCP_CLOSE.svg
Diffstat (limited to 'tests/test-pseudotcp.c')
-rw-r--r--tests/test-pseudotcp.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/test-pseudotcp.c b/tests/test-pseudotcp.c
index 1044a08..e4dd613 100644
--- a/tests/test-pseudotcp.c
+++ b/tests/test-pseudotcp.c
@@ -138,6 +138,8 @@ static void readable (PseudoTcpSocket *sock, gpointer data)
exit (-1);
}
}
+ } else if (len == 0) {
+ pseudo_tcp_socket_close (sock, FALSE);
}
} while (len > 0);