diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-10-08 12:39:34 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-10-08 12:39:34 +0000 |
commit | 36413704c1ff24a8e38e0fcf47c9a9c87621e71a (patch) | |
tree | 4393a2f84da0f02f8b1374b0e3ff29d4dce50fb1 /pjsip/src/pjsua-lib/pjsua_core.c | |
parent | b1cdeda73284f461f15c68468369baf7556cb0e3 (diff) |
Major addition to support DNS SRV resolution in PJSIP:
- added DNS asynchronous/caching resolver engine in
PJLIB-UTIL (resolver.[hc])
- modified SIP resolver (sip_resolve.c) to properly
perform DNS SRV/A resolution when DNS resolution is
enabled.
- added dns_test.c in PJSIP-TEST for testing the SIP
resolver.
- added nameserver configuration in PJSUA-LIB
- added "--nameserver" option in PJSUA.
- updated project/Makefiles and doxygen documentation.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@753 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua-lib/pjsua_core.c')
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_core.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c index 6b39fdbb..b4f4325f 100644 --- a/pjsip/src/pjsua-lib/pjsua_core.c +++ b/pjsip/src/pjsua-lib/pjsua_core.c @@ -456,6 +456,45 @@ PJ_DEF(pj_status_t) pjsua_init( const pjsua_config *ua_cfg, PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); } + /* If nameserver is configured, create DNS resolver instance and + * set it to be used by SIP resolver. + */ + if (ua_cfg->nameserver_count) { +#if PJSIP_HAS_RESOLVER + pj_dns_resolver *resv; + unsigned i; + + /* Create DNS resolver */ + status = pjsip_endpt_create_resolver(pjsua_var.endpt, &resv); + PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); + + /* Configure nameserver for the DNS resolver */ + status = pj_dns_resolver_set_ns(resv, ua_cfg->nameserver_count, + ua_cfg->nameserver, NULL); + if (status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "Error setting nameserver", status); + return status; + } + + /* Set this DNS resolver to be used by the SIP resolver */ + status = pjsip_endpt_set_resolver(pjsua_var.endpt, resv); + if (status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "Error setting DNS resolver", status); + return status; + } + + /* Print nameservers */ + for (i=0; i<ua_cfg->nameserver_count; ++i) { + PJ_LOG(4,(THIS_FILE, "Nameserver %.*s added", + (int)ua_cfg->nameserver[i].slen, + ua_cfg->nameserver[i].ptr)); + } +#else + PJ_LOG(2,(THIS_FILE, + "DNS resolver is disabled (PJSIP_HAS_RESOLVER==0)")); +#endif + } + /* Init SIP UA: */ /* Initialize transaction layer: */ |