static endpoint_t* create_endpoint(const char *ip, int port,const char* transport,belle_sip_listener_callbacks_t* listener_callbacks) { endpoint_t* endpoint = belle_sip_new0(endpoint_t); endpoint->stack=belle_sip_stack_new(NULL); endpoint->listener_callbacks=listener_callbacks; endpoint->lp=belle_sip_stack_create_listening_point(endpoint->stack,ip,port,transport); endpoint->connection_family=AF_INET; if (endpoint->lp) belle_sip_object_ref(endpoint->lp); endpoint->provider=belle_sip_stack_create_provider(endpoint->stack,endpoint->lp); belle_sip_provider_add_sip_listener(endpoint->provider,(endpoint->listener=belle_sip_listener_create_from_callbacks(endpoint->listener_callbacks,endpoint))); sprintf(endpoint->nonce,"%p",endpoint); /*initial nonce*/ endpoint->nonce_count=1; endpoint->register_count=3; return endpoint; }
Sal * sal_init(MSFactory *factory){ belle_sip_listener_callbacks_t listener_callbacks; Sal * sal=ms_new0(Sal,1); /*belle_sip_object_enable_marshal_check(TRUE);*/ sal->auto_contacts=TRUE; sal->factory = factory; /*first create the stack, which initializes the belle-sip object's pool for this thread*/ belle_sip_set_log_handler(_belle_sip_log); sal->stack = belle_sip_stack_new(NULL); sal->user_agent=belle_sip_header_user_agent_new(); #if defined(PACKAGE_NAME) && defined(LIBLINPHONE_VERSION) belle_sip_header_user_agent_add_product(sal->user_agent, PACKAGE_NAME "/" LIBLINPHONE_VERSION); #else belle_sip_header_user_agent_add_product(sal->user_agent, "Unknown"); #endif sal_append_stack_string_to_user_agent(sal); belle_sip_object_ref(sal->user_agent); sal->prov = belle_sip_stack_create_provider(sal->stack,NULL); sal_nat_helper_enable(sal,TRUE); memset(&listener_callbacks,0,sizeof(listener_callbacks)); 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; sal->listener=belle_sip_listener_create_from_callbacks(&listener_callbacks,sal); belle_sip_provider_add_sip_listener(sal->prov,sal->listener); sal->tls_verify=TRUE; sal->tls_verify_cn=TRUE; sal->refresher_retry_after=60000; /*default value in ms*/ sal->enable_sip_update=TRUE; sal->pending_trans_checking=TRUE; sal->ssl_config = NULL; return sal; }