Merge branch 'topic/mm-fixes' of git://208.110.73.182/silc into silc.1.1.branch
[silc.git] / lib / silcutil / tests / test_silcnet.c
index f678b255a23c199090077a9852dbb733757d10b3..2931bd7475ea13d51c59078602dfea91a33f89ec 100644 (file)
@@ -1,14 +1,14 @@
 /* SILC Net API tests */
 
-#include "silcincludes.h"
+#include "silc.h"
 
 SilcSchedule schedule;
 
 typedef struct {
   SilcFSM fsm;
-  SilcFSMSemaStruct sema;
+  SilcFSMEventStruct sema;
   SilcFSMThreadStruct thread;
-  SilcNetServer server;
+  SilcNetListener server;
   SilcStream client_stream;
   SilcNetStatus client_status;
   SilcStream server_stream;
@@ -30,7 +30,7 @@ static void test_accept_connection(SilcNetStatus status, SilcStream stream,
   SILC_LOG_DEBUG(("Accepted new connection"));
   f->client_status = status;
   f->client_stream = stream;
-  SILC_FSM_SEMA_POST(&f->sema);
+  SILC_FSM_EVENT_SIGNAL(&f->sema);
 }
 
 static void test_connected(SilcNetStatus status, SilcStream stream,
@@ -82,7 +82,7 @@ SILC_FSM_STATE(test_st_start)
   SILC_LOG_DEBUG(("test_st_start"));
 
   SILC_LOG_DEBUG(("Creating network listener"));
-  f->server = silc_net_create_server(NULL, 0, 5000, FALSE,
+  f->server = silc_net_tcp_create_listener(NULL, 0, 5000, TRUE, TRUE,
                                     silc_fsm_get_schedule(fsm),
                                     test_accept_connection, f);
   if (!f->server) {
@@ -98,7 +98,7 @@ SILC_FSM_STATE(test_st_start)
 
   /** Start waiting connection */
   SILC_LOG_DEBUG(("Start waiting for incoming connections"));
-  silc_fsm_sema_init(&f->sema, fsm, 0);
+  silc_fsm_event_init(&f->sema, fsm);
   silc_fsm_next(fsm, test_st_second);
   return SILC_FSM_CONTINUE;
 }
@@ -111,7 +111,7 @@ SILC_FSM_STATE(test_st_second)
 
   SILC_LOG_DEBUG(("test_st_second"));
 
-  SILC_FSM_SEMA_WAIT(&f->sema);
+  SILC_FSM_EVENT_WAIT(&f->sema);
 
   if (f->client_status != SILC_NET_OK) {
     /** Accepting new connection failed */
@@ -123,10 +123,10 @@ SILC_FSM_STATE(test_st_second)
   silc_socket_stream_get_info(f->client_stream, NULL, &host, &ip, &port);
   SILC_LOG_DEBUG(("Accepted new connection %s, %s:%d", host, ip, port));
 
-  /** Finish */
+  /** Wait thread to terminate */
   f->success = TRUE;
   silc_fsm_next(fsm, test_st_finish);
-  return SILC_FSM_CONTINUE;
+  SILC_FSM_THREAD_WAIT(&f->thread);
 }
 
 SILC_FSM_STATE(test_st_finish)
@@ -145,7 +145,7 @@ SILC_FSM_STATE(test_st_finish)
   }
 
   SILC_LOG_DEBUG(("Closing network listener"));
-  silc_net_close_server(f->server);
+  silc_net_close_listener(f->server);
 
   SILC_LOG_DEBUG(("Finish machine"));
   return SILC_FSM_FINISH;