Changeset 4802


Ignore:
Timestamp:
Mar 25, 2014 4:08:44 AM (10 years ago)
Author:
riza
Message:

Re #1752: Add option to resolve hostname when trying to get network interface.

Location:
pjproject/trunk/pjsip
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip/sip_config.h

    r4770 r4802  
    138138        pj_bool_t req_has_via_alias; 
    139139 
     140        /** 
     141         * Resolve hostname when trying to get the network interface to be put  
     142         * in Via or Contact header. 
     143         * 
     144         * Default is PJSIP_RESOLVE_HOSTNAME_TO_GET_INTERFACE. 
     145         */ 
     146        pj_bool_t resolve_hostname_to_get_interface; 
     147 
    140148    } endpt; 
    141149 
     
    364372#endif 
    365373 
     374/** 
     375 * Resolve hostname when trying to get the network interface to be put in Via  
     376 * or Contact header. 
     377 * 
     378 * This option can also be controlled at run-time by the 
     379 * \a resolve_hostname_to_get_interface setting in pjsip_cfg_t. 
     380 * 
     381 * Default is PJ_FALSE. 
     382 */ 
     383#ifndef PJSIP_RESOLVE_HOSTNAME_TO_GET_INTERFACE 
     384#   define PJSIP_RESOLVE_HOSTNAME_TO_GET_INTERFACE  PJ_FALSE 
     385#endif 
    366386 
    367387/** 
  • pjproject/trunk/pjsip/src/pjsip/sip_config.c

    r4770 r4802  
    3333       PJSIP_DONT_SWITCH_TO_TLS, 
    3434       PJSIP_FOLLOW_EARLY_MEDIA_FORK, 
    35        PJSIP_REQ_HAS_VIA_ALIAS 
     35       PJSIP_REQ_HAS_VIA_ALIAS, 
     36       PJSIP_RESOLVE_HOSTNAME_TO_GET_INTERFACE 
    3637    }, 
    3738 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport.c

    r4775 r4802  
    12921292    int af; 
    12931293    pj_sockaddr itf_addr; 
    1294     pj_status_t status; 
     1294    pj_status_t status = -1; 
    12951295 
    12961296    af = (tp_type & PJSIP_TRANSPORT_IPV6)? PJ_AF_INET6 : PJ_AF_INET; 
    1297     status = pj_getipinterface(af, dst, &itf_addr, PJ_FALSE, NULL); 
    1298     if (status != PJ_SUCCESS) { 
    1299         /* If it fails, e.g: on WM6 (http://support.microsoft.com/kb/129065), 
    1300          * just fallback using pj_gethostip(), see ticket #1660. 
    1301          */ 
    1302         PJ_LOG(5,(THIS_FILE,"Warning: unable to determine local " 
    1303                             "interface, fallback to default interface!")); 
    1304         status = pj_gethostip(af, &itf_addr); 
    1305         if (status != PJ_SUCCESS) 
    1306             return status; 
     1297 
     1298    if (pjsip_cfg()->endpt.resolve_hostname_to_get_interface) { 
     1299        status = pj_getipinterface(af, dst, &itf_addr, PJ_TRUE, NULL); 
     1300    } 
     1301 
     1302    if (status != PJ_SUCCESS) {  
     1303        status = pj_getipinterface(af, dst, &itf_addr, PJ_FALSE, NULL); 
     1304        if (status != PJ_SUCCESS) { 
     1305            /* If it fails, e.g: on WM6(http://support.microsoft.com/kb/129065), 
     1306             * just fallback using pj_gethostip(), see ticket #1660. 
     1307             */ 
     1308            PJ_LOG(5,(THIS_FILE,"Warning: unable to determine local " 
     1309                                "interface, fallback to default interface!")); 
     1310            status = pj_gethostip(af, &itf_addr); 
     1311            if (status != PJ_SUCCESS) 
     1312                return status; 
     1313        } 
    13071314    } 
    13081315 
Note: See TracChangeset for help on using the changeset viewer.