Vadim Saranov 1 week ago committed by GitHub
commit ee4f0d0a03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1294,6 +1294,12 @@ int AmB2BSession::relaySip(const AmSipRequest& req)
updateLocalBody(body);
}
/* a relayed message is sent as-is (SDP-wise): never generate an SDP body
* for it, only update endpoints in an existing one (updateLocalBody) */
int relay_flags = SIP_FLAGS_VERBATIM;
if (!body.hasContentType(SIP_APPLICATION_SDP))
relay_flags |= SIP_FLAGS_NO_SDP_GENERATION;
/* all methods apart ACK */
if (req.method != "ACK") {
relayed_req[dlg->cseq] = req;
@ -1328,7 +1334,7 @@ int AmB2BSession::relaySip(const AmSipRequest& req)
ILOG_DLG(L_DBG, "relaying SIP request %s %s\n", req.method.c_str(), req.r_uri.c_str());
int err = dlg->sendRequest(req.method, &body, *hdrs, SIP_FLAGS_VERBATIM);
int err = dlg->sendRequest(req.method, &body, *hdrs, relay_flags);
if(err < 0){
ILOG_DLG(L_ERR, "dlg->sendRequest() failed\n");
@ -1361,7 +1367,7 @@ int AmB2BSession::relaySip(const AmSipRequest& req)
ILOG_DLG(L_DBG, "sending relayed 200 ACK\n");
int err = dlg->send_200_ack(t->first, &body, req.hdrs, SIP_FLAGS_VERBATIM);
int err = dlg->send_200_ack(t->first, &body, req.hdrs, relay_flags);
if(err < 0) {
ILOG_DLG(L_ERR, "dlg->send_200_ack() failed\n");
return err;
@ -1407,6 +1413,13 @@ int AmB2BSession::relaySip(const AmSipRequest& orig, const AmSipReply& reply)
if(reply.to_tag.empty())
flags |= SIP_FLAGS_NOTAG;
/* a relayed message is sent as-is (SDP-wise): never generate an SDP body
* for it, only update endpoints in an existing one (updateLocalBody).
* IMS preconditions: the O/A is completed in 183+PRACK, the final 200 OK
* has no body and must not get one. */
if (!body.hasContentType(SIP_APPLICATION_SDP))
flags |= SIP_FLAGS_NO_SDP_GENERATION;
int err = dlg->reply(orig,reply.code,reply.reason,
&body, *hdrs, flags);

@ -49,6 +49,11 @@ using std::string;
#define SIP_FLAGS_SAVE_ESTB_SDP 1<<10 // save established SDP body when processing in OA, see `AmOfferAnswer::onReplyOut()`
#define SIP_FLAGS_NO_SDP_GENERATION 1<<11 // do not generate an SDP body for this message,
// even if the O/A state would require one. Used for
// relayed messages and explicit no-SDP replies.
/** \brief SIP transaction representation */
struct AmSipTransaction
{

@ -408,16 +408,17 @@ int AmOfferAnswer::onTxSdp(unsigned int m_cseq,
return 0;
}
int AmOfferAnswer::onRequestOut(AmSipRequest& req)
int AmOfferAnswer::onRequestOut(AmSipRequest& req, bool no_sdp_generation)
{
AmMimeBody* sdp_body = req.body.hasContentType(SIP_APPLICATION_SDP);
AmMimeBody* csta_body = req.body.hasContentType(SIP_APPLICATION_CSTA_XML);
bool generate_sdp = sdp_body && !sdp_body->getLen();
bool generate_sdp = !no_sdp_generation && sdp_body && !sdp_body->getLen();
bool has_sdp = sdp_body && sdp_body->getLen();
bool has_csta = csta_body && csta_body->getLen();
if ((!sdp_body && !csta_body) &&
if (!no_sdp_generation &&
(!sdp_body && !csta_body) &&
((req.method == SIP_METH_PRACK) || (req.method == SIP_METH_ACK)) &&
(state == OA_OfferRecved))
{
@ -464,7 +465,7 @@ int AmOfferAnswer::onReplyOut(AmSipReply& reply, int &flags, AmMimeBody &ret_bod
* or 183 with no SDP body */
bool force_no_sdp_update = false;
bool generate_sdp = sdp_body && !sdp_body->getLen();
bool generate_sdp = !no_sdp_generation && sdp_body && !sdp_body->getLen();
bool has_sdp = sdp_body && sdp_body->getLen();
bool has_csta = csta_body && csta_body->getLen();
@ -494,8 +495,9 @@ int AmOfferAnswer::onReplyOut(AmSipReply& reply, int &flags, AmMimeBody &ret_bod
/* TT#184101, a sequential 183, which has no SDP body, but the media session has
already had the local SDP and saved that.
Re-use it, and do not beget the 183 without SDP body */
if (reply.code == 183 && !sdp_local.media.empty()) {
Re-use it, and do not beget the 183 without SDP body.
Not when SDP generation is suppressed for this reply (relayed messages). */
if (reply.code == 183 && !no_sdp_generation && !sdp_local.media.empty()) {
ILOG_DLG(L_DBG, "The 183 with no SDP, but system already has local SDP for this session, re-using it..\n");
string existing_sdp;
@ -536,7 +538,7 @@ int AmOfferAnswer::onReplyOut(AmSipReply& reply, int &flags, AmMimeBody &ret_bod
if ((reply.code >= 200) && (reply.code < 300)) {
/* offer received: -> force SDP */
generate_sdp = (state == OA_OfferRecved);
generate_sdp = !no_sdp_generation && (state == OA_OfferRecved);
ILOG_DLG(L_DBG, "Now generate_sdp has been reset to <%c>.\n", generate_sdp ? 't' : 'f');
}
}

@ -93,7 +93,8 @@ public:
/** Event handlers */
int onRequestIn(const AmSipRequest& req);
int onReplyIn(const AmSipReply& reply);
int onRequestOut(AmSipRequest& req);
/* `no_sdp_generation` - suppress SDP generation (relayed messages, explicit no-SDP replies) */
int onRequestOut(AmSipRequest& req, bool no_sdp_generation = false);
/* `no_sdp_generation` - can be used for cases like absent SDP in coming INVITE */
int onReplyOut(AmSipReply& reply, int &flags, AmMimeBody &ret_body, bool no_sdp_generation = false);
int onRequestSent(const AmSipRequest& req);

@ -266,7 +266,7 @@ int AmSipDialog::onTxRequest(AmSipRequest& req, int& flags)
{
rel100.onRequestOut(req);
if (offeranswer_enabled && oa.onRequestOut(req))
if (offeranswer_enabled && oa.onRequestOut(req, flags & SIP_FLAGS_NO_SDP_GENERATION))
return -1;
if(AmBasicSipDialog::onTxRequest(req,flags) < 0)
@ -294,7 +294,8 @@ int AmSipDialog::onTxReply(const AmSipRequest& req, AmSipReply& reply, int& flag
{
if (offeranswer_enabled) {
AmMimeBody sdp_body;
if(oa.onReplyOut(reply, flags, sdp_body, req.body.empty()) < 0)
bool no_sdp_generation = req.body.empty() || (flags & SIP_FLAGS_NO_SDP_GENERATION);
if(oa.onReplyOut(reply, flags, sdp_body, no_sdp_generation) < 0)
return -1;
/* if generated by OA, save it */

Loading…
Cancel
Save