00001 /* 00002 This file is part of libmicrospdy 00003 Copyright (C) 2013 Andrey Uzunov 00004 00005 This program is free software: you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation, either version 3 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00025 #include "platform.h" 00026 #include "structures.h" 00027 #include "internal.h" 00028 #include "io.h" 00029 00030 00031 int 00032 SPDYF_io_set_daemon(struct SPDY_Daemon *daemon, 00033 enum SPDY_IO_SUBSYSTEM io_subsystem) 00034 { 00035 switch(io_subsystem) 00036 { 00037 case SPDY_IO_SUBSYSTEM_OPENSSL: 00038 daemon->fio_init = &SPDYF_openssl_init; 00039 daemon->fio_deinit = &SPDYF_openssl_deinit; 00040 break; 00041 00042 case SPDY_IO_SUBSYSTEM_RAW: 00043 daemon->fio_init = &SPDYF_raw_init; 00044 daemon->fio_deinit = &SPDYF_raw_deinit; 00045 break; 00046 00047 case SPDY_IO_SUBSYSTEM_NONE: 00048 default: 00049 SPDYF_DEBUG("Unsupported subsystem"); 00050 return SPDY_NO; 00051 } 00052 00053 return SPDY_YES; 00054 } 00055 00056 00057 int 00058 SPDYF_io_set_session(struct SPDY_Session *session, 00059 enum SPDY_IO_SUBSYSTEM io_subsystem) 00060 { 00061 switch(io_subsystem) 00062 { 00063 case SPDY_IO_SUBSYSTEM_OPENSSL: 00064 session->fio_new_session = &SPDYF_openssl_new_session; 00065 session->fio_close_session = &SPDYF_openssl_close_session; 00066 session->fio_is_pending = &SPDYF_openssl_is_pending; 00067 session->fio_recv = &SPDYF_openssl_recv; 00068 session->fio_send = &SPDYF_openssl_send; 00069 session->fio_before_write = &SPDYF_openssl_before_write; 00070 session->fio_after_write = &SPDYF_openssl_after_write; 00071 break; 00072 00073 case SPDY_IO_SUBSYSTEM_RAW: 00074 session->fio_new_session = &SPDYF_raw_new_session; 00075 session->fio_close_session = &SPDYF_raw_close_session; 00076 session->fio_is_pending = &SPDYF_raw_is_pending; 00077 session->fio_recv = &SPDYF_raw_recv; 00078 session->fio_send = &SPDYF_raw_send; 00079 session->fio_before_write = &SPDYF_raw_before_write; 00080 session->fio_after_write = &SPDYF_raw_after_write; 00081 break; 00082 00083 case SPDY_IO_SUBSYSTEM_NONE: 00084 default: 00085 SPDYF_DEBUG("Unsupported subsystem"); 00086 return SPDY_NO; 00087 } 00088 00089 return SPDY_YES; 00090 }