Changeset 5350 for pjproject/trunk/pjnath/src/pjnath-test/server.c
- Timestamp:
- Jun 21, 2016 6:55:10 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/src/pjnath-test/server.c
r5170 r5350 54 54 char strbuf[100]; 55 55 pj_status_t status; 56 pj_bool_t use_ipv6 = flags & SERVER_IPV6; 56 57 57 58 PJ_ASSERT_RETURN(stun_cfg && domain && p_test_srv, PJ_EINVAL); 58 59 59 status = pj_gethostip( pj_AF_INET(), &hostip);60 status = pj_gethostip(GET_AF(use_ipv6), &hostip); 60 61 if (status != PJ_SUCCESS) 61 62 return status; … … 75 76 if (flags & CREATE_DNS_SERVER) { 76 77 status = pj_dns_server_create(mem, test_srv->stun_cfg->ioqueue, 77 pj_AF_INET(), DNS_SERVER_PORT,78 GET_AF(use_ipv6), DNS_SERVER_PORT, 78 79 0, &test_srv->dns_server); 79 80 if (status != PJ_SUCCESS) { … … 86 87 pj_dns_parsed_rr rr; 87 88 pj_str_t res_name; 88 pj_in_addr ip_addr;89 89 90 90 pj_strdup2(pool, &res_name, domain); 91 ip_addr = hostip.ipv4.sin_addr; 92 pj_dns_init_a_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, &ip_addr); 91 92 if (use_ipv6) { 93 pj_dns_init_aaaa_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, 94 &hostip.ipv6.sin6_addr); 95 } else { 96 pj_dns_init_a_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, 97 &hostip.ipv4.sin_addr); 98 } 99 93 100 pj_dns_server_add_rec(test_srv->dns_server, 1, &rr); 94 101 } … … 103 110 stun_sock_cb.on_data_recvfrom = &stun_on_data_recvfrom; 104 111 105 pj_sockaddr_in_init(&bound_addr.ipv4, NULL, STUN_SERVER_PORT); 112 pj_sockaddr_init(GET_AF(use_ipv6), &bound_addr, 113 NULL, STUN_SERVER_PORT); 106 114 107 115 status = pj_activesock_create_udp(pool, &bound_addr, NULL, … … 124 132 pj_str_t res_name, target; 125 133 pj_dns_parsed_rr rr; 126 pj_in_addr ip_addr;127 134 128 135 /* Add DNS entries: … … 141 148 142 149 res_name = target; 143 ip_addr = hostip.ipv4.sin_addr; 144 pj_dns_init_a_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, &ip_addr); 150 if (use_ipv6) { 151 pj_dns_init_aaaa_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, 152 &hostip.ipv6.sin6_addr); 153 } else { 154 pj_dns_init_a_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, 155 &hostip.ipv4.sin_addr); 156 } 145 157 pj_dns_server_add_rec(test_srv->dns_server, 1, &rr); 146 158 } … … 155 167 turn_sock_cb.on_data_recvfrom = &turn_on_data_recvfrom; 156 168 157 pj_sockaddr_in _init(&bound_addr.ipv4, NULL, TURN_SERVER_PORT);169 pj_sockaddr_init(GET_AF(use_ipv6), &bound_addr, NULL, TURN_SERVER_PORT); 158 170 159 171 status = pj_activesock_create_udp(pool, &bound_addr, NULL, … … 176 188 pj_str_t res_name, target; 177 189 pj_dns_parsed_rr rr; 178 pj_in_addr ip_addr;179 190 180 191 /* Add DNS entries: … … 193 204 194 205 res_name = target; 195 ip_addr = hostip.ipv4.sin_addr; 196 pj_dns_init_a_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, &ip_addr); 206 207 if (use_ipv6) { 208 pj_dns_init_aaaa_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, 209 &hostip.ipv6.sin6_addr); 210 } else { 211 pj_dns_init_a_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, 212 &hostip.ipv4.sin_addr); 213 } 197 214 pj_dns_server_add_rec(test_srv->dns_server, 1, &rr); 198 215 } … … 345 362 unsigned i; 346 363 pj_ssize_t len; 364 pj_bool_t use_ipv6 = PJ_FALSE; 347 365 348 366 if (status != PJ_SUCCESS) … … 352 370 353 371 test_srv = (test_server*) pj_activesock_get_user_data(asock); 372 use_ipv6 = test_srv->flags & SERVER_IPV6; 354 373 pool = pj_pool_create(test_srv->stun_cfg->pf, NULL, 512, 512, NULL); 355 374 … … 481 500 alloc->pool = pj_pool_create(test_srv->stun_cfg->pf, "alloc", 512, 512, NULL); 482 501 483 /* Create relay socket */ 484 pj_sockaddr_in _init(&alloc->alloc_addr.ipv4, NULL, 0);485 pj_gethostip( pj_AF_INET(), &alloc->alloc_addr);502 /* Create relay socket */ 503 pj_sockaddr_init(GET_AF(use_ipv6), &alloc->alloc_addr, NULL, 0); 504 pj_gethostip(GET_AF(use_ipv6), &alloc->alloc_addr); 486 505 487 506 status = pj_activesock_create_udp(alloc->pool, &alloc->alloc_addr, NULL, … … 698 717 unsigned i; 699 718 719 PJ_UNUSED_ARG(addr_len); 720 700 721 if (status != PJ_SUCCESS) 701 722 return PJ_TRUE; … … 708 729 /* Check that this peer has a permission */ 709 730 for (i=0; i<alloc->perm_cnt; ++i) { 710 if (pj_sockaddr_get_len(&alloc->perm[i]) == (unsigned)addr_len && 711 pj_memcmp(pj_sockaddr_get_addr(&alloc->perm[i]), 712 pj_sockaddr_get_addr(src_addr), 713 addr_len) == 0) 731 if (pj_sockaddr_cmp(&alloc->perm[i], src_addr) == 0) 714 732 { 715 733 break;
Note: See TracChangeset
for help on using the changeset viewer.