Example #1
0
int ta_serv_init(void)
{
    CHECK_FCT( fd_sess_handler_create(&ta_cli_reg, (void *)free, NULL, NULL) );
    
	struct disp_when data;
	
	TRACE_DEBUG(FULL, "Initializing dispatch callbacks for test");
	
	memset(&data, 0, sizeof(data));
	data.app = ta_appli;
	data.command = ta_cmd_r;
	
	/* fallback CB if command != Test-Request received */
	CHECK_FCT( fd_disp_register( ta_fb_cb, DISP_HOW_APPID, &data, NULL, &ta_hdl_fb ) );
	
	/* Now specific handler for Test-Request */
	CHECK_FCT( fd_disp_register( ta_tr_cb, DISP_HOW_CC, &data, NULL, &ta_hdl_tr ) );
	
	return 0;
}
int s6a_init(hss_config_t *hss_config_p)
{
  int ret = 0;
  struct disp_when when;
  char why[100];

  fprintf(stdout, "Initializing s6a layer\n");

  ret = fd_core_initialize();

  if (ret != 0) {
    strcpy(why, "fd_core_initialize");
    goto err;
  }

  /* Parse the external configuration file */
  ret = fd_core_parseconf(hss_config_p->freediameter_config);

  if (ret != 0) {
    strcpy(why, "fd_core_parseconf");
    goto err;
  }


  ret = fd_core_start();

  if (ret != 0) {
    strcpy(why, "fd_core_start");
    goto err;
  }


  /* We wait till freediameter has completed loading extensions */
  fd_core_waitstartcomplete();

  /* Register the peer acceptor/rejector */
  fd_peer_validate_register(s6a_peer_validate);

  /* Initialize useful objects */
  ret = s6a_init_objs();

  if (ret != 0) {
    strcpy(why, "s6a_init_objs");
    goto err;
  }

  /* Create handler for sessions */
#if FREEDIAMETER_VERSION < 120
  CHECK_FCT(fd_sess_handler_create(&s6a_reg, s6a_cli_sess_cleanup, NULL));
#else
  session_state_dump dumper;
  CHECK_FCT(fd_sess_handler_create(&s6a_reg, s6a_cli_sess_cleanup, dumper, NULL));
#endif

  /* Register the callback */
  memset(&when, 0, sizeof(when));
  when.command = s6a_cnf.dataobj_s6a_auth_cmd;
  when.app     = s6a_cnf.dataobj_s6a_app;

  /* Register the callbacks for S6A Application */
  CHECK_FCT(fd_disp_register(s6a_auth_info_cb, DISP_HOW_CC, &when, NULL,
                             &handle));

  if (handle == NULL) {
    strcpy(why, "cannot register authentication info req cb");
    goto err;
  }

  when.command = s6a_cnf.dataobj_s6a_loc_up;
  when.app     = s6a_cnf.dataobj_s6a_app;

  /* Register the callbacks for S6A Application */
  CHECK_FCT(fd_disp_register(s6a_up_loc_cb, DISP_HOW_CC, &when, NULL,
                             &handle));

  if (handle == NULL) {
    strcpy(why, "cannot register update location req cb");
    goto err;
  }

  when.command = s6a_cnf.dataobj_s6a_purge_ue;
  when.app     = s6a_cnf.dataobj_s6a_app;

  /* Register the callbacks for S6A Application */
  CHECK_FCT(fd_disp_register(s6a_purge_ue_cb, DISP_HOW_CC, &when, NULL,
                             &handle));

  if (handle == NULL) {
    strcpy(why, "cannot register purge ue req cb");
    goto err;
  }

  fprintf(stdout, "Initializing s6a layer: DONE\n");

  return 0;

err:
  fprintf(stdout, "Initializing s6a layer: FAILED (%s)\n", why);
  return -1;
}