Esempio n. 1
0
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;
}
Esempio n. 2
0
int main (int argc, 
          char *argv[]) 
{
  TALLOC_CTX *main_ctx=talloc_new(NULL);
  TRPC_INSTANCE *trpc=NULL;
  TRP_CONNECTION *conn=NULL;
  struct cmdline_args opts;

  /* parse the command line*/
  /* set defaults */
  opts.msg=NULL;
  opts.server=NULL;
  opts.port=TRP_PORT;
  opts.repeat=1;

  argp_parse(&argp, argc, argv, 0, 0, &opts);

  /* Use standalone logging */
  tr_log_open();

  /* set logging levels */
  talloc_set_log_stderr();
  tr_log_threshold(LOG_CRIT);
  tr_console_threshold(LOG_DEBUG);

  printf("TRPC Client:\nServer = %s, port = %i\n", opts.server, opts.port);
 
  conn=trp_connection_new(trpc);
  if (conn==NULL) {
    printf("Could not allocate TRP_CONNECTION.\n");
    return 1;
  }
  trpc = trpc_new(main_ctx);
  trpc_set_server(trpc, opts.server);
  trpc_set_port(trpc, opts.port);
  trpc_set_conn(trpc, conn);
  /* Set-up TRP connection */
  if (TRP_SUCCESS != trpc_connect(trpc)) {
    /* Handle error */
    printf("Error in trpc_connect.\n");
    return 1;
  }

  /* Send a TRP message */
  while ((opts.repeat==-1) || (opts.repeat-->0)) {
    if (TRP_SUCCESS != trpc_send_msg(trpc, opts.msg)) {
      /* Handle error */
      printf("Error in trpc_send_request.");
      return 1;
    }
    usleep(1000000);
  }
    
  /* Clean-up the TRP client instance, and exit */
  trpc_free(trpc);

  return 0;
}
Esempio n. 3
0
TR_CFG_RC tr_apply_new_config (TR_INSTANCE *tr) {
  if (!tr)
    return TR_CFG_BAD_PARAMS;

  if (tr->active_cfg)
    tr_cfg_free(tr->active_cfg);

  tr->active_cfg = tr->new_cfg;

  tr_log_threshold(tr->active_cfg->internal->log_threshold);
  tr_console_threshold(tr->active_cfg->internal->console_threshold);

  return TR_CFG_SUCCESS;
}