Changeset 4944 for pjproject/trunk


Ignore:
Timestamp:
Oct 10, 2014 10:33:23 AM (10 years ago)
Author:
nanang
Message:

Fixed #1796: Avoid infinite registration loop caused by contact rewrite.

Location:
pjproject/trunk/pjsip
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h

    r4750 r4944  
    220220                                         It may be different than acc 
    221221                                         contact if outbound is used    */ 
     222    pj_bool_t        contact_rewritten; 
     223                                    /**< Contact rewrite has been done? */ 
    222224    pjsip_host_port  via_addr;      /**< Address for Via header         */ 
    223225    pjsip_transport *via_tp;        /**< Transport associated with 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c

    r4942 r4944  
    20932093    pj_log_push_indent(); 
    20942094 
    2095     if ((acc->cfg.contact_rewrite_method & 
     2095    /* Check if we should do NAT bound address check for contact rewrite. 
     2096     * Note that '!contact_rewritten' check here is to avoid overriding 
     2097     * the current contact generated from last 2xx. 
     2098     */ 
     2099    if (!acc->contact_rewritten && 
     2100        (acc->cfg.contact_rewrite_method & 
    20962101         PJSUA_CONTACT_REWRITE_ALWAYS_UPDATE) == 
    20972102        PJSUA_CONTACT_REWRITE_ALWAYS_UPDATE && 
     
    21042109            param->contact_cnt = 1; 
    21052110            param->contact[0] = acc->reg_contact; 
     2111 
     2112            /* Don't set 'contact_rewritten' to PJ_TRUE here to allow 
     2113             * further check of NAT bound address in 2xx response. 
     2114             */ 
    21062115        } 
    21072116    } 
     
    21782187            update_rfc5626_status(acc, param->rdata); 
    21792188 
    2180             /* Check NAT bound address */ 
    2181             if (acc_check_nat_addr(acc, (acc->cfg.contact_rewrite_method & 3), 
     2189            /* Check NAT bound address if it hasn't been done before */ 
     2190            if (!acc->contact_rewritten && 
     2191                acc_check_nat_addr(acc, (acc->cfg.contact_rewrite_method & 3), 
    21822192                                   param)) 
    21832193            { 
    21842194                PJSUA_UNLOCK(); 
    21852195                pj_log_pop_indent(); 
     2196 
     2197                /* Avoid another check of NAT bound address */ 
     2198                acc->contact_rewritten = PJ_TRUE; 
    21862199                return; 
    21872200            } 
     
    22162229    acc->reg_last_err = param->status; 
    22172230    acc->reg_last_code = param->code; 
     2231 
     2232    /* Reaching this point means no contact rewrite, so reset the flag */ 
     2233    acc->contact_rewritten = PJ_FALSE; 
    22182234 
    22192235    /* Check if we need to auto retry registration. Basically, registration 
Note: See TracChangeset for help on using the changeset viewer.