Index: pjproject/trunk/pjsip/src/pjsip/sip_dialog.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_dialog.c	(revision 4208)
+++ pjproject/trunk/pjsip/src/pjsip/sip_dialog.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * 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 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include <pjsip/sip_dialog.h>
@@ -74,6 +74,6 @@
 	return PJ_EINVALIDOP;
 
-    pool = pjsip_endpt_create_pool(endpt, "dlg%p", 
-				   PJSIP_POOL_LEN_DIALOG, 
+    pool = pjsip_endpt_create_pool(endpt, "dlg%p",
+				   PJSIP_POOL_LEN_DIALOG,
 				   PJSIP_POOL_INC_DIALOG);
     if (!pool)
@@ -195,6 +195,6 @@
     dlg->local.info = pjsip_from_hdr_create(dlg->pool);
     pj_strdup_with_null(dlg->pool, &dlg->local.info_str, local_uri);
-    dlg->local.info->uri = pjsip_parse_uri(dlg->pool, 
-					   dlg->local.info_str.ptr, 
+    dlg->local.info->uri = pjsip_parse_uri(dlg->pool,
+					   dlg->local.info_str.ptr,
 					   dlg->local.info_str.slen, 0);
     if (!dlg->local.info->uri) {
@@ -215,8 +215,8 @@
 
     /* Init local contact. */
-    pj_strdup_with_null(dlg->pool, &tmp, 
+    pj_strdup_with_null(dlg->pool, &tmp,
 			local_contact ? local_contact : local_uri);
     dlg->local.contact = (pjsip_contact_hdr*)
-			 pjsip_parse_hdr(dlg->pool, &HCONTACT, tmp.ptr, 
+			 pjsip_parse_hdr(dlg->pool, &HCONTACT, tmp.ptr,
 					 tmp.slen, NULL);
     if (!dlg->local.contact) {
@@ -228,6 +228,6 @@
     dlg->remote.info = pjsip_to_hdr_create(dlg->pool);
     pj_strdup_with_null(dlg->pool, &dlg->remote.info_str, remote_uri);
-    dlg->remote.info->uri = pjsip_parse_uri(dlg->pool, 
-					    dlg->remote.info_str.ptr, 
+    dlg->remote.info->uri = pjsip_parse_uri(dlg->pool,
+					    dlg->remote.info_str.ptr,
 					    dlg->remote.info_str.slen, 0);
     if (!dlg->remote.info->uri) {
@@ -240,5 +240,5 @@
 	PJSIP_URI_SCHEME_IS_SIPS(dlg->remote.info->uri))
     {
-	pjsip_sip_uri *sip_uri = (pjsip_sip_uri *) 
+	pjsip_sip_uri *sip_uri = (pjsip_sip_uri *)
 				 pjsip_uri_get_uri(dlg->remote.info->uri);
 	if (!pj_list_empty(&sip_uri->header_param)) {
@@ -249,8 +249,8 @@
 
 	    /* Print URI */
-	    tmp.ptr = (char*) pj_pool_alloc(dlg->pool, 
+	    tmp.ptr = (char*) pj_pool_alloc(dlg->pool,
 	    				    dlg->remote.info_str.slen);
 	    tmp.slen = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR,
-				       sip_uri, tmp.ptr, 
+				       sip_uri, tmp.ptr,
 				       dlg->remote.info_str.slen);
 
@@ -283,5 +283,5 @@
 
     /* Init client authentication session. */
-    status = pjsip_auth_clt_init(&dlg->auth_sess, dlg->endpt, 
+    status = pjsip_auth_clt_init(&dlg->auth_sess, dlg->endpt,
 				 dlg->pool, 0);
     if (status != PJ_SUCCESS)
@@ -333,9 +333,9 @@
 		     PJSIP_ENOTREQUESTMSG);
 
-    /* Request must not have To tag. 
+    /* Request must not have To tag.
      * This should have been checked in the user agent (or application?).
      */
     PJ_ASSERT_RETURN(rdata->msg_info.to->tag.slen == 0, PJ_EINVALIDOP);
-		     
+
     /* The request must be a dialog establishing request. */
     PJ_ASSERT_RETURN(
@@ -385,7 +385,7 @@
     /* TODO:
      *  Section 12.1.1, paragraph about using SIPS URI in Contact.
-     *  If the request that initiated the dialog contained a SIPS URI 
-     *  in the Request-URI or in the top Record-Route header field value, 
-     *  if there was any, or the Contact header field if there was no 
+     *  If the request that initiated the dialog contained a SIPS URI
+     *  in the Request-URI or in the top Record-Route header field value,
+     *  if there was any, or the Contact header field if there was no
      *  Record-Route header field, the Contact header field in the response
      *  MUST be a SIPS URI.
@@ -396,5 +396,5 @@
 	pj_strdup_with_null(dlg->pool, &tmp, contact);
 	dlg->local.contact = (pjsip_contact_hdr*)
-			     pjsip_parse_hdr(dlg->pool, &HCONTACT, tmp.ptr, 
+			     pjsip_parse_hdr(dlg->pool, &HCONTACT, tmp.ptr,
 					     tmp.slen, NULL);
 	if (!dlg->local.contact) {
@@ -409,5 +409,5 @@
 
     /* Init remote info from the From header. */
-    dlg->remote.info = (pjsip_fromto_hdr*) 
+    dlg->remote.info = (pjsip_fromto_hdr*)
     		       pjsip_hdr_clone(dlg->pool, rdata->msg_info.from);
     pjsip_fromto_hdr_set_to(dlg->remote.info);
@@ -426,5 +426,5 @@
 
 
-    /* Init remote's contact from Contact header. 
+    /* Init remote's contact from Contact header.
      * Iterate the Contact URI until we find sip: or sips: scheme.
      */
@@ -452,5 +452,5 @@
     }
 
-    dlg->remote.contact = (pjsip_contact_hdr*) 
+    dlg->remote.contact = (pjsip_contact_hdr*)
     			  pjsip_hdr_clone(dlg->pool, (pjsip_hdr*)contact_hdr);
 
@@ -464,7 +464,7 @@
     dlg->role = PJSIP_ROLE_UAS;
 
-    /* Secure? 
+    /* Secure?
      *  RFC 3261 Section 12.1.1:
-     *  If the request arrived over TLS, and the Request-URI contained a 
+     *  If the request arrived over TLS, and the Request-URI contained a
      *  SIPS URI, the 'secure' flag is set to TRUE.
      */
@@ -473,11 +473,11 @@
 
     /* Call-ID */
-    dlg->call_id = (pjsip_cid_hdr*) 
+    dlg->call_id = (pjsip_cid_hdr*)
     		   pjsip_hdr_clone(dlg->pool, rdata->msg_info.cid);
 
-    /* Route set. 
+    /* Route set.
      *  RFC 3261 Section 12.1.1:
-     *  The route set MUST be set to the list of URIs in the Record-Route 
-     *  header field from the request, taken in order and preserving all URI 
+     *  The route set MUST be set to the list of URIs in the Record-Route
+     *  header field from the request, taken in order and preserving all URI
      *  parameters. If no Record-Route header field is present in the request,
      * the route set MUST be set to the empty set.
@@ -499,5 +499,5 @@
 	if (rr == (void*)&rdata->msg_info.msg->hdr)
 	    break;
-	rr = (pjsip_route_hdr*) pjsip_msg_find_hdr(rdata->msg_info.msg, 
+	rr = (pjsip_route_hdr*) pjsip_msg_find_hdr(rdata->msg_info.msg,
 						   PJSIP_H_RECORD_ROUTE, rr);
     }
@@ -621,5 +621,5 @@
     /* Check arguments. */
     PJ_ASSERT_RETURN(first_dlg && rdata && new_dlg, PJ_EINVAL);
-    
+
     /* rdata must be response message. */
     PJ_ASSERT_RETURN(msg->type == PJSIP_RESPONSE_MSG,
@@ -649,5 +649,5 @@
 
     /* Clone local info. */
-    dlg->local.info = (pjsip_fromto_hdr*) 
+    dlg->local.info = (pjsip_fromto_hdr*)
     		      pjsip_hdr_clone(dlg->pool, first_dlg->local.info);
 
@@ -661,9 +661,9 @@
 
     /* Clone local Contact. */
-    dlg->local.contact = (pjsip_contact_hdr*) 
+    dlg->local.contact = (pjsip_contact_hdr*)
     			 pjsip_hdr_clone(dlg->pool, first_dlg->local.contact);
 
     /* Clone remote info. */
-    dlg->remote.info = (pjsip_fromto_hdr*) 
+    dlg->remote.info = (pjsip_fromto_hdr*)
     		       pjsip_hdr_clone(dlg->pool, first_dlg->remote.info);
 
@@ -690,5 +690,5 @@
 
     /* Clone Call-ID header. */
-    dlg->call_id = (pjsip_cid_hdr*) 
+    dlg->call_id = (pjsip_cid_hdr*)
     		   pjsip_hdr_clone(dlg->pool, first_dlg->call_id);
 
@@ -708,5 +708,5 @@
 
     /* Clone client authentication session. */
-    status = pjsip_auth_clt_clone(dlg->pool, &dlg->auth_sess, 
+    status = pjsip_auth_clt_clone(dlg->pool, &dlg->auth_sess,
 				  &first_dlg->auth_sess);
     if (status != PJ_SUCCESS)
@@ -842,5 +842,5 @@
 PJ_DEF(void) pjsip_dlg_inc_lock(pjsip_dialog *dlg)
 {
-    PJ_LOG(6,(dlg->obj_name, "Entering pjsip_dlg_inc_lock(), sess_count=%d", 
+    PJ_LOG(6,(dlg->obj_name, "Entering pjsip_dlg_inc_lock(), sess_count=%d",
 	      dlg->sess_count));
 
@@ -848,5 +848,5 @@
     dlg->sess_count++;
 
-    PJ_LOG(6,(dlg->obj_name, "Leaving pjsip_dlg_inc_lock(), sess_count=%d", 
+    PJ_LOG(6,(dlg->obj_name, "Leaving pjsip_dlg_inc_lock(), sess_count=%d",
 	      dlg->sess_count));
 }
@@ -859,5 +859,5 @@
     pj_status_t status;
 
-    PJ_LOG(6,(dlg->obj_name,"Entering pjsip_dlg_try_inc_lock(), sess_count=%d", 
+    PJ_LOG(6,(dlg->obj_name,"Entering pjsip_dlg_try_inc_lock(), sess_count=%d",
 	      dlg->sess_count));
 
@@ -870,5 +870,5 @@
     dlg->sess_count++;
 
-    PJ_LOG(6,(dlg->obj_name, "Leaving pjsip_dlg_try_inc_lock(), sess_count=%d", 
+    PJ_LOG(6,(dlg->obj_name, "Leaving pjsip_dlg_try_inc_lock(), sess_count=%d",
 	      dlg->sess_count));
 
@@ -885,5 +885,5 @@
     PJ_ASSERT_ON_FAIL(dlg!=NULL, return);
 
-    PJ_LOG(6,(dlg->obj_name, "Entering pjsip_dlg_dec_lock(), sess_count=%d", 
+    PJ_LOG(6,(dlg->obj_name, "Entering pjsip_dlg_dec_lock(), sess_count=%d",
 	      dlg->sess_count));
 
@@ -960,5 +960,5 @@
     PJ_ASSERT_RETURN(dlg->usage_cnt < PJSIP_MAX_MODULE, PJ_EBUG);
 
-    PJ_LOG(5,(dlg->obj_name, 
+    PJ_LOG(5,(dlg->obj_name,
 	      "Module %.*s added as dialog usage, data=%p",
 	      (int)mod->name.slen, mod->name.ptr, mod_data));
@@ -977,5 +977,5 @@
 	     * So return PJ_SUCCESS here.
 	     */
-	    PJ_LOG(4,(dlg->obj_name, 
+	    PJ_LOG(4,(dlg->obj_name,
 		      "Module %.*s already registered as dialog usage, "
 		      "updating the data %p",
@@ -1000,5 +1000,5 @@
     pj_array_insert(dlg->usage, sizeof(dlg->usage[0]), dlg->usage_cnt,
 		    index, &mod);
-    
+
     /* Set module data. */
     dlg->mod_data[mod->id] = mod_data;
@@ -1014,5 +1014,5 @@
 
 /*
- * Attach module specific data to the dialog. Application can also set 
+ * Attach module specific data to the dialog. Application can also set
  * the value directly by accessing dlg->mod_data[module_id].
  */
@@ -1044,5 +1044,5 @@
 /*
  * Create a new request within dialog (i.e. after the dialog session has been
- * established). The construction of such requests follows the rule in 
+ * established). The construction of such requests follows the rule in
  * RFC3261 section 12.2.1.
  */
@@ -1058,5 +1058,5 @@
 
     /* Contact Header field.
-     * Contact can only be present in requests that establish dialog (in the 
+     * Contact can only be present in requests that establish dialog (in the
      * core SIP spec, only INVITE).
      */
@@ -1083,5 +1083,5 @@
 	return status;
 
-    /* Just copy dialog route-set to Route header. 
+    /* Just copy dialog route-set to Route header.
      * The transaction will do the processing as specified in Section 12.2.1
      * of RFC 3261 in function tsx_process_route() in sip_transaction.c.
@@ -1193,8 +1193,8 @@
      */
     if (msg->line.req.method.id != PJSIP_CANCEL_METHOD &&
-	msg->line.req.method.id != PJSIP_ACK_METHOD) 
+	msg->line.req.method.id != PJSIP_ACK_METHOD)
     {
 	pjsip_cseq_hdr *ch;
-	
+
 	ch = PJSIP_MSG_CSEQ_HDR(msg);
 	PJ_ASSERT_RETURN(ch!=NULL, PJ_EBUG);
@@ -1245,5 +1245,5 @@
 
 	/* Send request */
-	status = pjsip_endpt_send_request_stateless(dlg->endpt, tdata, 
+	status = pjsip_endpt_send_request_stateless(dlg->endpt, tdata,
 						    NULL, NULL);
 	if (status != PJ_SUCCESS)
@@ -1260,5 +1260,5 @@
     /* Unlock dialog, may destroy dialog. */
     pjsip_dlg_dec_lock(dlg);
-   
+
     /* Whatever happen delete the message. */
     pjsip_tx_data_dec_ref( tdata );
@@ -1287,11 +1287,11 @@
 	/* Add Contact header for 1xx, 2xx, 3xx and 485 response. */
 	if (st_class==2 || st_class==3 || (st_class==1 && st_code != 100) ||
-	    st_code==485) 
+	    st_code==485)
 	{
 	    /* Add contact header only if one is not present. */
 	    if (pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CONTACT, NULL) == 0 &&
-		pjsip_msg_find_hdr_by_name(tdata->msg, &HCONTACT, NULL) == 0) 
+		pjsip_msg_find_hdr_by_name(tdata->msg, &HCONTACT, NULL) == 0)
 	    {
-		hdr = (pjsip_hdr*) pjsip_hdr_clone(tdata->pool, 
+		hdr = (pjsip_hdr*) pjsip_hdr_clone(tdata->pool,
 						   dlg->local.contact);
 		pjsip_msg_add_hdr(tdata->msg, hdr);
@@ -1302,5 +1302,5 @@
 	if ((((st_code/10==18 || st_class==2) && dlg->add_allow)
 	     || st_code==405) &&
-	    pjsip_msg_find_hdr(tdata->msg, PJSIP_H_ALLOW, NULL)==NULL) 
+	    pjsip_msg_find_hdr(tdata->msg, PJSIP_H_ALLOW, NULL)==NULL)
 	{
 	    c_hdr = pjsip_endpt_get_capability(dlg->endpt,
@@ -1313,6 +1313,6 @@
 
 	/* Add Supported header in 2xx response. */
-	if (st_class==2 && 
-	    pjsip_msg_find_hdr(tdata->msg, PJSIP_H_SUPPORTED, NULL)==NULL) 
+	if (st_class==2 &&
+	    pjsip_msg_find_hdr(tdata->msg, PJSIP_H_SUPPORTED, NULL)==NULL)
 	{
 	    c_hdr = pjsip_endpt_get_capability(dlg->endpt,
@@ -1401,5 +1401,5 @@
     }
 
-    /* Remove existing Contact header (without this, when dialog sent 
+    /* Remove existing Contact header (without this, when dialog sent
      * 180 and then 302, the Contact in 302 will not get updated).
      */
@@ -1446,5 +1446,5 @@
 	      pjsip_tx_data_get_info(tdata)));
 
-    /* Check that transaction method and cseq match the response. 
+    /* Check that transaction method and cseq match the response.
      * This operation is sloooww (search CSeq header twice), that's why
      * we only do it in debug mode.
@@ -1452,5 +1452,5 @@
 #if defined(PJ_DEBUG) && PJ_DEBUG!=0
     PJ_ASSERT_RETURN( PJSIP_MSG_CSEQ_HDR(tdata->msg)->cseq == tsx->cseq &&
-		      pjsip_method_cmp(&PJSIP_MSG_CSEQ_HDR(tdata->msg)->method, 
+		      pjsip_method_cmp(&PJSIP_MSG_CSEQ_HDR(tdata->msg)->method,
 				       &tsx->method)==0,
 		      PJ_EINVALIDOP);
@@ -1478,5 +1478,5 @@
     status = pjsip_tsx_send_msg(tsx, tdata);
 
-    /* This function must decrement transmit data request counter 
+    /* This function must decrement transmit data request counter
      * regardless of the operation status. The transaction only
      * decrements the counter if the operation is successful.
@@ -1563,5 +1563,5 @@
     if (rdata->msg_info.cseq->cseq <= dlg->remote.cseq &&
 	rdata->msg_info.msg->line.req.method.id != PJSIP_ACK_METHOD &&
-	rdata->msg_info.msg->line.req.method.id != PJSIP_CANCEL_METHOD) 
+	rdata->msg_info.msg->line.req.method.id != PJSIP_CANCEL_METHOD)
     {
 	/* Invalid CSeq.
@@ -1595,6 +1595,6 @@
 
     /* Create UAS transaction for this request. */
-    if (pjsip_rdata_get_tsx(rdata) == NULL && 
-	rdata->msg_info.msg->line.req.method.id != PJSIP_ACK_METHOD) 
+    if (pjsip_rdata_get_tsx(rdata) == NULL &&
+	rdata->msg_info.msg->line.req.method.id != PJSIP_ACK_METHOD)
     {
 	status = pjsip_tsx_create_uas(dlg->ua, rdata, &tsx);
@@ -1630,5 +1630,5 @@
 
 	contact = (pjsip_contact_hdr*)
-		  pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, 
+		  pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT,
 				     NULL);
 	if (contact && contact->uri &&
@@ -1638,5 +1638,5 @@
 			   contact->uri)))
 	{
-	    dlg->remote.contact = (pjsip_contact_hdr*) 
+	    dlg->remote.contact = (pjsip_contact_hdr*)
 	    			  pjsip_hdr_clone(dlg->pool, contact);
 	    dlg->target = dlg->remote.contact->uri;
@@ -1688,9 +1688,9 @@
 {
     const pjsip_hdr *hdr, *end_hdr;
-    pj_int32_t msg_cseq;
+    //pj_int32_t msg_cseq;
     const pjsip_msg *msg;
 
     msg = rdata->msg_info.msg;
-    msg_cseq = rdata->msg_info.cseq->cseq;
+    //msg_cseq = rdata->msg_info.cseq->cseq;
 
     /* Ignore if route set has been frozen */
@@ -1708,5 +1708,5 @@
 
 	/* Ignore subsequent responses with higher CSeq than initial CSeq.
-	 * Unfortunately this would be broken when the first request is 
+	 * Unfortunately this would be broken when the first request is
 	 * challenged!
 	 */
@@ -1747,6 +1747,6 @@
     PJ_LOG(5,(dlg->obj_name, "Route-set updated"));
 
-    /* Freeze the route set only when the route set comes in 2xx response. 
-     * If it is in 1xx response, prepare to recompute the route set when 
+    /* Freeze the route set only when the route set comes in 2xx response.
+     * If it is in 1xx response, prepare to recompute the route set when
      * the 2xx response comes in.
      *
@@ -1756,9 +1756,9 @@
      * upon receiving 2xx response). Also RFC 3261 says so in 13.2.2.4.
      *
-     * The pjsip_method_creates_dialog() check protects from wrongly 
+     * The pjsip_method_creates_dialog() check protects from wrongly
      * freezing the route set upon receiving 200/OK response for PRACK.
      */
     if (pjsip_method_creates_dialog(&rdata->msg_info.cseq->method) &&
-	PJSIP_IS_STATUS_IN_CLASS(msg->line.status.code, 200)) 
+	PJSIP_IS_STATUS_IN_CLASS(msg->line.status.code, 200))
     {
 	dlg->route_set_frozen = PJ_TRUE;
@@ -1789,5 +1789,5 @@
     res_code = rdata->msg_info.msg->line.status.code;
 
-    /* When we receive response that establishes dialog, update To tag, 
+    /* When we receive response that establishes dialog, update To tag,
      * route set and dialog target.
      *
@@ -1803,11 +1803,11 @@
      * New update:
      * We also need to update the dialog for 1xx responses, to handle the
-     * case when 100rel is used, otherwise PRACK will be sent to the 
+     * case when 100rel is used, otherwise PRACK will be sent to the
      * wrong target.
      */
-    if ((dlg->state == PJSIP_DIALOG_STATE_NULL && 
+    if ((dlg->state == PJSIP_DIALOG_STATE_NULL &&
 	 pjsip_method_creates_dialog(&rdata->msg_info.cseq->method) &&
 	 (res_code > 100 && res_code < 300) &&
-	 rdata->msg_info.to->tag.slen) 
+	 rdata->msg_info.to->tag.slen)
 	 ||
 	(dlg->role==PJSIP_ROLE_UAC &&
@@ -1820,5 +1820,5 @@
 	pjsip_contact_hdr *contact;
 
-	/* Update remote capability info, when To tags in the dialog remote 
+	/* Update remote capability info, when To tags in the dialog remote
 	 * info and the incoming response are different, e.g: first response
 	 * with To-tag or forking, apply strict update.
@@ -1834,7 +1834,7 @@
 	/* RFC 3271 Section 12.1.2:
 	 * The route set MUST be set to the list of URIs in the Record-Route
-	 * header field from the response, taken in reverse order and 
-	 * preserving all URI parameters. If no Record-Route header field 
-	 * is present in the response, the route set MUST be set to the 
+	 * header field from the response, taken in reverse order and
+	 * preserving all URI parameters. If no Record-Route header field
+	 * is present in the response, the route set MUST be set to the
 	 * empty set. This route set, even if empty, overrides any pre-existing
 	 * route set for future requests in this dialog.
@@ -1842,9 +1842,9 @@
 	dlg_update_routeset(dlg, rdata);
 
-	/* The remote target MUST be set to the URI from the Contact header 
+	/* The remote target MUST be set to the URI from the Contact header
 	 * field of the response.
 	 */
 	contact = (pjsip_contact_hdr*)
-		  pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, 
+		  pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT,
 				     NULL);
 	if (contact && contact->uri &&
@@ -1854,5 +1854,5 @@
 			   contact->uri)))
 	{
-	    dlg->remote.contact = (pjsip_contact_hdr*) 
+	    dlg->remote.contact = (pjsip_contact_hdr*)
 	    			  pjsip_hdr_clone(dlg->pool, contact);
 	    dlg->target = dlg->remote.contact->uri;
@@ -1864,6 +1864,6 @@
 	 * gets through this dialog (it shouldn't happen).
 	 */
-	if (dlg->role==PJSIP_ROLE_UAC && !dlg->uac_has_2xx && 
-	    res_code/100==2) 
+	if (dlg->role==PJSIP_ROLE_UAC && !dlg->uac_has_2xx &&
+	    res_code/100==2)
 	{
 	    dlg->uac_has_2xx = PJ_TRUE;
@@ -1872,5 +1872,5 @@
 
     /* Update remote target (again) when receiving 2xx response messages
-     * that's defined as target refresh. 
+     * that's defined as target refresh.
      *
      * Also upon receiving 2xx response, recheck again the route set.
@@ -1882,5 +1882,5 @@
 	the "confirmed" state, and the route set for the dialog MUST be
 	recomputed based on the 2xx response using the procedures of Section
-	12.2.1.2. 
+	12.2.1.2.
 
 	Note that the only piece of state that is recomputed is the route
@@ -1897,5 +1897,5 @@
 
 	contact = (pjsip_contact_hdr*) pjsip_msg_find_hdr(rdata->msg_info.msg,
-							  PJSIP_H_CONTACT, 
+							  PJSIP_H_CONTACT,
 				     			  NULL);
 	if (contact && contact->uri &&
@@ -1905,5 +1905,5 @@
 			   contact->uri)))
 	{
-	    dlg->remote.contact = (pjsip_contact_hdr*) 
+	    dlg->remote.contact = (pjsip_contact_hdr*)
 	    			  pjsip_hdr_clone(dlg->pool, contact);
 	    dlg->target = dlg->remote.contact->uri;
@@ -1943,6 +1943,6 @@
 	pj_status_t status;
 
-	if (rdata->msg_info.cseq->method.id==PJSIP_INVITE_METHOD && 
-	    rdata->msg_info.msg->line.status.code/100 == 2) 
+	if (rdata->msg_info.cseq->method.id==PJSIP_INVITE_METHOD &&
+	    rdata->msg_info.msg->line.status.code/100 == 2)
 	{
 	    pjsip_tx_data *ack;
@@ -1958,9 +1958,9 @@
 	    pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
 	    pjsip_tx_data *tdata;
-	    
-	    status = pjsip_auth_clt_reinit_req( &dlg->auth_sess, 
+
+	    status = pjsip_auth_clt_reinit_req( &dlg->auth_sess,
 						rdata, tsx->last_tx,
 						&tdata);
-	    
+
 	    if (status == PJ_SUCCESS) {
 		/* Re-send request. */
@@ -2015,5 +2015,5 @@
      */
     if (tsx->state == PJSIP_TSX_STATE_TERMINATED &&
-	tsx->mod_data[dlg->ua->id] == dlg) 
+	tsx->mod_data[dlg->ua->id] == dlg)
     {
 	pj_assert(dlg->tsx_count>0);
@@ -2045,5 +2045,5 @@
     pjsip_dlg_inc_lock(dlg);
 
-    hdr = (const pjsip_generic_array_hdr*) 
+    hdr = (const pjsip_generic_array_hdr*)
 	   pjsip_dlg_get_remote_cap_hdr(dlg, htype, hname);
     if (!hdr) {
@@ -2072,5 +2072,5 @@
 						pj_bool_t strict)
 {
-    pjsip_hdr_e htypes[] = 
+    pjsip_hdr_e htypes[] =
 	{ PJSIP_H_ACCEPT, PJSIP_H_ALLOW, PJSIP_H_SUPPORTED };
     unsigned i;
