2
* Drizzle Client & Protocol Library
4
* Copyright (C) 2008 Eric Day (eday@oddments.org)
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are
11
* * Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
14
* * Redistributions in binary form must reproduce the above
15
* copyright notice, this list of conditions and the following disclaimer
16
* in the documentation and/or other materials provided with the
19
* * The names of its contributors may not be used to endorse or
20
* promote products derived from this software without specific prior
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
* @brief Connection Declarations for Servers
42
#ifndef __DRIZZLE_CON_SERVER_H
43
#define __DRIZZLE_CON_SERVER_H
50
* @addtogroup drizzle_con_server Connection Declarations for Servers
51
* @ingroup drizzle_server_interface
53
* These functions extend the core connection functions with a set of functions
54
* for server application use. These functions allow you to set raw handshake
55
* information for use with the handshake write functions.
60
* Put a connection into listening mode.
62
* @param[in] con Connection structure previously initialized with
63
* drizzle_con_create(), drizzle_con_clone(), or related functions.
64
* @return Standard drizzle return value.
67
drizzle_return_t drizzle_con_listen(drizzle_con_st *con);
70
* Get connection backlog queue length.
72
* @param[in] con Connection structure previously initialized with
73
* drizzle_con_create(), drizzle_con_clone(), or related functions.
74
* @return Backlog for connection
77
int drizzle_con_backlog(const drizzle_con_st *con);
80
* Set connection backlog queue length.
82
* @param[in] con Connection structure previously initialized with
83
* drizzle_con_create(), drizzle_con_clone(), or related functions.
84
* @param[in] backlog Backlog to use for connection
87
void drizzle_con_set_backlog(drizzle_con_st *con, int backlog);
90
* Set protocol version for a connection.
92
* @param[in] con Connection structure previously initialized with
93
* drizzle_con_create(), drizzle_con_clone(), or related functions.
94
* @param[in] protocol_version Protocol version to use for connection
97
void drizzle_con_set_protocol_version(drizzle_con_st *con,
98
uint8_t protocol_version);
101
* Set server version string for a connection.
103
* @param[in] con Connection structure previously initialized with
104
* drizzle_con_create(), drizzle_con_clone(), or related functions.
105
* @param[in] server_version Server version to use for connection
108
void drizzle_con_set_server_version(drizzle_con_st *con,
109
const char *server_version);
112
* Set thread ID for a connection.
114
* @param[in] con Connection structure previously initialized with
115
* drizzle_con_create(), drizzle_con_clone(), or related functions.
116
* @param[in] thread_id Thread ID to use for connection
119
void drizzle_con_set_thread_id(drizzle_con_st *con, uint32_t thread_id);
122
* Set scramble buffer for a connection.
124
* @param[in] con Connection structure previously initialized with
125
* drizzle_con_create(), drizzle_con_clone(), or related functions.
126
* @param[in] scramble Scramble to use for connection
129
void drizzle_con_set_scramble(drizzle_con_st *con, const uint8_t *scramble);
132
* Set capabilities for a connection.
134
* @param[in] con Connection structure previously initialized with
135
* drizzle_con_create(), drizzle_con_clone(), or related functions.
136
* @param[in] capabilities Capabilities to use for connection
139
void drizzle_con_set_capabilities(drizzle_con_st *con,
143
* Set charset for a connection.
145
* @param[in] con Connection structure previously initialized with
146
* drizzle_con_create(), drizzle_con_clone(), or related functions.
147
* @param[in] charset Character set to use for connection
150
void drizzle_con_set_charset(drizzle_con_st *con, drizzle_charset_t charset);
153
* Set status for a connection.
155
* @param[in] con Connection structure previously initialized with
156
* drizzle_con_create(), drizzle_con_clone(), or related functions.
157
* @param[in] status Status to use for connection
160
void drizzle_con_set_status(drizzle_con_st *con, drizzle_con_status_t status);
163
* Set max packet size for a connection.
165
* @param[in] con Connection structure previously initialized with
166
* drizzle_con_create(), drizzle_con_clone(), or related functions.
167
* @param[in] max_packet_size Max packet size to use for connection
170
void drizzle_con_set_max_packet_size(drizzle_con_st *con,
171
uint32_t max_packet_size);
174
* Copy all handshake information from one connection into another.
176
* @param[in] con Connection structure previously initialized with
177
* drizzle_con_create(), drizzle_con_clone(), or related functions.
178
* @param[in] from Connection structure to copy from.
181
void drizzle_con_copy_handshake(drizzle_con_st *con, drizzle_con_st *from);
184
* Read command without buffering.
186
* @param[in] con Connection structure previously initialized with
187
* drizzle_con_create(), drizzle_con_clone(), or related functions.
188
* @param[out] command Command that was read.
189
* @param[out] offset Where the data being returned begins in the command data.
190
* @param[out] size The size of the data chunk being returned.
191
* @param[out] total The total size of all command data being read.
192
* @param[out] ret_ptr Standard drizzle return value.
193
* @return On success, a pointer to an internal buffer with the command data.
194
* It will be *size bytes in length.
197
void *drizzle_con_command_read(drizzle_con_st *con,
198
drizzle_command_t *command, size_t *offset,
199
size_t *size, size_t *total,
200
drizzle_return_t *ret_ptr);
203
* Read command and buffer it.
205
* @param[in] con Connection structure previously initialized with
206
* drizzle_con_create(), drizzle_con_clone(), or related functions.
207
* @param[out] command Command that was read.
208
* @param[out] total The total size of all command data being read.
209
* @param[out] ret_ptr Standard drizzle return value.
210
* @return On success, allocated buffer that holds the command data of length
214
void *drizzle_con_command_buffer(drizzle_con_st *con,
215
drizzle_command_t *command, size_t *total,
216
drizzle_return_t *ret_ptr);
219
void drizzle_con_command_buffer_free(uint8_t *command_buffer);
227
#endif /* __DRIZZLE_CON_SERVER_H */