summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2012-06-28 21:21:33 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2012-06-28 21:24:14 +0200
commitbc2a866e55f9b6851ee783c52afc5e29f90f914f (patch)
treed45f100efdccf04bb0b195f4f1def90b2e5681d1
parentc83354f4c329e685c43c1d28a1b2bcc988886b99 (diff)
downloadgnutls-bc2a866e55f9b6851ee783c52afc5e29f90f914f.tar.gz
Return GNUTLS_E_LARGE_PACKET when errno is EMSGSIZE
-rw-r--r--doc/cha-gtls-app.texi6
-rw-r--r--lib/gnutls_buffers.c27
-rw-r--r--lib/gnutls_errors.c4
-rw-r--r--lib/gnutls_record.c3
-rw-r--r--lib/system.c3
5 files changed, 24 insertions, 19 deletions
diff --git a/doc/cha-gtls-app.texi b/doc/cha-gtls-app.texi
index 35f705fe05..52f6126dd3 100644
--- a/doc/cha-gtls-app.texi
+++ b/doc/cha-gtls-app.texi
@@ -595,15 +595,17 @@ value instead of setting @code{errno} directly.
@showfuncdesc{gnutls_transport_set_errno}
-@acronym{GnuTLS} currently only interprets the EINTR and EAGAIN errno
+@acronym{GnuTLS} currently only interprets the EINTR, EAGAIN and EMSGSIZE errno
values and returns the corresponding @acronym{GnuTLS} error codes:
@itemize
@item @code{GNUTLS_E_INTERRUPTED}
@item @code{GNUTLS_E_AGAIN}
+@item @code{GNUTLS_E_LARGE_PACKET}
@end itemize
The EINTR and EAGAIN values are returned by interrupted system calls,
or when non blocking IO is used. All @acronym{GnuTLS} functions can be
-resumed (called again), if any of the above error codes is returned.
+resumed (called again), if any of the above error codes is returned. The
+EMSGSIZE value is returned when attempting to send a large datagram.
In the case of DTLS it is also desirable to override the generic
transport functions with functions that emulate the operation
diff --git a/lib/gnutls_buffers.c b/lib/gnutls_buffers.c
index 17ec06188f..cca3a187b8 100644
--- a/lib/gnutls_buffers.c
+++ b/lib/gnutls_buffers.c
@@ -186,22 +186,21 @@ _gnutls_dgram_read (gnutls_session_t session, mbuffer_st **bufel,
_gnutls_read_log ("READ: %d returned from %p, errno=%d gerrno=%d\n",
(int) i, fd, errno, session->internals.errnum);
- if (err == EAGAIN)
- {
- ret = GNUTLS_E_AGAIN;
- goto cleanup;
- }
- else if (err == EINTR)
+ switch(err)
{
- ret = GNUTLS_E_INTERRUPTED;
- goto cleanup;
- }
- else
- {
- gnutls_assert ();
- ret = GNUTLS_E_PULL_ERROR;
- goto cleanup;
+ case EAGAIN:
+ ret = GNUTLS_E_AGAIN;
+ goto cleanup;
+ case EINTR:
+ ret = GNUTLS_E_INTERRUPTED;
+ goto cleanup;
+ case EMSGSIZE:
+ ret = GNUTLS_E_LARGE_PACKET;
+ default:
+ gnutls_assert ();
+ ret = GNUTLS_E_PULL_ERROR;
}
+ goto cleanup;
}
else
{
diff --git a/lib/gnutls_errors.c b/lib/gnutls_errors.c
index c70b3bfdbe..71b6e6acf1 100644
--- a/lib/gnutls_errors.c
+++ b/lib/gnutls_errors.c
@@ -64,8 +64,6 @@ static const gnutls_error_entry error_algorithms[] = {
ERROR_ENTRY (N_("An algorithm that is not enabled was negotiated."),
GNUTLS_E_UNWANTED_ALGORITHM, 1),
- ERROR_ENTRY (N_("A large TLS record packet was received."),
- GNUTLS_E_LARGE_PACKET, 1),
ERROR_ENTRY (N_("A record packet with illegal version was received."),
GNUTLS_E_UNSUPPORTED_VERSION_PACKET, 1),
ERROR_ENTRY (N_
@@ -164,6 +162,8 @@ static const gnutls_error_entry error_algorithms[] = {
GNUTLS_E_KEY_USAGE_VIOLATION, 1),
ERROR_ENTRY (N_("Resource temporarily unavailable, try again."),
GNUTLS_E_AGAIN, 0),
+ ERROR_ENTRY (N_("The transmitted packet is too large (EMSGSIZE)."),
+ GNUTLS_E_LARGE_PACKET, 0),
ERROR_ENTRY (N_("Function was interrupted."), GNUTLS_E_INTERRUPTED, 0),
ERROR_ENTRY (N_("Rehandshake was requested by the peer."),
GNUTLS_E_REHANDSHAKE, 0),
diff --git a/lib/gnutls_record.c b/lib/gnutls_record.c
index 01c4fb0e8f..e6250f84f1 100644
--- a/lib/gnutls_record.c
+++ b/lib/gnutls_record.c
@@ -1226,7 +1226,8 @@ _gnutls_recv_int (gnutls_session_t session, content_type_t type,
* %GNUTLS_E_INTERRUPTED or %GNUTLS_E_AGAIN is returned, you must
* call this function again, with the same parameters; alternatively
* you could provide a %NULL pointer for data, and 0 for
- * size. cf. gnutls_record_get_direction().
+ * size. cf. gnutls_record_get_direction(). The errno value EMSGSIZE
+ * maps to %GNUTLS_E_LARGE_PACKET.
*
* Returns: The number of bytes sent, or a negative error code. The
* number of bytes sent might be less than @data_size. The maximum
diff --git a/lib/system.c b/lib/system.c
index bec2e09219..82572ba971 100644
--- a/lib/system.c
+++ b/lib/system.c
@@ -71,6 +71,9 @@ system_errno (gnutls_transport_ptr p)
case WSAEINTR:
ret = EINTR;
break;
+ case WSAEMSGSIZE:
+ ret = EMSGSIZE;
+ break;
default:
ret = EIO;
break;