Index: pjproject/trunk/pjnath/include/pjnath/stun_session.h
===================================================================
--- pjproject/trunk/pjnath/include/pjnath/stun_session.h	(revision 1497)
+++ pjproject/trunk/pjnath/include/pjnath/stun_session.h	(revision 1498)
@@ -260,4 +260,5 @@
  * @param msg_type  The STUN request message type, from pj_stun_method_e or
  *		    from pj_stun_msg_type.
+ * @param magic	    STUN magic, use PJ_STUN_MAGIC.
  * @param tsx_id    Optional transaction ID.
  * @param p_tdata   Pointer to receive STUN transmit data instance containing
@@ -268,4 +269,5 @@
 PJ_DECL(pj_status_t) pj_stun_session_create_req(pj_stun_session *sess,
 						int msg_type,
+						pj_uint32_t magic,
 						const pj_uint8_t tsx_id[12],
 						pj_stun_tx_data **p_tdata);
Index: pjproject/trunk/pjnath/src/pjnath/ice_session.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath/ice_session.c	(revision 1497)
+++ pjproject/trunk/pjnath/src/pjnath/ice_session.c	(revision 1498)
@@ -1377,5 +1377,5 @@
     /* Create request */
     status = pj_stun_session_create_req(comp->stun_sess, 
-					PJ_STUN_BINDING_REQUEST, 
+					PJ_STUN_BINDING_REQUEST, PJ_STUN_MAGIC,
 					NULL, &check->tdata);
     if (status != PJ_SUCCESS) {
Index: pjproject/trunk/pjnath/src/pjnath/ice_strans.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath/ice_strans.c	(revision 1497)
+++ pjproject/trunk/pjnath/src/pjnath/ice_strans.c	(revision 1498)
@@ -578,4 +578,5 @@
 	status = pj_stun_session_create_req(comp->stun_sess,
 					    PJ_STUN_BINDING_REQUEST, 
+					    PJ_STUN_MAGIC,
 					    comp->ka_tsx_id, &tdata);
 	if (status != PJ_SUCCESS)
@@ -679,4 +680,5 @@
     status = pj_stun_session_create_req(comp->stun_sess, 
 					PJ_STUN_BINDING_REQUEST, 
+					PJ_STUN_MAGIC,
 					comp->ka_tsx_id, 
 					&tdata);
Index: pjproject/trunk/pjnath/src/pjnath/nat_detect.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath/nat_detect.c	(revision 1497)
+++ pjproject/trunk/pjnath/src/pjnath/nat_detect.c	(revision 1498)
@@ -55,4 +55,12 @@
 };
 
+static const char *test_names[] =
+{
+    "Test I: Binding request",
+    "Test II: Binding request with change address and port request",
+    "Test IB: Binding request to alternate address",
+    "Test III: Binding request with change port request"
+};
+
 typedef struct nat_detect_session
 {
@@ -309,17 +317,15 @@
     /* Create BIND request */
     status = pj_stun_session_create_req(sess->stun_sess, 
-					PJ_STUN_BINDING_REQUEST,
+					PJ_STUN_BINDING_REQUEST, 0x83224,
 					NULL, &tdata);
     if (status != PJ_SUCCESS)
 	return status;
 
-    /* Add CHANGE-REQUEST attribute if necessary */
-    if (change_flag) {
-	status = pj_stun_msg_add_uint_attr(sess->pool, tdata->msg,
-					   PJ_STUN_ATTR_CHANGE_REQUEST,
-					   change_flag);
-	if (status != PJ_SUCCESS)
-	    return status;
-    }
+    /* Add CHANGE-REQUEST attribute */
+    status = pj_stun_msg_add_uint_attr(sess->pool, tdata->msg,
+				       PJ_STUN_ATTR_CHANGE_REQUEST,
+				       change_flag);
+    if (status != PJ_SUCCESS)
+	return status;
 
     /* Configure alternate address */
@@ -328,4 +334,10 @@
     else
 	sess->cur_server = &sess->server;
+
+    PJ_LOG(5,(sess->pool->obj_name, 
+              "Performing %s to %s:%d", 
+	      test_names[state],
+	      pj_inet_ntoa(sess->cur_server->sin_addr),
+	      pj_ntohs(sess->cur_server->sin_port)));
 
     /* Send the request */
@@ -562,10 +574,10 @@
 
 	    /* Compare mapped address with local address */
-	    sess->test1_same_ip = (pj_memcmp(&sess->local_addr, &mattr->sockaddr,
-					     sizeof(pj_sockaddr_in))==0);
+	    sess->test1_same_ip=(pj_memcmp(&sess->local_addr, &mattr->sockaddr,
+					   sizeof(pj_sockaddr_in))==0);
 	    
 	    /* Execute test 2:
-	     *  Send BINDING_REQUEST with both the "change IP" and "change port" 
-	     *  flags from the CHANGE-REQUEST attribute set
+	     * Send BINDING_REQUEST with both the "change IP" and "change port" 
+	     * flags from the CHANGE-REQUEST attribute set
 	     */
 	    start_test(sess, ST_TEST_2, NULL, CHANGE_ADDR_PORT);
@@ -663,2 +675,3 @@
     sess_destroy(sess);
 }
+
Index: pjproject/trunk/pjnath/src/pjnath/stun_session.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath/stun_session.c	(revision 1497)
+++ pjproject/trunk/pjnath/src/pjnath/stun_session.c	(revision 1498)
@@ -127,4 +127,5 @@
 static pj_status_t create_request_tdata(pj_stun_session *sess,
 					unsigned msg_type,
+					pj_uint32_t magic,
 					const pj_uint8_t tsx_id[12],
 					pj_stun_tx_data **p_tdata)
@@ -138,5 +139,5 @@
 
     /* Create STUN message */
-    status = pj_stun_msg_create(tdata->pool, msg_type,  PJ_STUN_MAGIC, 
+    status = pj_stun_msg_create(tdata->pool, msg_type,  magic, 
 				tsx_id, &tdata->msg);
     if (status != PJ_SUCCESS) {
@@ -477,4 +478,5 @@
 PJ_DEF(pj_status_t) pj_stun_session_create_req(pj_stun_session *sess,
 					       int method,
+					       pj_uint32_t magic,
 					       const pj_uint8_t tsx_id[12],
 					       pj_stun_tx_data **p_tdata)
@@ -485,5 +487,5 @@
     PJ_ASSERT_RETURN(sess && p_tdata, PJ_EINVAL);
 
-    status = create_request_tdata(sess, method, tsx_id, &tdata);
+    status = create_request_tdata(sess, method, magic, tsx_id, &tdata);
     if (status != PJ_SUCCESS)
 	return status;
Index: pjproject/trunk/pjnath/src/pjstun-client/client_main.c
===================================================================
--- pjproject/trunk/pjnath/src/pjstun-client/client_main.c	(revision 1497)
+++ pjproject/trunk/pjnath/src/pjstun-client/client_main.c	(revision 1498)
@@ -376,5 +376,5 @@
 
     rc = pj_stun_session_create_req(g.sess, PJ_STUN_BINDING_REQUEST, 
-				    NULL, &tdata);
+				    PJ_STUN_MAGIC, NULL, &tdata);
     pj_assert(rc == PJ_SUCCESS);
 
@@ -392,5 +392,5 @@
 
     rc = pj_stun_session_create_req(g.sess, PJ_STUN_ALLOCATE_REQUEST, 
-				    NULL, &tdata);
+				    PJ_STUN_MAGIC, NULL, &tdata);
     pj_assert(rc == PJ_SUCCESS);
 
@@ -452,5 +452,5 @@
     rc = pj_stun_session_create_req(g.sess, 
 				    PJ_STUN_SET_ACTIVE_DESTINATION_REQUEST, 
-				    NULL, &tdata);
+				    PJ_STUN_MAGIC, NULL, &tdata);
     pj_assert(rc == PJ_SUCCESS);
 
