Changeset 562 for pjproject/trunk
- Timestamp:
- Jun 28, 2006 4:23:23 PM (18 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_transport_udp.h
r550 r562 42 42 * 43 43 * @param endpt The SIP endpoint. 44 * @param local Local address to bind. 44 * @param local Optional local address to bind. If this argument 45 * is NULL, the UDP transport will be bound to arbitrary 46 * UDP port. 45 47 * @param a_name Published address (only the host and port portion is 46 48 * used). If this argument is NULL, then the bound address -
pjproject/trunk/pjsip/src/pjsip/sip_transport_udp.c
r550 r562 360 360 if (cnt == 0) 361 361 break; 362 } 363 364 /* Destroy rdata */ 365 for (i=0; i<tp->rdata_cnt; ++i) { 366 pj_pool_release(tp->rdata[i]->tp_info.pool); 362 367 } 363 368 … … 577 582 if (p_transport) 578 583 *p_transport = &tp->base; 584 585 PJ_LOG(4,(tp->base.obj_name, 586 "SIP UDP transport started, published address is %.*s:%d", 587 (int)tp->base.local_name.host.slen, 588 tp->base.local_name.host.ptr, 589 tp->base.local_name.port)); 590 579 591 return PJ_SUCCESS; 580 592 … … 590 602 */ 591 603 PJ_DEF(pj_status_t) pjsip_udp_transport_start( pjsip_endpoint *endpt, 592 const pj_sockaddr_in *local ,604 const pj_sockaddr_in *local_a, 593 605 const pjsip_host_port *a_name, 594 606 unsigned async_cnt, … … 598 610 pj_status_t status; 599 611 char addr_buf[16]; 612 pj_sockaddr_in tmp_addr; 600 613 pjsip_host_port bound_name; 601 614 602 PJ_ASSERT_RETURN( local != NULL, PJ_EINVAL);615 PJ_ASSERT_RETURN(endpt && async_cnt, PJ_EINVAL); 603 616 604 617 status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &sock); … … 606 619 return status; 607 620 608 status = pj_sock_bind(sock, local, sizeof(*local)); 621 if (local_a == NULL) { 622 pj_sockaddr_in_init(&tmp_addr, NULL, 0); 623 local_a = &tmp_addr; 624 } 625 626 status = pj_sock_bind(sock, local_a, sizeof(*local_a)); 609 627 if (status != PJ_SUCCESS) { 610 628 pj_sock_close(sock); … … 616 634 * Build a name based on bound address. 617 635 */ 636 int addr_len; 637 638 addr_len = sizeof(tmp_addr); 639 status = pj_sock_getsockname(sock, &tmp_addr, &addr_len); 640 if (status != PJ_SUCCESS) { 641 pj_sock_close(sock); 642 return status; 643 } 644 618 645 a_name = &bound_name; 619 646 bound_name.host.ptr = addr_buf; 620 bound_name.port = pj_ntohs( local->sin_port);647 bound_name.port = pj_ntohs(tmp_addr.sin_port); 621 648 622 649 /* If bound address specifies "0.0.0.0", get the IP address 623 650 * of local hostname. 624 651 */ 625 if ( local->sin_addr.s_addr == PJ_INADDR_ANY) {652 if (tmp_addr.sin_addr.s_addr == PJ_INADDR_ANY) { 626 653 pj_hostent he; 627 654 const pj_str_t *hostname = pj_gethostname(); … … 635 662 } else { 636 663 /* Otherwise use bound address. */ 637 pj_strcpy2(&bound_name.host, pj_inet_ntoa( local->sin_addr));664 pj_strcpy2(&bound_name.host, pj_inet_ntoa(tmp_addr.sin_addr)); 638 665 } 639 666
Note: See TracChangeset
for help on using the changeset viewer.