Changeset 1618


Ignore:
Timestamp:
Dec 5, 2007 4:09:59 AM (16 years ago)
Author:
bennylp
Message:

Fixed error when creating TLS transport in pjsua-lib (the TLS type was misidentified was UDP)

Location:
pjproject/trunk
Files:
3 edited

Legend:

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

    r1561 r1618  
    9191static pjsua_call_id    current_call = PJSUA_INVALID_ID; 
    9292static pj_str_t         uri_arg; 
     93 
     94static pjsua_transport_id   tls_id; 
    9395 
    9496#ifdef STEREO_DEMO 
     
    568570        case OPT_NO_UDP: /* no-udp */ 
    569571            if (cfg->no_tcp) { 
    570               PJ_LOG(1,(THIS_FILE,"Error: can not disable both TCP and UDP")); 
    571               return PJ_EINVAL; 
     572              //PJ_LOG(1,(THIS_FILE,"Error: cannot disable both TCP and UDP")); 
     573              //return PJ_EINVAL; 
    572574            } 
    573575 
     
    581583        case OPT_NO_TCP: /* no-tcp */ 
    582584            if (cfg->no_udp) { 
    583               PJ_LOG(1,(THIS_FILE,"Error: can not disable both TCP and UDP")); 
    584               return PJ_EINVAL; 
     585              //PJ_LOG(1,(THIS_FILE,"Error: cannot disable both TCP and UDP")); 
     586              //return PJ_EINVAL; 
    585587            } 
    586588 
     
    22172219 
    22182220    status = pjsua_acc_create_request(current_acc, &method, dst_uri, &tdata); 
    2219  
    2220     status = pjsip_endpt_send_request(endpt, tdata, -1, NULL, NULL); 
     2221    if (status == PJ_SUCCESS) { 
     2222        status = pjsip_endpt_send_request(endpt, tdata, -1, NULL, NULL); 
     2223    } 
     2224 
    22212225    if (status != PJ_SUCCESS) { 
    2222         pjsua_perror(THIS_FILE, "Unable to send request", status); 
     2226        pjsua_perror(THIS_FILE, "Unable to create/send request", status); 
    22232227        return; 
    22242228    } 
     2229 
    22252230} 
    22262231 
     
    34253430    } 
    34263431 
     3432    /* Add IPv6 UDP */ 
     3433#if 0 && defined(PJ_HAS_IPV6) && PJ_HAS_IPV6 
     3434    if (1) { 
     3435        pjsua_acc_id aid; 
     3436 
     3437        status = pjsua_transport_create(PJSIP_TRANSPORT_UDP6, 
     3438                                        &app_config.udp_cfg,  
     3439                                        &transport_id); 
     3440        if (status != PJ_SUCCESS) 
     3441            goto on_error; 
     3442 
     3443        /* Add local account */ 
     3444        pjsua_acc_add_local(transport_id, PJ_TRUE, &aid); 
     3445        //pjsua_acc_set_transport(aid, transport_id); 
     3446        pjsua_acc_set_online_status(current_acc, PJ_TRUE); 
     3447 
     3448        if (app_config.udp_cfg.port == 0) { 
     3449            pjsua_transport_info ti; 
     3450            pj_sockaddr_in *a; 
     3451 
     3452            pjsua_transport_get_info(transport_id, &ti); 
     3453            a = (pj_sockaddr_in*)&ti.local_addr; 
     3454 
     3455            tcp_cfg.port = pj_ntohs(a->sin_port); 
     3456        } 
     3457    } 
     3458#endif  /* PJ_HAS_IPV6 */ 
     3459 
    34273460    /* Add TCP transport unless it's disabled */ 
    34283461    if (!app_config.no_tcp) { 
     
    34553488            goto on_error; 
    34563489         
     3490        tls_id = transport_id; 
     3491 
    34573492        /* Add local account */ 
    34583493        pjsua_acc_add_local(transport_id, PJ_FALSE, &acc_id); 
     
    35563591        app_config.pool = NULL; 
    35573592    } 
     3593 
     3594    pjsua_transport_close(tls_id, 0); 
    35583595 
    35593596    status = pjsua_destroy(); 
  • pjproject/trunk/pjsip-apps/src/samples/debug.c

    r1576 r1618  
    2929 */ 
    3030//#include "aectest.c" 
     31//#include "strerror.c" 
     32 
    3133#include <pjlib.h> 
     34#include <pjlib-util.h> 
    3235 
     36#define THIS_FILE   "test.c" 
     37 
     38void check_error(const char *func, pj_status_t status) 
     39{ 
     40    if (status != PJ_SUCCESS) { 
     41        char errmsg[PJ_ERR_MSG_SIZE]; 
     42        pj_strerror(status, errmsg, sizeof(errmsg)); 
     43        PJ_LOG(1,(THIS_FILE, "%s error: %s", func, errmsg)); 
     44        exit(1); 
     45    } 
     46} 
     47 
     48#define DO(func)  status = func; check_error(#func, status); 
     49 
     50int main() 
     51{ 
     52    pj_sock_t sock; 
     53    pj_sockaddr_in addr; 
     54    pj_str_t stun_srv = pj_str("stun.fwdnet.net"); 
     55    pj_caching_pool cp; 
     56    pj_status_t status; 
     57 
     58    DO( pj_init() ); 
     59 
     60    pj_caching_pool_init(&cp, NULL, 0); 
     61 
     62    DO( pjlib_util_init() ); 
     63    DO( pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &sock) ); 
     64    DO( pj_sock_bind_in(sock, 0, 0) ); 
     65 
     66    DO( pjstun_get_mapped_addr(&cp.factory, 1, &sock, 
     67                               &stun_srv, 3478, 
     68                               &stun_srv, 3478, 
     69                               &addr) ); 
     70 
     71    PJ_LOG(3,(THIS_FILE, "Mapped address is %s:%d", 
     72              pj_inet_ntoa(addr.sin_addr), 
     73              (int)pj_ntohs(addr.sin_port))); 
     74 
     75    DO( pj_sock_close(sock) ); 
     76    pj_caching_pool_destroy(&cp); 
     77    pj_shutdown(); 
     78 
     79    return 0; 
     80} 
     81 
     82 
     83#if 0 
     84#include <pjlib.h> 
    3385 
    3486static void on_accept_complete(pj_ioqueue_key_t *key,  
     
    88140} 
    89141 
     142#endif 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c

    r1615 r1618  
    13471347 
    13481348    /* Create the transport */ 
    1349     if (type & PJSIP_TRANSPORT_UDP) { 
     1349    if (type==PJSIP_TRANSPORT_UDP || type==PJSIP_TRANSPORT_UDP6) { 
    13501350        /* 
    13511351         * Create UDP transport (IPv4 or IPv6). 
     
    14081408#if defined(PJ_HAS_TCP) && PJ_HAS_TCP!=0 
    14091409 
    1410     } else if (type == PJSIP_TRANSPORT_TCP) { 
     1410    } else if (type == PJSIP_TRANSPORT_TCP || type == PJSIP_TRANSPORT_TCP6) { 
    14111411        /* 
    14121412         * Create TCP transport. 
Note: See TracChangeset for help on using the changeset viewer.