Index: pjproject/trunk/pjnath/include/pjnath/turn_session.h
===================================================================
--- pjproject/trunk/pjnath/include/pjnath/turn_session.h	(revision 5481)
+++ pjproject/trunk/pjnath/include/pjnath/turn_session.h	(revision 5987)
@@ -299,4 +299,41 @@
 		     pj_turn_state_t new_state);
 
+    /**
+     * Notification when TURN client received a ConnectionAttempt Indication
+     * from the TURN server, which indicates that peer initiates a TCP
+     * connection to allocated slot in the TURN server. Application must
+     * implement this callback if it uses RFC 6062 (TURN TCP allocations).
+     *
+     * After receiving this callback, application should establish a new TCP
+     * connection to the TURN server and send ConnectionBind request (using
+     * pj_turn_session_connection_bind()). After the connection binding
+     * succeeds, this new connection will become a data only connection.
+     *
+     * @param sess	The TURN session.
+     * @param conn_id	The connection ID assigned by TURN server.
+     * @param peer_addr	Peer address that tried to connect to the TURN server.
+     * @param addr_len	Length of the peer address.
+     */
+    void (*on_connection_attempt)(pj_turn_session *sess,
+				  pj_uint32_t conn_id,
+				  const pj_sockaddr_t *peer_addr,
+				  unsigned addr_len);
+
+    /**
+     * Notification for ConnectionBind request sent using
+     * pj_turn_session_connection_bind().
+     *
+     * @param sess	The TURN session.
+     * @param status	The status code.
+     * @param conn_id	The connection ID.
+     * @param peer_addr	Peer address.
+     * @param addr_len	Length of the peer address.
+     */
+    void (*on_connection_bind_status)(pj_turn_session *sess,
+				      pj_status_t status,
+				      pj_uint32_t conn_id,
+				      const pj_sockaddr_t *peer_addr,
+				      unsigned addr_len);
+
 } pj_turn_session_cb;
 
@@ -340,4 +377,11 @@
     int	    af;
 
+    /**
+     * Type of connection to from TURN server to peer. Supported values are
+     * PJ_TURN_TP_UDP (RFC 5766) and PJ_TURN_TP_TCP (RFC 6062)
+     *
+     * Default is PJ_TURN_TP_UDP.
+     */
+    pj_turn_tp_type peer_conn_type;
 
 } pj_turn_alloc_param;
@@ -385,4 +429,38 @@
 
 } pj_turn_session_info;
+
+
+/**
+ * Parameters for function pj_turn_session_on_rx_pkt2().
+ */
+typedef struct pj_turn_session_on_rx_pkt_param
+{
+    /**
+     * The packet as received from the TURN server. This should contain
+     * either STUN encapsulated message or a ChannelData packet.
+     */
+    void		*pkt;
+
+    /**
+     * The length of the packet.
+     */
+    pj_size_t		 pkt_len;
+
+    /**
+     * The number of parsed or processed data from the packet.
+     */
+    pj_size_t		 parsed_len;
+
+    /**
+     * Source address where the packet is received from.
+     */
+    const pj_sockaddr_t	*src_addr;
+
+    /**
+     * Length of the source address.
+     */
+    unsigned		 src_addr_len;
+
+} pj_turn_session_on_rx_pkt_param;
 
 
@@ -742,4 +820,54 @@
 					       pj_size_t *parsed_len);
 
+/**
+ * Notify TURN client session upon receiving a packet from server. Since
+ * the TURN session is transport independent, it does not read packet from
+ * any sockets, and rather relies on application giving it packets that
+ * are received from the TURN server. The session then processes this packet
+ * and decides whether it is part of TURN protocol exchange or if it is a
+ * data to be reported back to user, which in this case it will call the
+ * \a on_rx_data() callback.
+ *
+ * This function is variant of pj_turn_session_on_rx_pkt() with additional
+ * parameters such as source address. Source address will allow STUN/TURN
+ * session to resend the request (e.g: with updated authentication) to the
+ * provided source address which may be different to the initial connection,
+ * for example in RFC 6062 scenario that there can be some data connection
+ * and a control connection.
+ *
+ * @param sess		The TURN client session.
+ * @param prm		The function parameters, e.g: packet, source address.
+ *
+ * @return		The function may return non-PJ_SUCCESS if it receives
+ *			non-STUN and non-ChannelData packet, or if the
+ *			\a on_rx_data() returns non-PJ_SUCCESS;
+ */
+PJ_DECL(pj_status_t) pj_turn_session_on_rx_pkt2(
+				    pj_turn_session *sess,
+				    pj_turn_session_on_rx_pkt_param *prm);
+
+/**
+ * Initiate connection binding to the specified peer using ConnectionBind
+ * request. Application must call this function when it uses RFC 6062
+ * (TURN TCP allocations) to establish a data connection with peer after
+ * opening/accepting connection to/from peer. The connection binding status
+ * will be notified via on_connection_bind_status callback.
+ *
+ * @param sess		The TURN session.
+ * @param pool		The memory pool.
+ * @param conn_id	The connection ID assigned by TURN server.
+ * @param peer_addr	Peer address.
+ * @param addr_len	Length of the peer address.
+ *
+ * @return		PJ_SUCCESS if the operation has been successfully
+ *			issued, or the appropriate error code. Note that
+ *			the operation itself will complete asynchronously.
+ */
+PJ_DECL(pj_status_t) pj_turn_session_connection_bind(
+					    pj_turn_session *sess,
+					    pj_pool_t *pool,
+					    pj_uint32_t conn_id,
+					    const pj_sockaddr_t *peer_addr,
+					    unsigned addr_len);
 
 /**
