long connect(long sd, const sockaddr *addr, long addrlen) { long ret; OS_mutex_lock(g_main_mutex, &mtx_key); ret = c_connect(sd, addr, addrlen); OS_mutex_unlock(g_main_mutex, mtx_key); return(ret); }
void *c_connect(const char *host, int32_t port) { void *socket; socket = create(); if (!c_connect(socket, host, port)) { destroy(socket); return NULL; } return socket; }
static void c_reconnect(char *args) { struct ui_tab *tab = ui_tab_cur->data; if(args[0]) ui_m(NULL, 0, "This command does not accept any arguments."); else if(tab->type == UIT_HUB) { if(tab->hub->net->conn || tab->hub->net->connecting || tab->hub->reconnect_timer) hub_disconnect(tab->hub, FALSE); c_connect(""); // also checks for the existence of "hubaddr" } else if(tab->type == UIT_MAIN) { ui_m(NULL, 0, "Reconnecting all hubs."); GList *n = ui_tabs; for(; n; n=n->next) { tab = n->data; if(tab->type != UIT_HUB) continue; if(tab->hub->net->conn || tab->hub->net->connecting || tab->hub->reconnect_timer) hub_disconnect(tab->hub, FALSE); ui_tab_cur = n; c_connect(""); } ui_tab_cur = g_list_find(ui_tabs, ui_main); } else ui_m(NULL, 0, "This command can only be used on the main tab or on hub tabs."); }
int main(int argc, char **argv) { SSL *conn; char *keytab = "tmp.keytab"; char *servername = "rekey.andrew.cmu.edu"; char *princname = REKEY_DEF_SERVICE; int optch; int flag=0; while ((optch = getopt(argc, argv, "k:s:P:d")) != -1) { switch (optch) { case 'k': keytab = optarg; break; case 's': servername = optarg; break; case 'P': princname = optarg; break; case 'd': flag|=REQFLAG_DESONLY; break; case '?': fprintf(stderr, "Usage: rekeytest [-k keytab] [-r realm] [-s servername] [-P serverprinc]\n [-d] [princ [hostname...] \n"); exit(1); } } ssl_startup(); conn=c_connect(servername); printf("Attach to remote server if required, then press return\n"); getc(stdin); c_auth(conn, servername, princname); if (argc > 2) c_newreq(conn, argv[1], flag, argc - 2, argv + 2); else if (argc == 2) c_status(conn, argv[1]); else c_getkeys(conn, keytab, 0, NULL, 0); SSL_shutdown(conn); SSL_free(conn); ssl_cleanup(); return 0; }