MT#61912 DSM: caller reinvite, keep track of PAI if requested

If requested by `b2b_build_pai_from_hdr` DSM parameter,
then get the value of PAI using this parameter and pass
it further for `B2BSipReplyEvent` processing.

Use event params to pass the value.
`b2b_build_pai_from_hdr` keeps the name of header
coming in the latest reply, from which the PAI's value
is to be built.

Update the `reinviteCaller()` function's signature,
to pass headers towards `dlg->sendRequest()`.

Change-Id: Ic6e66e326f26a830c3ed06c19a6ab7be4ebe0135
mr13.3.1
Donat Zenichev 2 years ago
parent dedc6e71f7
commit 8742b3c708

@ -633,6 +633,23 @@ void DSMCall::process(AmEvent* event)
}
}
B2BEvent* b2b_ev = dynamic_cast<B2BEvent*>(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);
}

@ -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"

@ -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<string,string>::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() {

@ -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;

Loading…
Cancel
Save