summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-01-14 00:39:45 +0000
committerBenny Prijono <bennylp@teluu.com>2007-01-14 00:39:45 +0000
commit37ebd8262c2fded33381779df58351ba11c050de (patch)
tree2fc55477ce7f52492bf7d8de73bb1e5e99322805
parent2fe4e4e9985b9c4cbff7209a9c876a314abc9779 (diff)
Continuing work on ticket #50: make explicit transport selection works for sending response
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@882 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip-apps/src/pjsua/pjsua_app.c20
-rw-r--r--pjsip/include/pjsip/sip_dialog.h4
-rw-r--r--pjsip/include/pjsip/sip_transaction.h8
-rw-r--r--pjsip/include/pjsip/sip_transport.h1
-rw-r--r--pjsip/src/pjsip/sip_dialog.c11
-rw-r--r--pjsip/src/pjsip/sip_transaction.c2
6 files changed, 29 insertions, 17 deletions
diff --git a/pjsip-apps/src/pjsua/pjsua_app.c b/pjsip-apps/src/pjsua/pjsua_app.c
index 42395174..ac469767 100644
--- a/pjsip-apps/src/pjsua/pjsua_app.c
+++ b/pjsip-apps/src/pjsua/pjsua_app.c
@@ -2891,23 +2891,25 @@ pj_status_t app_init(int argc, char *argv[])
app_config.rec_port = pjsua_recorder_get_conf_port(app_config.rec_id);
}
- /* Add TCP transport unless it's disabled */
- if (!app_config.no_tcp) {
- status = pjsua_transport_create(PJSIP_TRANSPORT_TCP,
+ /* Add UDP transport unless it's disabled. */
+ if (!app_config.no_udp) {
+ pjsua_acc_id aid;
+
+ status = pjsua_transport_create(PJSIP_TRANSPORT_UDP,
&app_config.udp_cfg,
&transport_id);
if (status != PJ_SUCCESS)
goto on_error;
/* Add local account */
- pjsua_acc_add_local(transport_id, PJ_TRUE, NULL);
+ pjsua_acc_add_local(transport_id, PJ_TRUE, &aid);
+ //pjsua_acc_set_transport(aid, transport_id);
pjsua_acc_set_online_status(current_acc, PJ_TRUE);
-
}
- /* Add UDP transport unless it's disabled. */
- if (!app_config.no_udp) {
- status = pjsua_transport_create(PJSIP_TRANSPORT_UDP,
+ /* Add TCP transport unless it's disabled */
+ if (!app_config.no_tcp) {
+ status = pjsua_transport_create(PJSIP_TRANSPORT_TCP,
&app_config.udp_cfg,
&transport_id);
if (status != PJ_SUCCESS)
@@ -2916,8 +2918,10 @@ pj_status_t app_init(int argc, char *argv[])
/* Add local account */
pjsua_acc_add_local(transport_id, PJ_TRUE, NULL);
pjsua_acc_set_online_status(current_acc, PJ_TRUE);
+
}
+
#if defined(PJSIP_HAS_TLS_TRANSPORT) && PJSIP_HAS_TLS_TRANSPORT!=0
/* Add TLS transport when application wants one */
if (app_config.use_tls) {
diff --git a/pjsip/include/pjsip/sip_dialog.h b/pjsip/include/pjsip/sip_dialog.h
index 9cea4ded..05a0d724 100644
--- a/pjsip/include/pjsip/sip_dialog.h
+++ b/pjsip/include/pjsip/sip_dialog.h
@@ -230,8 +230,8 @@ PJ_DECL(pj_status_t) pjsip_dlg_create_uas( pjsip_user_agent *ua,
/**
* Lock/bind dialog to a specific transport/listener. This is optional,
* as normally transport will be selected automatically based on the
- * destination of requests upon resolver completion. When the dialog is
- * explicitly bound to the specific transport/listener, all UAC transactions
+ * destination of messages upon resolver completion. When the dialog is
+ * explicitly bound to the specific transport/listener, all transactions
* originated by this dialog will use the specified transport/listener
* when sending outgoing requests.
*
diff --git a/pjsip/include/pjsip/sip_transaction.h b/pjsip/include/pjsip/sip_transaction.h
index dfd00339..0b5eee10 100644
--- a/pjsip/include/pjsip/sip_transaction.h
+++ b/pjsip/include/pjsip/sip_transaction.h
@@ -218,13 +218,9 @@ PJ_DECL(pj_status_t) pjsip_tsx_create_uas( pjsip_module *tsx_user,
/**
* Lock/bind transaction to a specific transport/listener. This is optional,
* as normally transport will be selected automatically based on the
- * destination of the request upon resolver completion. Also it's only valid
- * for UAC transaction (to send outgoing request), since for UAS the
- * transport will be selected according to rules about handling incoming
- * request (most likely it will use the transport where the request is
- * coming from if ";rport" parameter is present in Via header).
+ * destination of the message upon resolver completion.
*
- * @param tsx The UAC transaction.
+ * @param tsx The transaction.
* @param sel Transport selector containing the specification of
* transport or listener to be used by this transaction
* to send requests.
diff --git a/pjsip/include/pjsip/sip_transport.h b/pjsip/include/pjsip/sip_transport.h
index 1c82c385..d0e112f2 100644
--- a/pjsip/include/pjsip/sip_transport.h
+++ b/pjsip/include/pjsip/sip_transport.h
@@ -211,6 +211,7 @@ typedef struct pjsip_tpselector
union {
pjsip_transport *transport;
pjsip_tpfactory *listener;
+ void *ptr;
} u;
} pjsip_tpselector;
diff --git a/pjsip/src/pjsip/sip_dialog.c b/pjsip/src/pjsip/sip_dialog.c
index 7b97e5b8..7858f086 100644
--- a/pjsip/src/pjsip/sip_dialog.c
+++ b/pjsip/src/pjsip/sip_dialog.c
@@ -1325,6 +1325,17 @@ PJ_DEF(pj_status_t) pjsip_dlg_send_response( pjsip_dialog *dlg,
/* Must acquire dialog first, to prevent deadlock */
pjsip_dlg_inc_lock(dlg);
+ /* If the dialog is locked to transport, make sure that transaction
+ * is locked to the same transport too.
+ */
+ if (dlg->tp_sel.type != tsx->tp_sel.type ||
+ dlg->tp_sel.u.ptr != tsx->tp_sel.u.ptr)
+ {
+ status = pjsip_tsx_set_transport(tsx, &dlg->tp_sel);
+ pj_assert(status == PJ_SUCCESS);
+ }
+
+ /* Ask transaction to send the response */
status = pjsip_tsx_send_msg(tsx, tdata);
pjsip_dlg_dec_lock(dlg);
diff --git a/pjsip/src/pjsip/sip_transaction.c b/pjsip/src/pjsip/sip_transaction.c
index a0574ca4..4dc46520 100644
--- a/pjsip/src/pjsip/sip_transaction.c
+++ b/pjsip/src/pjsip/sip_transaction.c
@@ -1374,7 +1374,7 @@ PJ_DEF(pj_status_t) pjsip_tsx_set_transport(pjsip_transaction *tsx,
struct tsx_lock_data lck;
/* Must be UAC transaction */
- PJ_ASSERT_RETURN(tsx && sel && tsx->role == PJSIP_ROLE_UAC, PJ_EINVAL);
+ PJ_ASSERT_RETURN(tsx && sel, PJ_EINVAL);
/* Start locking the transaction. */
lock_tsx(tsx, &lck);