Bug 892161 - SetRemoteDescription should fail if peer gives no ICE info r=abr

This commit is contained in:
Ethan Hugg 2013-07-19 12:46:09 -07:00
parent 226c42acf1
commit 10dd59543a
4 changed files with 86 additions and 9 deletions

View File

@ -3712,6 +3712,17 @@ fsmdef_ev_setremotedesc(sm_event_t *event) {
return (fsmdef_release(fcb, cause, FALSE));
}
/* Now that the SDP is digested we need to sanity check
for ICE parameters */
cause = gsmsdp_check_ice_attributes_exist(fcb);
if (cause != CC_CAUSE_OK) {
ui_set_remote_description(evSetRemoteDescError, fcb->state, line,
call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "ICE attributes missing; cause = %s",
cc_cause_name(cause));
return (SM_RC_END);
}
gsmsdp_clean_media_list(dcb);
fsm_change_state(fcb, __LINE__, FSMDEF_S_HAVE_REMOTE_OFFER);

View File

@ -6529,6 +6529,76 @@ gsmsdp_process_offer_sdp (fsm_fcb_t *fcb_p,
return (status);
}
/*
* gsmsdp_check_peer_ice_attributes_exist
*
* Read ICE parameters from the SDP and return failure
* if they are not complete.
*
* fcb_p - pointer to the fcb
*
*/
cc_causes_t
gsmsdp_check_ice_attributes_exist(fsm_fcb_t *fcb_p) {
fsmdef_dcb_t *dcb_p = fcb_p->dcb;
sdp_result_e sdp_res;
char *ufrag;
char *pwd;
fsmdef_media_t *media;
boolean has_session_ufrag = FALSE;
boolean has_session_pwd = FALSE;
/* Check for valid ICE parameters */
sdp_res = sdp_attr_get_ice_attribute(dcb_p->sdp->dest_sdp,
SDP_SESSION_LEVEL, 0, SDP_ATTR_ICE_UFRAG, 1, &ufrag);
if (sdp_res == SDP_SUCCESS && ufrag) {
has_session_ufrag = TRUE;
}
sdp_res = sdp_attr_get_ice_attribute(dcb_p->sdp->dest_sdp,
SDP_SESSION_LEVEL, 0, SDP_ATTR_ICE_PWD, 1, &pwd);
if (sdp_res == SDP_SUCCESS && pwd) {
has_session_pwd = TRUE;
}
if (has_session_ufrag && has_session_pwd) {
/* Both exist at session level, success */
return CC_CAUSE_OK;
}
/* Incomplete ICE params at session level, check all media levels */
GSMSDP_FOR_ALL_MEDIA(media, dcb_p) {
if (!GSMSDP_MEDIA_ENABLED(media)) {
continue;
}
if (!has_session_ufrag) {
sdp_res = sdp_attr_get_ice_attribute(dcb_p->sdp->dest_sdp,
media->level, 0, SDP_ATTR_ICE_UFRAG, 1, &ufrag);
if (sdp_res != SDP_SUCCESS || !ufrag) {
GSM_ERR_MSG(GSM_L_C_F_PREFIX"missing ICE ufrag parameter.",
dcb_p->line, dcb_p->call_id, __FUNCTION__);
return CC_CAUSE_ERROR;
}
}
if (!has_session_pwd) {
sdp_res = sdp_attr_get_ice_attribute(dcb_p->sdp->dest_sdp,
media->level, 0, SDP_ATTR_ICE_PWD, 1, &pwd);
if (sdp_res != SDP_SUCCESS || !pwd) {
GSM_ERR_MSG(GSM_L_C_F_PREFIX"missing ICE pwd parameter.",
dcb_p->line, dcb_p->call_id, __FUNCTION__);
return CC_CAUSE_ERROR;
}
}
}
return CC_CAUSE_OK;
}
/*
* gsmsdp_install_peer_ice_attributes
*

View File

@ -129,6 +129,7 @@ extern boolean gsmsdp_update_local_sdp_media_capability(fsmdef_dcb_t *dcb_p,
boolean refresh, boolean hold);
boolean is_gsmsdp_media_ip_updated_to_latest( fsmdef_dcb_t * dcb );
cc_causes_t gsmsdp_check_ice_attributes_exist(fsm_fcb_t *fcb_p);
cc_causes_t gsmsdp_install_peer_ice_attributes(fsm_fcb_t *fcb_p);
cc_causes_t gsmsdp_configure_dtls_data_attributes(fsm_fcb_t *fcb_p);
cc_causes_t gsmsdp_find_level_from_mid(fsmdef_dcb_t * dcb, const char * mid, uint16_t *level);

View File

@ -2283,15 +2283,10 @@ TEST_F(SignalingTest, missingUfrag)
// FSM. This may change in the future.
a1_.CreateOffer(constraints, OFFER_AV, SHOULD_SENDRECV_AV);
a1_.SetLocal(TestObserver::OFFER, offer, true);
// Really we should detect failure at the SetRemote point,
// since without a ufrag, we aren't going to be successful.
// But for now, this isn't detected till SIPCC tries to impose
// the parameters on the ICE stack in SetLocal. Bug 892161.
a2_.SetRemote(TestObserver::OFFER, offer, true);
a2_.CreateAnswer(constraints, offer, OFFER_AV | ANSWER_AV);
a2_.SetLocal(TestObserver::ANSWER, a2_.answer(),
true, sipcc::PeerConnectionImpl::kSignalingHaveRemoteOffer);
// Since things have now failed, just stop.
// We now detect the missing ICE parameters at SetRemoteDescription
a2_.SetRemote(TestObserver::OFFER, offer, true,
sipcc::PeerConnectionImpl::kSignalingStable);
ASSERT_TRUE(a2_.pObserver->state == TestObserver::stateError);
}
} // End namespace test.