LinphoneAddress * linphone_core_manager_resolve(LinphoneCoreManager *mgr, const LinphoneAddress *source) { struct addrinfo *addrinfo = NULL; char ipstring [INET6_ADDRSTRLEN]; int err; int port = linphone_address_get_port(source); LinphoneAddress * dest; sal_resolve_a( mgr->lc->sal ,linphone_address_get_domain(source) ,linphone_address_get_port(source) ,AF_INET ,(SalResolverCallback)dest_server_server_resolved ,&addrinfo); dest=linphone_address_new(NULL); wait_for(mgr->lc, mgr->lc, (int*)&addrinfo, 1); err=getnameinfo((struct sockaddr*)addrinfo->ai_addr,addrinfo->ai_addrlen,ipstring,INET6_ADDRSTRLEN,NULL,0,NI_NUMERICHOST); if (err !=0 ){ ms_error("linphone_core_manager_resolve(): getnameinfo error %s", gai_strerror(err)); } linphone_address_set_domain(dest, ipstring); if (port > 0) linphone_address_set_port(dest, port); return dest; }
void linphone_core_resolve_stun_server(LinphoneCore *lc){ /* * WARNING: stun server resolution only done in IPv4. * TODO: use IPv6 resolution if linphone_core_ipv6_enabled()==TRUE and use V4Mapped addresses for ICE gathering. */ const char *server=lc->net_conf.stun_server; if (lc->sal && server){ char host[NI_MAXHOST]; int port=3478; linphone_parse_host_port(server,host,sizeof(host),&port); lc->net_conf.stun_res=sal_resolve_a(lc->sal,host,port,AF_INET,(SalResolverCallback)stun_server_resolved,lc); } }