Commit 00e90cef authored by jehan's avatar jehan

make sure PRACK can be still revceived by the app

parent 6fae7e1b
......@@ -96,7 +96,7 @@ BELLESIP_EXPORT void belle_sip_dialog_terminate_on_bye(belle_sip_dialog_t *dialo
*/
BELLESIP_EXPORT belle_sip_transaction_t* belle_sip_dialog_get_last_transaction(const belle_sip_dialog_t *dialog);
BELLESIP_EXPORT int belle_sip_dialog_request_pending(belle_sip_dialog_t *dialog);
BELLESIP_EXPORT int belle_sip_dialog_request_pending(const belle_sip_dialog_t *dialog);
BELLE_SIP_END_DECLS
......
......@@ -720,6 +720,7 @@ struct belle_sip_dialog{
belle_sip_dialog_t *belle_sip_dialog_new(belle_sip_transaction_t *t);
belle_sip_dialog_t * belle_sip_provider_create_dialog_internal(belle_sip_provider_t *prov, belle_sip_transaction_t *t,unsigned int check_last_resp);
int belle_sip_dialog_is_authorized_transaction(const belle_sip_dialog_t *dialog,const char* method) ;
/*returns 1 if message belongs to the dialog, 0 otherwise */
int _belle_sip_dialog_match(belle_sip_dialog_t *obj, const char *call_id, const char *local_tag, const char *remote_tag);
int belle_sip_dialog_match(belle_sip_dialog_t *obj, belle_sip_message_t *msg, int as_uas);
......
......@@ -748,7 +748,35 @@ belle_sip_transaction_t* belle_sip_dialog_get_last_transaction(const belle_sip_d
return dialog->last_transaction;
}
int belle_sip_dialog_request_pending(belle_sip_dialog_t *dialog){
int belle_sip_dialog_request_pending(const belle_sip_dialog_t *dialog){
return dialog->last_transaction ? belle_sip_transaction_state_is_transient(belle_sip_transaction_get_state(dialog->last_transaction)) : FALSE;
}
/* for notify exception
As per RFC 3265;
3.3.4. Dialog creation and termination
If an initial SUBSCRIBE request is not sent on a pre-existing dialog,
the subscriber will wait for a response to the SUBSCRIBE request or a
matching NOTIFY.
...
...
If an initial SUBSCRIBE is sent on a pre-existing dialog, a matching
200-class response or successful NOTIFY request merely creates a new
subscription associated with that dialog.
*/
int belle_sip_dialog_is_authorized_transaction(const belle_sip_dialog_t *dialog,const char* method) {
if (belle_sip_dialog_request_pending(dialog) && strcasecmp(method,"BYE")!=0 ){
const char* last_transaction_request = belle_sip_request_get_method(belle_sip_transaction_get_request(dialog->last_transaction));
return last_transaction_request && belle_sip_object_is_instance_of(BELLE_SIP_OBJECT(dialog->last_transaction),belle_sip_client_transaction_t_id)
&& ((strcasecmp(last_transaction_request,"SUBSCRIBE")==0 && strcasecmp(method,"NOTIFY")==0)
|| (strcasecmp(last_transaction_request,"INVITE")==0 && strcasecmp(method,"PRACK")==0));
} else {
return TRUE;
}
}
......@@ -103,24 +103,9 @@ static void belle_sip_provider_dispatch_request(belle_sip_provider_t* prov, bell
return;
}
}
/* for notify exception
As per RFC 3265;
3.3.4. Dialog creation and termination
If an initial SUBSCRIBE request is not sent on a pre-existing dialog,
the subscriber will wait for a response to the SUBSCRIBE request or a
matching NOTIFY.
...
...
If an initial SUBSCRIBE is sent on a pre-existing dialog, a matching
200-class response or successful NOTIFY request merely creates a new
subscription associated with that dialog.
*/
else if (belle_sip_dialog_request_pending(ev.dialog)
&& strcmp(method,"BYE")!=0
&& strcmp(method,"NOTIFY")!=0 /**/){
else if (!belle_sip_dialog_is_authorized_transaction(ev.dialog,method)){
belle_sip_server_transaction_t *tr=belle_sip_provider_create_server_transaction(prov,req);
belle_sip_server_transaction_send_response(tr,
belle_sip_response_create_from_request(req,491));
......
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