libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 489d8e1bad4b5ac84c6744d47a4e0f71890f2aa1
parent 31ff028b0b317f1389164c855c21114459b10fc1
Author: Andrey Uzunov <andrey.uzunov@gmail.com>
Date:   Fri,  5 Jul 2013 15:50:21 +0000

spdy: io_raw integrated; not yet settable

Diffstat:
Msrc/include/microspdy.h | 2+-
Msrc/microspdy/Makefile.am | 2+-
Msrc/microspdy/daemon.c | 4++--
Asrc/microspdy/io.c | 84+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/microspdy/io.h | 20++++++++++++++++++++
Msrc/microspdy/session.c | 8++------
6 files changed, 110 insertions(+), 10 deletions(-)

diff --git a/src/include/microspdy.h b/src/include/microspdy.h @@ -319,7 +319,7 @@ enum SPDY_IO_SUBSYSTEM /** * No TLS is used. */ - SPDY_IO_SUBSYSTEM_RAW = 0, + SPDY_IO_SUBSYSTEM_RAW = 2, }; diff --git a/src/microspdy/Makefile.am b/src/microspdy/Makefile.am @@ -15,7 +15,7 @@ lib_LTLIBRARIES = \ libmicrospdy.la libmicrospdy_la_SOURCES = \ - io.h \ + io.h io.c \ io_openssl.h io_openssl.c \ io_raw.h io_raw.c \ structures.h structures.c \ diff --git a/src/microspdy/daemon.c b/src/microspdy/daemon.c @@ -191,8 +191,8 @@ SPDYF_start_daemon_va (uint16_t port, memset (daemon, 0, sizeof (struct SPDY_Daemon)); daemon->socket_fd = -1; daemon->port = port; - daemon->fio_init = &SPDYF_openssl_init; - daemon->fio_deinit = &SPDYF_openssl_deinit; + SPDYF_io_set_daemon(daemon, SPDY_IO_SUBSYSTEM_OPENSSL); + if (NULL == (daemon->certfile = strdup (certfile))) { SPDYF_DEBUG("str"); diff --git a/src/microspdy/io.c b/src/microspdy/io.c @@ -0,0 +1,84 @@ +/* + 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.c + * @brief Functions for IO. + * @author Andrey Uzunov + */ + +#include "platform.h" +#include "structures.h" +#include "internal.h" +#include "io.h" + + +int +SPDYF_io_set_daemon(struct SPDY_Daemon *daemon, enum SPDY_IO_SUBSYSTEM io_subsystem) +{ + switch(io_subsystem) + { + case SPDY_IO_SUBSYSTEM_OPENSSL: + daemon->fio_init = &SPDYF_openssl_init; + daemon->fio_deinit = &SPDYF_openssl_deinit; + break; + + case SPDY_IO_SUBSYSTEM_RAW: + daemon->fio_init = &SPDYF_raw_init; + daemon->fio_deinit = &SPDYF_raw_deinit; + break; + + case SPDY_IO_SUBSYSTEM_NONE: + default: + SPDYF_DEBUG("Unsupported subsystem"); + return SPDY_NO; + } + + return SPDY_YES; +} + + +int +SPDYF_io_set_session(struct SPDY_Session *session, enum SPDY_IO_SUBSYSTEM io_subsystem) +{ + switch(io_subsystem) + { + case SPDY_IO_SUBSYSTEM_OPENSSL: + session->fio_new_session = &SPDYF_openssl_new_session; + session->fio_close_session = &SPDYF_openssl_close_session; + session->fio_is_pending = &SPDYF_openssl_is_pending; + session->fio_recv = &SPDYF_openssl_recv; + session->fio_send = &SPDYF_openssl_send; + break; + + case SPDY_IO_SUBSYSTEM_RAW: + session->fio_new_session = &SPDYF_raw_new_session; + session->fio_close_session = &SPDYF_raw_close_session; + session->fio_is_pending = &SPDYF_raw_is_pending; + session->fio_recv = &SPDYF_raw_recv; + session->fio_send = &SPDYF_raw_send; + break; + + case SPDY_IO_SUBSYSTEM_NONE: + default: + SPDYF_DEBUG("Unsupported subsystem"); + return SPDY_NO; + } + + return SPDY_YES; +} diff --git a/src/microspdy/io.h b/src/microspdy/io.h @@ -161,4 +161,24 @@ typedef int typedef int (*SPDYF_IOIsPending) (struct SPDY_Session *session); + +/** + * Sets callbacks for the daemon with regard to the IO subsystem. + * + * @param daemon + * @return SPDY_YES on success or SPDY_NO otherwise + */ +int +SPDYF_io_set_daemon(struct SPDY_Daemon *daemon, enum SPDY_IO_SUBSYSTEM io_subsystem); + + +/** + * Sets callbacks for the session with regard to the IO subsystem. + * + * @param session + * @return SPDY_YES on success or SPDY_NO otherwise + */ +int +SPDYF_io_set_session(struct SPDY_Session *session, enum SPDY_IO_SUBSYSTEM io_subsystem); + #endif diff --git a/src/microspdy/session.c b/src/microspdy/session.c @@ -1305,12 +1305,8 @@ SPDYF_session_accept(struct SPDY_Daemon *daemon) session->daemon = daemon; session->socket_fd = new_socket_fd; - - session->fio_new_session = &SPDYF_openssl_new_session; - session->fio_close_session = &SPDYF_openssl_close_session; - session->fio_is_pending = &SPDYF_openssl_is_pending; - session->fio_recv = &SPDYF_openssl_recv; - session->fio_send = &SPDYF_openssl_send; + + SPDYF_io_set_session(session, SPDY_IO_SUBSYSTEM_OPENSSL); //init TLS context, handshake will be done if(SPDY_YES != session->fio_new_session(session))