Changeset 1102 for pjproject/trunk
- Timestamp:
- Mar 24, 2007 5:37:25 PM (18 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/build/pjlib_util.dsp
r1062 r1102 142 142 # Begin Source File 143 143 144 SOURCE="..\src\pjlib-util\srv_resolver.c" 145 # End Source File 146 # Begin Source File 147 144 148 SOURCE="..\src\pjlib-util\string.c" 145 149 # End Source File … … 219 223 220 224 SOURCE="..\include\pjlib-util\sha1.h" 225 # End Source File 226 # Begin Source File 227 228 SOURCE="..\include\pjlib-util\srv_resolver.h" 221 229 # End Source File 222 230 # Begin Source File -
pjproject/trunk/pjlib-util/build/pjlib_util.vcproj
r1100 r1102 5 5 Name="pjlib_util" 6 6 ProjectGUID="{FE07F272-AE7F-4549-9E9F-EF9B80CB1693}" 7 RootNamespace="pjlib_util" 7 8 > 8 9 <Platforms> … … 466 467 </File> 467 468 <File 469 RelativePath="..\src\pjlib-util\srv_resolver.c" 470 > 471 </File> 472 <File 468 473 RelativePath="..\src\pjlib-util\string.c" 469 474 > … … 637 642 </File> 638 643 <File 644 RelativePath="..\include\pjlib-util\srv_resolver.h" 645 > 646 </File> 647 <File 639 648 RelativePath="..\include\pjlib-util\string.h" 640 649 > -
pjproject/trunk/pjlib-util/include/pjlib-util.h
r1062 r1102 42 42 #include <pjlib-util/dns.h> 43 43 #include <pjlib-util/resolver.h> 44 #include <pjlib-util/srv_resolver.h> 44 45 45 46 /* Text scanner */ -
pjproject/trunk/pjsip-apps/build/sample_debug.dsp
r794 r1102 43 43 # PROP Target_Dir "" 44 44 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 45 # ADD CPP /nologo /MD /W3 /Zi /O2 /I "../../pjsip/include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../../pjmedia/include" / D PJ_WIN32=1 /D PJ_M_I386=1 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /c45 # ADD CPP /nologo /MD /W3 /Zi /O2 /I "../../pjsip/include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../../pjmedia/include" /I "../../pjnath/include" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /c 46 46 # SUBTRACT CPP /YX 47 47 # ADD BASE RSC /l 0x409 /d "NDEBUG" … … 69 69 # PROP Target_Dir "" 70 70 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 71 # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../../pjsip/include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../../pjmedia/include" / D PJ_WIN32=1 /D PJ_M_I386=1 /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c71 # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../../pjsip/include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../../pjmedia/include" /I "../../pjnath/include" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c 72 72 # ADD BASE RSC /l 0x409 /d "_DEBUG" 73 73 # ADD RSC /l 0x409 /d "_DEBUG" -
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r1098 r1102 326 326 OPT_REGISTRAR, OPT_REG_TIMEOUT, OPT_PUBLISH, OPT_ID, OPT_CONTACT, 327 327 OPT_REALM, OPT_USERNAME, OPT_PASSWORD, 328 OPT_NAMESERVER, OPT_STUN_ SRV,328 OPT_NAMESERVER, OPT_STUN_DOMAIN, OPT_STUN_SRV, 329 329 OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE, 330 330 OPT_AUTO_ANSWER, OPT_AUTO_HANGUP, OPT_AUTO_PLAY, OPT_AUTO_LOOP, … … 367 367 { "password", 1, 0, OPT_PASSWORD}, 368 368 { "nameserver", 1, 0, OPT_NAMESERVER}, 369 { "stun-domain",1, 0, OPT_STUN_DOMAIN}, 369 370 { "stun-srv", 1, 0, OPT_STUN_SRV}, 370 371 { "add-buddy", 1, 0, OPT_ADD_BUDDY}, … … 632 633 break; 633 634 635 case OPT_STUN_DOMAIN: /* STUN domain */ 636 cfg->cfg.stun_domain = pj_str(pj_optarg); 637 break; 638 634 639 case OPT_STUN_SRV: /* STUN server */ 635 cfg->cfg.stun_ srv= pj_str(pj_optarg);640 cfg->cfg.stun_host = pj_str(pj_optarg); 636 641 break; 637 642 … … 1084 1089 1085 1090 /* STUN */ 1086 if (config->cfg.stun_srv.slen) { 1091 if (config->cfg.stun_domain.slen) { 1092 pj_ansi_sprintf(line, "--stun-domain %.*s\n", 1093 (int)config->cfg.stun_domain.slen, 1094 config->cfg.stun_domain.ptr); 1095 pj_strcat2(&cfg, line); 1096 } 1097 if (config->cfg.stun_host.slen) { 1087 1098 pj_ansi_sprintf(line, "--stun-srv %.*s\n", 1088 (int)config->cfg.stun_ srv.slen,1089 config->cfg.stun_ srv.ptr);1099 (int)config->cfg.stun_host.slen, 1100 config->cfg.stun_host.ptr); 1090 1101 pj_strcat2(&cfg, line); 1091 1102 } -
pjproject/trunk/pjsip/build/test_pjsip.dsp
r753 r1102 43 43 # PROP Target_Dir "" 44 44 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 45 # ADD CPP /nologo /MD /W3 /Zi /O2 /Ob2 /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" / D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "PJ_WIN32" /D "PJ_M_I386" /FR /FD /c45 # ADD CPP /nologo /MD /W3 /Zi /O2 /Ob2 /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../../pjnath/include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "PJ_WIN32" /D "PJ_M_I386" /FR /FD /c 46 46 # SUBTRACT CPP /YX 47 47 # ADD BASE RSC /l 0x409 /d "NDEBUG" … … 68 68 # PROP Target_Dir "" 69 69 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 70 # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" / D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "PJ_WIN32" /D "PJ_M_I386" /FR /FD /GZ /c70 # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../../pjnath/include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "PJ_WIN32" /D "PJ_M_I386" /FR /FD /GZ /c 71 71 # SUBTRACT CPP /YX 72 72 # ADD BASE RSC /l 0x409 /d "_DEBUG" -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r1098 r1102 904 904 905 905 /** 906 * Specify STUN server. This server will be first resolved with DNS SRV 907 * to get the actual server address. If DNS SRV resolution failed, or 908 * when nameserver is not configured, the server will be resolved using 909 * DNS A resolution (i.e. gethostbyname()). 910 */ 911 pj_str_t stun_srv; 906 * Specify domain name to be resolved with DNS SRV resolution to get the 907 * address of the STUN servers. Alternatively application may specify 908 * \a stun_host and \a stun_relay_host instead. 909 * 910 * If DNS SRV resolution failed for this domain, then DNS A resolution 911 * will be performed only if \a stun_host is specified. 912 */ 913 pj_str_t stun_domain; 914 915 /** 916 * Specify STUN server to be used. 917 */ 918 pj_str_t stun_host; 919 920 /** 921 * Specify STUN relay server to be used. 922 */ 923 pj_str_t stun_relay_host; 912 924 913 925 /** … … 1010 1022 1011 1023 pj_strdup_with_null(pool, &dst->user_agent, &src->user_agent); 1012 pj_strdup_with_null(pool, &dst->stun_srv, &src->stun_srv); 1024 pj_strdup_with_null(pool, &dst->stun_domain, &src->stun_domain); 1025 pj_strdup_with_null(pool, &dst->stun_host, &src->stun_host); 1026 pj_strdup_with_null(pool, &dst->stun_relay_host, &src->stun_relay_host); 1013 1027 } 1014 1028 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r1101 r1102 653 653 } 654 654 655 656 static pj_status_t resolve_stun_server(pj_bool_t use_dns_srv); 657 658 /* 659 * Callback function to receive notification from the resolver 660 * when the resolution process completes. 661 */ 662 static void stun_dns_srv_resolver_cb(void *user_data, 663 pj_status_t status, 664 const pj_dns_srv_record *rec) 665 { 666 unsigned i; 667 668 PJ_UNUSED_ARG(user_data); 669 670 pjsua_var.stun_status = status; 671 672 if (status != PJ_SUCCESS) { 673 /* DNS SRV resolution failed. If stun_host is specified, resolve 674 * it with gethostbyname() 675 */ 676 if (pjsua_var.ua_cfg.stun_host.slen) { 677 pj_hostent he; 678 679 pjsua_var.stun_status = pj_gethostbyname(&pjsua_var.ua_cfg.stun_host, &he); 680 681 if (pjsua_var.stun_status == PJ_SUCCESS) { 682 pj_sockaddr_in_init(&pjsua_var.stun_srv.ipv4, NULL, 0); 683 pjsua_var.stun_srv.ipv4.sin_addr = *(pj_in_addr*)he.h_addr; 684 pjsua_var.stun_srv.ipv4.sin_port = pj_htons((pj_uint16_t)3478); 685 686 PJ_LOG(3,(THIS_FILE, 687 "STUN server %.*s resolved, address is %s:%d", 688 (int)pjsua_var.ua_cfg.stun_host.slen, 689 pjsua_var.ua_cfg.stun_host.ptr, 690 pj_inet_ntoa(pjsua_var.stun_srv.ipv4.sin_addr), 691 (int)pj_ntohs(pjsua_var.stun_srv.ipv4.sin_port))); 692 } 693 } else { 694 char errmsg[PJ_ERR_MSG_SIZE]; 695 696 pj_strerror(status, errmsg, sizeof(errmsg)); 697 PJ_LOG(1,(THIS_FILE, 698 "DNS SRV resolution failed for STUN server %.*s: %s", 699 (int)pjsua_var.ua_cfg.stun_domain.slen, 700 pjsua_var.ua_cfg.stun_domain.ptr, 701 errmsg)); 702 } 703 return; 704 } 705 706 pj_memcpy(&pjsua_var.stun_srv, &rec->entry[0].addr, 707 rec->entry[0].addr_len); 708 709 PJ_LOG(3,(THIS_FILE, "_stun._udp.%.*s resolved, found %d entry(s):", 710 (int)pjsua_var.ua_cfg.stun_domain.slen, 711 pjsua_var.ua_cfg.stun_domain.ptr, 712 rec->count)); 713 714 for (i=0; i<rec->count; ++i) { 715 PJ_LOG(3,(THIS_FILE, 716 " %d: prio=%d, weight=%d %s:%d", 717 i, rec->entry[i].priority, rec->entry[i].weight, 718 pj_inet_ntoa(rec->entry[i].addr.ipv4.sin_addr), 719 (int)pj_ntohs(rec->entry[i].addr.ipv4.sin_port))); 720 } 721 722 } 723 655 724 /* 656 725 * Resolve STUN server. … … 665 734 666 735 /* Start STUN server resolution */ 667 /* For now just do DNS A resolution */ 668 669 if (pjsua_var.ua_cfg.stun_srv.slen == 0) { 670 pjsua_var.stun_status = PJ_SUCCESS; 671 } else { 736 737 pjsua_var.stun_status = PJ_EPENDING; 738 739 /* If stun_domain is specified, resolve STUN servers with DNS 740 * SRV resolution. 741 */ 742 if (pjsua_var.ua_cfg.stun_domain.slen) { 743 pj_str_t res_type; 744 745 /* Fail if resolver is not configured */ 746 if (pjsua_var.resolver == NULL) { 747 PJ_LOG(1,(THIS_FILE, "Nameserver must be configured when " 748 "stun_domain is specified")); 749 pjsua_var.stun_status = PJLIB_UTIL_EDNSNONS; 750 return PJLIB_UTIL_EDNSNONS; 751 } 752 res_type = pj_str("_stun._udp"); 753 pjsua_var.stun_status = 754 pj_dns_srv_resolve(&pjsua_var.ua_cfg.stun_domain, &res_type, 755 3478, pjsua_var.pool, pjsua_var.resolver, 756 0, NULL, stun_dns_srv_resolver_cb); 757 if (pjsua_var.stun_status != PJ_SUCCESS) { 758 pjsua_perror(THIS_FILE, "Error starting DNS SRV resolution", 759 pjsua_var.stun_status); 760 return pjsua_var.stun_status; 761 } 762 } 763 /* Otherwise if stun_host is specified, resolve STUN server with 764 * gethostbyname(). 765 */ 766 else if (pjsua_var.ua_cfg.stun_host.slen) { 672 767 pj_hostent he; 673 768 674 pjsua_var.stun_status = 675 pj_gethostbyname(&pjsua_var.ua_cfg.stun_srv, &he); 769 pjsua_var.stun_status = pj_gethostbyname(&pjsua_var.ua_cfg.stun_host, &he); 676 770 677 771 if (pjsua_var.stun_status == PJ_SUCCESS) { … … 680 774 pjsua_var.stun_srv.ipv4.sin_port = pj_htons((pj_uint16_t)3478); 681 775 682 PJ_LOG( 4,(THIS_FILE,776 PJ_LOG(3,(THIS_FILE, 683 777 "STUN server %.*s resolved, address is %s:%d", 684 (int)pjsua_var.ua_cfg.stun_ srv.slen,685 pjsua_var.ua_cfg.stun_ srv.ptr,778 (int)pjsua_var.ua_cfg.stun_host.slen, 779 pjsua_var.ua_cfg.stun_host.ptr, 686 780 pj_inet_ntoa(pjsua_var.stun_srv.ipv4.sin_addr), 687 781 (int)pj_ntohs(pjsua_var.stun_srv.ipv4.sin_port))); 688 782 } 689 } 783 784 } 785 /* Otherwise disable STUN. */ 786 else { 787 pjsua_var.stun_status = PJ_SUCCESS; 788 } 789 790 690 791 return pjsua_var.stun_status; 691 792 … … 694 795 * result. 695 796 */ 696 pj_assert(!"Should not happen"); 697 return PJ_EBUG; 797 if (wait) { 798 while (pjsua_var.stun_status == PJ_EPENDING) 799 pjsua_handle_events(10); 800 } 801 802 return pjsua_var.stun_status; 698 803 699 804 } else { … … 947 1052 p_pub_addr); 948 1053 if (status != PJ_SUCCESS) { 949 pjsua_perror(THIS_FILE, "Error resolving with STUN", status);1054 pjsua_perror(THIS_FILE, "Error contacting STUN server", status); 950 1055 pj_sock_close(sock); 951 1056 return status;
Note: See TracChangeset
for help on using the changeset viewer.