[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Thu Oct 7 11:48:16 CDT 2010
branch "master" has been updated
via 65548ca34fcc2e91109ab58cc8491284f3717112 (commit)
via 9f8ac9b947ddca8155545b1e4e8337d9bf605574 (commit)
via e9d84a01c2f829300cfda76f0bbacaefce6cf72a (commit)
via 03c084ce56b1503b1dbf4491c516779d9777e62d (commit)
via a24524e6bb8d5adbebbc39718d985261b87fe76f (commit)
via 101f58b8c80649662217f203e290a50a25ef990f (commit)
via 65433dd9f3f1f940854f5a64c9b397628d8d74d5 (commit)
via ee015185da46f8feb0483bfb28748f841b9be16f (commit)
from 1f706b33b2ae203003a54a75ad3ba4914a0b0aef (commit)
Summary of changes:
src/PJSipSessionModule.cpp | 70 ++++++++++++++++++++++++++++++-
src/PJSipSessionModule.h | 1 +
src/PJSipSessionModuleConstruction.cpp | 3 +
src/SipSession.cpp | 2 +
4 files changed, 73 insertions(+), 3 deletions(-)
- Log -----------------------------------------------------------------
commit 65548ca34fcc2e91109ab58cc8491284f3717112
Author: Joshua Colp <jcolp at digium.com>
Date: Thu Oct 7 13:48:59 2010 -0300
Squash sending a 500 Internal Server Error in the pjsip core and handle REFERs in the transaction state change code so we can send responses.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index a5df73d..fc26353 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -415,6 +415,9 @@ void PJSipSessionModule::handleRefer(pjsip_dialog *dlg, pjsip_rx_data *rdata)
// Now that we have the target user we can pass this into routing and go on our marry way
std::cout << "Doing a blind transfer to: " << target << std::endl;
+
+ // TODO: Actually... you know... do it
+ pjsip_dlg_respond(dlg, rdata, 400, NULL, NULL, NULL);
}
pj_bool_t PJSipSessionModule::on_rx_request(pjsip_rx_data *rdata)
@@ -435,7 +438,7 @@ pj_bool_t PJSipSessionModule::on_rx_request(pjsip_rx_data *rdata)
case PJSIP_OTHER_METHOD:
if (dlg && !pjsip_method_cmp(&rdata->msg_info.msg->line.req.method, pjsip_get_refer_method()))
{
- handleRefer(dlg, rdata);
+ // We are essentially stopping the pjsip code from sending a 500 here, but this will actually be handled within the transaction code
break;
}
default:
@@ -615,6 +618,10 @@ void PJSipSessionModule::invOnNewSession(pjsip_inv_session *inv, pjsip_event *ev
void PJSipSessionModule::invOnTsxStateChanged(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e)
{
+ if (tsx->role == PJSIP_ROLE_UAS && tsx->state == PJSIP_TSX_STATE_TRYING && !pjsip_method_cmp(&tsx->method, pjsip_get_refer_method()))
+ {
+ handleRefer(inv->dlg, e->body.tsx_state.src.rdata);
+ }
//This will be our key point for updating transaction state.
//This function will not be called until after a module has registered
//itself as the transaction user, so this won't be called on the initial
commit 9f8ac9b947ddca8155545b1e4e8337d9bf605574
Author: Joshua Colp <jcolp at digium.com>
Date: Thu Oct 7 13:19:40 2010 -0300
Add SIP part of blind transfers. The REFER is now properly handled and URI parsed.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 70ba0f8..a5df73d 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -383,7 +383,7 @@ void PJSipSessionModule::handleNewInvite(pjsip_rx_data *rdata)
}
}
-void PJSipSessionModule::handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdata)
+void PJSipSessionModule::handleRefer(pjsip_dialog *dlg, pjsip_rx_data *rdata)
{
const pj_str_t str_refer_to = { (char*)"Refer-To", 8 };
pjsip_generic_string_hdr *refer_to = static_cast<pjsip_generic_string_hdr *>(pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_refer_to, NULL));
@@ -391,7 +391,7 @@ void PJSipSessionModule::handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdat
if (!refer_to)
{
// Uh... so they didn't tell us where to REFER this to... yeah no
- pjsip_dlg_respond(inv->dlg, rdata, 400, NULL, NULL, NULL);
+ pjsip_dlg_respond(dlg, rdata, 400, NULL, NULL, NULL);
return;
}
@@ -400,13 +400,13 @@ void PJSipSessionModule::handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdat
// TODO: Provide method to send back suitable response
// Now parse the URI to get the actual target they want to refer to
- pjsip_uri *target_uri = static_cast<pjsip_uri *>(pjsip_parse_uri(inv->dlg->pool, refer_to->hvalue.ptr, refer_to->hvalue.slen, 0));
+ pjsip_uri *target_uri = static_cast<pjsip_uri *>(pjsip_parse_uri(dlg->pool, refer_to->hvalue.ptr, refer_to->hvalue.slen, 0));
// We only support SIP URIs, anything else is rubbish to us
if (!PJSIP_URI_SCHEME_IS_SIP(target_uri) && !PJSIP_URI_SCHEME_IS_SIPS(target_uri))
{
// TODO: Place proper response code in here
- pjsip_dlg_respond(inv->dlg, rdata, 400, NULL, NULL, NULL);
+ pjsip_dlg_respond(dlg, rdata, 400, NULL, NULL, NULL);
return;
}
@@ -414,6 +414,7 @@ void PJSipSessionModule::handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdat
std::string target = std::string(pj_strbuf(&target_sip_uri->user), pj_strlen(&target_sip_uri->user));
// Now that we have the target user we can pass this into routing and go on our marry way
+ std::cout << "Doing a blind transfer to: " << target << std::endl;
}
pj_bool_t PJSipSessionModule::on_rx_request(pjsip_rx_data *rdata)
@@ -431,6 +432,12 @@ pj_bool_t PJSipSessionModule::on_rx_request(pjsip_rx_data *rdata)
std::cerr << "[WARNING] on_rx_request called back in mid-dialog?" << std::endl;
}
break;
+ case PJSIP_OTHER_METHOD:
+ if (dlg && !pjsip_method_cmp(&rdata->msg_info.msg->line.req.method, pjsip_get_refer_method()))
+ {
+ handleRefer(dlg, rdata);
+ break;
+ }
default:
return PJ_FALSE;
}
@@ -608,13 +615,6 @@ void PJSipSessionModule::invOnNewSession(pjsip_inv_session *inv, pjsip_event *ev
void PJSipSessionModule::invOnTsxStateChanged(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e)
{
- // This is our point where we can determine if a REFER has been received
- if (tsx->role == PJSIP_ROLE_UAS && tsx->state == PJSIP_TSX_STATE_TRYING && !pjsip_method_cmp(&tsx->method, pjsip_get_refer_method()))
- {
- // Someone wants to do a transfer (we don't really know what it could be yet, but it is probably a blind transfer
- handleRefer(inv, e->body.tsx_state.src.rdata);
- }
-
//This will be our key point for updating transaction state.
//This function will not be called until after a module has registered
//itself as the transaction user, so this won't be called on the initial
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index a4e80d9..a2b009e 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -66,7 +66,7 @@ private:
PJSipSessionModInfo *sessionInfo);
void handleNewInvite(pjsip_rx_data *rdata);
void handleInviteResponse(pjsip_inv_session *inv, pjsip_rx_data *rdata, pjsip_dialog *dlg);
- void handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdata);
+ void handleRefer(pjsip_dialog *dlg, pjsip_rx_data *rdata);
pjsip_inv_callback mInvCallback;
pjsip_ua_init_param mUaParam;
const std::string mName;
commit e9d84a01c2f829300cfda76f0bbacaefce6cf72a
Author: Joshua Colp <jcolp at digium.com>
Date: Thu Oct 7 13:14:21 2010 -0300
Give the invite session dialog usage module priority over our own module.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 3a44bb6..70ba0f8 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -270,9 +270,6 @@ void PJSipSessionModule::handleNewInvite(pjsip_rx_data *rdata)
return;
}
- // Add our own module as a dialog usage
- pjsip_dlg_add_usage(dlg, &mModule, NULL);
-
PJSipDialogModInfo *dlg_mod_info = new PJSipDialogModInfo(dlg);
pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
@@ -291,6 +288,9 @@ void PJSipSessionModule::handleNewInvite(pjsip_rx_data *rdata)
return;
}
+ // Add our own module as a dialog usage
+ pjsip_dlg_add_usage(dlg, &mModule, NULL);
+
if (pjsip_inv_initial_answer(inv_session, rdata, 100, NULL, NULL, &tdata) != PJ_SUCCESS)
{
std::cerr << "[WARNING] Failed to create 100 Trying response" << std::endl;
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 989c9a6..5ff099d 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -342,8 +342,6 @@ void SipSession::start(const Ice::Current&)
return;
}
- pjsip_dlg_add_usage(dialog, &mImplPriv->mManager->getSessionModule(), NULL);
-
// Since the SDP generation requires a pool we use the dialog one, so it has to be set here
mImplPriv->mDialog = dialog;
@@ -358,6 +356,8 @@ void SipSession::start(const Ice::Current&)
return;
}
+ pjsip_dlg_add_usage(dialog, &mImplPriv->mManager->getSessionModule(), NULL);
+
// Record our session within the dialog so code handling pjsip events can do STUFF
SipSessionPtr session = new SipSession(*this);
PJSipSessionModInfo *session_mod_info = new PJSipSessionModInfo(inviteSession, session);
commit 03c084ce56b1503b1dbf4491c516779d9777e62d
Author: Joshua Colp <jcolp at digium.com>
Date: Thu Oct 7 13:11:21 2010 -0300
Get the module the proper way.
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 1b9ed5b..989c9a6 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -342,7 +342,7 @@ void SipSession::start(const Ice::Current&)
return;
}
- pjsip_dlg_add_usage(dialog, &mModule, NULL);
+ pjsip_dlg_add_usage(dialog, &mImplPriv->mManager->getSessionModule(), NULL);
// Since the SDP generation requires a pool we use the dialog one, so it has to be set here
mImplPriv->mDialog = dialog;
commit a24524e6bb8d5adbebbc39718d985261b87fe76f
Author: Joshua Colp <jcolp at digium.com>
Date: Thu Oct 7 12:59:27 2010 -0300
Add our own module to dialogs so we can handle additional requests.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index fb26e4c..3a44bb6 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -270,6 +270,9 @@ void PJSipSessionModule::handleNewInvite(pjsip_rx_data *rdata)
return;
}
+ // Add our own module as a dialog usage
+ pjsip_dlg_add_usage(dlg, &mModule, NULL);
+
PJSipDialogModInfo *dlg_mod_info = new PJSipDialogModInfo(dlg);
pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 5ebc78c..1b9ed5b 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -342,6 +342,8 @@ void SipSession::start(const Ice::Current&)
return;
}
+ pjsip_dlg_add_usage(dialog, &mModule, NULL);
+
// Since the SDP generation requires a pool we use the dialog one, so it has to be set here
mImplPriv->mDialog = dialog;
commit 101f58b8c80649662217f203e290a50a25ef990f
Author: Joshua Colp <jcolp at digium.com>
Date: Thu Oct 7 10:15:41 2010 -0300
Add the beginning bits for REFER without replaces support.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 9696762..fb26e4c 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -380,6 +380,39 @@ void PJSipSessionModule::handleNewInvite(pjsip_rx_data *rdata)
}
}
+void PJSipSessionModule::handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdata)
+{
+ const pj_str_t str_refer_to = { (char*)"Refer-To", 8 };
+ pjsip_generic_string_hdr *refer_to = static_cast<pjsip_generic_string_hdr *>(pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_refer_to, NULL));
+
+ if (!refer_to)
+ {
+ // Uh... so they didn't tell us where to REFER this to... yeah no
+ pjsip_dlg_respond(inv->dlg, rdata, 400, NULL, NULL, NULL);
+ return;
+ }
+
+ // TODO: Add support for subscription
+
+ // TODO: Provide method to send back suitable response
+
+ // Now parse the URI to get the actual target they want to refer to
+ pjsip_uri *target_uri = static_cast<pjsip_uri *>(pjsip_parse_uri(inv->dlg->pool, refer_to->hvalue.ptr, refer_to->hvalue.slen, 0));
+
+ // We only support SIP URIs, anything else is rubbish to us
+ if (!PJSIP_URI_SCHEME_IS_SIP(target_uri) && !PJSIP_URI_SCHEME_IS_SIPS(target_uri))
+ {
+ // TODO: Place proper response code in here
+ pjsip_dlg_respond(inv->dlg, rdata, 400, NULL, NULL, NULL);
+ return;
+ }
+
+ pjsip_sip_uri *target_sip_uri = (pjsip_sip_uri *)target_uri;
+ std::string target = std::string(pj_strbuf(&target_sip_uri->user), pj_strlen(&target_sip_uri->user));
+
+ // Now that we have the target user we can pass this into routing and go on our marry way
+}
+
pj_bool_t PJSipSessionModule::on_rx_request(pjsip_rx_data *rdata)
{
pjsip_dialog *dlg = pjsip_rdata_get_dlg(rdata);
@@ -572,6 +605,13 @@ void PJSipSessionModule::invOnNewSession(pjsip_inv_session *inv, pjsip_event *ev
void PJSipSessionModule::invOnTsxStateChanged(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e)
{
+ // This is our point where we can determine if a REFER has been received
+ if (tsx->role == PJSIP_ROLE_UAS && tsx->state == PJSIP_TSX_STATE_TRYING && !pjsip_method_cmp(&tsx->method, pjsip_get_refer_method()))
+ {
+ // Someone wants to do a transfer (we don't really know what it could be yet, but it is probably a blind transfer
+ handleRefer(inv, e->body.tsx_state.src.rdata);
+ }
+
//This will be our key point for updating transaction state.
//This function will not be called until after a module has registered
//itself as the transaction user, so this won't be called on the initial
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index ba6d3b9..a4e80d9 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -66,6 +66,7 @@ private:
PJSipSessionModInfo *sessionInfo);
void handleNewInvite(pjsip_rx_data *rdata);
void handleInviteResponse(pjsip_inv_session *inv, pjsip_rx_data *rdata, pjsip_dialog *dlg);
+ void handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdata);
pjsip_inv_callback mInvCallback;
pjsip_ua_init_param mUaParam;
const std::string mName;
commit 65433dd9f3f1f940854f5a64c9b397628d8d74d5
Author: Joshua Colp <jcolp at digium.com>
Date: Thu Oct 7 09:29:22 2010 -0300
Add a bit of logic for attended transfers.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 225208c..9696762 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -251,7 +251,14 @@ void PJSipSessionModule::handleNewInvite(pjsip_rx_data *rdata)
//pjsip_inv_verify_request to be sure we can
//handle the request. For now, just plunge forward.
- pjsip_dialog *dlg;
+ pjsip_dialog *dlg, *replaced_dlg;
+ pjsip_tx_data *tdata;
+
+ // If this is an attended transfer and something is amuck... respond accordingly
+ if (pjsip_replaces_verify_request(rdata, &replaced_dlg, PJ_FALSE, &tdata) != PJ_SUCCESS)
+ {
+ return;
+ }
//XXX The NULL parameter should be replaced with
//An appropriate Contact header. Leaving it NULL makes
@@ -281,7 +288,6 @@ void PJSipSessionModule::handleNewInvite(pjsip_rx_data *rdata)
return;
}
- pjsip_tx_data *tdata;
if (pjsip_inv_initial_answer(inv_session, rdata, 100, NULL, NULL, &tdata) != PJ_SUCCESS)
{
std::cerr << "[WARNING] Failed to create 100 Trying response" << std::endl;
@@ -348,7 +354,15 @@ void PJSipSessionModule::handleNewInvite(pjsip_rx_data *rdata)
AsteriskSCF::SessionCommunications::V1::SessionRouterPrx router = dataModel.getSessionRouter();
try
{
- router->routeSession(session->getSessionProxy(), destination);
+ if (replaced_dlg)
+ {
+ // For attended transfers we need to contact the routing service which should then (hopefully) replace the other session
+ }
+ else
+ {
+ // If this is not an attended transfer we can just route the session as normally
+ router->routeSession(session->getSessionProxy(), destination);
+ }
}
catch (AsteriskSCF::Core::Routing::V1::DestinationNotFoundException&)
{
commit ee015185da46f8feb0483bfb28748f841b9be16f
Author: Joshua Colp <jcolp at digium.com>
Date: Thu Oct 7 09:21:09 2010 -0300
Initialize required modules for transfers.
diff --git a/src/PJSipSessionModuleConstruction.cpp b/src/PJSipSessionModuleConstruction.cpp
index 303ee91..d876ca5 100644
--- a/src/PJSipSessionModuleConstruction.cpp
+++ b/src/PJSipSessionModuleConstruction.cpp
@@ -120,6 +120,9 @@ PJSipSessionModule::PJSipSessionModule(pjsip_endpoint *endpt, boost::shared_ptr<
pjsip_ua_init_module(endpt, &mUaParam);
pjsip_100rel_init_module(endpt);
pjsip_inv_usage_init(endpt, &mInvCallback);
+ pjsip_evsub_init_module(endpt);
+ pjsip_xfer_init_module(endpt);
+ pjsip_replaces_init_module(endpt);
pjsip_endpt_register_module(endpt, &mModule);
}
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list