Commit 92a2db9d authored by jehan's avatar jehan

confirmed dialogs are now terminated by 481.

parent f0e82db1
......@@ -84,6 +84,14 @@ BELLESIP_EXPORT void belle_sip_provider_set_recv_error(belle_sip_provider_t *pro
**/
BELLESIP_EXPORT void belle_sip_provider_enable_unconditional_answer(belle_sip_provider_t *prov, int enable);
/**
* Can be used to choose unconditionally answer to incoming sip messages.
* use belle_sip_provider_enable_unconditional_answer to enable/disable
* @param prov
* @param code 0 to sip response code
**/
BELLESIP_EXPORT void belle_sip_provider_set_unconditional_answer(belle_sip_provider_t *prov, unsigned short code);
/**
* Provides access to a specific dialog
* @param prov object
......
......@@ -555,6 +555,7 @@ struct belle_sip_provider{
unsigned char rport_enabled; /*0 if rport should not be set in via header*/
unsigned char nat_helper;
unsigned char unconditional_answer_enabled;
unsigned short unconditional_answer;
};
BELLESIP_INTERNAL_EXPORT belle_sip_provider_t *belle_sip_provider_new(belle_sip_stack_t *s, belle_sip_listening_point_t *lp);
......
......@@ -459,6 +459,11 @@ int belle_sip_dialog_update(belle_sip_dialog_t *obj, belle_sip_transaction_t* tr
}
break;
case BELLE_SIP_DIALOG_CONFIRMED:
if (code==481 && (is_invite || is_subscribe)) {
/*Dialog is terminated in such case*/
delete_dialog=TRUE;
break;
}
/*refreshing target is also true in case of subscribe*/
if ((is_invite || is_subscribe) && (code>=200 && code<300)) {
/*refresh the remote_target*/
......
......@@ -130,9 +130,9 @@ static void belle_sip_provider_dispatch_request(belle_sip_provider_t* prov, bell
}
}
if (prov->unconditional_answer_enabled && strcmp("ACK",method)!=0) { /*always answer 480 in this case*/
if (prov->unconditional_answer_enabled && strcmp("ACK",method)!=0) { /*always answer predefined value (I.E 480 by default)*/
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,480));
belle_sip_server_transaction_send_response(tr,belle_sip_response_create_from_request(req,prov->unconditional_answer));
return;
} else {
ev.source=(belle_sip_object_t*)prov;
......@@ -472,6 +472,7 @@ belle_sip_provider_t *belle_sip_provider_new(belle_sip_stack_t *s, belle_sip_lis
belle_sip_provider_t *p=belle_sip_object_new(belle_sip_provider_t);
p->stack=s;
p->rport_enabled=1;
p->unconditional_answer = 480;
if (lp) belle_sip_provider_add_listening_point(p,lp);
return p;
}
......@@ -1235,5 +1236,7 @@ int belle_sip_provider_nat_helper_enabled(const belle_sip_provider_t *prov){
}
void belle_sip_provider_enable_unconditional_answer(belle_sip_provider_t *prov, int enable) {
prov->unconditional_answer_enabled=enable;
}
void belle_sip_provider_set_unconditional_answer(belle_sip_provider_t *prov, unsigned short code) {
prov->unconditional_answer=code;
}
......@@ -318,6 +318,10 @@ static void process_response_event(belle_sip_listener_t *user_ctx, const belle_s
}else belle_sip_warning("Receiving 423 but no min-expires header.");
break;
}
case 481: {
/* will trigger dialog terminated, so nothing to do here*/
return;
}
case 491: {
if (refresher->target_expires>0) {
retry_later_on_io_error(refresher);
......
......@@ -201,8 +201,8 @@ static void server_process_request_event(void *obj, const belle_sip_request_even
belle_sip_header_www_authenticate_add_qop(www_authenticate,"auth");
if (endpoint->nonce_count>=MAX_NC_COUNT) {
belle_sip_header_www_authenticate_set_stale(www_authenticate,1);
endpoint->nonce_count=1;
}
endpoint->nonce_count=1;
}
}
}
......@@ -593,10 +593,27 @@ static void subscribe_base(int with_resource_lists) {
/*make sure dialog has changed*/
BC_ASSERT_PTR_NOT_EQUAL(client_dialog, belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(belle_sip_refresher_get_transaction(refresher))));
/*unsubscribe twice to make sure refresh operation can be safely cascaded*/
belle_sip_refresher_refresh(refresher,0);
belle_sip_refresher_refresh(refresher,0);
belle_sip_message("simulating dialog terminated server side and recovery");
client_dialog = belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(belle_sip_refresher_get_transaction(refresher)));
belle_sip_provider_enable_unconditional_answer(server->provider,TRUE);
belle_sip_provider_set_unconditional_answer(server->provider,481);
belle_sip_refresher_refresh(refresher, 10);
BC_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.fourHundredEightyOne,2,4000));
belle_sip_provider_enable_unconditional_answer(server->provider,FALSE);
BC_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.refreshOk,5,4000));
BC_ASSERT_EQUAL(client->stat.dialogTerminated, 0, int, "%i");
/*make sure dialog has changed*/
BC_ASSERT_PTR_NOT_EQUAL(client_dialog, belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(belle_sip_refresher_get_transaction(refresher))));
belle_sip_refresher_refresh(refresher, 0);
belle_sip_refresher_refresh(refresher, 0);
belle_sip_refresher_stop(refresher);
BC_ASSERT_TRUE(wait_for(server->stack,client->stack,&server->stat.dialogTerminated,1,4000));
......@@ -606,6 +623,7 @@ static void subscribe_base(int with_resource_lists) {
BC_ASSERT_EQUAL(server->number_of_body_found, (server->auth == none ?1:2), int, "%i");
}
destroy_endpoint(client);
destroy_endpoint(server);
}
......
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