Changeset 5806


Ignore:
Timestamp:
Jun 19, 2018 10:00:33 AM (6 years ago)
Author:
nanang
Message:

Fix #2120:

  • Adjust local SE to comply to remote Min-SE when incoming request has Min-SE header but no SE header.
  • Handle the case of receiving 422 response for subsequent INVITE or UPDATE.
  • Add best effort to avoid INVITE/UPDATE req + 422 resp loop.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip-ua/sip_timer.c

    r5701 r5806  
    6969    pj_timer_entry               expire_timer;  /**< Timer entry for expire  
    7070                                                     refresher              */ 
     71    pj_int32_t                   last_422_cseq; /**< Last 422 resp CSeq.    */ 
    7172}; 
    7273 
     
    786787        } 
    787788 
     789        /* Avoid 422 retry loop. Ignore it and stop retrying if dialog is 
     790         * established, otherwise, just return error to disconnect the call. 
     791         */ 
     792        if (rdata->msg_info.cseq->cseq == inv->timer->last_422_cseq + 1) { 
     793            if (inv->state == PJSIP_INV_STATE_CONFIRMED) { 
     794                inv->invite_tsx = NULL; 
     795                return PJ_SUCCESS; 
     796            } else { 
     797                return PJSIP_ERRNO_FROM_SIP_STATUS( 
     798                                            PJSIP_SC_SESSION_TIMER_TOO_SMALL); 
     799            } 
     800        } 
     801        inv->timer->last_422_cseq = rdata->msg_info.cseq->cseq; 
     802 
    788803        /* Session Timers should have been initialized here */ 
    789804        pj_assert(inv->timer); 
     
    799814        /* Prepare to restart the request */ 
    800815 
    801         /* Get the original INVITE request. */ 
    802         tdata = inv->invite_req; 
     816        /* Get the original INVITE/UPDATE request. */ 
     817        tdata = pjsip_rdata_get_tsx((pjsip_rx_data*)rdata)->last_tx; 
    803818 
    804819        /* Remove branch param in Via header. */ 
     
    828843        add_timer_headers(inv, tdata, PJ_TRUE, PJ_TRUE); 
    829844 
    830         /* Restart UAC */ 
    831         pjsip_inv_uac_restart(inv, PJ_FALSE); 
     845        /* Restart UAC if this is initial INVITE, or simply reset tsx for 
     846         * subsequent INVITE. 
     847         */ 
     848        if (inv->state < PJSIP_INV_STATE_CONFIRMED) 
     849            pjsip_inv_uac_restart(inv, PJ_FALSE); 
     850        else if (tdata->msg->line.req.method.id == PJSIP_INVITE_METHOD) 
     851            inv->invite_tsx = NULL; 
     852 
     853        /* Resend the updated request */ 
    832854        pjsip_inv_send_msg(inv, tdata); 
    833855 
     
    10421064    } 
    10431065 
     1066    /* Make sure Session Timers is initialized */ 
     1067    if (inv->timer == NULL) 
     1068        pjsip_timer_init_session(inv, NULL); 
     1069 
    10441070    /* Find Session-Expires header */ 
    10451071    se_hdr = (pjsip_sess_expires_hdr*) pjsip_msg_find_hdr_by_names( 
    10461072                                            msg, &STR_SE, &STR_SHORT_SE, NULL); 
    1047     if (se_hdr == NULL) { 
    1048         /* Remote doesn't support/want Session Timers, check if local  
    1049          * require or force to use Session Timers. Note that Supported and  
    1050          * Require headers negotiation should have been verified by invite  
    1051          * session. 
    1052          */ 
    1053         if ((inv->options &  
    1054             (PJSIP_INV_REQUIRE_TIMER | PJSIP_INV_ALWAYS_USE_TIMER)) == 0) 
    1055         { 
    1056             /* Session Timers not forced/required */ 
    1057             pjsip_timer_end_session(inv); 
    1058             return PJ_SUCCESS; 
    1059         } 
    1060     } 
    1061  
    1062     /* Make sure Session Timers is initialized */ 
    1063     if (inv->timer == NULL) 
    1064         pjsip_timer_init_session(inv, NULL); 
    1065  
    10661073    /* Find Min-SE header */ 
    10671074    min_se_hdr = (pjsip_min_se_hdr*) pjsip_msg_find_hdr_by_name(msg,  
     
    10941101         */ 
    10951102        inv->timer->setting.sess_expires = min_se; 
     1103    } 
     1104 
     1105    /* If incoming request has no SE header, it means remote doesn't 
     1106     * support/want Session Timers. So let's check if local require or 
     1107     * force to use Session Timers. Note that Supported and Require headers 
     1108     * negotiation should have been verified by invite session. 
     1109     */ 
     1110    if (se_hdr == NULL) { 
     1111        if ((inv->options &  
     1112            (PJSIP_INV_REQUIRE_TIMER | PJSIP_INV_ALWAYS_USE_TIMER)) == 0) 
     1113        { 
     1114            /* Session Timers not forced/required */ 
     1115            pjsip_timer_end_session(inv); 
     1116            return PJ_SUCCESS; 
     1117        } 
    10961118    } 
    10971119 
Note: See TracChangeset for help on using the changeset viewer.