Index: /pjproject/trunk/pjsip-apps/src/swig/symbols.i
===================================================================
--- /pjproject/trunk/pjsip-apps/src/swig/symbols.i	(revision 5720)
+++ /pjproject/trunk/pjsip-apps/src/swig/symbols.i	(revision 5721)
@@ -172,5 +172,5 @@
 typedef enum pjsua_vid_req_keyframe_method {PJSUA_VID_REQ_KEYFRAME_SIP_INFO = 1, PJSUA_VID_REQ_KEYFRAME_RTCP_PLI = 2} pjsua_vid_req_keyframe_method;
 
-typedef enum pjsua_call_flag {PJSUA_CALL_UNHOLD = 1, PJSUA_CALL_UPDATE_CONTACT = 2, PJSUA_CALL_INCLUDE_DISABLED_MEDIA = 4, PJSUA_CALL_NO_SDP_OFFER = 8, PJSUA_CALL_REINIT_MEDIA = 16, PJSUA_CALL_UPDATE_VIA = 32} pjsua_call_flag;
+typedef enum pjsua_call_flag {PJSUA_CALL_UNHOLD = 1, PJSUA_CALL_UPDATE_CONTACT = 2, PJSUA_CALL_INCLUDE_DISABLED_MEDIA = 4, PJSUA_CALL_NO_SDP_OFFER = 8, PJSUA_CALL_REINIT_MEDIA = 16, PJSUA_CALL_UPDATE_VIA = 32, PJSUA_CALL_UPDATE_TARGET = 64} pjsua_call_flag;
 
 typedef enum pjsua_create_media_transport_flag {PJSUA_MED_TP_CLOSE_MEMBER = 1} pjsua_create_media_transport_flag;
Index: /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
===================================================================
--- /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 5720)
+++ /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 5721)
@@ -1985,6 +1985,7 @@
     /**
      * Optional remote target URI (i.e. Target header). If NULL, the target
-     * will be set to the remote URI (To header). At the moment this field
-     * is only used by #pjsua_call_make_call() and #pjsua_im_send().
+     * will be set to the remote URI (To header). This field is used by
+     * pjsua_call_make_call(), pjsua_im_send(), pjsua_call_reinvite(),
+     * pjsua_call_set_hold(), and pjsua_call_update().
      */
     pj_str_t    target_uri;
@@ -4640,5 +4641,14 @@
      * been updated (typically with re-registration).
      */
-    PJSUA_CALL_UPDATE_VIA = 32
+    PJSUA_CALL_UPDATE_VIA = 32,
+
+    /**
+     * Update dialog target to URI specified in pjsua_msg_data.target_uri.
+     * This flag is only valid for pjsua_call_set_hold(),
+     * pjsua_call_reinvite(), and pjsua_call_update(). This flag can be
+     * useful in IP address change scenario where IP version has been changed
+     * and application needs to update target IP address.
+     */
+    PJSUA_CALL_UPDATE_TARGET = 64
 
 } pjsua_call_flag;
Index: /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c	(revision 5720)
+++ /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c	(revision 5721)
@@ -664,4 +664,62 @@
     }
 }
+
+
+static pj_status_t dlg_set_target(pjsip_dialog *dlg, const pj_str_t *target)
+{
+    pjsip_uri *target_uri;
+    pj_str_t tmp;
+    pj_status_t status;
+
+    /* Parse target & verify */
+    pj_strdup_with_null(dlg->pool, &tmp, target);
+    target_uri = pjsip_parse_uri(dlg->pool, tmp.ptr, tmp.slen, 0);
+    if (!target_uri) {
+	return PJSIP_EINVALIDURI;
+    }
+    if (!PJSIP_URI_SCHEME_IS_SIP(target_uri) &&
+	!PJSIP_URI_SCHEME_IS_SIPS(target_uri))
+    {
+	return PJSIP_EINVALIDSCHEME;
+    }
+
+    /* Add the new target */
+    status = pjsip_target_set_add_uri(&dlg->target_set, dlg->pool,
+				      target_uri, 0);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    /* Set it as current target */
+    status = pjsip_target_set_set_current(&dlg->target_set,
+			    pjsip_target_set_get_next(&dlg->target_set));
+    if (status != PJ_SUCCESS)
+	return status;
+
+    /* Update dialog target URI */
+    dlg->target = target_uri;
+
+    return PJ_SUCCESS;
+}
+
+
+/* Get account contact for call and update dialog transport */
+void call_update_contact(pjsua_call *call, pj_str_t **new_contact)
+{
+    pjsip_tpselector tp_sel;
+    pjsua_acc *acc = &pjsua_var.acc[call->acc_id];
+
+    if (acc->cfg.force_contact.slen)
+	*new_contact = &acc->cfg.force_contact;
+    else if (acc->contact.slen)
+	*new_contact = &acc->contact;
+
+    /* When contact is changed, the account transport may have been
+     * changed too, so let's update the dialog's transport too.
+     */
+    pjsua_init_tpselector(acc->cfg.transport_id, &tp_sel);
+    pjsip_dlg_set_transport(call->inv->dlg, &tp_sel);
+}
+
+
 
 /*
@@ -2512,5 +2570,5 @@
 	pjsua_acc_is_valid(call->acc_id))
     {
-	new_contact = &pjsua_var.acc[call->acc_id].contact;
+	call_update_contact(call, &new_contact);
     }
 
@@ -2519,4 +2577,14 @@
     {
     	dlg_set_via(call->inv->dlg, &pjsua_var.acc[call->acc_id]);
+    }
+
+    if ((call->opt.flag & PJSUA_CALL_UPDATE_TARGET) &&
+	msg_data && msg_data->target_uri.slen)
+    {
+	status = dlg_set_target(dlg, &msg_data->target_uri);
+	if (status != PJ_SUCCESS) {
+	    pjsua_perror(THIS_FILE, "Unable to set new target", status);
+	    goto on_return;
+	}
     }
 
@@ -2639,5 +2707,5 @@
 	    pjsua_acc_is_valid(call->acc_id))
     {
-	new_contact = &pjsua_var.acc[call->acc_id].contact;
+	call_update_contact(call, &new_contact);
     }
 
@@ -2646,4 +2714,14 @@
     {
     	dlg_set_via(call->inv->dlg, &pjsua_var.acc[call->acc_id]);
+    }
+
+    if ((call->opt.flag & PJSUA_CALL_UPDATE_TARGET) &&
+	msg_data && msg_data->target_uri.slen)
+    {
+	status = dlg_set_target(dlg, &msg_data->target_uri);
+	if (status != PJ_SUCCESS) {
+	    pjsua_perror(THIS_FILE, "Unable to set new target", status);
+	    goto on_return;
+	}
     }
 
@@ -2757,5 +2835,5 @@
 	    pjsua_acc_is_valid(call->acc_id))
     {
-	new_contact = &pjsua_var.acc[call->acc_id].contact;
+	call_update_contact(call, &new_contact);
     }
 
@@ -2764,4 +2842,14 @@
     {
 	dlg_set_via(call->inv->dlg, &pjsua_var.acc[call->acc_id]);
+    }
+
+    if ((call->opt.flag & PJSUA_CALL_UPDATE_TARGET) &&
+	msg_data && msg_data->target_uri.slen)
+    {
+	status = dlg_set_target(dlg, &msg_data->target_uri);
+	if (status != PJ_SUCCESS) {
+	    pjsua_perror(THIS_FILE, "Unable to set new target", status);
+	    goto on_return;
+	}
     }
 
