Changeset 1636


Ignore:
Timestamp:
Dec 20, 2007 11:23:07 AM (16 years ago)
Author:
bennylp
Message:

Related to Ticket #429: when bind address is specified and public address is not, the bind address should be used as the public address (thanks Arie Velthoen)

Location:
pjproject/trunk/pjsip/src/pjsua-lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c

    r1621 r1636  
    13001300        pj_bzero(p_pub_addr, sizeof(pj_sockaddr)); 
    13011301 
    1302         status = pj_gethostip(af, p_pub_addr); 
    1303         if (status != PJ_SUCCESS) { 
    1304             pjsua_perror(THIS_FILE, "Unable to get local host IP", status); 
    1305             pj_sock_close(sock); 
    1306             return status; 
     1302        if (pj_sockaddr_has_addr(&bind_addr)) { 
     1303            pj_sockaddr_copy_addr(p_pub_addr, &bind_addr); 
     1304        } else { 
     1305            status = pj_gethostip(af, p_pub_addr); 
     1306            if (status != PJ_SUCCESS) { 
     1307                pjsua_perror(THIS_FILE, "Unable to get local host IP", status); 
     1308                pj_sock_close(sock); 
     1309                return status; 
     1310            } 
    13071311        } 
    13081312 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r1625 r1636  
    347347 
    348348        } else { 
    349             pj_sockaddr addr; 
    350  
    351             /* Get local IP address. */ 
    352             status = pj_gethostip(pj_AF_INET(), &addr); 
    353             if (status != PJ_SUCCESS) 
    354                 goto on_error; 
     349 
     350            if (bound_addr.sin_addr.s_addr == 0) { 
     351                pj_sockaddr addr; 
     352 
     353                /* Get local IP address. */ 
     354                status = pj_gethostip(pj_AF_INET(), &addr); 
     355                if (status != PJ_SUCCESS) 
     356                    goto on_error; 
     357 
     358                bound_addr.sin_addr.s_addr = addr.ipv4.sin_addr.s_addr; 
     359            } 
    355360 
    356361            for (i=0; i<2; ++i) { 
    357362                pj_sockaddr_in_init(&mapped_addr[i], NULL, 0); 
    358                 mapped_addr[i].sin_addr.s_addr = addr.ipv4.sin_addr.s_addr; 
     363                mapped_addr[i].sin_addr.s_addr = bound_addr.sin_addr.s_addr; 
    359364            } 
    360365 
Note: See TracChangeset for help on using the changeset viewer.