From 11e0aa7dac9feb0b09155a73eabc161e9db1d55f Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Tue, 16 May 2006 13:20:00 +0000 Subject: 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 --- pjsip/src/pjsip/sip_endpoint.c | 7 ---- pjsip/src/pjsip/sip_transaction.c | 10 +++++ pjsip/src/pjsip/sip_util.c | 67 --------------------------------- pjsip/src/pjsip/sip_util_statefull.c | 72 ++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 74 deletions(-) (limited to 'pjsip') 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 @@ -1256,73 +1256,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. */ 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; +} + + -- cgit v1.2.3