Changeset 5706
- Timestamp:
- Nov 30, 2017 4:41:52 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_resolve.c
r5635 r5706 34 34 35 35 #define THIS_FILE "sip_resolve.c" 36 37 #define ADDR_MAX_COUNT 838 36 39 37 struct naptr_target … … 273 271 char addr_str[PJ_INET6_ADDRSTRLEN+10]; 274 272 pj_uint16_t srv_port; 273 unsigned i; 275 274 276 275 if (ip_addr_ver != 0) { 277 276 /* Target is an IP address, no need to resolve */ 277 svr_addr.count = 1; 278 278 if (ip_addr_ver == 4) { 279 279 if (af == pj_AF_INET6()) { … … 312 312 } 313 313 } else { 314 pj_addrinfo ai ;314 pj_addrinfo ai[PJSIP_MAX_RESOLVED_ADDRESSES]; 315 315 unsigned count; 316 316 … … 324 324 325 325 /* Resolve */ 326 count = 1;327 status = pj_getaddrinfo(af, &target->addr.host, &count, &ai);326 count = PJSIP_MAX_RESOLVED_ADDRESSES; 327 status = pj_getaddrinfo(af, &target->addr.host, &count, ai); 328 328 if (status != PJ_SUCCESS) { 329 329 /* "Normalize" error to PJ_ERESOLVE. This is a special error … … 335 335 } 336 336 337 pj_sockaddr_cp(&svr_addr.entry[0].addr, &ai.ai_addr); 338 if (af == pj_AF_UNSPEC()) 339 af = ai.ai_addr.addr.sa_family; 340 } 341 342 /* After address resolution, update IPv6 bitflag in transport type. */ 343 if (af == pj_AF_INET6()) 344 type |= PJSIP_TRANSPORT_IPV6; 345 346 /* Set the port number */ 347 if (target->addr.port == 0) { 348 srv_port = (pj_uint16_t) 349 pjsip_transport_get_default_port_for_type(type); 350 } else { 351 srv_port = (pj_uint16_t)target->addr.port; 352 } 353 pj_sockaddr_set_port(&svr_addr.entry[0].addr, srv_port); 337 svr_addr.count = count; 338 for (i = 0; i < count; i++) { 339 pj_sockaddr_cp(&svr_addr.entry[i].addr, &ai[i].ai_addr); 340 } 341 } 342 343 for (i = 0; i < svr_addr.count; i++) { 344 /* After address resolution, update IPv6 bitflag in 345 * transport type. 346 */ 347 af = svr_addr.entry[i].addr.addr.sa_family; 348 if (af == pj_AF_INET6()) { 349 type |= PJSIP_TRANSPORT_IPV6; 350 } else { 351 type &= ~PJSIP_TRANSPORT_IPV6; 352 } 353 354 /* Set the port number */ 355 if (target->addr.port == 0) { 356 srv_port = (pj_uint16_t) 357 pjsip_transport_get_default_port_for_type(type); 358 } else { 359 srv_port = (pj_uint16_t)target->addr.port; 360 } 361 pj_sockaddr_set_port(&svr_addr.entry[i].addr, srv_port); 362 363 PJ_LOG(5,(THIS_FILE, 364 "Target '%.*s:%d' type=%s resolved to " 365 "'%s' type=%s (%s)", 366 (int)target->addr.host.slen, 367 target->addr.host.ptr, 368 target->addr.port, 369 pjsip_transport_get_type_name(target->type), 370 pj_sockaddr_print(&svr_addr.entry[i].addr, addr_str, 371 sizeof(addr_str), 3), 372 pjsip_transport_get_type_name(type), 373 pjsip_transport_get_type_desc(type))); 374 375 svr_addr.entry[i].priority = 0; 376 svr_addr.entry[i].weight = 0; 377 svr_addr.entry[i].type = type; 378 svr_addr.entry[i].addr_len = 379 pj_sockaddr_get_len(&svr_addr.entry[i].addr); 380 } 354 381 355 382 /* Call the callback. */ 356 PJ_LOG(5,(THIS_FILE,357 "Target '%.*s:%d' type=%s resolved to "358 "'%s' type=%s (%s)",359 (int)target->addr.host.slen,360 target->addr.host.ptr,361 target->addr.port,362 pjsip_transport_get_type_name(target->type),363 pj_sockaddr_print(&svr_addr.entry[0].addr, addr_str,364 sizeof(addr_str), 3),365 pjsip_transport_get_type_name(type),366 pjsip_transport_get_type_desc(type)));367 svr_addr.count = 1;368 svr_addr.entry[0].priority = 0;369 svr_addr.entry[0].weight = 0;370 svr_addr.entry[0].type = type;371 svr_addr.entry[0].addr_len =372 pj_sockaddr_get_len(&svr_addr.entry[0].addr);373 383 (*cb)(status, token, &svr_addr); 374 384
Note: See TracChangeset
for help on using the changeset viewer.