Changeset 4347 for pjproject


Ignore:
Timestamp:
Feb 13, 2013 10:19:25 AM (11 years ago)
Author:
nanang
Message:

Close #1614: Added call redirect option PJSIP_REDIRECT_ACCEPT_REPLACE to accept call redirection with replaced 'To' header.

Location:
pjproject/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c

    r4330 r4347  
    378378    puts  ("  --no-force-lr       Allow strict-route to be used (i.e. do not force lr)"); 
    379379    puts  ("  --accept-redirect=N Specify how to handle call redirect (3xx) response."); 
    380     puts  ("                      0: reject, 1: follow automatically (default), 2: ask"); 
     380    puts  ("                      0: reject, 1: follow automatically,"); 
     381    puts  ("                      2: follow + replace To header (default), 3: ask"); 
    381382 
    382383    puts  (""); 
     
    405406    pjsua_transport_config_default(&cfg->rtp_cfg); 
    406407    cfg->rtp_cfg.port = 4000; 
    407     cfg->redir_op = PJSIP_REDIRECT_ACCEPT; 
     408    cfg->redir_op = PJSIP_REDIRECT_ACCEPT_REPLACE; 
    408409    cfg->duration = NO_LIMIT; 
    409410    cfg->wav_id = PJSUA_INVALID_ID; 
     
    22422243 
    22432244    /* accept-redirect */ 
    2244     if (config->redir_op != PJSIP_REDIRECT_ACCEPT) { 
     2245    if (config->redir_op != PJSIP_REDIRECT_ACCEPT_REPLACE) { 
    22452246        pj_ansi_sprintf(line, "--accept-redirect %d\n", 
    22462247                        config->redir_op); 
     
    30523053 
    30533054        PJ_LOG(3,(THIS_FILE, "Call %d is being redirected to %.*s. " 
    3054                   "Press 'Ra' to accept, 'Rr' to reject, or 'Rd' to " 
    3055                   "disconnect.", 
     3055                  "Press 'Ra' to accept+replace To header, 'RA' to accept, " 
     3056                  "'Rr' to reject, or 'Rd' to disconnect.", 
    30563057                  call_id, len, uristr)); 
    30573058    } 
     
    53825383            } else if (menuin[1] == 'a') { 
    53835384                pjsua_call_process_redirect(current_call,  
     5385                                            PJSIP_REDIRECT_ACCEPT_REPLACE); 
     5386            } else if (menuin[1] == 'A') { 
     5387                pjsua_call_process_redirect(current_call,  
    53845388                                            PJSIP_REDIRECT_ACCEPT); 
    53855389            } else if (menuin[1] == 'r') { 
  • pjproject/trunk/pjsip/include/pjsip/sip_util.h

    r3553 r4347  
    9191     */ 
    9292    PJSIP_REDIRECT_ACCEPT, 
     93 
     94    /** 
     95     * Accept the redirection to the current target and replace the To 
     96     * header in the INVITE request with the current target. The INVITE 
     97     * request will be resent to the current target. 
     98     */ 
     99    PJSIP_REDIRECT_ACCEPT_REPLACE, 
    93100 
    94101    /** 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r4343 r4347  
    11261126     * received redirection response. 
    11271127     * 
    1128      * Application may accept the redirection to the specified target  
    1129      * (the default behavior if this callback is implemented), reject  
    1130      * this target only and make the session continue to try the next  
     1128     * Application may accept the redirection to the specified target, 
     1129     * reject this target only and make the session continue to try the next  
    11311130     * target in the list if such target exists, stop the whole 
    11321131     * redirection process altogether and cause the session to be 
     
    11481147     *                  parameter to one of the value below: 
    11491148     *                  - PJSIP_REDIRECT_ACCEPT: immediately accept the 
    1150      *                    redirection (default value). When set, the 
    1151      *                    call will immediately resend INVITE request 
    1152      *                    to the target. 
     1149     *                    redirection. When set, the call will immediately 
     1150     *                    resend INVITE request to the target. 
     1151     *                  - PJSIP_REDIRECT_ACCEPT_REPLACE: immediately accept 
     1152     *                    the redirection and replace the To header with the 
     1153     *                    current target. When set, the call will immediately 
     1154     *                    resend INVITE request to the target. 
    11531155     *                  - PJSIP_REDIRECT_REJECT: immediately reject this 
    11541156     *                    target. The call will continue retrying with 
  • pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c

    r4323 r4347  
    23302330    switch (op) { 
    23312331    case PJSIP_REDIRECT_ACCEPT: 
     2332    case PJSIP_REDIRECT_ACCEPT_REPLACE: 
    23322333    case PJSIP_REDIRECT_STOP: 
    23332334        /* Must increment session counter, that's the convention of the  
     
    23952396    switch (op) { 
    23962397    case PJSIP_REDIRECT_ACCEPT: 
     2398    case PJSIP_REDIRECT_ACCEPT_REPLACE: 
    23972399        /* User accept the redirection. Reset the session and resend the  
    23982400         * INVITE request. 
     
    24192421                  pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL); 
    24202422            via->branch_param.slen = 0; 
     2423 
     2424            /* Process PJSIP_REDIRECT_ACCEPT_REPLACE */ 
     2425            if (op == PJSIP_REDIRECT_ACCEPT_REPLACE) { 
     2426                pjsip_to_hdr *to; 
     2427                pjsip_dialog *dlg = inv->dlg; 
     2428                enum { TMP_LEN = 128 }; 
     2429                char tmp[TMP_LEN]; 
     2430                int len; 
     2431 
     2432                /* Replace To header */ 
     2433                to = PJSIP_MSG_TO_HDR(tdata->msg); 
     2434                to->uri = (pjsip_uri*) 
     2435                          pjsip_uri_clone(tdata->pool, 
     2436                                          dlg->target_set.current->uri); 
     2437                to->tag.slen = 0; 
     2438                pj_list_init(&to->other_param); 
     2439                 
     2440                /* Re-init dialog remote info */ 
     2441                dlg->remote.info = (pjsip_to_hdr*) 
     2442                                   pjsip_hdr_clone(dlg->pool, to); 
     2443 
     2444                /* Remove header param from remote info */ 
     2445                if (PJSIP_URI_SCHEME_IS_SIP(dlg->remote.info->uri) || 
     2446                    PJSIP_URI_SCHEME_IS_SIPS(dlg->remote.info->uri)) 
     2447                { 
     2448                    pjsip_sip_uri *sip_uri = (pjsip_sip_uri *)  
     2449                                   pjsip_uri_get_uri(dlg->remote.info->uri); 
     2450                    if (!pj_list_empty(&sip_uri->header_param)) { 
     2451                        /* Remove all header param */ 
     2452                        pj_list_init(&sip_uri->header_param); 
     2453                    } 
     2454                } 
     2455 
     2456                /* Print the remote info. */ 
     2457                len = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, 
     2458                                      dlg->remote.info->uri, tmp, TMP_LEN); 
     2459                if (len < 1) { 
     2460                    pj_ansi_strcpy(tmp, "<-error: uri too long->"); 
     2461                    len = pj_ansi_strlen(tmp); 
     2462                } 
     2463                pj_strdup2_with_null(dlg->pool, &dlg->remote.info_str, tmp); 
     2464 
     2465                /* Secure? */ 
     2466                dlg->secure = PJSIP_URI_SCHEME_IS_SIPS(to->uri); 
     2467            } 
    24212468 
    24222469            /* Reset message destination info (see #1248). */ 
Note: See TracChangeset for help on using the changeset viewer.