* Version 2.99.0 (unreleased)
+** libgnutls: gnutls_transport_set_lowat() is no more.
+
** libgnutls-openssl: modified to use modern gnutls' functions.
This introduces an ABI incompatibility with previous versions.
@item @ref{gnutls_transport_set_push_function}
@item @ref{gnutls_transport_set_pull_function}
@item @ref{gnutls_transport_set_ptr}
-@item @ref{gnutls_transport_set_lowat}
@item @ref{gnutls_transport_set_errno}
@end itemize
above refer to the system call, not the @acronym{GnuTLS} function,
since signals do not interrupt @acronym{GnuTLS}' functions.
-For non blocking sockets or other custom made pull/push functions
-the @ref{gnutls_transport_set_lowat} must be called, with a zero
-low water mark value.
-
By default, if the transport functions are not set, @acronym{GnuTLS}
-will use the Berkeley Sockets functions. In this case
-@acronym{GnuTLS} will use some hacks in order for @code{select} to
-work, thus making it easy to add @acronym{TLS} support to existing
-TCP/IP servers.
+will use the Berkeley Sockets functions.
@node The TLS record protocol
@section The TLS Record Protocol
return i;
}
-#define RCVLOWAT session->internals.lowat
-
-/* This function is only used with berkeley style sockets.
- * Clears the peeked data (read with MSG_PEEK).
- */
-int
-_gnutls_io_clear_peeked_data (gnutls_session_t session)
-{
- mbuffer_st *peekdata;
- int ret, sum;
-
- if (session->internals.have_peeked_data == 0 || RCVLOWAT == 0)
- return 0;
-
- /* this was already read by using MSG_PEEK - so it shouldn't fail */
- sum = 0;
- do
- { /* we need this to finish now */
- ret =
- _gnutls_read (session, &peekdata, RCVLOWAT - sum,
- session->internals.pull_func);
- if (ret > 0)
- sum += ret;
- _mbuffer_xfree (&peekdata);
- }
- while (ret == GNUTLS_E_INTERRUPTED || ret == GNUTLS_E_AGAIN
- || sum < RCVLOWAT);
-
- if (ret < 0)
- {
- gnutls_assert ();
- return ret;
- }
-
- session->internals.have_peeked_data = 0;
-
- return 0;
-}
-
/* This function is like recv(with MSG_PEEK). But it does not return -1 on error.
* It does return gnutls_errno instead.
* This function reads data from the socket and keeps them in a buffer, of up to
_gnutls_io_read_buffered (gnutls_session_t session, size_t total,
content_type_t recv_type)
{
- ssize_t ret = 0, ret2 = 0;
+ ssize_t ret = 0;
size_t min;
mbuffer_st *bufel = NULL;
- size_t recvlowat, recvdata, readsize;
+ size_t recvdata, readsize;
if (total > MAX_RECV_SIZE(session) || total == 0)
{
return GNUTLS_E_INVALID_REQUEST;
}
- /* If an external pull function is used, then do not leave
- * any data into the kernel buffer.
- */
- if (session->internals.pull_func != system_read)
- {
- recvlowat = 0;
- }
- else
- {
- /* leave peeked data to the kernel space only if application data
- * is received and we don't have any peeked
- * data in gnutls session.
- */
- if (recv_type != GNUTLS_APPLICATION_DATA
- && session->internals.have_peeked_data == 0)
- recvlowat = 0;
- else
- recvlowat = RCVLOWAT;
- }
-
-
-
/* calculate the actual size, ie. get the minimum of the
* buffered data and the requested data.
*/
* receive in order to return the requested data.
*/
recvdata = total - min;
- readsize = recvdata - recvlowat;
+ readsize = recvdata;
/* Check if the previously read data plus the new data to
* receive are longer than the maximum receive buffer size.
else
_mbuffer_xfree (&bufel);
-
- /* This is hack in order for select to work. Just leave recvlowat data,
- * into the kernel buffer (using a read with MSG_PEEK), thus making
- * select think, that the socket is ready for reading.
- * MSG_PEEK is only used with berkeley style sockets.
- */
- if (ret == readsize && recvlowat > 0 && !_gnutls_is_dtls(session) &&
- session->internals.pull_func == system_read)
- {
- ret2 = _gnutls_read (session, &bufel, recvlowat, system_read_peek);
-
- if (ret2 < 0 && gnutls_error_is_fatal (ret2) == 0)
- {
- _mbuffer_xfree (&bufel);
- return ret2;
- }
-
- if (ret2 > 0)
- {
- _gnutls_read_log ("RB-PEEK: Read %d bytes in PEEK MODE.\n",
- (int) ret2);
- _gnutls_read_log
- ("RB-PEEK: Have %d bytes into buffer. Adding %d bytes.\nRB: Requested %d bytes\n",
- (int) session->internals.record_recv_buffer.byte_length,
- (int) ret2, (int) total);
- session->internals.have_peeked_data = 1;
- _mbuffer_enqueue (&session->internals.record_recv_buffer, bufel);
- }
- else
- _mbuffer_xfree (&bufel);
- }
-
- if (ret < 0 || ret2 < 0)
+ if (ret < 0)
{
gnutls_assert ();
- /* that's because they are initialized to 0 */
- return MIN (ret, ret2);
- }
-
- ret += ret2;
-
- if (ret > 0 && ret < recvlowat)
- {
- return gnutls_assert_val(GNUTLS_E_AGAIN);
+ return ret;
}
if (ret == 0)
} gnutls_ext_parse_type_t;
-/* the default for TCP */
-#define DEFAULT_LOWAT 0
-
/* expire time for resuming sessions */
#define DEFAULT_EXPIRE_TIME 3600
security_parameters_st resumed_security_parameters;
gnutls_compression_method_t resumed_compression_method;
- /* sockets internals */
- int lowat;
-
/* These buffers are used in the handshake
* protocol only. freed using _gnutls_handshake_io_buffer_clear();
*/
* send.
*/
-
- /* 0 if no peeked data was kept, 1 otherwise.
- */
- int have_peeked_data:1;
-
int expire_time; /* after expire_time seconds this session will expire */
struct mod_auth_st_int *auth_struct; /* used in handshake packets and KX algorithms */
session->security_parameters.version = version;
}
-/**
- * gnutls_transport_set_lowat:
- * @session: is a #gnutls_session_t structure.
- * @num: is the low water value.
- *
- * Used to set the lowat value in order for select to check if there
- * are pending data to socket buffer. Used only if you have changed
- * the default low water value (default is 1). Normally you will not
- * need that function. This function is only useful if using
- * berkeley style sockets. Otherwise it must be called and set lowat
- * to zero.
- **/
-void
-gnutls_transport_set_lowat (gnutls_session_t session, int num)
-{
- session->internals.lowat = num;
-}
-
/**
* gnutls_record_disable_padding:
* @session: is a #gnutls_session_t structure.
{
do
{
- _gnutls_io_clear_peeked_data (session);
ret = _gnutls_recv_int (session, GNUTLS_ALERT, -1, NULL, 0, NULL);
}
while (ret == GNUTLS_E_GOT_APPLICATION_DATA);
type == GNUTLS_CHANGE_CIPHER_SPEC)
&& _gnutls_record_buffer_get_size (type, session) > 0)
{
- int ret, ret2;
+ int ret;
ret = _gnutls_record_buffer_get (type, session, data, data_size, seq);
if (ret < 0)
{
return ret;
}
- /* if the buffer just got empty */
- if (_gnutls_record_buffer_get_size (type, session) == 0)
- {
- if ((ret2 = _gnutls_io_clear_peeked_data (session)) < 0)
- {
- gnutls_assert ();
- return ret2;
- }
- }
-
return ret;
}
gnutls_dh_set_prime_bits ((*session), MIN_DH_BITS);
- gnutls_transport_set_lowat ((*session), DEFAULT_LOWAT); /* the default for tcp */
-
gnutls_handshake_set_max_packet_length ((*session),
MAX_HANDSHAKE_PACKET_SIZE);
/* gnutls_connection_end_t was made redundant in 2.99.0 */
#define gnutls_connection_end_t unsigned int
+/* no longer valid since 2.99.0 */
+#define gnutls_transport_set_lowat(session, num)
+
/* Stuff deprected in 2.x */
#define gnutls_cipher_algorithm gnutls_cipher_algorithm_t
#define gnutls_kx_algorithm gnutls_kx_algorithm_t
gnutls_transport_ptr_t * recv_ptr,
gnutls_transport_ptr_t * send_ptr);
- void gnutls_transport_set_lowat (gnutls_session_t session, int num);
-
-
void gnutls_transport_set_vec_push_function (gnutls_session_t session,
gnutls_vec_push_func vec_func);
void gnutls_transport_set_push_function (gnutls_session_t session,
gnutls_transport_get_ptr;
gnutls_transport_set_errno;
gnutls_transport_set_global_errno;
- gnutls_transport_set_lowat;
gnutls_transport_set_ptr2;
gnutls_transport_set_ptr;
gnutls_transport_set_pull_function;