Esempio n. 1
0
/**
 * The initialization function, called when the module is loaded by
 * the script. This function is called only once.
 *
 * Bind to the dialog module and setup the callbacks. Also initialize
 * the shared memory to store our interninal information in.
 *
 * @return 0 to continue to load the OpenSIPS, -1 to stop the loading
 * and abort OpenSIPS.
 */
static int mod_init(void) 
{
	str s;
	LM_INFO("SIP Session Timer module - initializing\n");
	/*
	 * if statistics are disabled, prevent their registration to core.
	 */
	if (sst_enable_stats==0) {
		exports.stats = 0;
	}

	if (sst_flag == -1) {
		LM_ERR("no sst flag set!!\n");
		return -1;
	} 
	else if (sst_flag > MAX_FLAG) {
		LM_ERR("invalid sst flag %d!!\n", sst_flag);
		return -1;
	}

	if (timeout_spec != NULL) {
		LM_DBG("Dialog AVP is %s", timeout_spec);
		s.s = timeout_spec; s.len = strlen(s.s);
		if (pv_parse_spec(&s, &timeout_avp)==0 
		&& (timeout_avp.type != PVT_AVP)){
			LM_ERR("malformed or non AVP timeout AVP definition in '%s'\n",
					timeout_spec);
			return -1;
		}
	}

	/* load SIGNALING API */
	if(load_sig_api(&sigb)< 0) {
		LM_ERR("can't load signaling functions\n");
		return -1;
	}

	/*
	 * Init the handlers
	 */
	sst_handler_init((timeout_spec?&timeout_avp:0), sst_minSE, 
			sst_flag, sst_reject,sst_interval);

	/*
	 * Register the main (static) dialog call back.
	 */
	if (load_dlg_api(&dialog_st) != 0) {
		LM_ERR("failed to load dialog hooks");
		return(-1);
	}

	/* Load dialog hooks */
	dialog_st.register_dlgcb(NULL, DLGCB_CREATED, sst_dialog_created_CB, NULL, NULL);

	/*
	 * We are GOOD-TO-GO.
	 */
	return 0;
}
Esempio n. 2
0
/**
 * The initialization function, called when the module is loaded by
 * the script. This function is called only once.
 *
 * Bind to the dialog module and setup the callbacks. Also initialize
 * the shared memory to store our interninal information in.
 *
 * @return 0 to continue to load the Kamailio, -1 to stop the loading
 * and abort Kamailio.
 */
static int mod_init(void) 
{
	str s;
	/* if statistics are disabled, prevent their registration to core. */
	if (sst_enable_stats==0) {
		exports.stats = 0;
	}

#ifdef STATISTICS
	/* register statistics */
	if (sst_enable_stats!=0)
	{
		if (register_module_stats( exports.name, mod_stats)!=0 ) {
			LM_ERR("failed to register core statistics\n");
			return -1;
		}
	}
#endif


	if (sst_flag == -1) {
		LM_ERR("no sst flag set!!\n");
		return -1;
	} 
	else if (sst_flag > MAX_FLAG) {
		LM_ERR("invalid sst flag %d!!\n", sst_flag);
		return -1;
	}

	if (timeout_spec != NULL) {
		LM_DBG("Dialog AVP is %s", timeout_spec);
		s.s = timeout_spec; s.len = strlen(s.s);
		if (pv_parse_spec(&s, &timeout_avp)==0 
		&& (timeout_avp.type != PVT_AVP)){
			LM_ERR("malformed or non AVP timeout AVP definition in '%s'\n",
					timeout_spec);
			return -1;
		}
	}

	/* bind the SL API */
	if (sl_load_api(&slb)!=0) {
		LM_ERR("cannot bind to SL API\n");
		return -1;
	}

	/* Init the handlers */
	sst_handler_init((timeout_spec?&timeout_avp:0), sst_minSE, 
			sst_flag, sst_reject);

	/* Register the main (static) dialog call back. */
	if (load_dlg_api(&dialog_st) != 0) {
		LM_ERR("failed to load dialog hooks");
		return(-1);
	}

	/* Load dialog hooks */
	dialog_st.register_dlgcb(NULL, DLGCB_CREATED, sst_dialog_created_CB, NULL, NULL);

	return 0;
}