MT#62253 log: AmOfferAnswer: add call-id based logging

Introduce usage of `ILOG_DLG()`

Change-Id: I23134faa11b7ac11f6825002f70e200c00b07a18
mr13.4
Donat Zenichev 1 year ago
parent a29e09fc90
commit 700c1a0c51

@ -34,6 +34,8 @@
#include <assert.h>
#define GET_CALL_ID() (dlg->getCallid().c_str())
const char* __dlg_oa_status2str[AmOfferAnswer::__max_OA] = {
"None",
"OfferRecved",
@ -67,7 +69,7 @@ AmOfferAnswer::OAState AmOfferAnswer::getState()
void AmOfferAnswer::setState(AmOfferAnswer::OAState n_st)
{
DBG("setting SIP dialog O/A status: %s->%s\n",
ILOG_DLG(L_DBG, "setting SIP dialog O/A status: %s->%s\n",
getOAStateStr(state), getOAStateStr(n_st));
state = n_st;
}
@ -153,7 +155,7 @@ int AmOfferAnswer::onRequestIn(const AmSipRequest& req)
}
else { // ACK
// TODO: only if reply to initial INVITE (if re-INV, app should decide)
DBG("error %i with SDP received in ACK request: sending BYE\n",err_code);
ILOG_DLG(L_DBG, "error %i with SDP received in ACK request: sending BYE\n",err_code);
dlg->bye();
}
}
@ -162,7 +164,7 @@ int AmOfferAnswer::onRequestIn(const AmSipRequest& req)
(req.cseq == cseq)){
// 200 ACK received:
// -> reset OA state
DBG("200 ACK received: resetting OA state");
ILOG_DLG(L_DBG, "200 ACK received: resetting OA state");
clearTransitionalState();
}
@ -188,8 +190,8 @@ int AmOfferAnswer::onReplyIn(const AmSipReply& reply)
(state == OA_OfferRecved)) &&
(reply.cseq == cseq))
{
DBG("ignoring subsequent SDP reply within the same transaction\n");
DBG("this usually happens when 183 and 200 have SDP\n");
ILOG_DLG(L_DBG, "ignoring subsequent SDP reply within the same transaction\n");
ILOG_DLG(L_DBG, "this usually happens when 183 and 200 have SDP\n");
/* Make sure that session is started when 200 OK is received */
if (reply.code == 200) dlg->onSdpCompleted();
@ -206,13 +208,13 @@ int AmOfferAnswer::onReplyIn(const AmSipReply& reply)
(reply.cseq == cseq))
{
/* final error reply -> cleanup OA state */
DBG("after %u reply to %s: resetting OA state\n", reply.code, reply.cseq_method.c_str());
ILOG_DLG(L_DBG, "after %u reply to %s: resetting OA state\n", reply.code, reply.cseq_method.c_str());
clearTransitionalState();
}
if (err_code) {
/* TODO: only if initial INVITE (if re-INV, app should decide) */
DBG("error %i (%s) with SDP received in %i reply: sending ACK+BYE\n", err_code, err_txt ? err_txt : "none", reply.code);
ILOG_DLG(L_DBG, "error %i (%s) with SDP received in %i reply: sending ACK+BYE\n", err_code, err_txt ? err_txt : "none", reply.code);
dlg->bye();
}
@ -221,7 +223,7 @@ int AmOfferAnswer::onReplyIn(const AmSipReply& reply)
int AmOfferAnswer::onRxSdp(unsigned int m_cseq, const AmMimeBody& body, const char** err_txt)
{
DBG("entering onRxSdp(), oa_state=%s\n", getOAStateStr(state));
ILOG_DLG(L_DBG, "entering onRxSdp(), oa_state=%s\n", getOAStateStr(state));
OAState old_oa_state = state;
int err_code = 0;
@ -273,19 +275,19 @@ int AmOfferAnswer::onRxSdp(unsigned int m_cseq, const AmMimeBody& body, const ch
}
}
DBG("oa_state: %s -> %s\n", getOAStateStr(old_oa_state), getOAStateStr(state));
ILOG_DLG(L_DBG, "oa_state: %s -> %s\n", getOAStateStr(old_oa_state), getOAStateStr(state));
return err_code;
}
int AmOfferAnswer::onTxSdp(unsigned int m_cseq, const AmMimeBody& body, bool force_no_sdp_update)
{
DBG("AmOfferAnswer::onTxSdp()\n");
ILOG_DLG(L_DBG, "AmOfferAnswer::onTxSdp()\n");
/* assume that the payload is ok if it is not empty.
* (do not parse again self-generated SDP) */
if (body.empty()) {
DBG("Body is empty, cannot do anything here.\n");
ILOG_DLG(L_DBG, "Body is empty, cannot do anything here.\n");
return -1;
}
@ -305,7 +307,7 @@ int AmOfferAnswer::onTxSdp(unsigned int m_cseq, const AmMimeBody& body, bool for
case OA_OfferSent:
/* There is already a pending offer */
DBG("There is already a pending offer, onTxSdp fails\n");
ILOG_DLG(L_DBG, "There is already a pending offer, onTxSdp fails\n");
return -1;
default:
@ -347,14 +349,14 @@ int AmOfferAnswer::onRequestOut(AmSipRequest& req)
} else if (sdp_body && has_sdp) {
// update local SDP copy
if (sdp_local.parse((const char*)sdp_body->getPayload())) {
ERROR("parser failed on Tx SDP: '%s'\n", (const char*)sdp_body->getPayload());
ILOG_DLG(L_ERR, "parser failed on Tx SDP: '%s'\n", (const char*)sdp_body->getPayload());
}
}
if ((has_sdp || (has_csta && req.method != SIP_METH_INFO)) &&
(onTxSdp(req.cseq,req.body) != 0))
{
WARN("onTxSdp() failed\n");
ILOG_DLG(L_WARN, "onTxSdp() failed\n");
return -1;
}
@ -371,7 +373,7 @@ int AmOfferAnswer::onReplyOut(AmSipReply& reply, int &flags, AmMimeBody &ret_bod
bool has_sdp = sdp_body && sdp_body->getLen();
bool has_csta = csta_body && csta_body->getLen();
DBG("AmOfferAnswer::onReplyOut(), has_sdp = <%c>, generate_sdp = <%c>.\n",
ILOG_DLG(L_DBG, "AmOfferAnswer::onReplyOut(), has_sdp = <%c>, generate_sdp = <%c>.\n",
has_sdp ? 't' : 'f',
generate_sdp ? 't' : 'f');
@ -381,11 +383,11 @@ int AmOfferAnswer::onReplyOut(AmSipReply& reply, int &flags, AmMimeBody &ret_bod
{
AmSdp parser_sdp;
if (parser_sdp.parse((const char*)sdp_body->getPayload())) {
WARN("SDP parsing for the coming reply failed (cannot create AmSdp object).\n");
ILOG_DLG(L_WARN, "SDP parsing for the coming reply failed (cannot create AmSdp object).\n");
} else {
force_no_sdp_update = (sdp_local.origin.sessV == parser_sdp.origin.sessV);
if (force_no_sdp_update)
DBG("Forcing no OA state update (no SDP changes, same session version: was <%s>, now is <%s>).\n",
ILOG_DLG(L_DBG, "Forcing no OA state update (no SDP changes, same session version: was <%s>, now is <%s>).\n",
uint128ToStr(sdp_local.origin.sessV).c_str(), uint128ToStr(parser_sdp.origin.sessV).c_str());
}
}
@ -400,21 +402,21 @@ int AmOfferAnswer::onReplyOut(AmSipReply& reply, int &flags, AmMimeBody &ret_bod
Re-use it, and do not beget the 183 without SDP body */
if (reply.code == 183 && !sdp_local.media.empty()) {
DBG("The 183 with no SDP, but system already has local SDP for this session, re-using it..\n");
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;
sdp_local.print(existing_sdp);
if(!sdp_body){
if( (sdp_body = reply.body.addPart(SIP_APPLICATION_SDP)) == NULL ) {
DBG("AmMimeBody::addPart() failed\n");
ILOG_DLG(L_DBG, "AmMimeBody::addPart() failed\n");
return -1;
}
}
sdp_body->setPayload((const unsigned char*)existing_sdp.c_str(), existing_sdp.length());
has_sdp = true;
DBG("Now has_sdp has been reset to true.\n");
ILOG_DLG(L_DBG, "Now has_sdp has been reset to true.\n");
/* - 183 reply without SDP body, but is very first one (no SDP saved before)
- 200-299 responses with no SDP */
@ -425,7 +427,7 @@ int AmOfferAnswer::onReplyOut(AmSipReply& reply, int &flags, AmMimeBody &ret_bod
((state == OA_OfferRecved)
|| (state == OA_None)
|| (state == OA_Completed));
DBG("Now generate_sdp has been reset to <%c>.\n", generate_sdp ? 't' : 'f');
ILOG_DLG(L_DBG, "Now generate_sdp has been reset to <%c>.\n", generate_sdp ? 't' : 'f');
}
} else if (reply.cseq_method == SIP_METH_UPDATE) {
@ -433,7 +435,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);
DBG("Now generate_sdp has been reset to <%c>.\n", generate_sdp ? 't' : 'f');
ILOG_DLG(L_DBG, "Now generate_sdp has been reset to <%c>.\n", generate_sdp ? 't' : 'f');
}
}
}
@ -443,17 +445,17 @@ int AmOfferAnswer::onReplyOut(AmSipReply& reply, int &flags, AmMimeBody &ret_bod
in late offer/answer */
if (has_sdp && (state == OA_OfferSent) && reply.cseq == cseq) {
has_sdp = false;
DBG("Now has_sdp has been reset to false.\n");
ILOG_DLG(L_DBG, "Now has_sdp has been reset to false.\n");
}
}
DBG("Saving OA state, saved_state = <%d>.\n", state);
ILOG_DLG(L_DBG, "Saving OA state, saved_state = <%d>.\n", state);
saveState();
if (generate_sdp) {
string sdp_buf;
DBG("Generating of the new SDP body is required.\n");
ILOG_DLG(L_DBG, "Generating of the new SDP body is required.\n");
if (getSdpBody(sdp_buf)) {
if (reply.code == 183 && reply.cseq_method == SIP_METH_INVITE) {
@ -466,43 +468,43 @@ int AmOfferAnswer::onReplyOut(AmSipReply& reply, int &flags, AmMimeBody &ret_bod
} else {
if (!sdp_body) {
if ((sdp_body = reply.body.addPart(SIP_APPLICATION_SDP)) == NULL ) {
DBG("AmMimeBody::addPart() failed\n");
ILOG_DLG(L_DBG, "AmMimeBody::addPart() failed\n");
return -1;
}
}
sdp_body->setPayload((const unsigned char*)sdp_buf.c_str(), sdp_buf.length());
has_sdp = true;
DBG("Now has_sdp has been reset to true.\n");
ILOG_DLG(L_DBG, "Now has_sdp has been reset to true.\n");
/* some of sessions want generated body to be kept for the future, e.g. for the case
* when we want to reinvite the other side, before this side got actual SDP answer.
* e.g. this happens in DSM, when we generate faked SDP in some cases. */
if (flags & SIP_FLAGS_SAVE_ESTB_SDP) {
DBG("Saving established_body based on newly generated SDP.\n");
ILOG_DLG(L_DBG, "Saving established_body based on newly generated SDP.\n");
ret_body = *sdp_body;
}
}
} else if (sdp_body && has_sdp) {
DBG("Generating of the new SDP body was Not required. Just updating local SDP..\n");
ILOG_DLG(L_DBG, "Generating of the new SDP body was Not required. Just updating local SDP..\n");
/* update local SDP copy */
if (sdp_local.parse((const char*)sdp_body->getPayload())) {
WARN("parser failed on Tx SDP: '%s'\n", (const char*)sdp_body->getPayload());
ILOG_DLG(L_WARN, "parser failed on Tx SDP: '%s'\n", (const char*)sdp_body->getPayload());
}
}
if ((has_sdp || (has_csta && reply.cseq_method != SIP_METH_INFO)) &&
(onTxSdp(reply.cseq, reply.body, force_no_sdp_update) != 0))
{
WARN("onTxSdp() failed\n");
ILOG_DLG(L_WARN, "onTxSdp() failed\n");
return -1;
}
if ((reply.code >= 300) && (reply.cseq == cseq)) {
/* final error reply -> cleanup OA state */
DBG("after %u reply to %s: resetting OA state\n", reply.code, reply.cseq_method.c_str());
ILOG_DLG(L_DBG, "after %u reply to %s: resetting OA state\n", reply.code, reply.cseq_method.c_str());
clearTransitionalState();
}
@ -518,7 +520,7 @@ int AmOfferAnswer::onRequestSent(const AmSipRequest& req)
// transaction has been removed:
// -> cleanup OA state
DBG("200 ACK sent: resetting OA state\n");
ILOG_DLG(L_DBG, "200 ACK sent: resetting OA state\n");
clearTransitionalState();
}
@ -537,7 +539,7 @@ int AmOfferAnswer::onReplySent(const AmSipReply& reply)
// transaction has been removed:
// -> cleanup OA state
DBG("transaction finished by final reply %u: resetting OA state\n", reply.cseq);
ILOG_DLG(L_DBG, "transaction finished by final reply %u: resetting OA state\n", reply.cseq);
clearTransitionalState();
}
@ -553,7 +555,7 @@ int AmOfferAnswer::getSdpBody(string& sdp_body)
sdp_local.print(sdp_body);
}
else {
DBG("No SDP Offer.\n");
ILOG_DLG(L_DBG, "No SDP Offer.\n");
return -1;
}
break;
@ -562,13 +564,13 @@ int AmOfferAnswer::getSdpBody(string& sdp_body)
sdp_local.print(sdp_body);
}
else {
DBG("No SDP Answer.\n");
ILOG_DLG(L_DBG, "No SDP Answer.\n");
return -1;
}
break;
case OA_OfferSent:
DBG("Still waiting for a reply\n");
ILOG_DLG(L_DBG, "Still waiting for a reply\n");
return -1;
default:
@ -581,7 +583,7 @@ int AmOfferAnswer::getSdpBody(string& sdp_body)
void AmOfferAnswer::onNoAck(unsigned int ack_cseq)
{
if(ack_cseq == cseq){
DBG("ACK timeout: resetting OA state\n");
ILOG_DLG(L_DBG, "ACK timeout: resetting OA state\n");
clearTransitionalState();
}
}

Loading…
Cancel
Save