diff --git a/apps/dsm/DSMCall.cpp b/apps/dsm/DSMCall.cpp index f7d2151b..4758439a 100644 --- a/apps/dsm/DSMCall.cpp +++ b/apps/dsm/DSMCall.cpp @@ -633,6 +633,23 @@ void DSMCall::process(AmEvent* event) } } + B2BEvent* b2b_ev = dynamic_cast(event); + if (b2b_ev) { + string pai_from_hdr = getVar(DSM_B2B_BUILD_PAI_FROM_HDR); + if (b2b_ev->event_id == B2BSipReply && !pai_from_hdr.empty()) { + string pai_value; + B2BgetHeaderReply(pai_from_hdr, pai_value); + DBG("Building '%s' value from header '%s'.\n", SIP_HDR_P_ASSERTED_IDENTITY, pai_from_hdr.c_str()); + if (!pai_value.empty()) { + DBG("Passing '%s' with value '%s' to B2BSipReply handling.\n", SIP_HDR_P_ASSERTED_IDENTITY, pai_value.c_str()); + /* CRLF required later for reinviteCaller(), dlg->sendRequest() */ + b2b_ev->params["hdrs"] = SIP_HDR_COLSP(SIP_HDR_P_ASSERTED_IDENTITY) + pai_value + CRLF; + } else { + DBG("Impossible to get the value of '%s'.\n", pai_from_hdr.c_str()); + } + } + } + AmB2BCallerSession::process(event); } diff --git a/apps/dsm/DSMSession.h b/apps/dsm/DSMSession.h index f686a5c0..b17ceb86 100644 --- a/apps/dsm/DSMSession.h +++ b/apps/dsm/DSMSession.h @@ -68,6 +68,8 @@ using std::map; #define DSM_B2B_CALLID "b2b_callid" +#define DSM_B2B_BUILD_PAI_FROM_HDR "b2b_build_pai_from_hdr" + #define DSM_AVAR_REQUEST "request" #define DSM_AVAR_REPLY "reply" diff --git a/core/AmB2BSession.cpp b/core/AmB2BSession.cpp index b991fdc2..e2919301 100644 --- a/core/AmB2BSession.cpp +++ b/core/AmB2BSession.cpp @@ -1326,6 +1326,15 @@ void AmB2BCallerSession::onB2BEvent(B2BEvent* ev) case Ringing: if (reply.cseq == invite_req.cseq) { + /* get possibly passed headers for updates towards caller */ + string hdrs; + map::const_iterator hdrs_it; + hdrs_it = ((B2BSipReplyEvent*)ev)->params.find("hdrs"); + if (hdrs_it != ((B2BSipReplyEvent*)ev)->params.end()) { + hdrs = hdrs_it->second; + DBG("Got some headers, which can later be used for re-inviting the caller: '%s'\n", hdrs.c_str()); + } + if (reply.code < 200) { if ((!sip_relay_only) && (reply.code>=180 && reply.code<=183 && (!reply.body.empty()))) { @@ -1334,7 +1343,7 @@ void AmB2BCallerSession::onB2BEvent(B2BEvent* ev) updateSessionDescription(reply.body); if (sip_relay_early_media_sdp) { - if (reinviteCaller(reply)) { + if (reinviteCaller(reply, hdrs)) { ERROR("re-INVITEing caller for early session failed - stopping this and other leg\n"); terminateOtherLeg(); terminateLeg(); @@ -1362,7 +1371,7 @@ void AmB2BCallerSession::onB2BEvent(B2BEvent* ev) n_reply.body = established_body; } - if (reinviteCaller(n_reply)) { + if (reinviteCaller(reply, hdrs)) { ERROR("re-INVITEing caller failed - stopping this and other leg\n"); terminateOtherLeg(); terminateLeg(); @@ -1500,11 +1509,11 @@ void AmB2BCallerSession::connectCallee(const string& remote_party, callee_status = NoReply; } -int AmB2BCallerSession::reinviteCaller(const AmSipReply& callee_reply) +int AmB2BCallerSession::reinviteCaller(const AmSipReply& callee_reply, const string& hdrs) { return dlg->sendRequest(SIP_METH_INVITE, &callee_reply.body, - "" /* hdrs */, SIP_FLAGS_VERBATIM); + hdrs, SIP_FLAGS_VERBATIM); } void AmB2BCallerSession::createCalleeSession() { diff --git a/core/AmB2BSession.h b/core/AmB2BSession.h index c68d91bc..8c6c3322 100644 --- a/core/AmB2BSession.h +++ b/core/AmB2BSession.h @@ -404,7 +404,7 @@ class AmB2BCallerSession: public AmB2BSession // Callee Status CalleeStatus callee_status; - int reinviteCaller(const AmSipReply& callee_reply); + int reinviteCaller(const AmSipReply& callee_reply, const string& hdrs = ""); protected: AmSipRequest invite_req;