summaryrefslogtreecommitdiff
path: root/pjsip/src
diff options
context:
space:
mode:
Diffstat (limited to 'pjsip/src')
-rw-r--r--pjsip/src/pjsip-ua/sip_100rel.c2
-rw-r--r--pjsip/src/pjsip/sip_auth_client.c1
-rw-r--r--pjsip/src/pjsip/sip_config.c41
-rw-r--r--pjsip/src/pjsip/sip_transaction.c51
-rw-r--r--pjsip/src/test-pjsip/tsx_uac_test.c6
-rw-r--r--pjsip/src/test-pjsip/tsx_uas_test.c12
6 files changed, 85 insertions, 28 deletions
diff --git a/pjsip/src/pjsip-ua/sip_100rel.c b/pjsip/src/pjsip-ua/sip_100rel.c
index bca90947..9e4b7a5c 100644
--- a/pjsip/src/pjsip-ua/sip_100rel.c
+++ b/pjsip/src/pjsip-ua/sip_100rel.c
@@ -559,7 +559,7 @@ static void on_retransmit(pj_timer_heap_t *timer_heap,
if (dd->uas_state->retransmit_count < 6) {
delay.sec = 0;
delay.msec = (1 << dd->uas_state->retransmit_count) *
- PJSIP_T1_TIMEOUT;
+ pjsip_cfg()->tsx.t1;
pj_time_val_normalize(&delay);
} else {
delay.sec = 1;
diff --git a/pjsip/src/pjsip/sip_auth_client.c b/pjsip/src/pjsip/sip_auth_client.c
index bf09bad8..5730d6f2 100644
--- a/pjsip/src/pjsip/sip_auth_client.c
+++ b/pjsip/src/pjsip/sip_auth_client.c
@@ -23,6 +23,7 @@
#include <pjsip/sip_transport.h>
#include <pjsip/sip_endpoint.h>
#include <pjsip/sip_errno.h>
+#include <pjsip/sip_util.h>
#include <pjlib-util/md5.h>
#include <pj/log.h>
#include <pj/string.h>
diff --git a/pjsip/src/pjsip/sip_config.c b/pjsip/src/pjsip/sip_config.c
new file mode 100644
index 00000000..e0913792
--- /dev/null
+++ b/pjsip/src/pjsip/sip_config.c
@@ -0,0 +1,41 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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
+ */
+
+#include <pjsip/sip_config.h>
+
+/* pjsip configuration instance, initialized with default values */
+PJ_DEF_DATA(pjsip_cfg_t) pjsip_sip_cfg_var =
+{
+ /* Transaction settings */
+ {
+ PJSIP_MAX_TSX_COUNT,
+ PJSIP_T1_TIMEOUT,
+ PJSIP_T2_TIMEOUT,
+ PJSIP_T4_TIMEOUT,
+ PJSIP_TD_TIMEOUT
+ }
+};
+
+
+#ifdef PJ_DLL
+PJ_DEF(pjsip_cfg_t*) pjsip_cfg(void)
+{
+ return &pjsip_sip_cfg_var;
+}
+#endif
diff --git a/pjsip/src/pjsip/sip_transaction.c b/pjsip/src/pjsip/sip_transaction.c
index 61f85cef..ca767bb5 100644
--- a/pjsip/src/pjsip/sip_transaction.c
+++ b/pjsip/src/pjsip/sip_transaction.c
@@ -130,16 +130,16 @@ typedef struct tsx_lock_data {
/* Timer timeout value constants */
-static const pj_time_val t1_timer_val = { PJSIP_T1_TIMEOUT/1000,
- PJSIP_T1_TIMEOUT%1000 };
-static const pj_time_val t2_timer_val = { PJSIP_T2_TIMEOUT/1000,
- PJSIP_T2_TIMEOUT%1000 };
-static const pj_time_val t4_timer_val = { PJSIP_T4_TIMEOUT/1000,
- PJSIP_T4_TIMEOUT%1000 };
-static const pj_time_val td_timer_val = { PJSIP_TD_TIMEOUT/1000,
- PJSIP_TD_TIMEOUT%1000 };
-static const pj_time_val timeout_timer_val = { (64*PJSIP_T1_TIMEOUT)/1000,
- (64*PJSIP_T1_TIMEOUT)%1000 };
+static pj_time_val t1_timer_val = { PJSIP_T1_TIMEOUT/1000,
+ PJSIP_T1_TIMEOUT%1000 };
+static pj_time_val t2_timer_val = { PJSIP_T2_TIMEOUT/1000,
+ PJSIP_T2_TIMEOUT%1000 };
+static pj_time_val t4_timer_val = { PJSIP_T4_TIMEOUT/1000,
+ PJSIP_T4_TIMEOUT%1000 };
+static pj_time_val td_timer_val = { PJSIP_TD_TIMEOUT/1000,
+ PJSIP_TD_TIMEOUT%1000 };
+static pj_time_val timeout_timer_val = { (64*PJSIP_T1_TIMEOUT)/1000,
+ (64*PJSIP_T1_TIMEOUT)%1000 };
#define TIMER_INACTIVE 0
#define TIMER_ACTIVE 1
@@ -427,6 +427,18 @@ PJ_DEF(pj_status_t) pjsip_tsx_layer_init_module(pjsip_endpoint *endpt)
PJ_ASSERT_RETURN(mod_tsx_layer.endpt==NULL, PJ_EINVALIDOP);
+ /* Initialize timer values */
+ t1_timer_val.sec = pjsip_cfg()->tsx.t1 / 1000;
+ t1_timer_val.msec = pjsip_cfg()->tsx.t1 % 1000;
+ t2_timer_val.sec = pjsip_cfg()->tsx.t2 / 1000;
+ t2_timer_val.msec = pjsip_cfg()->tsx.t2 % 1000;
+ t4_timer_val.sec = pjsip_cfg()->tsx.t4 / 1000;
+ t4_timer_val.msec = pjsip_cfg()->tsx.t4 % 1000;
+ td_timer_val.sec = pjsip_cfg()->tsx.td / 1000;
+ td_timer_val.msec = pjsip_cfg()->tsx.td % 1000;
+ timeout_timer_val.sec = (64 * pjsip_cfg()->tsx.t1) / 1000;
+ timeout_timer_val.msec = (64 * pjsip_cfg()->tsx.t1) % 1000;
+
/* Initialize TLS ID for transaction lock. */
status = pj_thread_local_alloc(&pjsip_tsx_lock_tls_id);
if (status != PJ_SUCCESS)
@@ -452,7 +464,7 @@ PJ_DEF(pj_status_t) pjsip_tsx_layer_init_module(pjsip_endpoint *endpt)
/* Create hash table. */
- mod_tsx_layer.htable = pj_hash_create( pool, PJSIP_MAX_TSX_COUNT );
+ mod_tsx_layer.htable = pj_hash_create( pool, pjsip_cfg()->tsx.max_count );
if (!mod_tsx_layer.htable) {
pjsip_endpt_release_pool(endpt, pool);
return PJ_ENOMEM;
@@ -1867,25 +1879,28 @@ PJ_DEF(pj_status_t) pjsip_tsx_retransmit_no_state(pjsip_transaction *tsx,
static void tsx_resched_retransmission( pjsip_transaction *tsx )
{
pj_time_val timeout;
- int msec_time;
+ unsigned msec_time;
pj_assert((tsx->transport_flag & TSX_HAS_PENDING_TRANSPORT) == 0);
if (tsx->role==PJSIP_ROLE_UAC && tsx->status_code >= 100)
- msec_time = PJSIP_T2_TIMEOUT;
+ msec_time = pjsip_cfg()->tsx.t2;
else
- msec_time = (1 << (tsx->retransmit_count)) * PJSIP_T1_TIMEOUT;
+ msec_time = (1 << (tsx->retransmit_count)) * pjsip_cfg()->tsx.t1;
if (tsx->role == PJSIP_ROLE_UAC) {
pj_assert(tsx->status_code < 200);
/* Retransmission for non-INVITE transaction caps-off at T2 */
- if (msec_time>PJSIP_T2_TIMEOUT && tsx->method.id!=PJSIP_INVITE_METHOD)
- msec_time = PJSIP_T2_TIMEOUT;
+ if (msec_time > pjsip_cfg()->tsx.t2 &&
+ tsx->method.id != PJSIP_INVITE_METHOD)
+ {
+ msec_time = pjsip_cfg()->tsx.t2;
+ }
} else {
/* Retransmission of INVITE final response also caps-off at T2 */
pj_assert(tsx->status_code >= 200);
- if (msec_time>PJSIP_T2_TIMEOUT)
- msec_time = PJSIP_T2_TIMEOUT;
+ if (msec_time > pjsip_cfg()->tsx.t2)
+ msec_time = pjsip_cfg()->tsx.t2;
}
timeout.sec = msec_time / 1000;
diff --git a/pjsip/src/test-pjsip/tsx_uac_test.c b/pjsip/src/test-pjsip/tsx_uac_test.c
index 60b7bcee..a4a340de 100644
--- a/pjsip/src/test-pjsip/tsx_uac_test.c
+++ b/pjsip/src/test-pjsip/tsx_uac_test.c
@@ -614,11 +614,11 @@ static pj_bool_t msg_receiver_on_rx_request(pjsip_rx_data *rdata)
msec_elapsed = now.sec*1000 + now.msec;
++recv_count;
- msec_expected = (1<<(recv_count-2))*PJSIP_T1_TIMEOUT;
+ msec_expected = (1<<(recv_count-2))*pjsip_cfg()->tsx.t1;
if (msg->line.req.method.id != PJSIP_INVITE_METHOD) {
- if (msec_expected > PJSIP_T2_TIMEOUT)
- msec_expected = PJSIP_T2_TIMEOUT;
+ if (msec_expected > pjsip_cfg()->tsx.t2)
+ msec_expected = pjsip_cfg()->tsx.t2;
max_received = 11;
} else {
max_received = 7;
diff --git a/pjsip/src/test-pjsip/tsx_uas_test.c b/pjsip/src/test-pjsip/tsx_uas_test.c
index 7ca05a89..74c40c71 100644
--- a/pjsip/src/test-pjsip/tsx_uas_test.c
+++ b/pjsip/src/test-pjsip/tsx_uas_test.c
@@ -986,9 +986,9 @@ static pj_bool_t on_rx_message(pjsip_rx_data *rdata)
PJ_TIME_VAL_SUB(now, recv_last);
msec = now.sec*1000 + now.msec;
- msec_expected = (1 << (recv_count-2)) * PJSIP_T1_TIMEOUT;
- if (msec_expected > PJSIP_T2_TIMEOUT)
- msec_expected = PJSIP_T2_TIMEOUT;
+ msec_expected = (1 << (recv_count-2)) * pjsip_cfg()->tsx.t1;
+ if (msec_expected > pjsip_cfg()->tsx.t2)
+ msec_expected = pjsip_cfg()->tsx.t2;
if (DIFF(msec, msec_expected) > MAX_ALLOWED_DIFF) {
PJ_LOG(3,(THIS_FILE,
@@ -1058,9 +1058,9 @@ static pj_bool_t on_rx_message(pjsip_rx_data *rdata)
PJ_TIME_VAL_SUB(now, recv_last);
msec = now.sec*1000 + now.msec;
- msec_expected = (1 << (recv_count-2)) * PJSIP_T1_TIMEOUT;
- if (msec_expected > PJSIP_T2_TIMEOUT)
- msec_expected = PJSIP_T2_TIMEOUT;
+ msec_expected = (1 << (recv_count-2)) * pjsip_cfg()->tsx.t1;
+ if (msec_expected > pjsip_cfg()->tsx.t2)
+ msec_expected = pjsip_cfg()->tsx.t2;
if (DIFF(msec, msec_expected) > MAX_ALLOWED_DIFF) {
PJ_LOG(3,(THIS_FILE,