Commit e59db8da authored by jehan's avatar jehan

Answer 500 server internal error in case of unexpected request arriving at core level

parent 6fffcc0f
......@@ -464,6 +464,9 @@ SalReason sal_reason_to_sip_code(SalReason r){
case SalReasonBadGateway:
ret=502;
break;
case SalReasonInternalError:
ret=500;
break;
}
return ret;
}
......@@ -508,6 +511,8 @@ SalReason _sal_reason_from_sip_code(int code) {
return SalReasonNotAcceptable;
case 491:
return SalReasonRequestPending;
case 500:
return SalReasonInternalError;
case 501:
return SalReasonNotImplemented;
case 502:
......
......@@ -747,7 +747,7 @@ static void call_updating(SalOp *op, bool_t is_update){
case LinphoneCallPausing:
case LinphoneCallResuming:
case LinphoneCallUpdatedByRemote:
sal_call_decline(call->op,SalReasonNotImplemented,NULL);
sal_call_decline(call->op,SalReasonInternalError,NULL);
/*no break*/
case LinphoneCallIdle:
case LinphoneCallOutgoingInit:
......
......@@ -1274,6 +1274,7 @@ LinphoneReason linphone_reason_from_sal(SalReason r){
ret=LinphoneReasonIOError;
break;
case SalReasonUnknown:
case SalReasonInternalError:
ret=LinphoneReasonUnknown;
break;
case SalReasonBusy:
......@@ -1304,7 +1305,7 @@ LinphoneReason linphone_reason_from_sal(SalReason r){
ret=LinphoneReasonIOError;
break;
case SalReasonRequestPending:
ret=LinphoneReasonNone;
ret=LinphoneReasonTemporarilyUnavailable; /*might not be exactly the perfect matching, but better than LinphoneReasonNone*/
break;
case SalReasonUnauthorized:
ret=LinphoneReasonUnauthorized;
......
......@@ -355,7 +355,8 @@ typedef enum SalReason{
SalReasonNotImplemented,
SalReasonBadGateway,
SalReasonServerTimeout,
SalReasonIOError
SalReasonIOError,
SalReasonInternalError
}SalReason;
const char* sal_reason_to_string(const SalReason reason);
......
......@@ -1837,7 +1837,7 @@ static void video_call_base_2(LinphoneCoreManager* pauline,LinphoneCoreManager*
}
}
static void video_call_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) {
void video_call_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) {
video_call_base_2(pauline,marie,using_policy,mode,callee_video_enabled,caller_video_enabled);
linphone_core_terminate_all_calls(pauline->lc);
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1));
......@@ -2805,6 +2805,89 @@ static void call_established_with_rejected_info(void) {
linphone_core_manager_destroy(pauline);
}
static void call_established_with_complex_rejected_operation(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
bool_t call_ok=FALSE;
LinphoneCallParams *params;
BC_ASSERT_TRUE((call_ok=call(pauline,marie)));
if (call_ok){
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,1));
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,1));
linphone_core_enable_payload_type(pauline->lc,linphone_core_find_payload_type(pauline->lc,"PCMU",8000,1),FALSE); /*disable PCMU*/
linphone_core_enable_payload_type(pauline->lc,linphone_core_find_payload_type(pauline->lc,"PCMA",8000,1),TRUE); /*enable PCMA*/
linphone_core_enable_payload_type(marie->lc,linphone_core_find_payload_type(marie->lc,"PCMU",8000,1),FALSE); /*disable PCMU*/
linphone_core_enable_payload_type(marie->lc,linphone_core_find_payload_type(marie->lc,"PCMA",8000,1),TRUE); /*enable PCMA*/
/*just to authenticate marie*/
linphone_call_send_info_message(linphone_core_get_current_call(marie->lc),linphone_core_create_info_message(marie->lc));
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_inforeceived,1));
BC_ASSERT_EQUAL(pauline->stat.number_of_inforeceived,1, int, "%d");
/*to give time for 200ok to arrive*/
wait_for_until(marie->lc,pauline->lc,NULL,0,1000);
linphone_core_update_call( pauline->lc
,linphone_core_get_current_call(pauline->lc)
,linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)));
linphone_core_update_call( marie->lc
,linphone_core_get_current_call(marie->lc)
,linphone_call_get_current_params(linphone_core_get_current_call(marie->lc)));
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
BC_ASSERT_EQUAL(linphone_call_get_reason(linphone_core_get_current_call(pauline->lc)),LinphoneReasonTemporarilyUnavailable, int, "%d");
BC_ASSERT_EQUAL(linphone_call_get_reason(linphone_core_get_current_call(pauline->lc)),LinphoneReasonTemporarilyUnavailable, int, "%d");
check_call_state(pauline,LinphoneCallStreamsRunning);
check_call_state(marie,LinphoneCallStreamsRunning);
linphone_core_update_call( pauline->lc
,linphone_core_get_current_call(pauline->lc)
,linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)));
linphone_call_send_info_message(linphone_core_get_current_call(marie->lc),linphone_core_create_info_message(marie->lc));
/*by chance, UPDATES can be sent in // to invite, but drawback is that it will not be rejected with 491*/
params=linphone_core_create_call_params(marie->lc,linphone_core_get_current_call(marie->lc));
params->no_user_consent=TRUE;
linphone_core_update_call( marie->lc
,linphone_core_get_current_call(marie->lc)
,params);
linphone_call_params_destroy(params);
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,3));
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3));
BC_ASSERT_EQUAL(linphone_call_get_reason(linphone_core_get_current_call(pauline->lc)),LinphoneReasonTemporarilyUnavailable, int, "%d");
BC_ASSERT_EQUAL(linphone_call_get_reason(linphone_core_get_current_call(pauline->lc)),LinphoneReasonTemporarilyUnavailable, int, "%d");
/*just to sleep*/
linphone_core_terminate_all_calls(pauline->lc);
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1));
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1));
}
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void call_established_with_rejected_reinvite(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
......@@ -4264,6 +4347,7 @@ test_t call_tests[] = {
{ "Call established with rejected RE-INVITE",call_established_with_rejected_reinvite},
{ "Call established with rejected incoming RE-INVITE", call_established_with_rejected_incoming_reinvite },
{ "Call established with rejected RE-INVITE in error", call_established_with_rejected_reinvite_with_error},
{ "Call established with complex rejected operation",call_established_with_complex_rejected_operation},
{ "Call redirected by callee", call_redirect},
{ "Call with specified codec bitrate", call_with_specified_codec_bitrate},
{ "Call with in-dialog UPDATE request", call_with_in_dialog_update },
......
......@@ -328,6 +328,6 @@ static const int audio_cmp_max_shift=20;
* this function return max value in the last 3 seconds*/
int linphone_core_manager_get_max_audio_down_bw(const LinphoneCoreManager *mgr);
int linphone_core_manager_get_max_audio_up_bw(const LinphoneCoreManager *mgr);
void video_call_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled);
#endif /* LIBLINPHONE_TESTER_H_ */
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