2 #include "silcserver.h"
6 static void running(SilcServer server, void *context)
8 SILC_LOG_DEBUG(("***** RUNNING"));
11 static void stopped(SilcServer server, void *context)
13 SILC_LOG_DEBUG(("***** STOPPED"));
14 silc_schedule_stop(schedule);
17 int main(int argc, char **argv)
19 SilcBool success = FALSE;
21 SilcServerParams params;
22 SilcServerParamServerInfo info;
23 SilcServerParamInterface iface;
24 SilcServerParamClient client_all;
26 if (argc > 1 && !strcmp(argv[1], "-d")) {
28 silc_log_debug_hexdump(TRUE);
29 silc_log_set_debug_string("*server*,*skr*,*ske*,*connauth*,*packet*,*stream*,*net*,*pkcs*,*asn1*");
32 SILC_LOG_DEBUG(("Allocating scheduler"));
33 schedule = silc_schedule_init(0, NULL);
35 silc_cipher_register_default();
36 silc_pkcs_register_default();
37 silc_hash_register_default();
38 silc_hmac_register_default();
40 SILC_LOG_DEBUG(("Allocating server params context"));
41 params = silc_server_params_alloc();
45 SILC_LOG_DEBUG(("Creating server params"));
47 info = silc_server_params_serverinfo_alloc();
50 info->server_name = strdup("test server");
52 if (!silc_load_key_pair("test.pub", "test.prv", "",
54 &info->private_key)) {
55 if (!silc_create_key_pair("rsa", 2048, "test.pub", "test.prv", NULL, "",
57 &info->private_key, FALSE)) {
62 iface = silc_calloc(1, sizeof(*iface));
65 iface->ip = strdup("127.0.0.1");
67 silc_server_params_serverinfo_add_iface(info, iface);
68 silc_server_params_set_serverinfo(params, info);
70 client_all = silc_calloc(1, sizeof(*client_all));
73 silc_server_params_add_client(params, client_all);
75 params->use_threads = TRUE;
77 SILC_LOG_DEBUG(("Allocating server context"));
78 server = silc_server_alloc(NULL, params, schedule);
80 SILC_LOG_DEBUG(("Error allocating server"));
84 SILC_LOG_DEBUG(("Running server"));
85 silc_server_run(server, running, NULL);
87 SILC_LOG_DEBUG(("Running scheduler"));
88 silc_schedule(schedule);
90 silc_server_free(server);
91 silc_server_params_free(params);
92 silc_schedule_uninit(schedule);
97 SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE"));
98 fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE");