Changeset 2744
- Timestamp:
- Jun 4, 2009 3:29:14 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r2724 r2744 872 872 */ 873 873 if (pjsua_var.ua_cfg.stun_host.slen) { 874 pj_str_t str_host, str_port; 875 int port; 876 pj_hostent he; 877 878 str_port.ptr = pj_strchr(&pjsua_var.ua_cfg.stun_host, ':'); 879 if (str_port.ptr != NULL) { 880 str_host.ptr = pjsua_var.ua_cfg.stun_host.ptr; 881 str_host.slen = (str_port.ptr - str_host.ptr); 882 str_port.ptr++; 883 str_port.slen = pjsua_var.ua_cfg.stun_host.slen - 884 str_host.slen - 1; 885 port = (int)pj_strtoul(&str_port); 886 if (port < 1 || port > 65535) { 887 pjsua_perror(THIS_FILE, "Invalid STUN server", PJ_EINVAL); 888 pjsua_var.stun_status = PJ_EINVAL; 889 return; 890 } 874 pjsua_var.stun_status = 875 pj_sockaddr_parse(pj_AF_INET(), 0, 876 &pjsua_var.ua_cfg.stun_host, 877 &pjsua_var.stun_srv); 878 if (pjsua_var.stun_status != PJ_SUCCESS) { 879 pjsua_perror(THIS_FILE, "Invalid STUN server", 880 pjsua_var.stun_status); 891 881 } else { 892 str_host = pjsua_var.ua_cfg.stun_host; 893 port = 3478; 894 } 895 896 pjsua_var.stun_status = pj_gethostbyname(&str_host, &he); 897 898 if (pjsua_var.stun_status == PJ_SUCCESS) { 899 pj_sockaddr_in_init(&pjsua_var.stun_srv.ipv4, NULL, 0); 900 pjsua_var.stun_srv.ipv4.sin_addr = *(pj_in_addr*)he.h_addr; 901 pjsua_var.stun_srv.ipv4.sin_port = pj_htons((pj_uint16_t)port); 882 if (pj_sockaddr_get_port(&pjsua_var.stun_srv)==0) 883 pj_sockaddr_set_port(&pjsua_var.stun_srv, 3478); 902 884 903 885 PJ_LOG(3,(THIS_FILE, … … 989 971 */ 990 972 else if (pjsua_var.ua_cfg.stun_host.slen) { 991 pj_str_t str_host, str_port; 992 int port; 993 pj_hostent he; 994 995 str_port.ptr = pj_strchr(&pjsua_var.ua_cfg.stun_host, ':'); 996 if (str_port.ptr != NULL) { 997 str_host.ptr = pjsua_var.ua_cfg.stun_host.ptr; 998 str_host.slen = (str_port.ptr - str_host.ptr); 999 str_port.ptr++; 1000 str_port.slen = pjsua_var.ua_cfg.stun_host.slen - 1001 str_host.slen - 1; 1002 port = (int)pj_strtoul(&str_port); 1003 if (port < 1 || port > 65535) { 1004 pjsua_perror(THIS_FILE, "Invalid STUN server", PJ_EINVAL); 1005 pjsua_var.stun_status = PJ_EINVAL; 1006 return pjsua_var.stun_status; 1007 } 1008 } else { 1009 str_host = pjsua_var.ua_cfg.stun_host; 1010 port = 3478; 973 pjsua_var.stun_status = 974 pj_sockaddr_parse(pj_AF_INET(), 0, 975 &pjsua_var.ua_cfg.stun_host, 976 &pjsua_var.stun_srv); 977 if (pjsua_var.stun_status != PJ_SUCCESS) { 978 pjsua_perror(THIS_FILE, "Invalid STUN server", 979 pjsua_var.stun_status); 980 return pjsua_var.stun_status; 1011 981 } 1012 982 1013 pjsua_var.stun_status = 1014 pj_sockaddr_in_init(&pjsua_var.stun_srv.ipv4, &str_host, 1015 (pj_uint16_t)port); 1016 1017 if (pjsua_var.stun_status != PJ_SUCCESS) { 1018 pjsua_var.stun_status = pj_gethostbyname(&str_host, &he); 1019 1020 if (pjsua_var.stun_status == PJ_SUCCESS) { 1021 pj_sockaddr_in_init(&pjsua_var.stun_srv.ipv4, NULL, 0); 1022 pjsua_var.stun_srv.ipv4.sin_addr = *(pj_in_addr*)he.h_addr; 1023 pjsua_var.stun_srv.ipv4.sin_port = pj_htons((pj_uint16_t)port); 1024 } 1025 } 983 if (pj_sockaddr_get_port(&pjsua_var.stun_srv)==0) 984 pj_sockaddr_set_port(&pjsua_var.stun_srv, 3478); 1026 985 1027 986 PJ_LOG(3,(THIS_FILE,
Note: See TracChangeset
for help on using the changeset viewer.