- Timestamp:
- Apr 10, 2007 10:35:00 AM (18 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r1135 r1184 914 914 915 915 /** 916 * Specify STUN server to be used. 916 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is 917 * not specified, default port 3478 will be used. 917 918 */ 918 919 pj_str_t stun_host; -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r1159 r1184 679 679 */ 680 680 if (pjsua_var.ua_cfg.stun_host.slen) { 681 pj_str_t str_host, str_port; 682 int port; 681 683 pj_hostent he; 682 684 683 pjsua_var.stun_status = pj_gethostbyname(&pjsua_var.ua_cfg.stun_host, &he); 685 str_port.ptr = pj_strchr(&pjsua_var.ua_cfg.stun_host, ':'); 686 if (str_port.ptr != NULL) { 687 str_host.ptr = pjsua_var.ua_cfg.stun_host.ptr; 688 str_host.slen = (str_port.ptr - str_host.ptr); 689 str_port.ptr++; 690 str_port.slen = pjsua_var.ua_cfg.stun_host.slen - 691 str_host.slen - 1; 692 port = (int)pj_strtoul(&str_port); 693 if (port < 1 || port > 65535) { 694 pjsua_perror(THIS_FILE, "Invalid STUN server", PJ_EINVAL); 695 pjsua_var.stun_status = PJ_EINVAL; 696 return; 697 } 698 } else { 699 str_host = pjsua_var.ua_cfg.stun_host; 700 port = 3478; 701 } 702 703 pjsua_var.stun_status = pj_gethostbyname(&str_host, &he); 684 704 685 705 if (pjsua_var.stun_status == PJ_SUCCESS) { 686 706 pj_sockaddr_in_init(&pjsua_var.stun_srv.ipv4, NULL, 0); 687 707 pjsua_var.stun_srv.ipv4.sin_addr = *(pj_in_addr*)he.h_addr; 688 pjsua_var.stun_srv.ipv4.sin_port = pj_htons((pj_uint16_t) 3478);708 pjsua_var.stun_srv.ipv4.sin_port = pj_htons((pj_uint16_t)port); 689 709 690 710 PJ_LOG(3,(THIS_FILE, … … 773 793 */ 774 794 else if (pjsua_var.ua_cfg.stun_host.slen) { 795 pj_str_t str_host, str_port; 796 int port; 775 797 pj_hostent he; 776 798 777 pjsua_var.stun_status = pj_gethostbyname(&pjsua_var.ua_cfg.stun_host, &he); 799 str_port.ptr = pj_strchr(&pjsua_var.ua_cfg.stun_host, ':'); 800 if (str_port.ptr != NULL) { 801 str_host.ptr = pjsua_var.ua_cfg.stun_host.ptr; 802 str_host.slen = (str_port.ptr - str_host.ptr); 803 str_port.ptr++; 804 str_port.slen = pjsua_var.ua_cfg.stun_host.slen - 805 str_host.slen - 1; 806 port = (int)pj_strtoul(&str_port); 807 if (port < 1 || port > 65535) { 808 pjsua_perror(THIS_FILE, "Invalid STUN server", PJ_EINVAL); 809 pjsua_var.stun_status = PJ_EINVAL; 810 return pjsua_var.stun_status; 811 } 812 } else { 813 str_host = pjsua_var.ua_cfg.stun_host; 814 port = 3478; 815 } 816 817 818 pjsua_var.stun_status = pj_gethostbyname(&str_host, &he); 778 819 779 820 if (pjsua_var.stun_status == PJ_SUCCESS) { 780 821 pj_sockaddr_in_init(&pjsua_var.stun_srv.ipv4, NULL, 0); 781 822 pjsua_var.stun_srv.ipv4.sin_addr = *(pj_in_addr*)he.h_addr; 782 pjsua_var.stun_srv.ipv4.sin_port = pj_htons((pj_uint16_t) 3478);823 pjsua_var.stun_srv.ipv4.sin_port = pj_htons((pj_uint16_t)port); 783 824 784 825 PJ_LOG(3,(THIS_FILE, … … 1056 1097 */ 1057 1098 status = pjstun_get_mapped_addr(&pjsua_var.cp.factory, 1, &sock, 1058 &stun_srv, 3478,1059 &stun_srv, 3478,1099 &stun_srv, pj_ntohs(pjsua_var.stun_srv.ipv4.sin_port), 1100 &stun_srv, pj_ntohs(pjsua_var.stun_srv.ipv4.sin_port), 1060 1101 p_pub_addr); 1061 1102 if (status != PJ_SUCCESS) { -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r1156 r1184 290 290 291 291 status=pjstun_get_mapped_addr(&pjsua_var.cp.factory, 2, sock, 292 &stun_srv, 3478,293 &stun_srv, 3478,292 &stun_srv, pj_ntohs(pjsua_var.stun_srv.ipv4.sin_port), 293 &stun_srv, pj_ntohs(pjsua_var.stun_srv.ipv4.sin_port), 294 294 mapped_addr); 295 295 if (status != PJ_SUCCESS) {
Note: See TracChangeset
for help on using the changeset viewer.