Commit 8fc42239 authored by jehan's avatar jehan

fix dialog destruction case

parent 8827e51c
......@@ -273,6 +273,7 @@ void belle_sip_header_content_type_set_type(belle_sip_header_content_type_t* con
const char* belle_sip_header_content_type_get_subtype(const belle_sip_header_content_type_t* content_type);
void belle_sip_header_content_type_set_subtype(belle_sip_header_content_type_t* content_type,const char* sub_type);
#define BELLE_SIP_HEADER_CONTENT_TYPE(t) BELLE_SIP_CAST(t,belle_sip_header_content_type_t)
#define BELLE_SIP_CONTENT_TYPE "Content-Type"
/******************************
*
* Expires inherit from header
......
......@@ -616,7 +616,7 @@ int belle_sip_header_content_type_marshal(belle_sip_header_content_type_t* conte
current_offset+=belle_sip_parameters_marshal(&content_type->params_list, buff,current_offset, buff_size);
return current_offset-offset;
}
BELLE_SIP_NEW_HEADER(header_content_type,parameters,"Content-Type")
BELLE_SIP_NEW_HEADER(header_content_type,parameters,BELLE_SIP_CONTENT_TYPE)
BELLE_SIP_PARSE(header_content_type)
belle_sip_header_content_type_t* belle_sip_header_content_type_create (const char* type,const char* sub_type) {
belle_sip_header_content_type_t* header = belle_sip_header_content_type_new();
......
......@@ -218,7 +218,7 @@ int belle_sip_dialog_establish(belle_sip_dialog_t *obj, belle_sip_request_t *req
}
if (belle_sip_dialog_establish_full(obj,req,resp)==0){
obj->state=BELLE_SIP_DIALOG_CONFIRMED;
obj->needs_ack=strcmp("INVITE",belle_sip_request_get_method(req))==0; /*only for invite*/
obj->needs_ack=(strcmp("INVITE",belle_sip_request_get_method(req))==0); /*only for invite*/
}else return -1;
} else if (code>=300 && obj->state!=BELLE_SIP_DIALOG_CONFIRMED) {
/*12.3 Termination of a Dialog
......@@ -265,8 +265,24 @@ int belle_sip_dialog_update(belle_sip_dialog_t *obj,belle_sip_request_t *req, be
obj->remote_target=(belle_sip_header_address_t*)belle_sip_object_ref(ct);
}
obj->needs_ack=TRUE;
}else if (strcmp(belle_sip_request_get_method(req),"BYE")==0 && code>=200 && code<300){
if (obj->terminate_on_bye && as_uas /*only when receive 200ok from BYE*/) belle_sip_dialog_delete(obj);
}else if (strcmp(belle_sip_request_get_method(req),"BYE")==0 && ((code>=200 && code<300) || code==481 || code==408)){
/*15.1.1 UAC Behavior
A BYE request is constructed as would any other request within a
dialog, as described in Section 12.
Once the BYE is constructed, the UAC core creates a new non-INVITE
client transaction, and passes it the BYE request. The UAC MUST
consider the session terminated (and therefore stop sending or
listening for media) as soon as the BYE request is passed to the
client transaction. If the response for the BYE is a 481
(Call/Transaction Does Not Exist) or a 408 (Request Timeout) or no
response at all is received for the BYE (that is, a timeout is
returned by the client transaction), the UAC MUST consider the
session and the dialog terminated. */
if (obj->terminate_on_bye) belle_sip_dialog_delete(obj);
obj->needs_ack=FALSE; /*no longuer need ACK*/
}
break;
case BELLE_SIP_DIALOG_TERMINATED:
......@@ -507,12 +523,15 @@ int _belle_sip_dialog_match(belle_sip_dialog_t *obj, const char *call_id, const
}
void belle_sip_dialog_check_ack_sent(belle_sip_dialog_t*obj){
belle_sip_client_transaction_t* client_trans;
if (obj->needs_ack){
belle_sip_request_t *req;
belle_sip_error("Your listener did not ACK'd the 200Ok for your INVITE request. The dialog will be terminated.");
req=belle_sip_dialog_create_request(obj,"BYE");
belle_sip_client_transaction_send_request(
belle_sip_provider_create_client_transaction(obj->provider,req));
client_trans=belle_sip_provider_create_client_transaction(obj->provider,req);
BELLE_SIP_TRANSACTION(client_trans)->is_internal=TRUE; /*internal transaction, don't bother user with 200ok*/
belle_sip_client_transaction_send_request(client_trans);
}
}
......
......@@ -30,9 +30,8 @@ struct belle_sip_refresher {
void* user_data;
};
static void process_dialog_terminated(void *sal, const belle_sip_dialog_terminated_event_t *event){
/*belle_sip_dialog_t* dialog = belle_sip_dialog_terminated_get_dialog(event);*/
belle_sip_fatal("Refresher process_dialog_terminated not implemented yet");
static void process_dialog_terminated(void *user_ctx, const belle_sip_dialog_terminated_event_t *event){
/*nop*/
}
static void process_io_error(void *user_ctx, const belle_sip_io_error_event_t *event){
belle_sip_fatal("Refresher process_io_error not implemented yet");
......@@ -79,22 +78,20 @@ static void process_response_event(void *user_ctx, const belle_sip_response_even
}
static void process_timeout(void *user_ctx, const belle_sip_timeout_event_t *event) {
/* belle_sip_client_transaction_t* client_transaction = belle_sip_timeout_event_get_client_transaction(event);
SalOp* op = (SalOp*)belle_sip_transaction_get_application_data(BELLE_SIP_TRANSACTION(client_transaction));
if (op->callbacks.process_timeout) {
op->callbacks.process_timeout(op,event);
} else*/ {
/* belle_sip_client_transaction_t* client_transaction = belle_sip_response_event_get_client_transaction(event);
belle_sip_refresher_t* refresher=(belle_sip_refresher_t*)user_ctx;
if (refresher && (client_transaction !=refresher->transaction))
return;*/ /*not for me*/
belle_sip_fatal("Unhandled event timeout [%p]",event);
}
}
static void process_transaction_terminated(void *user_ctx, const belle_sip_transaction_terminated_event_t *event) {
/* belle_sip_client_transaction_t* client_transaction = belle_sip_transaction_terminated_event_get_client_transaction(event);
SalOp* op = (SalOp*)belle_sip_transaction_get_application_data(client_transaction);
if (op->calbacks.process_transaction_terminated) {
op->calbacks.process_transaction_terminated(op,event);
} else */{
belle_sip_fatal("Unhandled transaction terminated [%p]",event);
}
/* belle_sip_client_transaction_t* client_transaction = belle_sip_response_event_get_client_transaction(event);
belle_sip_refresher_t* refresher=(belle_sip_refresher_t*)user_ctx;
if (refresher && (client_transaction !=refresher->transaction))
return;*/ /*not for me*/
belle_sip_fatal("Unhandled transaction terminated [%p]",event);
}
static void destroy(belle_sip_refresher_t *refresher){
......
......@@ -283,8 +283,10 @@ void belle_sip_client_transaction_notify_response(belle_sip_client_transaction_t
&& (dialog->state==BELLE_SIP_DIALOG_EARLY || dialog->state==BELLE_SIP_DIALOG_CONFIRMED)){
/*make sure this response matches the current dialog, or creates a new one*/
if (!belle_sip_dialog_match(dialog,(belle_sip_message_t*)resp,FALSE)){
dialog=belle_sip_dialog_new(base);
dialog=belle_sip_provider_create_dialog(t->base.provider,BELLE_SIP_TRANSACTION(t));/*belle_sip_dialog_new(base);*/
if (dialog){
/*copy userdata to avoid application from being lost*/
belle_sip_dialog_set_application_data(dialog,belle_sip_dialog_get_application_data(base->dialog));
belle_sip_message("Handling response creating a new dialog !");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment