Skip to content

Commit 0847438

Browse files
author
souradeep.bera
committed
fix rfc 3311
1 parent 50a509b commit 0847438

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

libsofia-sip-ua/nua/nua_session.c

+20-10
Original file line numberDiff line numberDiff line change
@@ -3525,7 +3525,6 @@ int nua_update_server_init(nua_server_request_t *sr)
35253525
if (sr->sr_sdp) { /* Check for overlap */
35263526
nua_client_request_t *cr;
35273527
nua_server_request_t *sr0;
3528-
int overlap = 0;
35293528

35303529
/*
35313530
A UAS that receives an UPDATE before it has generated a final
@@ -3542,18 +3541,29 @@ int nua_update_server_init(nua_server_request_t *sr)
35423541
reject the UPDATE with a 500 response, and MUST include a Retry-After
35433542
header field with a randomly chosen value between 0 and 10 seconds.
35443543
*/
3545-
for (cr = nh->nh_ds->ds_cr; cr; cr = cr->cr_next)
3546-
if ((overlap = cr->cr_offer_sent && !cr->cr_answer_recv))
3544+
for (sr0 = nh->nh_ds->ds_sr; sr0; sr0 = sr0->sr_next) {
3545+
/* Previous INVITE has not been ACKed */
3546+
if (sr0->sr_method == sip_method_invite)
3547+
break;
3548+
/* Or we have sent offer but have not received an answer */
3549+
if (sr->sr_sdp && sr0->sr_offer_sent && !sr0->sr_answer_recv)
35473550
break;
3551+
/* Or we have received request with offer but not sent an answer */
3552+
if (sr->sr_sdp && sr0->sr_offer_recv && !sr0->sr_answer_sent)
3553+
break;
3554+
}
35483555

3549-
if (!overlap)
3550-
for (sr0 = nh->nh_ds->ds_sr; sr0; sr0 = sr0->sr_next)
3551-
if ((overlap = sr0->sr_offer_recv && !sr0->sr_answer_sent))
3552-
break;
3556+
if (sr0) {
3557+
/* Overlapping invites - RFC 3261 14.2 */
3558+
return nua_server_retry_after(sr, 500, "Overlapping Requests", 0, 10);
3559+
}
3560+
3561+
for (cr = nh->nh_ds->ds_cr; cr; cr = cr->cr_next) {
3562+
if (cr->cr_usage == sr->sr_usage && cr->cr_orq && cr->cr_offer_sent)
3563+
/* Glare - RFC 3261 14.2 and RFC 3311 section 5.2 */
3564+
return SR_STATUS1(sr, SIP_491_REQUEST_PENDING);
3565+
}
35533566

3554-
if (nh->nh_soa && overlap) {
3555-
return nua_server_retry_after(sr, 500, "Overlapping Offer/Answer", 1, 9);
3556-
}
35573567

35583568
if (nh->nh_soa &&
35593569
soa_set_remote_sdp(nh->nh_soa, NULL, sr->sr_sdp, sr->sr_sdp_len) < 0) {

0 commit comments

Comments
 (0)