aboutsummaryrefslogtreecommitdiff
path: root/include/libssh
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2009-11-30 22:35:43 +0100
committerAris Adamantiadis <aris@0xbadc0de.be>2009-11-30 22:35:43 +0100
commit76d6838223718a5432baddb4fa5b3e82440c9ff2 (patch)
tree87ab207db64dc0d1772d273ffc5749cfe0820581 /include/libssh
parent0bfb9d476c3dfc1ed74763665611891bcc277e9e (diff)
downloadlibssh-76d6838223718a5432baddb4fa5b3e82440c9ff2.tar.gz
libssh-76d6838223718a5432baddb4fa5b3e82440c9ff2.tar.xz
libssh-76d6838223718a5432baddb4fa5b3e82440c9ff2.zip
Some brain surgery to add event-based sockets
chapter 1- SSH Socket Connections. I would like to be able to -Have a ssh_poll_ctx object -Add a ssh socket over it -launch the socket connection (using socket functions) -ssh_poll_ctx_dopoll() -Wait for the timeout or have the "connected" callback called
Diffstat (limited to 'include/libssh')
-rw-r--r--include/libssh/poll.h2
-rw-r--r--include/libssh/priv.h8
-rw-r--r--include/libssh/socket.h7
3 files changed, 11 insertions, 6 deletions
diff --git a/include/libssh/poll.h b/include/libssh/poll.h
index 4aa2f333..ca5ec181 100644
--- a/include/libssh/poll.h
+++ b/include/libssh/poll.h
@@ -90,10 +90,12 @@ void ssh_poll_set_events(ssh_poll_handle p, short events);
void ssh_poll_add_events(ssh_poll_handle p, short events);
void ssh_poll_remove_events(ssh_poll_handle p, short events);
socket_t ssh_poll_get_fd(ssh_poll_handle p);
+void ssh_poll_set_fd(ssh_poll_handle p, socket_t fd);
void ssh_poll_set_callback(ssh_poll_handle p, ssh_poll_callback cb, void *userdata);
ssh_poll_ctx ssh_poll_ctx_new(size_t chunk_size);
void ssh_poll_ctx_free(ssh_poll_ctx ctx);
int ssh_poll_ctx_add(ssh_poll_ctx ctx, ssh_poll_handle p);
+int ssh_poll_ctx_add_socket (ssh_poll_ctx ctx, struct socket *s);
void ssh_poll_ctx_remove(ssh_poll_ctx ctx, ssh_poll_handle p);
int ssh_poll_ctx_dopoll(ssh_poll_ctx ctx, int timeout);
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index 90c700d5..f96e87c5 100644
--- a/include/libssh/priv.h
+++ b/include/libssh/priv.h
@@ -114,12 +114,6 @@ struct ssh_bind_struct {
int toaccept;
};
-struct socket;
-struct ssh_poll;
-void ssh_socket_set_callbacks(struct socket *s, ssh_socket_callbacks callbacks);
-int ssh_socket_pollcallback(struct ssh_poll_handle_struct *p, int fd, int revents, void *s);
-void ssh_socket_register_pollcallback(struct socket *s, struct ssh_poll_handle_struct *p);
-
SSH_PACKET_CALLBACK(ssh_packet_disconnect_callback);
SSH_PACKET_CALLBACK(ssh_packet_ignore_callback);
@@ -143,6 +137,8 @@ unsigned char *packet_encrypt(ssh_session session,void *packet,unsigned int len)
/* it returns the hmac buffer if exists*/
int packet_hmac_verify(ssh_session session,ssh_buffer buffer,unsigned char *mac);
+struct socket;
+
int ssh_packet_socket_callback(const void *data, size_t len, void *user);
void ssh_packet_register_socket_callback(ssh_session session, struct socket *s);
void ssh_packet_set_callbacks(ssh_session session, ssh_packet_callbacks callbacks);
diff --git a/include/libssh/socket.h b/include/libssh/socket.h
index bb54c7ea..858c5d82 100644
--- a/include/libssh/socket.h
+++ b/include/libssh/socket.h
@@ -22,6 +22,8 @@
#ifndef SOCKET_H_
#define SOCKET_H_
+#include "libssh/callbacks.h"
+struct ssh_poll_handle_struct;
/* socket.c */
struct socket;
@@ -52,4 +54,9 @@ int ssh_socket_get_status(struct socket *s);
int ssh_socket_data_available(struct socket *s);
int ssh_socket_data_writable(struct socket *s);
+void ssh_socket_set_callbacks(struct socket *s, ssh_socket_callbacks callbacks);
+int ssh_socket_pollcallback(struct ssh_poll_handle_struct *p, int fd, int revents, void *s);
+void ssh_socket_register_pollcallback(struct socket *s, struct ssh_poll_handle_struct *p);
+struct ssh_poll_handle_struct * ssh_socket_get_poll_handle(struct socket *s);
+
#endif /* SOCKET_H_ */