aboutsummaryrefslogtreecommitdiff
path: root/libssh
diff options
context:
space:
mode:
authormilo <milo@r0ot.me>2010-08-08 22:48:54 +0200
committerAndreas Schneider <asn@cynapses.org>2010-08-09 20:53:49 +0200
commiteb361626cbc782bb65aa536fb22c5d100fdefdaf (patch)
tree5123f9b61099d7a9edb4c7a08b706a16de340f89 /libssh
parentb0f8ca556bc2bb18b9177d13b802a5ce11204bd8 (diff)
downloadlibssh-eb361626cbc782bb65aa536fb22c5d100fdefdaf.tar.gz
libssh-eb361626cbc782bb65aa536fb22c5d100fdefdaf.tar.xz
libssh-eb361626cbc782bb65aa536fb22c5d100fdefdaf.zip
session: Added callback for the connection per session.
Signed-off-by: Andreas Schneider <asn@cynapses.org>
Diffstat (limited to 'libssh')
-rw-r--r--libssh/client.c11
-rw-r--r--libssh/kex.c2
2 files changed, 7 insertions, 6 deletions
diff --git a/libssh/client.c b/libssh/client.c
index 42c896ac..0c875260 100644
--- a/libssh/client.c
+++ b/libssh/client.c
@@ -60,7 +60,7 @@ static void socket_callback_connected(int code, int errno_code, void *user){
session->session_state=SSH_SESSION_STATE_ERROR;
ssh_set_error(session,SSH_FATAL,"%s",strerror(errno_code));
}
- ssh_connection_callback(session);
+ session->ssh_connection_callback(session);
leave_function();
}
@@ -75,7 +75,7 @@ static void socket_callback_exception(int code, int errno_code, void *user){
ssh_log(session,SSH_LOG_RARE,"Socket exception callback: %d (%d)",code, errno_code);
session->session_state=SSH_SESSION_STATE_ERROR;
ssh_set_error(session,SSH_FATAL,"Socket error: %s",strerror(errno_code));
- ssh_connection_callback(session);
+ session->ssh_connection_callback(session);
leave_function();
}
@@ -113,7 +113,7 @@ static int callback_receive_banner(const void *data, size_t len, void *user) {
session->serverbanner=str;
session->session_state=SSH_SESSION_STATE_BANNER_RECEIVED;
ssh_log(session,SSH_LOG_PACKET,"Received banner: %s",str);
- ssh_connection_callback(session);
+ session->ssh_connection_callback(session);
leave_function();
return ret;
}
@@ -371,7 +371,7 @@ SSH_PACKET_CALLBACK(ssh_packet_newkeys){
}
}
session->dh_handshake_state = DH_STATE_FINISHED;
- ssh_connection_callback(session);
+ session->ssh_connection_callback(session);
return SSH_PACKET_USED;
error:
session->session_state=SSH_SESSION_STATE_ERROR;
@@ -554,7 +554,7 @@ int ssh_service_request(ssh_session session, const char *service) {
* @brief A function to be called each time a step has been done in the
* connection.
*/
-void ssh_connection_callback(ssh_session session){
+static void ssh_client_connection_callback(ssh_session session){
int ssh1,ssh2;
enter_function();
switch(session->session_state){
@@ -696,6 +696,7 @@ int ssh_connect(ssh_session session) {
return SSH_ERROR;
}
+ session->ssh_connection_callback = ssh_client_connection_callback;
session->session_state=SSH_SESSION_STATE_CONNECTING;
ssh_socket_set_callbacks(session->socket,&session->socket_callbacks);
session->socket_callbacks.connected=socket_callback_connected;
diff --git a/libssh/kex.c b/libssh/kex.c
index 1e50eb1f..4bb7e389 100644
--- a/libssh/kex.c
+++ b/libssh/kex.c
@@ -315,7 +315,7 @@ SSH_PACKET_CALLBACK(ssh_packet_kexinit){
leave_function();
session->session_state=SSH_SESSION_STATE_KEXINIT_RECEIVED;
- ssh_connection_callback(session);
+ session->ssh_connection_callback(session);
return SSH_PACKET_USED;
error:
ssh_string_free(str);