libssh  0.5.4
socket.h
1 /*
2  * This file is part of the SSH Library
3  *
4  * Copyright (c) 2009 by Aris Adamantiadis
5  *
6  * The SSH Library is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or (at your
9  * option) any later version.
10  *
11  * The SSH Library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with the SSH Library; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19  * MA 02111-1307, USA.
20  */
21 
22 #ifndef SOCKET_H_
23 #define SOCKET_H_
24 
25 #include "libssh/callbacks.h"
26 struct ssh_poll_handle_struct;
27 /* socket.c */
28 
29 struct ssh_socket_struct;
30 typedef struct ssh_socket_struct* ssh_socket;
31 
32 int ssh_socket_init(void);
33 void ssh_socket_cleanup(void);
34 ssh_socket ssh_socket_new(ssh_session session);
35 void ssh_socket_reset(ssh_socket s);
36 void ssh_socket_free(ssh_socket s);
37 void ssh_socket_set_fd(ssh_socket s, socket_t fd);
38 socket_t ssh_socket_get_fd_in(ssh_socket s);
39 #ifndef _WIN32
40 int ssh_socket_unix(ssh_socket s, const char *path);
41 void ssh_execute_command(const char *command, socket_t in, socket_t out);
42 int ssh_socket_connect_proxycommand(ssh_socket s, const char *command);
43 #endif
44 void ssh_socket_close(ssh_socket s);
45 int ssh_socket_write(ssh_socket s,const void *buffer, int len);
46 int ssh_socket_is_open(ssh_socket s);
47 int ssh_socket_fd_isset(ssh_socket s, fd_set *set);
48 void ssh_socket_fd_set(ssh_socket s, fd_set *set, socket_t *max_fd);
49 void ssh_socket_set_fd_in(ssh_socket s, socket_t fd);
50 void ssh_socket_set_fd_out(ssh_socket s, socket_t fd);
51 int ssh_socket_nonblocking_flush(ssh_socket s);
52 void ssh_socket_set_write_wontblock(ssh_socket s);
53 void ssh_socket_set_read_wontblock(ssh_socket s);
54 void ssh_socket_set_except(ssh_socket s);
55 int ssh_socket_get_status(ssh_socket s);
56 int ssh_socket_buffered_write_bytes(ssh_socket s);
57 int ssh_socket_data_available(ssh_socket s);
58 int ssh_socket_data_writable(ssh_socket s);
59 
60 void ssh_socket_set_callbacks(ssh_socket s, ssh_socket_callbacks callbacks);
61 int ssh_socket_pollcallback(struct ssh_poll_handle_struct *p, socket_t fd, int revents, void *v_s);
62 struct ssh_poll_handle_struct * ssh_socket_get_poll_handle_in(ssh_socket s);
63 struct ssh_poll_handle_struct * ssh_socket_get_poll_handle_out(ssh_socket s);
64 
65 void ssh_socket_set_connecting(ssh_socket s, socket_t fd);
66 int ssh_socket_connect(ssh_socket s, const char *host, int port, const char *bind_addr);
67 
68 #endif /* SOCKET_H_ */