gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r27767 - in libmicrohttpd/src: include microspdy


From: gnunet
Subject: [GNUnet-SVN] r27767 - in libmicrohttpd/src: include microspdy
Date: Fri, 5 Jul 2013 17:34:19 +0200

Author: andreyu
Date: 2013-07-05 17:34:19 +0200 (Fri, 05 Jul 2013)
New Revision: 27767

Added:
   libmicrohttpd/src/microspdy/io_raw.c
   libmicrohttpd/src/microspdy/io_raw.h
Modified:
   libmicrohttpd/src/include/microspdy.h
   libmicrohttpd/src/microspdy/Makefile.am
   libmicrohttpd/src/microspdy/applicationlayer.c
   libmicrohttpd/src/microspdy/io.h
Log:
spdy: io_raw just added; not yet integrated

Modified: libmicrohttpd/src/include/microspdy.h
===================================================================
--- libmicrohttpd/src/include/microspdy.h       2013-07-05 15:15:55 UTC (rev 
27766)
+++ libmicrohttpd/src/include/microspdy.h       2013-07-05 15:34:19 UTC (rev 
27767)
@@ -315,6 +315,11 @@
         * Default TLS implementation provided by openSSL/libssl.
         */
        SPDY_IO_SUBSYSTEM_OPENSSL = 1,
+
+       /**
+        * No TLS is used.
+        */
+       SPDY_IO_SUBSYSTEM_RAW = 0,
 };
 
 

Modified: libmicrohttpd/src/microspdy/Makefile.am
===================================================================
--- libmicrohttpd/src/microspdy/Makefile.am     2013-07-05 15:15:55 UTC (rev 
27766)
+++ libmicrohttpd/src/microspdy/Makefile.am     2013-07-05 15:34:19 UTC (rev 
27767)
@@ -17,6 +17,7 @@
 libmicrospdy_la_SOURCES = \
   io.h \
   io_openssl.h io_openssl.c \
+  io_raw.h io_raw.c \
   structures.h structures.c \
   internal.h internal.c \
   daemon.h daemon.c \

Modified: libmicrohttpd/src/microspdy/applicationlayer.c
===================================================================
--- libmicrohttpd/src/microspdy/applicationlayer.c      2013-07-05 15:15:55 UTC 
(rev 27766)
+++ libmicrohttpd/src/microspdy/applicationlayer.c      2013-07-05 15:34:19 UTC 
(rev 27767)
@@ -247,6 +247,11 @@
     SPDYF_openssl_global_init();
     spdyf_io_initialized |= SPDY_IO_SUBSYSTEM_OPENSSL;
   }
+  else if(SPDY_IO_SUBSYSTEM_RAW & io_subsystem)
+  {
+    SPDYF_raw_global_init();
+    spdyf_io_initialized |= SPDY_IO_SUBSYSTEM_RAW;
+  }
   
        SPDYF_ASSERT(SPDY_IO_SUBSYSTEM_NONE != spdyf_io_initialized,
                "SPDY_init could not find even one IO subsystem");
@@ -261,9 +266,11 @@
        SPDYF_ASSERT(SPDY_IO_SUBSYSTEM_NONE != spdyf_io_initialized,
                "SPDY_init has not been called!");
     
-       //currently nothing to be freed/deinited
-       //SPDYF_openssl_global_deinit doesn't do anything now
-       //SPDYF_openssl_global_deinit();
+  if(SPDY_IO_SUBSYSTEM_OPENSSL & spdyf_io_initialized)
+    SPDYF_openssl_global_deinit();
+  else if(SPDY_IO_SUBSYSTEM_RAW & spdyf_io_initialized)
+    SPDYF_raw_global_deinit();
+  
   spdyf_io_initialized = SPDY_IO_SUBSYSTEM_NONE;
 }
 

Modified: libmicrohttpd/src/microspdy/io.h
===================================================================
--- libmicrohttpd/src/microspdy/io.h    2013-07-05 15:15:55 UTC (rev 27766)
+++ libmicrohttpd/src/microspdy/io.h    2013-07-05 15:34:19 UTC (rev 27767)
@@ -27,6 +27,7 @@
 
 #include "platform.h"
 #include "io_openssl.h"
+#include "io_raw.h"
 
 
 /**

Added: libmicrohttpd/src/microspdy/io_raw.c
===================================================================
--- libmicrohttpd/src/microspdy/io_raw.c                                (rev 0)
+++ libmicrohttpd/src/microspdy/io_raw.c        2013-07-05 15:34:19 UTC (rev 
27767)
@@ -0,0 +1,139 @@
+/*
+    This file is part of libmicrospdy
+    Copyright (C) 2013 Andrey Uzunov
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file io_raw.c
+ * @brief  IO for SPDY without TLS.
+ * @author Andrey Uzunov
+ */
+
+#include "platform.h"
+#include "internal.h"
+#include "session.h"
+#include "io_raw.h"
+
+
+void
+SPDYF_raw_global_init()
+{
+}
+
+
+void
+SPDYF_raw_global_deinit()
+{
+}
+
+
+int
+SPDYF_raw_init(struct SPDY_Daemon *daemon)
+{
+  (void)daemon;
+  
+       return SPDY_YES;
+}
+
+
+void
+SPDYF_raw_deinit(struct SPDY_Daemon *daemon)
+{
+  (void)daemon;
+}
+
+
+int
+SPDYF_raw_new_session(struct SPDY_Session *session)
+{      
+  (void)session;
+  
+       return SPDY_YES;
+}
+
+
+void
+SPDYF_raw_close_session(struct SPDY_Session *session)
+{
+  (void)session;
+}
+
+
+int
+SPDYF_raw_recv(struct SPDY_Session *session,
+                               void * buffer,
+                               size_t size)
+{
+       int n = read(session->socket_fd, 
+                                       buffer,
+                                       size);
+       //if(n > 0) SPDYF_DEBUG("recvd: %i",n);
+       if (n < 0)
+       {
+               switch(errno)
+               {                               
+                       case EAGAIN:
+#if EAGAIN != EWOULDBLOCK
+      case EWOULDBLOCK:
+#endif
+                       case EINTR:
+        return SPDY_IO_ERROR_AGAIN;
+                               
+                       default:
+                               return SPDY_IO_ERROR_ERROR;
+               }
+       }
+
+       return n;
+}
+
+
+int
+SPDYF_raw_send(struct SPDY_Session *session,
+                               const void * buffer,
+                               size_t size)
+{
+       int n = write(session->socket_fd, 
+                                       buffer,
+                                       size);
+       //if(n > 0) SPDYF_DEBUG("sent: %i",n);
+       if (n < 0)
+       {
+               switch(errno)
+               {                               
+                       case EAGAIN:
+#if EAGAIN != EWOULDBLOCK
+      case EWOULDBLOCK:
+#endif
+                       case EINTR:
+        return SPDY_IO_ERROR_AGAIN;
+                               
+                       default:
+                               return SPDY_IO_ERROR_ERROR;
+               }
+       }
+       
+       return n;
+}
+
+
+int
+SPDYF_raw_is_pending(struct SPDY_Session *session)
+{
+  (void)session;
+  
+       return SPDY_NO;
+}

Added: libmicrohttpd/src/microspdy/io_raw.h
===================================================================
--- libmicrohttpd/src/microspdy/io_raw.h                                (rev 0)
+++ libmicrohttpd/src/microspdy/io_raw.h        2013-07-05 15:34:19 UTC (rev 
27767)
@@ -0,0 +1,135 @@
+/*
+    This file is part of libmicrospdy
+    Copyright (C) 2013 Andrey Uzunov
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file io_raw.h
+ * @brief  IO for SPDY without TLS.
+ * @author Andrey Uzunov
+ */
+
+#ifndef IO_RAW_H
+#define IO_RAW_H
+
+#include "platform.h"
+
+
+/**
+ * Must be called only once in the program.
+ *
+ */
+void
+SPDYF_raw_global_init();
+
+
+/**
+ * Should be called
+ * at the end of the program.
+ *
+ */
+void
+SPDYF_raw_global_deinit();
+
+
+/**
+ * Must be called when the daemon starts.
+ *
+ * @param daemon SPDY_Daemon 
+ * @return SPDY_YES on success or SPDY_NO on error
+ */
+int
+SPDYF_raw_init(struct SPDY_Daemon *daemon);
+
+
+/**
+ * Should be called
+ * when the deamon is stopped.
+ *
+ * @param daemon SPDY_Daemon which is being stopped
+ */
+void
+SPDYF_raw_deinit(struct SPDY_Daemon *daemon);
+
+
+/**
+ * Must be called
+ * after the connection has been accepted.
+ *
+ * @param session SPDY_Session whose socket will be used
+ * @return SPDY_NO if some funcs fail. SPDY_YES otherwise
+ */
+int
+SPDYF_raw_new_session(struct SPDY_Session *session);
+
+
+/**
+ * Should be called
+ * closing session's socket.
+ *
+ * @param session SPDY_Session whose socket is used
+ */
+void
+SPDYF_raw_close_session(struct SPDY_Session *session);
+
+
+/**
+ * Reading from socket. Reads available data and put it to the
+ * buffer.
+ *
+ * @param session for which data is received
+ * @param buffer where data from the socket will be written to
+ * @param size of the buffer
+ * @return number of bytes (at most size) read from the connection
+ *         0 if the other party has closed the connection
+ *         SPDY_IO_ERROR code on error
+ */
+int
+SPDYF_raw_recv(struct SPDY_Session *session,
+                               void * buffer,
+                               size_t size);
+
+
+/**
+ * Writing to socket. Writes the data given into the buffer to the
+ * socket.
+ *
+ * @param session whose context is used
+ * @param buffer from where data will be written to the socket
+ * @param size number of bytes to be taken from the buffer
+ * @return number of bytes (at most size) from the buffer that has been
+ *                     written to the connection
+ *         0 if the other party has closed the connection
+ *         SPDY_IO_ERROR code on error
+ */
+int
+SPDYF_raw_send(struct SPDY_Session *session,
+                               const void * buffer,
+                               size_t size);
+
+
+/**
+ * Checks if there is data staying in the buffers of the underlying
+ * system that waits to be read. Always returns SPDY_NO, as we do not
+ * use a subsystem here.
+ *
+ * @param session which is checked
+ * @return SPDY_YES if data is pending or SPDY_NO otherwise
+ */
+int
+SPDYF_raw_is_pending(struct SPDY_Session *session);
+
+#endif




reply via email to

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