Index: /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
===================================================================
--- /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 3212)
+++ /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 3213)
@@ -1901,4 +1901,28 @@
 
 /**
+ * This macro specifies the default value for \a contact_rewrite_method
+ * field in pjsua_acc_config. I specifies  how Contact update will be
+ * done with the registration, if \a allow_contact_rewrite is enabled in
+ *  the account config.
+ *
+ * If set to 1, the Contact update will be done by sending unregistration
+ * to the currently registered Contact, while simultaneously sending new
+ * registration (with different Call-ID) for the updated Contact.
+ *
+ * If set to 2, the Contact update will be done in a single, current
+ * registration session, by removing the current binding (by setting its
+ * Contact's expires parameter to zero) and adding a new Contact binding,
+ * all done in a single request.
+ *
+ * Value 1 is the legacy behavior.
+ *
+ * Default value: 2
+ */
+#ifndef PJSUA_CONTACT_REWRITE_METHOD
+#   define PJSUA_CONTACT_REWRITE_METHOD		2
+#endif
+
+
+/**
  * This structure describes account configuration to be specified when
  * adding a new account with #pjsua_acc_add(). Application MUST initialize
@@ -2107,7 +2131,28 @@
      * configured. 
      *
+     * See also contact_rewrite_method field.
+     *
      * Default: 1 (yes)
      */
     pj_bool_t allow_contact_rewrite;
+
+    /**
+     * Specify how Contact update will be done with the registration, if
+     * \a allow_contact_rewrite is enabled.
+     *
+     * If set to 1, the Contact update will be done by sending unregistration
+     * to the currently registered Contact, while simultaneously sending new
+     * registration (with different Call-ID) for the updated Contact.
+     *
+     * If set to 2, the Contact update will be done in a single, current
+     * registration session, by removing the current binding (by setting its
+     * Contact's expires parameter to zero) and adding a new Contact binding,
+     * all done in a single request.
+     *
+     * Value 1 is the legacy behavior.
+     *
+     * Default value: PJSUA_CONTACT_REWRITE_METHOD (2)
+     */
+    int		     contact_rewrite_method;
 
     /**
Index: /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c	(revision 3212)
+++ /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c	(revision 3213)
@@ -1099,5 +1099,6 @@
 
     PJ_LOG(3,(THIS_FILE, "IP address change detected for account %d "
-			 "(%.*s:%d --> %.*s:%d). Updating registration..",
+			 "(%.*s:%d --> %.*s:%d). Updating registration "
+			 "(using method %d)",
 			 acc->index,
 			 (int)uri->host.slen,
@@ -1106,15 +1107,23 @@
 			 (int)via_addr->slen,
 			 via_addr->ptr,
-			 rport));
-
-    /* Unregister current contact */
-    pjsua_acc_set_registration(acc->index, PJ_FALSE);
-    if (acc->regc != NULL) {
-	pjsip_regc_destroy(acc->regc);
-	acc->regc = NULL;
-	acc->contact.slen = 0;
-    }
-
-    /* Update account's Contact header */
+			 rport,
+			 acc->cfg.contact_rewrite_method));
+
+    pj_assert(acc->cfg.contact_rewrite_method == 1 ||
+	      acc->cfg.contact_rewrite_method == 2);
+
+    if (acc->cfg.contact_rewrite_method == 1) {
+	/* Unregister current contact */
+	pjsua_acc_set_registration(acc->index, PJ_FALSE);
+	if (acc->regc != NULL) {
+	    pjsip_regc_destroy(acc->regc);
+	    acc->regc = NULL;
+	    acc->contact.slen = 0;
+	}
+    }
+
+    /*
+     * Build new Contact header
+     */
     {
 	char *tmp;
@@ -1152,9 +1161,14 @@
 	}
 	pj_strdup2_with_null(acc->pool, &acc->contact, tmp);
-    }
-
-    /* Always update, by http://trac.pjsip.org/repos/ticket/864. */
-    pj_strdup_with_null(tp->pool, &tp->local_name.host, via_addr);
-    tp->local_name.port = rport;
+
+	/* Always update, by http://trac.pjsip.org/repos/ticket/864. */
+	pj_strdup_with_null(tp->pool, &tp->local_name.host, via_addr);
+	tp->local_name.port = rport;
+
+    }
+
+    if (acc->cfg.contact_rewrite_method == 2 && acc->regc != NULL) {
+	pjsip_regc_update_contact(acc->regc, 1, &acc->contact);
+    }
 
     /* Perform new registration */
Index: /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 3212)
+++ /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 3213)
@@ -179,4 +179,5 @@
 #endif
     cfg->reg_retry_interval = PJSUA_REG_RETRY_INTERVAL;
+    cfg->contact_rewrite_method = PJSUA_CONTACT_REWRITE_METHOD;
 }
 
