libssh  0.5.4
server.h
1 /* Public include file for server support */
2 /*
3  * This file is part of the SSH Library
4  *
5  * Copyright (c) 2003-2008 by Aris Adamantiadis
6  *
7  * The SSH Library is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation; either version 2.1 of the License, or (at your
10  * option) any later version.
11  *
12  * The SSH Library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15  * License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with the SSH Library; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA 02111-1307, USA.
21  */
22 
29 #ifndef SERVER_H
30 #define SERVER_H
31 
32 #include "libssh/libssh.h"
33 #define SERVERBANNER CLIENTBANNER
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 enum ssh_bind_options_e {
40  SSH_BIND_OPTIONS_BINDADDR,
41  SSH_BIND_OPTIONS_BINDPORT,
42  SSH_BIND_OPTIONS_BINDPORT_STR,
43  SSH_BIND_OPTIONS_HOSTKEY,
44  SSH_BIND_OPTIONS_DSAKEY,
45  SSH_BIND_OPTIONS_RSAKEY,
46  SSH_BIND_OPTIONS_BANNER,
47  SSH_BIND_OPTIONS_LOG_VERBOSITY,
48  SSH_BIND_OPTIONS_LOG_VERBOSITY_STR
49 };
50 
51 typedef struct ssh_bind_struct* ssh_bind;
52 
53 /* Callback functions */
54 
62 typedef void (*ssh_bind_incoming_connection_callback) (ssh_bind sshbind,
63  void *userdata);
64 
72  size_t size;
75 };
76 typedef struct ssh_bind_callbacks_struct *ssh_bind_callbacks;
77 
83 LIBSSH_API ssh_bind ssh_bind_new(void);
84 
148 LIBSSH_API int ssh_bind_options_set(ssh_bind sshbind,
149  enum ssh_bind_options_e type, const void *value);
150 
158 LIBSSH_API int ssh_bind_listen(ssh_bind ssh_bind_o);
159 
180 LIBSSH_API int ssh_bind_set_callbacks(ssh_bind sshbind, ssh_bind_callbacks callbacks,
181  void *userdata);
182 
190 LIBSSH_API void ssh_bind_set_blocking(ssh_bind ssh_bind_o, int blocking);
191 
199 LIBSSH_API socket_t ssh_bind_get_fd(ssh_bind ssh_bind_o);
200 
208 LIBSSH_API void ssh_bind_set_fd(ssh_bind ssh_bind_o, socket_t fd);
209 
215 LIBSSH_API void ssh_bind_fd_toaccept(ssh_bind ssh_bind_o);
216 
225 LIBSSH_API int ssh_bind_accept(ssh_bind ssh_bind_o, ssh_session session);
226 
234 LIBSSH_API int ssh_handle_key_exchange(ssh_session session);
235 
241 LIBSSH_API void ssh_bind_free(ssh_bind ssh_bind_o);
242 
243 /* messages.c */
244 LIBSSH_API int ssh_message_reply_default(ssh_message msg);
245 
246 LIBSSH_API char *ssh_message_auth_user(ssh_message msg);
247 LIBSSH_API char *ssh_message_auth_password(ssh_message msg);
248 LIBSSH_API ssh_public_key ssh_message_auth_publickey(ssh_message msg);
249 LIBSSH_API enum ssh_publickey_state_e ssh_message_auth_publickey_state(ssh_message msg);
250 LIBSSH_API int ssh_message_auth_reply_success(ssh_message msg,int partial);
251 LIBSSH_API int ssh_message_auth_reply_pk_ok(ssh_message msg, ssh_string algo, ssh_string pubkey);
252 LIBSSH_API int ssh_message_auth_reply_pk_ok_simple(ssh_message msg);
253 
254 LIBSSH_API int ssh_message_auth_set_methods(ssh_message msg, int methods);
255 
256 LIBSSH_API int ssh_message_service_reply_success(ssh_message msg);
257 LIBSSH_API char *ssh_message_service_service(ssh_message msg);
258 
259 LIBSSH_API int ssh_message_global_request_reply_success(ssh_message msg,
260  uint16_t bound_port);
261 
262 LIBSSH_API void ssh_set_message_callback(ssh_session session,
263  int(*ssh_bind_message_callback)(ssh_session session, ssh_message msg, void *data),
264  void *data);
265 LIBSSH_API int ssh_execute_message_callbacks(ssh_session session);
266 
267 LIBSSH_API char *ssh_message_channel_request_open_originator(ssh_message msg);
268 LIBSSH_API int ssh_message_channel_request_open_originator_port(ssh_message msg);
269 LIBSSH_API char *ssh_message_channel_request_open_destination(ssh_message msg);
270 LIBSSH_API int ssh_message_channel_request_open_destination_port(ssh_message msg);
271 
272 LIBSSH_API ssh_channel ssh_message_channel_request_channel(ssh_message msg);
273 
274 LIBSSH_API char *ssh_message_channel_request_pty_term(ssh_message msg);
275 LIBSSH_API int ssh_message_channel_request_pty_width(ssh_message msg);
276 LIBSSH_API int ssh_message_channel_request_pty_height(ssh_message msg);
277 LIBSSH_API int ssh_message_channel_request_pty_pxwidth(ssh_message msg);
278 LIBSSH_API int ssh_message_channel_request_pty_pxheight(ssh_message msg);
279 
280 LIBSSH_API char *ssh_message_channel_request_env_name(ssh_message msg);
281 LIBSSH_API char *ssh_message_channel_request_env_value(ssh_message msg);
282 
283 LIBSSH_API char *ssh_message_channel_request_command(ssh_message msg);
284 
285 LIBSSH_API char *ssh_message_channel_request_subsystem(ssh_message msg);
286 
287 LIBSSH_API char *ssh_message_global_request_address(ssh_message msg);
288 LIBSSH_API int ssh_message_global_request_port(ssh_message msg);
289 
290 LIBSSH_API int ssh_channel_open_reverse_forward(ssh_channel channel, const char *remotehost,
291  int remoteport, const char *sourcehost, int localport);
292 
293 LIBSSH_API int ssh_channel_request_send_exit_status(ssh_channel channel,
294  int exit_status);
295 LIBSSH_API int ssh_channel_request_send_exit_signal(ssh_channel channel,
296  const char *signum,
297  int core,
298  const char *errmsg,
299  const char *lang);
300 LIBSSH_API int ssh_channel_write_stderr(ssh_channel channel,
301  const void *data,
302  uint32_t len);
303 
304 /* deprecated functions */
305 SSH_DEPRECATED LIBSSH_API int ssh_accept(ssh_session session);
306 SSH_DEPRECATED LIBSSH_API int channel_write_stderr(ssh_channel channel,
307  const void *data, uint32_t len);
308 
309 #ifdef __cplusplus
310 }
311 #endif /* __cplusplus */
312 
313 #endif /* SERVER_H */
314