diff --git a/coreapi/bellesip_sal/sal_impl.h b/coreapi/bellesip_sal/sal_impl.h index 424fc6961..f6f395fb5 100644 --- a/coreapi/bellesip_sal/sal_impl.h +++ b/coreapi/bellesip_sal/sal_impl.h @@ -81,7 +81,7 @@ void set_or_update_dialog(SalOp* op, belle_sip_dialog_t* dialog); void sal_op_set_remote_ua(SalOp*op,belle_sip_message_t* message); int sal_op_send_request(SalOp* op, belle_sip_request_t* request); -int sal_op_send_request_with_contact(SalOp* op, belle_sip_request_t* request) ; + void sal_op_resend_request(SalOp* op, belle_sip_request_t* request); void sal_process_authentication(SalOp *op, belle_sip_response_t *response); belle_sip_header_contact_t* sal_op_create_contact(SalOp *op,belle_sip_header_from_t* from_header) ; diff --git a/coreapi/bellesip_sal/sal_op_call.c b/coreapi/bellesip_sal/sal_op_call.c index c75eb0e18..611ddf62f 100644 --- a/coreapi/bellesip_sal/sal_op_call.c +++ b/coreapi/bellesip_sal/sal_op_call.c @@ -430,9 +430,9 @@ int sal_call(SalOp *op, const char *from, const char *to){ belle_sip_message_add_header(BELLE_SIP_MESSAGE(invite),BELLE_SIP_HEADER(op->referred_by)); } - sal_op_send_request_with_contact(op,invite); + return sal_op_send_request(op,invite); + - return 0; } void sal_op_call_fill_cbs(SalOp*op) { op->callbacks.process_io_error=call_process_io_error; @@ -549,7 +549,7 @@ int sal_call_update(SalOp *op, const char *subject){ belle_sip_request_t *reinvite=belle_sip_dialog_create_request(op->dialog,"INVITE"); belle_sip_message_add_header(BELLE_SIP_MESSAGE(reinvite),belle_sip_header_create( "Subject", subject)); sal_op_fill_invite(op, reinvite); - return sal_op_send_request_with_contact(op,reinvite); + return sal_op_send_request(op,reinvite); } SalMediaDescription * sal_call_get_remote_media_description(SalOp *h){ return h->base.remote_media;; diff --git a/coreapi/bellesip_sal/sal_op_impl.c b/coreapi/bellesip_sal/sal_op_impl.c index 7f052e358..8f3254460 100644 --- a/coreapi/bellesip_sal/sal_op_impl.c +++ b/coreapi/bellesip_sal/sal_op_impl.c @@ -151,6 +151,7 @@ static int _sal_op_send_request_with_contact(SalOp* op, belle_sip_request_t* req } if (add_contact) { contact = sal_op_create_contact(op,belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(request),belle_sip_header_from_t)); + belle_sip_message_remove_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_CONTACT); belle_sip_message_add_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_HEADER(contact)); } if (!belle_sip_message_get_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_AUTHORIZATION) @@ -163,12 +164,22 @@ static int _sal_op_send_request_with_contact(SalOp* op, belle_sip_request_t* req } int sal_op_send_request(SalOp* op, belle_sip_request_t* request) { - return _sal_op_send_request_with_contact(op, request,FALSE); -} -int sal_op_send_request_with_contact(SalOp* op, belle_sip_request_t* request) { - return _sal_op_send_request_with_contact(op, request,TRUE); + bool_t need_ack=FALSE; + /* + Header field where proxy ACK BYE CAN INV OPT REG + ___________________________________________________________ + Contact R o - - m o o + */ + if (strcmp(belle_sip_request_get_method(request),"INVITE")==0 + ||strcmp(belle_sip_request_get_method(request),"REGISTER")==0 + ||strcmp(belle_sip_request_get_method(request),"SUBSCRIBE")==0 + ||strcmp(belle_sip_request_get_method(request),"OPTION")==0) + need_ack=TRUE; + + return _sal_op_send_request_with_contact(op, request,need_ack); } + void sal_compute_sal_errors_from_code(int code ,SalError* sal_err,SalReason* sal_reason) { switch(code) { case 400: diff --git a/coreapi/bellesip_sal/sal_op_presence.c b/coreapi/bellesip_sal/sal_op_presence.c index 590a92a18..9da9e1080 100644 --- a/coreapi/bellesip_sal/sal_op_presence.c +++ b/coreapi/bellesip_sal/sal_op_presence.c @@ -591,7 +591,7 @@ int sal_subscribe_presence(SalOp *op, const char *from, const char *to){ belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),belle_sip_header_create("Event","Presence")); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_expires_create(600))); - return sal_op_send_request_with_contact(op,req); + return sal_op_send_request(op,req); } int sal_unsubscribe(SalOp *op){ belle_sip_request_t* req=op->dialog?belle_sip_dialog_create_request(op->dialog,"SUBSCRIBE"):NULL; /*cannot create request if dialog not set yet*/ @@ -601,7 +601,7 @@ int sal_unsubscribe(SalOp *op){ } belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),belle_sip_header_create("Event","Presence")); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_expires_create(0))); - return sal_op_send_request_with_contact(op,req); + return sal_op_send_request(op,req); } int sal_subscribe_accept(SalOp *op){ belle_sip_request_t* req=belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(op->pending_server_trans)); diff --git a/coreapi/bellesip_sal/sal_op_registration.c b/coreapi/bellesip_sal/sal_op_registration.c index ea1eb6c82..a8ac7e874 100644 --- a/coreapi/bellesip_sal/sal_op_registration.c +++ b/coreapi/bellesip_sal/sal_op_registration.c @@ -119,7 +119,7 @@ static int send_register_request_with_expires(SalOp* op, belle_sip_request_t* re belle_sip_message_add_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_HEADER(expires_header=belle_sip_header_expires_new())); } if (expires_header) belle_sip_header_expires_set_expires(expires_header,expires); - return sal_op_send_request_with_contact(op,request); + return sal_op_send_request(op,request); } diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 92df31eed..47a7cdd57 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -255,7 +255,7 @@ void linphone_proxy_config_apply(LinphoneProxyConfig *obj,LinphoneCore *lc) obj->lc=lc; linphone_proxy_config_done(obj); } -#ifndef USE_BELLESIP + static char *guess_contact_for_register(LinphoneProxyConfig *obj){ LinphoneAddress *proxy=linphone_address_new(obj->reg_proxy); char *ret=NULL; @@ -278,6 +278,12 @@ static char *guess_contact_for_register(LinphoneProxyConfig *obj){ localport = linphone_upnp_context_get_external_port(obj->lc->upnp); } #endif //BUILD_UPNP +#ifndef USE_BELLESIP + else { + linphone_address_destroy(contact); + return NULL; + } +#endif if(localip == NULL) { localip = localip_tmp; linphone_core_get_local_ip(obj->lc,host,localip_tmp); @@ -288,7 +294,7 @@ static char *guess_contact_for_register(LinphoneProxyConfig *obj){ linphone_address_set_port_int(contact,localport); linphone_address_set_domain(contact,localip); linphone_address_set_display_name(contact,NULL); - + linphone_core_get_sip_transports(obj->lc,&tr); if (tr.udp_port <= 0) { if (tr.tcp_port>0) { @@ -297,6 +303,7 @@ static char *guess_contact_for_register(LinphoneProxyConfig *obj){ sal_address_set_param(contact,"transport","tls"); } } + tmp=linphone_address_as_string_uri_only(contact); if (obj->contact_params) ret=ms_strdup_printf("<%s;%s>",tmp,obj->contact_params); @@ -307,20 +314,17 @@ static char *guess_contact_for_register(LinphoneProxyConfig *obj){ linphone_address_destroy (proxy); return ret; } -#endif + static void linphone_proxy_config_register(LinphoneProxyConfig *obj){ if (obj->reg_sendregister){ -#ifndef USE_BELLESIP char *contact; -#endif if (obj->op) sal_op_release(obj->op); obj->op=sal_op_new(obj->lc->sal); -#ifndef USE_BELLESIP /*contact is automatically guessed by belle-sip*/ - contact=guess_contact_for_register(obj); - sal_op_set_contact(obj->op,contact); - ms_free(contact); -#endif + if ((contact=guess_contact_for_register(obj))) { + sal_op_set_contact(obj->op,contact); + ms_free(contact); + } sal_op_set_user_pointer(obj->op,obj); if (sal_register(obj->op,obj->reg_proxy,obj->reg_identity,obj->expires)==0) { linphone_proxy_config_set_state(obj,LinphoneRegistrationProgress,"Registration in progress");