From c1da22781bc970d7948f35e5fa6ede7b54f45549 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Thu, 20 Sep 2012 06:00:23 +0000 Subject: Fixed #1585: IPv6 support for SIP TCP and TLS transports and PJSUA-LIB v2 git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4262 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip-apps/src/pjsua/pjsua_app.c | 167 ++++++++++++++------------------------- 1 file changed, 61 insertions(+), 106 deletions(-) (limited to 'pjsip-apps') diff --git a/pjsip-apps/src/pjsua/pjsua_app.c b/pjsip-apps/src/pjsua/pjsua_app.c index b6a253c7..494520e7 100644 --- a/pjsip-apps/src/pjsua/pjsua_app.c +++ b/pjsip-apps/src/pjsua/pjsua_app.c @@ -170,7 +170,6 @@ static char some_buf[SOME_BUF_SIZE]; #ifdef STEREO_DEMO static void stereo_demo(); #endif -static pj_status_t create_ipv6_media_transports(void); pj_status_t app_destroy(void); static void ringback_start(pjsua_call_id call_id); @@ -876,8 +875,8 @@ static pj_status_t parse_args(int argc, char *argv[], break; case OPT_NO_UDP: /* no-udp */ - if (cfg->no_tcp) { - PJ_LOG(1,(THIS_FILE,"Error: can not disable both TCP and UDP")); + if (cfg->no_tcp && !cfg->use_tls) { + PJ_LOG(1,(THIS_FILE,"Error: cannot disable both TCP and UDP")); return PJ_EINVAL; } @@ -889,8 +888,8 @@ static pj_status_t parse_args(int argc, char *argv[], break; case OPT_NO_TCP: /* no-tcp */ - if (cfg->no_udp) { - PJ_LOG(1,(THIS_FILE,"Error: can not disable both TCP and UDP")); + if (cfg->no_udp && !cfg->use_tls) { + PJ_LOG(1,(THIS_FILE,"Error: cannot disable both TCP and UDP")); return PJ_EINVAL; } @@ -5907,6 +5906,8 @@ pj_status_t app_init(int argc, char *argv[]) pjsua_acc_config acc_cfg; pjsua_acc_get_config(aid, &acc_cfg); app_config_init_video(&acc_cfg); + if (app_config.ipv6) + acc_cfg.ipv6_media_use = PJSUA_IPV6_ENABLED; pjsua_acc_modify(aid, &acc_cfg); } //pjsua_acc_set_transport(aid, transport_id); @@ -5945,6 +5946,33 @@ pj_status_t app_init(int argc, char *argv[]) } + /* Add TCP IPv6 transport unless it's disabled. */ + if (!app_config.no_tcp && app_config.ipv6) { + pjsua_acc_id aid; + pjsip_transport_type_e type = PJSIP_TRANSPORT_TCP6; + + tcp_cfg.port += 10; + + status = pjsua_transport_create(type, + &tcp_cfg, + &transport_id); + if (status != PJ_SUCCESS) + goto on_error; + + /* Add local account */ + pjsua_acc_add_local(transport_id, PJ_TRUE, &aid); + if (PJMEDIA_HAS_VIDEO) { + pjsua_acc_config acc_cfg; + pjsua_acc_get_config(aid, &acc_cfg); + app_config_init_video(&acc_cfg); + if (app_config.ipv6) + acc_cfg.ipv6_media_use = PJSUA_IPV6_ENABLED; + pjsua_acc_modify(aid, &acc_cfg); + } + //pjsua_acc_set_transport(aid, transport_id); + pjsua_acc_set_online_status(current_acc, PJ_TRUE); + } + #if defined(PJSIP_HAS_TLS_TRANSPORT) && PJSIP_HAS_TLS_TRANSPORT!=0 /* Add TLS transport when application wants one */ @@ -5976,6 +6004,34 @@ pj_status_t app_init(int argc, char *argv[]) } pjsua_acc_set_online_status(acc_id, PJ_TRUE); } + + /* Add TLS IPv6 transport unless it's disabled. */ + if (app_config.use_tls && app_config.ipv6) { + pjsua_acc_id aid; + pjsip_transport_type_e type = PJSIP_TRANSPORT_TLS6; + + tcp_cfg.port += 10; + + status = pjsua_transport_create(type, + &tcp_cfg, + &transport_id); + if (status != PJ_SUCCESS) + goto on_error; + + /* Add local account */ + pjsua_acc_add_local(transport_id, PJ_TRUE, &aid); + if (PJMEDIA_HAS_VIDEO) { + pjsua_acc_config acc_cfg; + pjsua_acc_get_config(aid, &acc_cfg); + app_config_init_video(&acc_cfg); + if (app_config.ipv6) + acc_cfg.ipv6_media_use = PJSUA_IPV6_ENABLED; + pjsua_acc_modify(aid, &acc_cfg); + } + //pjsua_acc_set_transport(aid, transport_id); + pjsua_acc_set_online_status(current_acc, PJ_TRUE); + } + #endif if (transport_id == -1) { @@ -6026,16 +6082,6 @@ pj_status_t app_init(int argc, char *argv[]) #endif } - /* Add RTP transports */ - if (app_config.ipv6) - status = create_ipv6_media_transports(); - #if DISABLED_FOR_TICKET_1185 - else - status = pjsua_media_transports_create(&app_config.rtp_cfg); - #endif - if (status != PJ_SUCCESS) - goto on_error; - /* Use null sound device? */ #ifndef STEREO_DEMO if (app_config.null_audio) { @@ -6251,94 +6297,3 @@ static void stereo_demo() } #endif -static pj_status_t create_ipv6_media_transports(void) -{ - pjsua_media_transport tp[PJSUA_MAX_CALLS]; - pj_status_t status; - int port = app_config.rtp_cfg.port; - unsigned i; - - for (i=0; i