gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r7382 - libmicrohttpd/src/daemon


From: gnunet
Subject: [GNUnet-SVN] r7382 - libmicrohttpd/src/daemon
Date: Fri, 4 Jul 2008 19:26:36 -0600 (MDT)

Author: lv-426
Date: 2008-07-04 19:26:36 -0600 (Fri, 04 Jul 2008)
New Revision: 7382

Modified:
   libmicrohttpd/src/daemon/connection.c
   libmicrohttpd/src/daemon/daemon.c
Log:
relocated handshake handling code

Modified: libmicrohttpd/src/daemon/connection.c
===================================================================
--- libmicrohttpd/src/daemon/connection.c       2008-07-05 00:42:25 UTC (rev 
7381)
+++ libmicrohttpd/src/daemon/connection.c       2008-07-05 01:26:36 UTC (rev 
7382)
@@ -163,18 +163,28 @@
 
 #if HTTPS_SUPPORT
 /* get cipher spec for this connection */
-gnutls_cipher_algorithm_t MHDS_get_session_cipher (struct MHD_Connection * 
session ){
-  return gnutls_cipher_get(session->tls_session);
+gnutls_cipher_algorithm_t
+MHDS_get_session_cipher (struct MHD_Connection * session)
+{
+  return gnutls_cipher_get (session->tls_session);
 }
 
-gnutls_mac_algorithm_t MHDS_get_session_mac (struct MHD_Connection * session ){
-  return gnutls_mac_get(session->tls_session);
+gnutls_mac_algorithm_t
+MHDS_get_session_mac (struct MHD_Connection * session)
+{
+  return gnutls_mac_get (session->tls_session);
 }
-gnutls_compression_method_t MHDS_get_session_compression (struct 
MHD_Connection * session ){
-  return gnutls_compression_get(session->tls_session);
+
+gnutls_compression_method_t
+MHDS_get_session_compression (struct MHD_Connection * session)
+{
+  return gnutls_compression_get (session->tls_session);
 }
-gnutls_certificate_type_t MHDS_get_session_cert_type (struct MHD_Connection * 
session ){
-  return gnutls_certificate_type_get(session->tls_session);
+
+gnutls_certificate_type_t
+MHDS_get_session_cert_type (struct MHD_Connection * session)
+{
+  return gnutls_certificate_type_get (session->tls_session);
 }
 #endif
 
@@ -1543,6 +1553,8 @@
 int
 MHDS_connection_handle_read (struct MHD_Connection *connection)
 {
+  int ret;
+
   connection->last_activity = time (NULL);
 
   if (connection->s_state == MHDS_CONNECTION_CLOSED)
@@ -1619,8 +1631,29 @@
       /* forward application level content to MHD */
     case GNUTLS_APPLICATION_DATA:
       return MHD_connection_handle_read (connection);
-      // TODO impl
+
     case GNUTLS_HANDSHAKE:
+      ret = gnutls_handshake (connection->tls_session);
+      if (ret == 0)
+        {
+          connection->s_state = MHDS_HANDSHAKE_COMPLETE;
+          connection->state = MHD_CONNECTION_INIT;
+        }
+      /* set connection as closed */
+      else
+        {
+#if HAVE_MESSAGES
+          MHD_DLOG (connection->daemon,
+                    "Error: Handshake has failed (%s)\n",
+                    ret);
+#endif
+          connection->s_state = MHDS_HANDSHAKE_FAILED;
+          gnutls_bye (connection->tls_session, GNUTLS_SHUT_WR);
+          gnutls_deinit (connection->tls_session);
+          connection->socket_fd = -1;
+          return MHD_NO;
+
+        }
       break;
     case GNUTLS_INNER_APPLICATION:
       break;

Modified: libmicrohttpd/src/daemon/daemon.c
===================================================================
--- libmicrohttpd/src/daemon/daemon.c   2008-07-05 00:42:25 UTC (rev 7381)
+++ libmicrohttpd/src/daemon/daemon.c   2008-07-05 01:26:36 UTC (rev 7382)
@@ -225,26 +225,6 @@
 
   gnutls_transport_set_ptr (tls_session, con->socket_fd);
 
-  ret = gnutls_handshake (tls_session);
-
-  if (ret == 0)
-    {
-      con->s_state = MHDS_HANDSHAKE_COMPLETE;
-      con->state = MHD_CONNECTION_INIT;
-    }
-  else
-    {
-      /* set connection as closed */
-      fprintf (stderr, "*** Handshake has failed (%s)\n\n",
-               gnutls_strerror (ret));
-      con->s_state = MHDS_HANDSHAKE_FAILED;
-      gnutls_bye (con->tls_session, GNUTLS_SHUT_WR);
-      gnutls_deinit (tls_session);
-      con->socket_fd = -1;
-      return MHD_NO;
-
-    }
-
   MHD_handle_connection (data);
 }
 #endif





reply via email to

[Prev in Thread] Current Thread [Next in Thread]