Changeset 4543


Ignore:
Timestamp:
Jun 24, 2013 9:53:16 AM (11 years ago)
Author:
bennylp
Message:

Closed #1668: Option to use the IP address found in REGISTER response in the SDP

Location:
pjproject/trunk/pjsip
Files:
4 edited

Legend:

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

    r4534 r4543  
    30323032 
    30333033    /** 
     3034     * This option controls whether the IP address in SDP should be replaced 
     3035     * with the IP address found in Via header of the REGISTER response, ONLY 
     3036     * when STUN and ICE are not used. If the value is FALSE (the original 
     3037     * behavior), then the local IP address will be used. If TRUE, and when 
     3038     * STUN and ICE are disabled, then the IP address found in registration 
     3039     * response will be used. 
     3040     * 
     3041     * Default: PJ_FALSE (no) 
     3042     */ 
     3043    pj_bool_t        allow_sdp_nat_rewrite; 
     3044 
     3045    /** 
    30343046     * Control the use of SIP outbound feature. SIP outbound is described in 
    30353047     * RFC 5626 to enable proxies or registrar to send inbound requests back 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h

    r4542 r4543  
    230230    int              reg_last_code; /**< Last status last register.     */ 
    231231 
     232    pj_str_t         reg_mapped_addr;/**< Our addr as seen by reg srv. 
     233                                          Only if allow_sdp_nat_rewrite 
     234                                          is set                        */ 
     235 
    232236    struct { 
    233237        pj_bool_t        active;    /**< Flag of reregister status.     */ 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c

    r4542 r4543  
    651651    acc->valid = PJ_FALSE; 
    652652    acc->contact.slen = 0; 
     653    acc->reg_mapped_addr.slen = 0; 
    653654    pj_bzero(&acc->via_addr, sizeof(acc->via_addr)); 
    654655    acc->via_tp = NULL; 
     
    12561257            acc->regc = NULL; 
    12571258            acc->contact.slen = 0; 
     1259            acc->reg_mapped_addr.slen = 0; 
    12581260        } 
    12591261    } 
     
    14641466                                               &acc->via_addr, acc->via_tp); 
    14651467        } 
     1468    } 
     1469 
     1470    /* Save mapped address if needed */ 
     1471    if (acc->cfg.allow_sdp_nat_rewrite && 
     1472        pj_strcmp(&acc->reg_mapped_addr, via_addr)) 
     1473    { 
     1474        pj_strdup(acc->pool, &acc->reg_mapped_addr, via_addr); 
    14661475    } 
    14671476 
     
    19901999        acc->regc = NULL; 
    19912000        acc->contact.slen = 0; 
     2001        acc->reg_mapped_addr.slen = 0; 
    19922002         
    19932003        /* Stop keep-alive timer if any. */ 
     
    20012011        acc->regc = NULL; 
    20022012        acc->contact.slen = 0; 
     2013        acc->reg_mapped_addr.slen = 0; 
    20032014 
    20042015        /* Stop keep-alive timer if any. */ 
     
    20152026            acc->regc = NULL; 
    20162027            acc->contact.slen = 0; 
     2028            acc->reg_mapped_addr.slen = 0; 
    20172029 
    20182030            /* Stop keep-alive timer if any. */ 
     
    21202132        acc->regc = NULL; 
    21212133        acc->contact.slen = 0; 
     2134        acc->reg_mapped_addr.slen = 0; 
    21222135    } 
    21232136 
     
    21682181        acc->regc = NULL; 
    21692182        acc->contact.slen = 0; 
     2183        acc->reg_mapped_addr.slen = 0; 
    21702184        return status; 
    21712185    } 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r4542 r4543  
    240240    pj_status_t status = PJ_SUCCESS; 
    241241    char addr_buf[PJ_INET6_ADDRSTRLEN+10]; 
     242    pjsua_acc *acc; 
    242243    pj_sock_t sock[2]; 
    243     pjsua_acc *acc = &pjsua_var.acc[call_med->call->acc_id]; 
    244244 
    245245    use_ipv6 = (acc->cfg.ipv6_media_use != PJSUA_IPV6_DISABLED); 
    246246    af = use_ipv6 ? pj_AF_INET6() : pj_AF_INET(); 
     247 
     248    acc = &pjsua_var.acc[call_med->call->acc_id]; 
    247249 
    248250    /* Make sure STUN server resolution has completed */ 
     
    424426 
    425427        } else { 
     428            if (acc->cfg.allow_sdp_nat_rewrite && acc->reg_mapped_addr.slen) { 
     429                pj_status_t status; 
     430 
     431                /* Take the address from mapped addr as seen by registrar */ 
     432                status = pj_sockaddr_set_str_addr(af, &bound_addr, 
     433                                                  &acc->reg_mapped_addr); 
     434                if (status != PJ_SUCCESS) { 
     435                    /* just leave bound_addr with whatever it was 
     436                    pj_bzero(pj_sockaddr_get_addr(&bound_addr), 
     437                             pj_sockaddr_get_addr_len(&bound_addr)); 
     438                     */ 
     439                } 
     440            } 
    426441 
    427442            if (!pj_sockaddr_has_addr(&bound_addr)) { 
Note: See TracChangeset for help on using the changeset viewer.