static pj_status_t get_net_interface(pjsip_transport_type_e tp_type,
				     const pj_str_t *dst,
                                     pj_str_t *itf_str_addr)
{
    int af;
    pj_sockaddr itf_addr;
    pj_status_t status = -1;

    af = (tp_type & PJSIP_TRANSPORT_IPV6)? pj_AF_INET6() : pj_AF_INET();

    if (pjsip_cfg()->endpt.resolve_hostname_to_get_interface) {
	status = pj_getipinterface(af, dst, &itf_addr, PJ_TRUE, NULL);
    }

    if (status != PJ_SUCCESS) { 
	status = pj_getipinterface(af, dst, &itf_addr, PJ_FALSE, NULL);
	if (status != PJ_SUCCESS) {
	    /* If it fails, e.g: on WM6(http://support.microsoft.com/kb/129065),
	     * just fallback using pj_gethostip(), see ticket #1660.
	     */
	    PJ_PERROR(5,(THIS_FILE, status,
			 "Warning: unable to determine local interface, "
			 "fallback to default interface!"));
	    status = pj_gethostip(af, &itf_addr);
	    if (status != PJ_SUCCESS)
		return status;
	}
    }

    /* Print address */
    pj_sockaddr_print(&itf_addr, itf_str_addr->ptr,
		      PJ_INET6_ADDRSTRLEN, 0);
    itf_str_addr->slen = pj_ansi_strlen(itf_str_addr->ptr);

    return PJ_SUCCESS;
}
static pj_status_t get_net_interface(pjsip_transport_type_e tp_type,
				     const pj_str_t *dst,
                                     pj_str_t *itf_str_addr)
{
    int af;
    pj_sockaddr itf_addr;
    pj_status_t status = -1;

    af = (tp_type & PJSIP_TRANSPORT_IPV6)? pj_AF_INET6() : pj_AF_INET();

    if (pjsip_cfg()->endpt.resolve_hostname_to_get_interface) {
	status = pj_getipinterface(af, dst, &itf_addr, PJ_TRUE, NULL);
    }

    if (status != PJ_SUCCESS) { 
	status = pj_getipinterface(af, dst, &itf_addr, PJ_FALSE, NULL);
	if (status != PJ_SUCCESS) {
	     
	    PJ_PERROR(5,(THIS_FILE, status,
			 "Warning: unable to determine local interface, "
			 "fallback to default interface!"));
	    status = pj_gethostip(af, &itf_addr);
	    if (status != PJ_SUCCESS)
		return status;
	}
    }

     
    pj_sockaddr_print(&itf_addr, itf_str_addr->ptr,
		      PJ_INET6_ADDRSTRLEN, 0);
    itf_str_addr->slen = pj_ansi_strlen(itf_str_addr->ptr);

    return PJ_SUCCESS;
}