- Timestamp:
- Mar 10, 2007 11:19:11 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/src/pjstun-srv-test/turn_usage.c
r1052 r1053 90 90 pj_stun_session *session; 91 91 pj_mutex_t *mutex; 92 93 /* Socket and socket address of the allocated port */ 92 94 int sock_type; 93 94 /* Socket and socket address of the allocated port */95 95 pj_sock_t sock; 96 96 pj_ioqueue_key_t *key; … … 504 504 pj_uint32_t hval); 505 505 506 static const char *get_tp_type(int type) 507 { 508 if (type==0) 509 return "udp"; 510 else if (type==1) 511 return "tcp"; 512 else 513 return "???"; 514 } 515 506 516 507 517 /* … … 576 586 const pj_sockaddr_in *a4 = (const pj_sockaddr_in *)src_addr; 577 587 pj_ansi_snprintf(client->obj_name, sizeof(client->obj_name), 578 "%s:%d", 588 "%s:%s:%d", 589 get_tp_type(tu->type), 579 590 pj_inet_ntoa(a4->sin_addr), 580 591 (int)pj_ntohs(a4->sin_port)); … … 586 597 sess_cb.on_send_msg = &client_sess_on_send_msg; 587 598 sess_cb.on_rx_request = &client_sess_on_rx_request; 588 status = pj_stun_session_create(tu->endpt, "turnc%p", &sess_cb, PJ_FALSE, 599 status = pj_stun_session_create(tu->endpt, client->obj_name, 600 &sess_cb, PJ_FALSE, 589 601 &client->session); 590 602 if (status != PJ_SUCCESS) { … … 599 611 600 612 /* Mutex */ 601 status = pj_mutex_create_recursive(client->pool, pool->obj_name, 613 status = pj_mutex_create_recursive(client->pool, pool->obj_name, 602 614 &client->mutex); 603 615 if (status != PJ_SUCCESS) { … … 693 705 { 694 706 pj_ioqueue_callback client_ioq_cb; 707 int addrlen; 695 708 pj_status_t status; 709 710 /* Update address */ 711 addrlen = sizeof(pj_sockaddr_in); 712 status = pj_sock_getsockname(client->sock, &client->client_addr, 713 &addrlen); 714 if (status != PJ_SUCCESS) { 715 pj_sock_close(client->sock); 716 client->sock = PJ_INVALID_SOCKET; 717 return status; 718 } 696 719 697 720 /* Register to ioqueue */ … … 715 738 client_on_read_complete(client->key, &client->pkt_read_key, 0); 716 739 740 PJ_LOG(4,(THIS_FILE, "TURN client %s: relay allocated on %s:%s:%d", 741 client->obj_name, 742 get_tp_type(client->sock_type), 743 pj_inet_ntoa(client->client_addr.sin_addr), 744 (int)pj_ntohs(client->client_addr.sin_port))); 745 717 746 return PJ_SUCCESS; 718 747 } … … 735 764 } 736 765 737 PJ_LOG(4,(THIS_FILE, "TURN client %s: relay allocation %s:% d destroyed",766 PJ_LOG(4,(THIS_FILE, "TURN client %s: relay allocation %s:%s:%d destroyed", 738 767 client->obj_name, 768 get_tp_type(client->sock_type), 739 769 pj_inet_ntoa(client->client_addr.sin_addr), 740 770 (int)pj_ntohs(client->client_addr.sin_port))); … … 772 802 773 803 PJ_LOG(4,(THIS_FILE, "TURN client %s: peer %s:%s:%d added", 774 client->obj_name, "udp", pj_inet_ntoa(peer_addr->sin_addr), 804 client->obj_name, get_tp_type(client->sock_type), 805 pj_inet_ntoa(peer_addr->sin_addr), 775 806 (int)pj_ntohs(peer_addr->sin_port))); 776 807 … … 825 856 pj_sockaddr_in req_addr; 826 857 int addr_len; 827 unsigned r pp_bits;858 unsigned req_bw, rpp_bits; 828 859 pj_time_val timeout; 829 860 pj_status_t status; … … 849 880 return PJ_SUCCESS; 850 881 } else if (a_bw) { 851 client->bw_kbps = a_bw->value;882 client->bw_kbps = req_bw = a_bw->value; 852 883 } else { 884 req_bw = 0; 853 885 client->bw_kbps = client->tu->max_bw_kbps; 854 886 } … … 900 932 901 933 PJ_LOG(4,(THIS_FILE, "TURN client %s: received initial Allocate " 902 "request, requested type:addr:port=% d:%s:%d, rpp "903 "bits=%d ",904 client->obj_name, client->sock_type,934 "request, requested type:addr:port=%s:%s:%d, rpp " 935 "bits=%d, bw=%dkbps, lifetime=%d", 936 client->obj_name, get_tp_type(client->sock_type), 905 937 pj_inet_ntoa(req_addr.sin_addr), pj_ntohs(req_addr.sin_port), 906 rpp_bits ));938 rpp_bits, client->bw_kbps, client->lifetime)); 907 939 908 940 status = tu_alloc_port(client->tu, client->sock_type, rpp_bits, … … 931 963 /* Otherwise check if the port parameter stays the same */ 932 964 /* TODO */ 933 PJ_LOG(4,(THIS_FILE, "TURN client %s: received Allocate refresh", 934 client->obj_name)); 965 PJ_LOG(4,(THIS_FILE, "TURN client %s: received Allocate refresh, " 966 "lifetime=%d", 967 client->obj_name, client->lifetime)); 935 968 } 936 969 … … 970 1003 971 1004 PJ_LOG(4,(THIS_FILE, "TURN client %s: relay allocated or refreshed, " 972 "internal address is %s:% d",1005 "internal address is %s:%s:%d", 973 1006 client->obj_name, 1007 get_tp_type(client->sock_type), 974 1008 pj_inet_ntoa(req_addr.sin_addr), 975 1009 (int)pj_ntohs(req_addr.sin_port)));
Note: See TracChangeset
for help on using the changeset viewer.