int register_init(void) {
	belle_sip_listening_point_t *lp;
	stack=belle_sip_stack_new(NULL);
	lp=belle_sip_stack_create_listening_point(stack,"0.0.0.0",7060,"UDP");
	prov=belle_sip_stack_create_provider(stack,lp);

	lp=belle_sip_stack_create_listening_point(stack,"0.0.0.0",7060,"TCP");
	belle_sip_provider_add_listening_point(prov,lp);
	lp=belle_sip_stack_create_listening_point(stack,"0.0.0.0",7061,"TLS");
	if (lp) {
		/* since test.linphone.org does not have proper certificates, don't verify anything*/
		belle_sip_tls_listening_point_set_verify_exceptions(BELLE_SIP_TLS_LISTENING_POINT(lp),BELLE_SIP_TLS_LISTENING_POINT_BADCERT_ANY_REASON);
		if (belle_sip_tester_get_root_ca_path() != NULL) {
			belle_sip_tls_listening_point_set_root_ca(BELLE_SIP_TLS_LISTENING_POINT(lp), belle_sip_tester_get_root_ca_path());
		}
		belle_sip_provider_add_listening_point(prov,lp);
	}

	listener_callbacks.process_dialog_terminated=process_dialog_terminated;
	listener_callbacks.process_io_error=process_io_error;
	listener_callbacks.process_request_event=process_request_event;
	listener_callbacks.process_response_event=process_response_event;
	listener_callbacks.process_timeout=process_timeout;
	listener_callbacks.process_transaction_terminated=process_transaction_terminated;
	listener_callbacks.process_auth_requested=process_auth_requested;
	listener_callbacks.listener_destroyed=NULL;
	listener=belle_sip_listener_create_from_callbacks(&listener_callbacks,NULL);
	return 0;
}
Exemple #2
0
static int sal_add_listen_port(Sal *ctx, SalAddress* addr, bool_t is_tunneled){
	int result;
	belle_sip_listening_point_t* lp;
	if (is_tunneled){
#ifdef TUNNEL_ENABLED
		if (sal_address_get_transport(addr)!=SalTransportUDP){
			ms_error("Tunneled mode is only available for UDP kind of transports.");
			return -1;
		}
		lp = belle_sip_tunnel_listening_point_new(ctx->stack, ctx->tunnel_client);
		if (!lp){
			ms_error("Could not create tunnel listening point.");
			return -1;
		}
#else
		ms_error("No tunnel support in library.");
		return -1;
#endif
	}else{
		lp = belle_sip_stack_create_listening_point(ctx->stack,
									sal_address_get_domain(addr),
									sal_address_get_port(addr),
									sal_transport_to_string(sal_address_get_transport(addr)));
	}
	if (lp) {
		belle_sip_listening_point_set_keep_alive(lp,ctx->keep_alive);
		result = belle_sip_provider_add_listening_point(ctx->prov,lp);
		if (sal_address_get_transport(addr)==SalTransportTLS) {
			set_tls_properties(ctx);
		}
	} else {
		return -1;
	}
	return result;
}
int sal_add_listen_port(Sal *ctx, SalAddress* addr){
	int result;
	belle_sip_listening_point_t* lp = belle_sip_stack_create_listening_point(ctx->stack
																			,sal_address_get_domain(addr)
																			,sal_address_get_port_int(addr)
																			,sal_transport_to_string(sal_address_get_transport(addr)));
	if (lp) {
		belle_sip_listening_point_set_keep_alive(lp,ctx->keep_alive);
		result = belle_sip_provider_add_listening_point(ctx->prov,lp);
		set_tls_properties(ctx);
	} else {
		return -1;
	}
	return result;
}
int sal_enable_tunnel(Sal *ctx, void *tunnelclient) {
#ifdef TUNNEL_ENABLED
	belle_sip_listening_point_t *lp;
	int result;

	sal_unlisten_ports(ctx);
	lp = belle_sip_tunnel_listening_point_new(ctx->stack, tunnelclient);
	if (lp == NULL) return -1;

	belle_sip_listening_point_set_keep_alive(lp, ctx->keep_alive);
	result = belle_sip_provider_add_listening_point(ctx->prov, lp);
	set_tls_properties(ctx);
	return result;
#else
	return 0;
#endif
}
Exemple #5
0
int sal_add_listen_port(Sal *ctx, SalAddress* addr){
	int result;
	belle_sip_listening_point_t* lp = belle_sip_stack_create_listening_point(ctx->stack,
									sal_address_get_domain(addr),
									sal_address_get_port(addr),
									sal_transport_to_string(sal_address_get_transport(addr)));
	if (sal_address_get_port(addr)==-1 && lp==NULL){
		int random_port=(0xDFFF&random())+1024;
		ms_warning("This version of belle-sip doesn't support random port, choosing one here.");
		lp = belle_sip_stack_create_listening_point(ctx->stack,
						sal_address_get_domain(addr),
						random_port,
						sal_transport_to_string(sal_address_get_transport(addr)));
	}
	if (lp) {
		belle_sip_listening_point_set_keep_alive(lp,ctx->keep_alive);
		result = belle_sip_provider_add_listening_point(ctx->prov,lp);
		if (sal_address_get_transport(addr)==SalTransportTLS) set_tls_properties(ctx);
	} else {
		return -1;
	}
	return result;
}