aboutsummaryrefslogtreecommitdiff
path: root/src/microspdy/io.h
diff options
context:
space:
mode:
authorAndrey Uzunov <andrey.uzunov@gmail.com>2013-07-05 14:04:26 +0000
committerAndrey Uzunov <andrey.uzunov@gmail.com>2013-07-05 14:04:26 +0000
commitb8d6c063fe9e425e08652f74cb617514e6a8440d (patch)
treeb2c10117465c31376cf14a5609db68540e63de08 /src/microspdy/io.h
parent6e07994a8bfa4227444ad5b178b4a54cb4ec69da (diff)
downloadlibmicrohttpd-b8d6c063fe9e425e08652f74cb617514e6a8440d.tar.gz
libmicrohttpd-b8d6c063fe9e425e08652f74cb617514e6a8440d.zip
spdy: TLS functions are called via callbacks now
Diffstat (limited to 'src/microspdy/io.h')
-rw-r--r--src/microspdy/io.h162
1 files changed, 162 insertions, 0 deletions
diff --git a/src/microspdy/io.h b/src/microspdy/io.h
new file mode 100644
index 00000000..b1be69e6
--- /dev/null
+++ b/src/microspdy/io.h
@@ -0,0 +1,162 @@
1/*
2 This file is part of libmicrospdy
3 Copyright (C) 2013 Andrey Uzunov
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/**
20 * @file io.h
21 * @brief Signatures for IO functions.
22 * @author Andrey Uzunov
23 */
24
25#ifndef IO_H
26#define IO_H
27
28#include "platform.h"
29
30
31/**
32 * Used for return code when reading and writing to the TLS socket.
33 */
34enum SPDY_IO_ERROR
35{
36 /**
37 * The connection was closed by the other party.
38 */
39 SPDY_IO_ERROR_CLOSED = 0,
40
41 /**
42 * Any kind of error ocurred. The session has to be closed.
43 */
44 SPDY_IO_ERROR_ERROR = -2,
45
46 /**
47 * The function had to return without processing any data. The whole
48 * cycle of events has to be called again (SPDY_run) as something
49 * either has to be written or read or the the syscall was
50 * interrupted by a signal.
51 */
52 SPDY_IO_ERROR_AGAIN = -3,
53};
54
55
56/**
57 * Global initializing. Must be called only once in the program.
58 *
59 */
60typedef void
61(*SPDYF_IOGlobalInit) ();
62
63
64/**
65 * Global deinitializing for the whole program. Should be called
66 * at the end of the program.
67 *
68 */
69typedef void
70(*SPDYF_IOGlobalDeinit) ();
71
72
73/**
74 * Initializing of io context for a specific daemon.
75 * Must be called when the daemon starts.
76 *
77 * @param daemon SPDY_Daemon for which io will be used. Daemon's
78 * certificate and key file are used for tls.
79 * @return SPDY_YES on success or SPDY_NO on error
80 */
81typedef int
82(*SPDYF_IOInit) (struct SPDY_Daemon *daemon);
83
84
85/**
86 * Deinitializing io context for a daemon. Should be called
87 * when the deamon is stopped.
88 *
89 * @param daemon SPDY_Daemon which is being stopped
90 */
91typedef void
92(*SPDYF_IODeinit) (struct SPDY_Daemon *daemon);
93
94
95/**
96 * Initializing io for a specific connection. Must be called
97 * after the connection has been accepted.
98 *
99 * @param session SPDY_Session whose socket will be used
100 * @return SPDY_NO if some funcs inside fail. SPDY_YES otherwise
101 */
102typedef int
103(*SPDYF_IONewSession) (struct SPDY_Session *session);
104
105
106/**
107 * Deinitializing io for a specific connection. Should be called
108 * closing session's socket.
109 *
110 * @param session SPDY_Session whose socket is used
111 */
112typedef void
113(*SPDYF_IOCloseSession) (struct SPDY_Session *session);
114
115
116/**
117 * Reading from session's socket. Reads available data and put it to the
118 * buffer.
119 *
120 * @param session for which data is received
121 * @param buffer where data from the socket will be written to
122 * @param size of the buffer
123 * @return number of bytes (at most size) read from the connection
124 * 0 if the other party has closed the connection
125 * SPDY_IO_ERROR code on error
126 */
127typedef int
128(*SPDYF_IORecv) (struct SPDY_Session *session,
129 void * buffer,
130 size_t size);
131
132
133/**
134 * Writing to session's socket. Writes the data given into the buffer to the
135 * socket.
136 *
137 * @param session whose context is used
138 * @param buffer from where data will be written to the socket
139 * @param size number of bytes to be taken from the buffer
140 * @return number of bytes (at most size) from the buffer that has been
141 * written to the connection
142 * 0 if the other party has closed the connection
143 * SPDY_IO_ERROR code on error
144 */
145typedef int
146(*SPDYF_IOSend) (struct SPDY_Session *session,
147 const void * buffer,
148 size_t size);
149
150
151/**
152 * Checks if there is data staying in the buffers of the underlying
153 * system that waits to be read. In case of TLS, this will call
154 * something like SSL_pending().
155 *
156 * @param session which is checked
157 * @return SPDY_YES if data is pending or SPDY_NO otherwise
158 */
159typedef int
160(*SPDYF_IOIsPending) (struct SPDY_Session *session);
161
162#endif