summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-03-02 10:37:41 +0000
committerBenny Prijono <bennylp@teluu.com>2008-03-02 10:37:41 +0000
commit6d938000550afc2c62cf7607adc44f1508ab3d94 (patch)
tree27f71e7c05538c1e725723ddd5bca06737574f6d /pjsip
parente8774b43447fd993b62f8f59b00734a769845a76 (diff)
Ticket #498: Option in client registration to ignore Contact address in REGISTER response
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1837 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/include/pjsip/sip_config.h32
-rw-r--r--pjsip/src/pjsip-ua/sip_reg.c16
-rw-r--r--pjsip/src/pjsip/sip_config.c5
3 files changed, 50 insertions, 3 deletions
diff --git a/pjsip/include/pjsip/sip_config.h b/pjsip/include/pjsip/sip_config.h
index f54397a7..a23ea2b8 100644
--- a/pjsip/include/pjsip/sip_config.h
+++ b/pjsip/include/pjsip/sip_config.h
@@ -23,7 +23,7 @@
* @file sip_config.h
* @brief Compile time configuration.
*/
-#include <pj/config.h>
+#include <pj/types.h>
/**
* @defgroup PJSIP PJSIP Library Collection
@@ -103,6 +103,21 @@ typedef struct pjsip_cfg_t
/* Dialog layer settings .. TODO */
+ /** Client registration settings. */
+ struct {
+ /**
+ * Specify whether client registration should check for its
+ * registered contact in Contact header of successful REGISTE
+ * response to determine whether registration has been successful.
+ * This setting may be disabled if non-compliant registrar is unable
+ * to return correct Contact header.
+ *
+ * Default is PJSIP_REGISTER_CLIENT_CHECK_CONTACT
+ */
+ pj_bool_t check_contact;
+
+ } regc;
+
} pjsip_cfg_t;
@@ -699,6 +714,21 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void)
/**
+ * Specify whether client registration should check for its registered
+ * contact in Contact header of successful REGISTE response to determine
+ * whether registration has been successful. This setting may be disabled
+ * if non-compliant registrar is unable to return correct Contact header.
+ *
+ * This setting can be changed in run-time with using pjsip_cfg().
+ *
+ * Default is 1
+ */
+#ifndef PJSIP_REGISTER_CLIENT_CHECK_CONTACT
+# define PJSIP_REGISTER_CLIENT_CHECK_CONTACT 1
+#endif
+
+
+/**
* @}
*/
diff --git a/pjsip/src/pjsip-ua/sip_reg.c b/pjsip/src/pjsip-ua/sip_reg.c
index e9f77ac1..a183f8f1 100644
--- a/pjsip/src/pjsip-ua/sip_reg.c
+++ b/pjsip/src/pjsip-ua/sip_reg.c
@@ -723,8 +723,20 @@ static void tsx_callback(void *token, pjsip_event *event)
/* Enumerate all Contact headers found in the response and
* find the Contact(s) that we register.
+ *
+ * Note:
+ * by default we require that the exact same URI that we
+ * register is returned in the 200/OK response (by exact,
+ * meaning all URI components including transport param),
+ * otherwise if we don't detect that our URI is there, we
+ * treat registration as failed.
+ *
+ * If your registrar server couldn't do this, you can
+ * disable this exact URI checking. See the compile time
+ * setting PJSIP_REGISTER_CLIENT_CHECK_CONTACT or the
+ * corresponding run-time setting in pjsip_cfg().
*/
- for (i=0; i<contact_cnt; ++i) {
+ for (i=0; i<contact_cnt && pjsip_cfg()->regc.check_contact; ++i) {
pjsip_contact_hdr *our_contact;
our_contact = (pjsip_contact_hdr*)
@@ -760,7 +772,7 @@ static void tsx_callback(void *token, pjsip_event *event)
/* When the response doesn't contain our Contact header, that
* means we have been unregistered.
*/
- if (!has_our_contact)
+ if (pjsip_cfg()->regc.check_contact && !has_our_contact)
expiration = 0;
/* Schedule next registration */
diff --git a/pjsip/src/pjsip/sip_config.c b/pjsip/src/pjsip/sip_config.c
index e0913792..701607fd 100644
--- a/pjsip/src/pjsip/sip_config.c
+++ b/pjsip/src/pjsip/sip_config.c
@@ -29,6 +29,11 @@ PJ_DEF_DATA(pjsip_cfg_t) pjsip_sip_cfg_var =
PJSIP_T2_TIMEOUT,
PJSIP_T4_TIMEOUT,
PJSIP_TD_TIMEOUT
+ },
+
+ /* Client registration client */
+ {
+ PJSIP_REGISTER_CLIENT_CHECK_CONTACT
}
};