From 92a50f731cdb098bbbb605630f335a07d839496f Mon Sep 17 00:00:00 2001 From: Aris Adamantiadis Date: Mon, 30 Nov 2009 23:44:40 +0100 Subject: Socket connect callback working... Still need to make sure the connect syscall is correctly called --- tests/Makefile | 2 +- tests/test_socket.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 67353465..c3176e05 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,5 +1,5 @@ all: test_socket test_tunnel test_exec test_pcap -CFLAGS=-I../include/ -g -Wall +CFLAGS=-I../include/ -g -Wall -I../build/ LDFLAGS=-lssh -L../build/libssh/ test_tunnel: test_tunnel.o authentication.o connection.o diff --git a/tests/test_socket.c b/tests/test_socket.c index b0ca03ed..2c53d976 100644 --- a/tests/test_socket.c +++ b/tests/test_socket.c @@ -28,6 +28,7 @@ #include #include +#include static int data_rcv(const void *data, size_t len, void *user){ printf("Received data: '"); @@ -36,15 +37,15 @@ static int data_rcv(const void *data, size_t len, void *user){ return len; } -static void controlflow(void *user, int code){ +static void controlflow(int code,void *user){ printf("Control flow: %x\n",code); } -static void exception(void *user, int code, int errno_code){ +static void exception(int code, int errno_code,void *user){ printf("Exception: %d (%d)\n",code,errno_code); } -static void connected(void *user, int code, int errno_code){ +static void connected(int code, int errno_code,void *user){ printf("Connected: %d (%d)\n",code, errno_code); } @@ -64,10 +65,15 @@ int main(int argc, char **argv){ return EXIT_FAILURE; } session=ssh_new(); + ssh_init(); s=ssh_socket_new(session); ctx=ssh_poll_ctx_new(2); ssh_socket_set_callbacks(s, &callbacks); ssh_poll_ctx_add_socket(ctx,s); - + if(ssh_socket_connect(s,argv[1],atoi(argv[2]),NULL)){ + printf("ssh_socket_connect: %s\n",ssh_get_error(session)); + return EXIT_FAILURE; + } + ssh_poll_ctx_dopoll(ctx,-1); return EXIT_SUCCESS; } -- cgit v1.2.3