Index: /pjproject/trunk/pjlib-util/build/pjlib_util.dsp
===================================================================
--- /pjproject/trunk/pjlib-util/build/pjlib_util.dsp	(revision 1052)
+++ /pjproject/trunk/pjlib-util/build/pjlib_util.dsp	(revision 1053)
@@ -278,4 +278,8 @@
 # Begin Source File
 
+SOURCE="..\include\pjlib-util\turn_client.h"
+# End Source File
+# Begin Source File
+
 SOURCE="..\include\pjlib-util\types.h"
 # End Source File
Index: /pjproject/trunk/pjlib-util/include/pjlib-util.h
===================================================================
--- /pjproject/trunk/pjlib-util/include/pjlib-util.h	(revision 1052)
+++ /pjproject/trunk/pjlib-util/include/pjlib-util.h	(revision 1053)
@@ -1,3 +1,3 @@
-/* $Id */
+/* $Id$ */
 /* 
  * Copyright (C)2003-2007 Benny Prijono <benny@prijono.org>
@@ -55,4 +55,5 @@
 #include <pjlib-util/stun_session.h>
 #include <pjlib-util/stun_transaction.h>
+/*#include <pjlib-util/turn_client.h>*/
 
 /* Old STUN */
Index: /pjproject/trunk/pjlib-util/include/pjlib-util/stun_auth.h
===================================================================
--- /pjproject/trunk/pjlib-util/include/pjlib-util/stun_auth.h	(revision 1052)
+++ /pjproject/trunk/pjlib-util/include/pjlib-util/stun_auth.h	(revision 1053)
@@ -17,6 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
  */
-#ifndef __PJ_STUN_AUTH_H__
-#define __PJ_STUN_AUTH_H__
+#ifndef __PJLIB_UTIL_STUN_AUTH_H__
+#define __PJLIB_UTIL_STUN_AUTH_H__
 
 /**
@@ -272,4 +272,4 @@
 
 
-#endif	/* __PJ_STUN_AUTH_H__ */
-
+#endif	/* __PJLIB_UTIL_STUN_AUTH_H__ */
+
Index: /pjproject/trunk/pjlib-util/include/pjlib-util/stun_endpoint.h
===================================================================
--- /pjproject/trunk/pjlib-util/include/pjlib-util/stun_endpoint.h	(revision 1052)
+++ /pjproject/trunk/pjlib-util/include/pjlib-util/stun_endpoint.h	(revision 1053)
@@ -17,6 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
  */
-#ifndef __PJ_STUN_ENDPOINT_H__
-#define __PJ_STUN_ENDPOINT_H__
+#ifndef __PJLIB_UTIL_STUN_ENDPOINT_H__
+#define __PJLIB_UTIL_STUN_ENDPOINT_H__
 
 /**
@@ -114,4 +114,4 @@
 
 
-#endif	/* __PJ_STUN_ENDPOINT_H__ */
+#endif	/* __PJLIB_UTIL_STUN_ENDPOINT_H__ */
 
Index: /pjproject/trunk/pjlib-util/include/pjlib-util/stun_msg.h
===================================================================
--- /pjproject/trunk/pjlib-util/include/pjlib-util/stun_msg.h	(revision 1052)
+++ /pjproject/trunk/pjlib-util/include/pjlib-util/stun_msg.h	(revision 1053)
@@ -17,6 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
  */
-#ifndef __PJ_STUN_MSG_H__
-#define __PJ_STUN_MSG_H__
+#ifndef __PJLIB_UTIL_STUN_MSG_H__
+#define __PJLIB_UTIL_STUN_MSG_H__
 
 /**
@@ -1530,4 +1530,4 @@
 
 
-#endif	/* __PJ_STUN_MSG_H__ */
-
+#endif	/* __PJLIB_UTIL_STUN_MSG_H__ */
+
Index: /pjproject/trunk/pjlib-util/include/pjlib-util/stun_session.h
===================================================================
--- /pjproject/trunk/pjlib-util/include/pjlib-util/stun_session.h	(revision 1052)
+++ /pjproject/trunk/pjlib-util/include/pjlib-util/stun_session.h	(revision 1053)
@@ -56,10 +56,9 @@
      * Callback to be called by the STUN session to send outgoing message.
      *
-     * @param tdata	    The STUN transmit data containing the original
-     *			    STUN message
+     * @param sess	    The STUN session.
      * @param pkt	    Packet to be sent.
      * @param pkt_size	    Size of the packet to be sent.
+     * @param dst_addr	    The destination address.
      * @param addr_len	    Length of destination address.
-     * @param dst_addr	    The destination address.
      *
      * @return		    The callback should return the status of the
Index: /pjproject/trunk/pjlib-util/include/pjlib-util/stun_transaction.h
===================================================================
--- /pjproject/trunk/pjlib-util/include/pjlib-util/stun_transaction.h	(revision 1052)
+++ /pjproject/trunk/pjlib-util/include/pjlib-util/stun_transaction.h	(revision 1053)
@@ -17,6 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
  */
-#ifndef __PJ_STUN_TRANSACTION_H__
-#define __PJ_STUN_TRANSACTION_H__
+#ifndef __PJLIB_UTIL_STUN_TRANSACTION_H__
+#define __PJLIB_UTIL_STUN_TRANSACTION_H__
 
 /**
@@ -214,4 +214,4 @@
 
 
-#endif	/* __PJ_STUN_TRANSACTION_H__ */
-
+#endif	/* __PJLIB_UTIL_STUN_TRANSACTION_H__ */
+
Index: /pjproject/trunk/pjlib-util/include/pjlib-util/turn_client.h
===================================================================
--- /pjproject/trunk/pjlib-util/include/pjlib-util/turn_client.h	(revision 1053)
+++ /pjproject/trunk/pjlib-util/include/pjlib-util/turn_client.h	(revision 1053)
@@ -0,0 +1,132 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2003-2005 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
+#ifndef __PJLIB_UTIL_TURN_CLIENT_H__
+#define __PJLIB_UTIL_TURN_CLIENT_H__
+
+/**
+ * @file turn_client.h
+ * @brief TURN client session.
+ */
+
+#include <pjlib-util/stun_msg.h>
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * @defgroup PJLIB_UTIL_TURN_CLIENT TURN Client Session
+ * @brief Management of STUN/TURN client session
+ * @ingroup PJLIB_UTIL_STUN
+ * @{
+ */
+
+typedef struct pj_turn_client pj_turn_client;
+
+/**
+ * This describes TURN client config.
+ */
+typedef struct pj_turn_client_cb
+{
+    /**
+     * Callback to be called by the TURN session to send outgoing message.
+     *
+     * @param client	    The TURN client session.
+     * @param pkt	    Packet to be sent.
+     * @param pkt_size	    Size of the packet to be sent.
+     * @param dst_addr	    The destination address.
+     * @param addr_len	    Length of destination address.
+     *
+     * @return		    The callback should return the status of the
+     *			    packet sending.
+     */
+    pj_status_t (*on_send_msg)(pj_turn_client *client,
+			       const void *pkt,
+			       pj_size_t pkt_size,
+			       const pj_sockaddr_t *dst_addr,
+			       unsigned addr_len);
+
+    /**
+     * Callback to be called by TURN session when its state has changed.
+     */
+    pj_status_t (*on_state_changed)(pj_turn_client *client);
+
+} pj_turn_client_cb;
+
+
+/**
+ * Options
+ */
+typedef struct pj_turn_client_config
+{
+    int	    bandwidth;
+    int	    lifetime;
+    int	    sock_type;
+    int	    port;
+} pj_turn_client_config;
+
+
+PJ_INLINE(void) pj_turn_client_config_default(pj_turn_client_config *cfg)
+{
+    pj_bzero(cfg, sizeof(*cfg));
+    cfg->bandwidth = -1;
+    cfg->lifetime = -1;
+    cfg->sock_type = -1;
+    cfg->port = -1;
+}
+
+
+/**
+ * This describes the TURN client session.
+ */
+struct pj_turn_client
+{
+    pj_pool_t	    *pool;
+    pj_stun_session *session;
+    pj_timer_entry   alloc_timer;
+    pj_sockaddr_in   mapped_addr;
+    pj_sockaddr_in   relay_addr;
+};
+
+
+
+
+/**
+ * Create the TURN client session.
+ */
+PJ_DECL(pj_status_t) pj_turn_client_create(pj_stun_endpoint *endpt,
+					   const pj_turn_client_config *cfg,
+					   const pj_turn_client_cb *cb,
+					   pj_turn_client **p_client);
+
+/**
+ * Start the TURN client session by sending Allocate request to the server.
+ */
+
+
+/**
+ * @}
+ */
+
+
+PJ_END_DECL
+
+
+#endif	/* __PJLIB_UTIL_TURN_CLIENT_H__ */
+
Index: /pjproject/trunk/pjlib-util/src/pjlib-util/stun_msg.c
===================================================================
--- /pjproject/trunk/pjlib-util/src/pjlib-util/stun_msg.c	(revision 1052)
+++ /pjproject/trunk/pjlib-util/src/pjlib-util/stun_msg.c	(revision 1053)
@@ -406,5 +406,5 @@
     },
     {
-	/* Unassigned, 0x8025 */
+	/* ID 0x8025 is not assigned*/
 	NULL,
 	NULL,
@@ -412,5 +412,5 @@
     },
     {
-	/* Padding, 0x8026 */
+	/* PADDING, 0x8026 */
 	NULL,
 	NULL,
@@ -418,5 +418,5 @@
     },
     {
-	/* Padding, 0x8027 */
+	/* CACHE-TIMEOUT, 0x8027 */
 	NULL,
 	NULL,
Index: /pjproject/trunk/pjlib-util/src/pjstun-client/client_main.c
===================================================================
--- /pjproject/trunk/pjlib-util/src/pjstun-client/client_main.c	(revision 1052)
+++ /pjproject/trunk/pjlib-util/src/pjstun-client/client_main.c	(revision 1053)
@@ -22,4 +22,10 @@
 
 #define THIS_FILE	"client_main.c"
+#define BANDWIDTH	64		    /* -1 to disable */
+#define LIFETIME	30		    /* -1 to disable */
+#define REQ_TRANSPORT	-1		    /* 0: udp, 1: tcp, -1: disable */
+#define REQ_PORT_PROPS	-1		    /* -1 to disable */
+#define REQ_IP		NULL		    /* IP address string */
+
 
 static struct global
@@ -33,6 +39,6 @@
     pj_thread_t		*thread;
     pj_bool_t		 quit;
-
-    pj_sockaddr_in	 dst_addr;  /**< destination addr */
+    pj_sockaddr_in	 peer_addr;
+    pj_sockaddr_in	 srv_addr;  /**< server addr */
 
 } g;
@@ -40,6 +46,6 @@
 static struct options
 {
-    char    *dst_addr;
-    char    *dst_port;
+    char    *srv_addr;
+    char    *srv_port;
     char    *realm;
     char    *user_name;
@@ -61,5 +67,5 @@
 			       const void *pkt,
 			       pj_size_t pkt_size,
-			       const pj_sockaddr_t *dst_addr,
+			       const pj_sockaddr_t *srv_addr,
 			       unsigned addr_len)
 {
@@ -68,5 +74,5 @@
 
     len = pkt_size;
-    status = pj_sock_sendto(g.sock, pkt, &len, 0, dst_addr, addr_len);
+    status = pj_sock_sendto(g.sock, pkt, &len, 0, srv_addr, addr_len);
 
     if (status != PJ_SUCCESS)
@@ -142,14 +148,14 @@
     pj_caching_pool_init(&g.cp, &pj_pool_factory_default_policy, 0);
 
-    if (o.dst_addr) {
+    if (o.srv_addr) {
 	pj_str_t s;
 	pj_uint16_t port;
 
-	if (o.dst_port)
-	    port = (pj_uint16_t) atoi(o.dst_port);
+	if (o.srv_port)
+	    port = (pj_uint16_t) atoi(o.srv_port);
 	else
 	    port = PJ_STUN_PORT;
 
-	status = pj_sockaddr_in_init(&g.dst_addr, pj_cstr(&s, o.dst_addr), port);
+	status = pj_sockaddr_in_init(&g.srv_addr, pj_cstr(&s, o.srv_addr), port);
 	if (status != PJ_SUCCESS) {
 	    my_perror("Invalid address", status);
@@ -157,5 +163,5 @@
 	}
 
-	printf("Destination address set to %s:%d\n", o.dst_addr, (int)port);
+	printf("Destination address set to %s:%d\n", o.srv_addr, (int)port);
     } else {
 	printf("Error: address must be specified\n");
@@ -246,5 +252,5 @@
 
     rc = pj_stun_session_send_msg(g.sess, PJ_FALSE, 
-				  &g.dst_addr, sizeof(g.dst_addr),
+				  &g.srv_addr, sizeof(g.srv_addr),
 				  tdata);
     if (rc != PJ_SUCCESS)
@@ -252,10 +258,80 @@
 }
 
-static void send_allocate_request(void)
-{
-}
-
-static void send_sad_request(void)
-{
+static void send_allocate_request(pj_bool_t allocate)
+{
+    pj_stun_tx_data *tdata;
+    pj_status_t rc;
+
+    rc = pj_stun_session_create_req(g.sess, PJ_STUN_ALLOCATE_REQUEST, &tdata);
+    pj_assert(rc == PJ_SUCCESS);
+
+
+    if (BANDWIDTH != -1) {
+	pj_stun_msg_add_uint_attr(tdata->pool, tdata->msg, 
+				  PJ_STUN_ATTR_BANDWIDTH, BANDWIDTH);
+    }
+
+    if (!allocate) {
+	pj_stun_msg_add_uint_attr(tdata->pool, tdata->msg, 
+				  PJ_STUN_ATTR_LIFETIME, 0);
+
+    } else {
+	if (LIFETIME != -1) {
+	    pj_stun_msg_add_uint_attr(tdata->pool, tdata->msg, 
+				      PJ_STUN_ATTR_LIFETIME, LIFETIME);
+	}
+
+	if (REQ_TRANSPORT != -1) {
+	    pj_stun_msg_add_uint_attr(tdata->pool, tdata->msg, 
+				      PJ_STUN_ATTR_REQ_TRANSPORT, REQ_TRANSPORT);
+	}
+
+	if (REQ_PORT_PROPS != -1) {
+	    pj_stun_msg_add_uint_attr(tdata->pool, tdata->msg, 
+				      PJ_STUN_ATTR_REQ_PORT_PROPS, REQ_PORT_PROPS);
+	}
+
+	if (REQ_IP != NULL) {
+	    pj_sockaddr_in addr;
+	    pj_str_t tmp;
+
+	    pj_sockaddr_in_init(&addr, pj_cstr(&tmp, REQ_IP), 0);
+	    pj_stun_msg_add_ip_addr_attr(tdata->pool, tdata->msg,
+					 PJ_STUN_ATTR_REQ_IP, PJ_FALSE,
+					 &addr, sizeof(addr));
+	}
+    }
+
+    rc = pj_stun_session_send_msg(g.sess, PJ_FALSE, 
+				  &g.srv_addr, sizeof(g.srv_addr),
+				  tdata);
+    pj_assert(rc == PJ_SUCCESS);
+}
+
+static void send_sad_request(pj_bool_t set)
+{
+    pj_stun_tx_data *tdata;
+    pj_status_t rc;
+
+    if (g.peer_addr.sin_addr.s_addr == 0 ||
+	g.peer_addr.sin_port == 0)
+    {
+	puts("Error: peer address is not set");
+	return;
+    }
+
+    rc = pj_stun_session_create_req(g.sess, PJ_STUN_ALLOCATE_REQUEST, &tdata);
+    pj_assert(rc == PJ_SUCCESS);
+
+    if (set) {
+	pj_stun_msg_add_ip_addr_attr(tdata->pool, tdata->msg,
+				     PJ_STUN_ATTR_REMOTE_ADDR, PJ_FALSE,
+				     &g.peer_addr, sizeof(g.peer_addr));
+    }
+
+    rc = pj_stun_session_send_msg(g.sess, PJ_FALSE, 
+				  &g.srv_addr, sizeof(g.srv_addr),
+				  tdata);
+    pj_assert(rc == PJ_SUCCESS);
 }
 
@@ -268,11 +344,43 @@
 }
 
+static void set_peer_addr(void)
+{
+    char ip_addr[64];
+    pj_str_t tmp;
+    pj_sockaddr_in addr;
+    int port;
+
+    printf("Current peer address: %s:%d\n", 
+	   pj_inet_ntoa(g.peer_addr.sin_addr), 
+	   pj_ntohs(g.peer_addr.sin_port));
+
+    printf("Input peer address in IP:PORT format: ");
+    fflush(stdout);
+
+    if (scanf("%s:%d", ip_addr, &port) != 2) {
+	puts("Error.");
+	return;
+    }
+
+    if (pj_sockaddr_in_init(&addr, pj_cstr(&tmp,ip_addr), (pj_uint16_t)port) != PJ_SUCCESS) {
+	puts("Error: invalid address");
+	return;
+    }
+
+    g.peer_addr = addr;
+}
+
 static void menu(void)
 {
     puts("Menu:");
+    printf("  pr      Set peer address (currently %s:%d)\n",
+	   pj_inet_ntoa(g.peer_addr.sin_addr), pj_ntohs(g.peer_addr.sin_port));
+    puts("");
     puts("  br      Send Bind request");
     puts("  ar      Send Allocate request");
+    puts("  dr      Send de-Allocate request");
     puts("  sr      Send Set Active Indication request");
-    puts("  si      Send Send Indication");
+    puts("  cr      Send clear Active Indication request");
+    puts("  si      Send data with Send Indication");
     puts("  rw      Send raw data");
     puts("  q       Quit");
@@ -281,4 +389,5 @@
 }
 
+
 static void console_main(void)
 {
@@ -294,8 +403,14 @@
 	    
 	} else if (input[0]=='a' && input[1]=='r') {
-	    send_allocate_request();
+	    send_allocate_request(PJ_TRUE);
+	    
+	} else if (input[0]=='d' && input[1]=='r') {
+	    send_allocate_request(PJ_FALSE);
 	    
 	} else if (input[0]=='s' && input[1]=='r') {
-	    send_sad_request();
+	    send_sad_request(PJ_TRUE);
+	    
+	} else if (input[0]=='c' && input[1]=='r') {
+	    send_sad_request(PJ_FALSE);
 	    
 	} else if (input[0]=='s' && input[1]=='i') {
@@ -304,4 +419,7 @@
 	} else if (input[0]=='r' && input[1]=='w') {
 	    send_raw_data();
+	    
+	} else if (input[0]=='p' && input[1]=='r') {
+	    set_peer_addr();
 	    
 	} else if (input[0]=='q') {
@@ -374,9 +492,9 @@
 
     if ((pos=pj_ansi_strchr(argv[pj_optind], ':')) != NULL) {
-	o.dst_addr = argv[pj_optind];
+	o.srv_addr = argv[pj_optind];
 	*pos = '\0';
-	o.dst_port = pos+1;
+	o.srv_port = pos+1;
     } else {
-	o.dst_addr = argv[pj_optind];
+	o.srv_addr = argv[pj_optind];
     }
 
Index: /pjproject/trunk/pjlib-util/src/pjstun-srv-test/turn_usage.c
===================================================================
--- /pjproject/trunk/pjlib-util/src/pjstun-srv-test/turn_usage.c	(revision 1052)
+++ /pjproject/trunk/pjlib-util/src/pjstun-srv-test/turn_usage.c	(revision 1053)
@@ -90,7 +90,7 @@
     pj_stun_session	*session;
     pj_mutex_t		*mutex;
+
+    /* Socket and socket address of the allocated port */
     int			 sock_type;
-
-    /* Socket and socket address of the allocated port */
     pj_sock_t		 sock;
     pj_ioqueue_key_t	*key;
@@ -504,4 +504,14 @@
 				    pj_uint32_t hval);
 
+static const char *get_tp_type(int type)
+{
+    if (type==0)
+	return "udp";
+    else if (type==1)
+	return "tcp";
+    else
+	return "???";
+}
+
 
 /*
@@ -576,5 +586,6 @@
 	const pj_sockaddr_in *a4 = (const pj_sockaddr_in *)src_addr;
 	pj_ansi_snprintf(client->obj_name, sizeof(client->obj_name),
-			 "%s:%d",
+			 "%s:%s:%d",
+			 get_tp_type(tu->type),
 			 pj_inet_ntoa(a4->sin_addr),
 			 (int)pj_ntohs(a4->sin_port));
@@ -586,5 +597,6 @@
     sess_cb.on_send_msg = &client_sess_on_send_msg;
     sess_cb.on_rx_request = &client_sess_on_rx_request;
-    status = pj_stun_session_create(tu->endpt, "turnc%p", &sess_cb, PJ_FALSE,
+    status = pj_stun_session_create(tu->endpt, client->obj_name, 
+				    &sess_cb, PJ_FALSE,
 				    &client->session);
     if (status != PJ_SUCCESS) {
@@ -599,5 +611,5 @@
 
     /* Mutex */
-    status = pj_mutex_create_recursive(client->pool, pool->obj_name, 
+    status = pj_mutex_create_recursive(client->pool, pool->obj_name,
 				       &client->mutex);
     if (status != PJ_SUCCESS) {
@@ -693,5 +705,16 @@
 {
     pj_ioqueue_callback client_ioq_cb;
+    int addrlen;
     pj_status_t status;
+
+    /* Update address */
+    addrlen = sizeof(pj_sockaddr_in);
+    status = pj_sock_getsockname(client->sock, &client->client_addr, 
+			         &addrlen);
+    if (status != PJ_SUCCESS) {
+	pj_sock_close(client->sock);
+	client->sock = PJ_INVALID_SOCKET;
+	return status;
+    }
 
     /* Register to ioqueue */
@@ -715,4 +738,10 @@
     client_on_read_complete(client->key, &client->pkt_read_key, 0);
 
+    PJ_LOG(4,(THIS_FILE, "TURN client %s: relay allocated on %s:%s:%d",
+	      client->obj_name,
+	      get_tp_type(client->sock_type),
+	      pj_inet_ntoa(client->client_addr.sin_addr),
+	      (int)pj_ntohs(client->client_addr.sin_port)));
+
     return PJ_SUCCESS;
 }
@@ -735,6 +764,7 @@
     }
 
-    PJ_LOG(4,(THIS_FILE, "TURN client %s: relay allocation %s:%d destroyed",
+    PJ_LOG(4,(THIS_FILE, "TURN client %s: relay allocation %s:%s:%d destroyed",
 	      client->obj_name,
+	      get_tp_type(client->sock_type),
 	      pj_inet_ntoa(client->client_addr.sin_addr),
 	      (int)pj_ntohs(client->client_addr.sin_port)));
@@ -772,5 +802,6 @@
 
     PJ_LOG(4,(THIS_FILE, "TURN client %s: peer %s:%s:%d added",
-	      client->obj_name, "udp", pj_inet_ntoa(peer_addr->sin_addr),
+	      client->obj_name, get_tp_type(client->sock_type), 
+	      pj_inet_ntoa(peer_addr->sin_addr),
 	      (int)pj_ntohs(peer_addr->sin_port)));
 
@@ -825,5 +856,5 @@
     pj_sockaddr_in req_addr;
     int addr_len;
-    unsigned rpp_bits;
+    unsigned req_bw, rpp_bits;
     pj_time_val timeout;
     pj_status_t status;
@@ -849,6 +880,7 @@
 	return PJ_SUCCESS;
     } else if (a_bw) {
-	client->bw_kbps = a_bw->value;
+	client->bw_kbps = req_bw = a_bw->value;
     } else {
+	req_bw = 0;
 	client->bw_kbps = client->tu->max_bw_kbps;
     }
@@ -900,9 +932,9 @@
 
 	PJ_LOG(4,(THIS_FILE, "TURN client %s: received initial Allocate "
-			     "request, requested type:addr:port=%d:%s:%d, rpp "
-			     "bits=%d",
-		  client->obj_name, client->sock_type,
+			     "request, requested type:addr:port=%s:%s:%d, rpp "
+			     "bits=%d, bw=%dkbps, lifetime=%d",
+		  client->obj_name, get_tp_type(client->sock_type),
 		  pj_inet_ntoa(req_addr.sin_addr), pj_ntohs(req_addr.sin_port),
-		  rpp_bits));
+		  rpp_bits, client->bw_kbps, client->lifetime));
 
 	status = tu_alloc_port(client->tu, client->sock_type, rpp_bits, 
@@ -931,6 +963,7 @@
 	/* Otherwise check if the port parameter stays the same */
 	/* TODO */
-	PJ_LOG(4,(THIS_FILE, "TURN client %s: received Allocate refresh",
-		  client->obj_name));
+	PJ_LOG(4,(THIS_FILE, "TURN client %s: received Allocate refresh, "
+			     "lifetime=%d",
+		  client->obj_name, client->lifetime));
     }
 
@@ -970,6 +1003,7 @@
 
     PJ_LOG(4,(THIS_FILE, "TURN client %s: relay allocated or refreshed, "
-			 "internal address is %s:%d",
+			 "internal address is %s:%s:%d",
 			 client->obj_name,
+			 get_tp_type(client->sock_type),
 			 pj_inet_ntoa(req_addr.sin_addr),
 			 (int)pj_ntohs(req_addr.sin_port)));
