int main (int argc, char *argv[]) { TIDC_INSTANCE *tidc; int conn = 0; int rc; gss_ctx_id_t gssctx; struct cmdline_args opts; /* parse the command line*/ /* set defaults */ opts.server=NULL; opts.rp_realm=NULL; opts.target_realm=NULL; opts.community=NULL; opts.port=TID_PORT; argp_parse(&argp, argc, argv, 0, 0, &opts); /* TBD -- validity checking, dealing with quotes, etc. */ print_version_info(); /* Use standalone logging */ tr_log_open(); /* set logging levels */ talloc_set_log_stderr(); tr_log_threshold(LOG_CRIT); tr_console_threshold(LOG_DEBUG); printf("TIDC Client:\nServer = %s, rp_realm = %s, target_realm = %s, community = %s, port = %i\n", opts.server, opts.rp_realm, opts.target_realm, opts.community, opts.port); /* Create a TID client instance & the client DH */ tidc = tidc_create(); if (NULL == (tidc->client_dh = tr_create_dh_params(NULL, 0))) { printf("Error creating client DH params.\n"); return 1; } /* Set-up TID connection */ if (-1 == (conn = tidc_open_connection(tidc, opts.server, opts.port, &gssctx))) { /* Handle error */ printf("Error in tidc_open_connection.\n"); return 1; }; /* Send a TID request */ if (0 > (rc = tidc_send_request(tidc, conn, gssctx, opts.rp_realm, opts.target_realm, opts.community, &tidc_resp_handler, NULL))) { /* Handle error */ printf("Error in tidc_send_request, rc = %d.\n", rc); return 1; } /* Clean-up the TID client instance, and exit */ tidc_destroy(tidc); return 0; }
bool tr_init(void) { if (global_tidc) return true; global_tidc = tidc_create(); if (!global_tidc) { DEBUG2( "tr_init: Error creating global TIDC instance.\n"); return false; } if (!tidc_set_dh(global_tidc, tr_create_dh_params(NULL, 0))) { DEBUG2( "tr_init: Error creating client DH params.\n"); return false; } return true; }