Example #1
0
static int mod_init(void)
{
	LM_DBG("Initializing...\n");

	connection_timeout_ms = connection_timeout * 1000L;

	if (connect_poll_interval < 0) {
		LM_ERR("Bad connect_poll_interval (%ldms), setting to 20ms\n",
		       connect_poll_interval);
		connect_poll_interval = 20;
	}

	if (connection_timeout > curl_timeout) {
		LM_WARN("'connection_timeout' must be less than or equal "
		        "to 'curl_timeout'! setting it to %ld...\n", curl_timeout);
		connection_timeout = curl_timeout;
	}

	lock_init(&thread_lock);

	curl_global_init_mem(CURL_GLOBAL_ALL,
						 osips_malloc,
						 osips_free,
						 osips_realloc,
						 osips_strdup,
						 osips_calloc);

	INIT_LIST_HEAD(&multi_pool);

	/* try loading the trace api */
	if (register_trace_type) {
		rest_proto_id = register_trace_type(rest_id_s);
		if ( global_trace_api ) {
			memcpy(&tprot, global_trace_api, sizeof tprot);
		} else {
			memset(&tprot, 0, sizeof tprot);
			if (trace_prot_bind( REST_TRACE_API_MODULE, &tprot))
				LM_DBG("Can't bind <%s>!\n", REST_TRACE_API_MODULE);
		}
	} else {
		memset(&tprot, 0, sizeof tprot);
	}

	if (is_script_func_used("rest_init_client_tls", -1)) {
		if (load_tls_mgm_api(&tls_api) != 0) {
			LM_ERR("failed to load the tls_mgm API! "
			       "Is the tls_mgm module loaded?\n");
			return -1;
		}
	}

	if (!validate_curl_http_version(&curl_http_version))
		return -1;

	LM_INFO("Module initialized!\n");

	return 0;
}
Example #2
0
static int mod_init(void)
{
	LM_INFO("initializing Secure WebSocket protocol\n");

	if(load_tls_mgm_api(&tls_mgm_api) != 0){
		LM_DBG("failed to find tls API - is tls_mgm module loaded?\n");
		return -1;
	}

	return 0;
}
Example #3
0
static int mod_init(void)
{
	LM_INFO("initializing Secure WebSocket protocol\n");

	if(load_tls_mgm_api(&tls_mgm_api) != 0){
		LM_DBG("failed to find tls API - is tls_mgm module loaded?\n");
		return -1;
	}

	if (trace_destination_name.s) {
		if ( !net_trace_api ) {
			if ( trace_prot_bind( WS_TRACE_PROTO, &tprot) < 0 ) {
				LM_ERR( "can't bind trace protocol <%s>\n", WS_TRACE_PROTO );
				return -1;
			}

			net_trace_api = &tprot;
		} else {
			tprot = *net_trace_api;
		}
		trace_destination_name.len = strlen( trace_destination_name.s );

		if ( net_trace_proto_id == -1 )
			net_trace_proto_id = tprot.get_message_id( WS_TRANS_TRACE_PROTO_ID );

		t_dst = tprot.get_trace_dest_by_name( &trace_destination_name );
	}

	/* fix route name */
	if ( !(trace_is_on = shm_malloc(sizeof(int))) ) {
		LM_ERR("no more shared memory!\n");
		return -1;
	}

	*trace_is_on = trace_is_on_tmp;
	if ( trace_filter_route ) {
		trace_filter_route_id =
			get_script_route_ID_by_name( trace_filter_route, rlist, RT_NO);
	}



	return 0;
}