Changeset 106 for pjproject/trunk/pjsip/src/pjsip/sip_transport_udp.c
- Timestamp:
- Dec 30, 2005 11:50:15 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_transport_udp.c
r105 r106 22 22 #include <pj/pool.h> 23 23 #include <pj/sock.h> 24 #include <pj/addr_resolv.h> 24 25 #include <pj/os.h> 25 26 #include <pj/lock.h> … … 268 269 pj_status_t status; 269 270 271 PJ_ASSERT_RETURN(endpt && sock!=PJ_INVALID_SOCKET && a_name && async_cnt>0, 272 PJ_EINVAL); 273 270 274 /* Create pool. */ 271 275 pool = pjsip_endpt_create_pool(endpt, "udp%p", PJSIP_POOL_LEN_TRANSPORT, … … 328 332 pj_inet_ntoa(((pj_sockaddr_in*)&tp->base.local_addr)->sin_addr), 329 333 pj_ntohs(((pj_sockaddr_in*)&tp->base.local_addr)->sin_port), 330 tp->base.local_name.host ,334 tp->base.local_name.host.ptr, 331 335 tp->base.local_name.port); 332 336 … … 368 372 /* Create rdata and put it in the array. */ 369 373 tp->rdata_cnt = 0; 374 tp->rdata = pj_pool_calloc(tp->base.pool, async_cnt, 375 sizeof(pjsip_rx_data*)); 370 376 for (i=0; i<async_cnt; ++i) { 371 377 pj_pool_t *rdata_pool = pjsip_endpt_create_pool(endpt, "rtd%p", … … 383 389 tp->rdata[i]->tp_info.pool = rdata_pool; 384 390 tp->rdata[i]->tp_info.transport = &tp->base; 391 tp->rdata[i]->tp_info.op_key.rdata = tp->rdata[i]; 385 392 pj_ioqueue_op_key_init(&tp->rdata[i]->tp_info.op_key.op_key, 386 393 sizeof(pj_ioqueue_op_key_t)); … … 437 444 pjsip_host_port bound_name; 438 445 446 PJ_ASSERT_RETURN(local != NULL, PJ_EINVAL); 447 439 448 status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &sock); 440 449 if (status != PJ_SUCCESS) … … 448 457 449 458 if (a_name == NULL) { 459 /* Address name is not specified. 460 * Build a name based on bound address. 461 */ 450 462 a_name = &bound_name; 451 463 bound_name.host.ptr = addr_buf; 452 pj_strcpy2(&bound_name.host, pj_inet_ntoa(local->sin_addr));453 464 bound_name.port = pj_ntohs(local->sin_port); 465 466 /* If bound address specifies "0.0.0.0", get the IP address 467 * of local hostname. 468 */ 469 if (local->sin_addr.s_addr == PJ_INADDR_ANY) { 470 pj_hostent he; 471 const pj_str_t *hostname = pj_gethostname(); 472 status = pj_gethostbyname(hostname, &he); 473 if (status != PJ_SUCCESS) { 474 pj_sock_close(sock); 475 return status; 476 } 477 pj_strcpy2(&bound_name.host, 478 pj_inet_ntoa(*(pj_in_addr*)he.h_addr)); 479 } else { 480 /* Otherwise use bound address. */ 481 pj_strcpy2(&bound_name.host, pj_inet_ntoa(local->sin_addr)); 482 } 483 454 484 } 455 485
Note: See TracChangeset
for help on using the changeset viewer.