summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-05-16 13:20:00 +0000
committerBenny Prijono <bennylp@teluu.com>2006-05-16 13:20:00 +0000
commit11e0aa7dac9feb0b09155a73eabc161e9db1d55f (patch)
tree6b07f893c52dbef12144c079faf2caf3874ba768 /pjsip
parentca05e325d99bde3c74889348aacc77571f21a0b9 (diff)
Rearrange transaction statefull stuffs in SIP so that it will not be linked when transaction is disabled
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@448 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/src/pjsip/sip_endpoint.c7
-rw-r--r--pjsip/src/pjsip/sip_transaction.c10
-rw-r--r--pjsip/src/pjsip/sip_util.c67
-rw-r--r--pjsip/src/pjsip/sip_util_statefull.c72
4 files changed, 82 insertions, 74 deletions
diff --git a/pjsip/src/pjsip/sip_endpoint.c b/pjsip/src/pjsip/sip_endpoint.c
index c4aeb742..3ede0102 100644
--- a/pjsip/src/pjsip/sip_endpoint.c
+++ b/pjsip/src/pjsip/sip_endpoint.c
@@ -103,9 +103,6 @@ void init_sip_parser(void);
/* Defined in sip_tel_uri.c */
pj_status_t pjsip_tel_uri_subsys_init(void);
-/* Defined in sip_util_statefull.c */
-extern pjsip_module mod_stateful_util;
-
/* Specifies whether error subsystem has been registered to pjlib. */
static int error_subsys_initialized;
@@ -486,10 +483,6 @@ PJ_DEF(pj_status_t) pjsip_endpt_create(pj_pool_factory *pf,
/* Initialize capability header list. */
pj_list_init(&endpt->cap_hdr);
- /* Register mod_stateful_util module (sip_util_statefull.c) */
- status = pjsip_endpt_register_module(endpt, &mod_stateful_util);
- if (status != PJ_SUCCESS)
- goto on_error;
/* Done. */
*p_endpt = endpt;
diff --git a/pjsip/src/pjsip/sip_transaction.c b/pjsip/src/pjsip/sip_transaction.c
index 8b20d8c2..b3c0609b 100644
--- a/pjsip/src/pjsip/sip_transaction.c
+++ b/pjsip/src/pjsip/sip_transaction.c
@@ -39,6 +39,10 @@
#endif
+/* Defined in sip_util_statefull.c */
+extern pjsip_module mod_stateful_util;
+
+
/*****************************************************************************
**
** Declarations and static variable definitions section.
@@ -465,6 +469,12 @@ PJ_DEF(pj_status_t) pjsip_tsx_layer_init_module(pjsip_endpoint *endpt)
return status;
}
+ /* Register mod_stateful_util module (sip_util_statefull.c) */
+ status = pjsip_endpt_register_module(endpt, &mod_stateful_util);
+ if (status != PJ_SUCCESS) {
+ return status;
+ }
+
return PJ_SUCCESS;
}
diff --git a/pjsip/src/pjsip/sip_util.c b/pjsip/src/pjsip/sip_util.c
index 60f48681..d4f2dbac 100644
--- a/pjsip/src/pjsip/sip_util.c
+++ b/pjsip/src/pjsip/sip_util.c
@@ -1257,73 +1257,6 @@ PJ_DEF(pj_status_t) pjsip_endpt_respond_stateless( pjsip_endpoint *endpt,
/*
- * Send response statefully.
- */
-PJ_DEF(pj_status_t) pjsip_endpt_respond( pjsip_endpoint *endpt,
- pjsip_module *tsx_user,
- pjsip_rx_data *rdata,
- int st_code,
- const pj_str_t *st_text,
- const pjsip_hdr *hdr_list,
- const pjsip_msg_body *body,
- pjsip_transaction **p_tsx )
-{
- pj_status_t status;
- pjsip_tx_data *tdata;
- pjsip_transaction *tsx;
-
- /* Validate arguments. */
- PJ_ASSERT_RETURN(endpt && rdata, PJ_EINVAL);
-
- if (p_tsx) *p_tsx = NULL;
-
- /* Create response message */
- status = pjsip_endpt_create_response( endpt, rdata, st_code, st_text,
- &tdata);
- if (status != PJ_SUCCESS)
- return status;
-
- /* Add the message headers, if any */
- if (hdr_list) {
- const pjsip_hdr *hdr = hdr_list->next;
- while (hdr != hdr_list) {
- pjsip_msg_add_hdr( tdata->msg, pjsip_hdr_clone(tdata->pool, hdr) );
- hdr = hdr->next;
- }
- }
-
- /* Add the message body, if any. */
- if (body) {
- tdata->msg->body = pjsip_msg_body_clone( tdata->pool, body );
- if (tdata->msg->body == NULL) {
- pjsip_tx_data_dec_ref(tdata);
- return status;
- }
- }
-
- /* Create UAS transaction. */
- status = pjsip_tsx_create_uas(tsx_user, rdata, &tsx);
- if (status != PJ_SUCCESS) {
- pjsip_tx_data_dec_ref(tdata);
- return status;
- }
-
- /* Feed the request to the transaction. */
- pjsip_tsx_recv_msg(tsx, rdata);
-
- /* Send the message. */
- status = pjsip_tsx_send_msg(tsx, tdata);
- if (status != PJ_SUCCESS) {
- pjsip_tx_data_dec_ref(tdata);
- } else if (p_tsx) {
- *p_tsx = tsx;
- }
-
- return status;
-}
-
-
-/*
* Get the event string from the event ID.
*/
PJ_DEF(const char *) pjsip_event_str(pjsip_event_id_e e)
diff --git a/pjsip/src/pjsip/sip_util_statefull.c b/pjsip/src/pjsip/sip_util_statefull.c
index c0427653..d211af93 100644
--- a/pjsip/src/pjsip/sip_util_statefull.c
+++ b/pjsip/src/pjsip/sip_util_statefull.c
@@ -89,6 +89,10 @@ PJ_DEF(pj_status_t) pjsip_endpt_send_request( pjsip_endpoint *endpt,
PJ_ASSERT_RETURN(endpt && tdata && (timeout==-1 || timeout>0), PJ_EINVAL);
+ /* Check that transaction layer module is registered to endpoint */
+ PJ_ASSERT_RETURN(mod_stateful_util.id != -1, PJ_EINVALIDOP);
+
+
status = pjsip_tsx_create_uac(&mod_stateful_util, tdata, &tsx);
if (status != PJ_SUCCESS) {
pjsip_tx_data_dec_ref(tdata);
@@ -105,3 +109,71 @@ PJ_DEF(pj_status_t) pjsip_endpt_send_request( pjsip_endpoint *endpt,
return pjsip_tsx_send_msg(tsx, NULL);
}
+
+/*
+ * Send response statefully.
+ */
+PJ_DEF(pj_status_t) pjsip_endpt_respond( pjsip_endpoint *endpt,
+ pjsip_module *tsx_user,
+ pjsip_rx_data *rdata,
+ int st_code,
+ const pj_str_t *st_text,
+ const pjsip_hdr *hdr_list,
+ const pjsip_msg_body *body,
+ pjsip_transaction **p_tsx )
+{
+ pj_status_t status;
+ pjsip_tx_data *tdata;
+ pjsip_transaction *tsx;
+
+ /* Validate arguments. */
+ PJ_ASSERT_RETURN(endpt && rdata, PJ_EINVAL);
+
+ if (p_tsx) *p_tsx = NULL;
+
+ /* Create response message */
+ status = pjsip_endpt_create_response( endpt, rdata, st_code, st_text,
+ &tdata);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ /* Add the message headers, if any */
+ if (hdr_list) {
+ const pjsip_hdr *hdr = hdr_list->next;
+ while (hdr != hdr_list) {
+ pjsip_msg_add_hdr( tdata->msg, pjsip_hdr_clone(tdata->pool, hdr) );
+ hdr = hdr->next;
+ }
+ }
+
+ /* Add the message body, if any. */
+ if (body) {
+ tdata->msg->body = pjsip_msg_body_clone( tdata->pool, body );
+ if (tdata->msg->body == NULL) {
+ pjsip_tx_data_dec_ref(tdata);
+ return status;
+ }
+ }
+
+ /* Create UAS transaction. */
+ status = pjsip_tsx_create_uas(tsx_user, rdata, &tsx);
+ if (status != PJ_SUCCESS) {
+ pjsip_tx_data_dec_ref(tdata);
+ return status;
+ }
+
+ /* Feed the request to the transaction. */
+ pjsip_tsx_recv_msg(tsx, rdata);
+
+ /* Send the message. */
+ status = pjsip_tsx_send_msg(tsx, tdata);
+ if (status != PJ_SUCCESS) {
+ pjsip_tx_data_dec_ref(tdata);
+ } else if (p_tsx) {
+ *p_tsx = tsx;
+ }
+
+ return status;
+}
+
+