]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Return GNUTLS_E_LARGE_PACKET when errno is EMSGSIZE
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 28 Jun 2012 19:21:33 +0000 (21:21 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 28 Jun 2012 19:24:14 +0000 (21:24 +0200)
doc/cha-gtls-app.texi
lib/gnutls_buffers.c
lib/gnutls_errors.c
lib/gnutls_record.c
lib/system.c

index 35f705fe05a317fcddd1100d0039db20afafbdcb..52f6126dd36ba6620c8d7d3b6e66a9cb937d0486 100644 (file)
@@ -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
index 17ec06188f5b101365cf667c8fdd4e084722d939..cca3a187b8f3c5843c5724497eab83ac49419c6a 100644 (file)
@@ -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
     {
index c70b3bfdbee29c9cfc211e1e3af015cc9d536251..71b6e6acf1123cd8d2d3da402d9727c6bb93b17d 100644 (file)
@@ -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),
index 01c4fb0e8fe92f9a95f7c877789eb1018ae9bf44..e6250f84f179e0e204c4be3e284749dc2b03a2ae 100644 (file)
@@ -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
index bec2e09219c95047c2c99354dcad3e89720bf0c2..82572ba971ca4d98a1be2b93359dac100bc5ac65 100644 (file)
@@ -71,6 +71,9 @@ system_errno (gnutls_transport_ptr p)
     case WSAEINTR:
       ret = EINTR;
       break;
+    case WSAEMSGSIZE:
+      ret = EMSGSIZE;
+      break;
     default:
       ret = EIO;
       break;