MCPcopy Create free account
hub / github.com/SIPp/sipp / executeAction

Method executeAction

src/call.cpp:5614–6508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5612}
5613
5614call::T_ActionResult call::executeAction(const char* msg, message* curmsg)
5615{
5616 CActions* actions;
5617 CAction* currentAction;
5618 int rc = 0;
5619
5620 actions = curmsg->M_actions;
5621 // looking for action to do on this message
5622 if (actions == nullptr) {
5623 return(call::E_AR_NO_ERROR);
5624 }
5625
5626 for (int i = 0; i < actions->getActionSize(); i++) {
5627 currentAction = actions->getAction(i);
5628 if(currentAction == nullptr) {
5629 continue;
5630 }
5631
5632 if(currentAction->getActionType() == CAction::E_AT_ASSIGN_FROM_REGEXP) {
5633 char msgPart[MAX_SUB_MESSAGE_LENGTH];
5634
5635 /* Where to look. */
5636 const char* haystack = nullptr;
5637
5638 if(currentAction->getLookingPlace() == CAction::E_LP_HDR) {
5639 extractSubMessage (msg,
5640 currentAction->getLookingChar(),
5641 msgPart,
5642 currentAction->getCaseIndep(),
5643 currentAction->getOccurrence(),
5644 currentAction->getHeadersOnly());
5645 if(currentAction->getCheckIt() == true && (strlen(msgPart) == 0)) {
5646 // the sub message is not found and the checking action say it
5647 // MUST match --> Call will be marked as failed but will go on
5648 WARNING("Failed regexp match: header %s not found in message\n%s\n", currentAction->getLookingChar(), msg);
5649 return(call::E_AR_HDR_NOT_FOUND);
5650 }
5651 haystack = msgPart;
5652 } else if(currentAction->getLookingPlace() == CAction::E_LP_BODY) {
5653 haystack = strstr(msg, "\r\n\r\n");
5654 if (!haystack) {
5655 if (currentAction->getCheckIt() == true) {
5656 WARNING("Failed regexp match: body not found in message\n%s\n", msg);
5657 return(call::E_AR_HDR_NOT_FOUND);
5658 }
5659 msgPart[0] = '\0';
5660 haystack = msgPart;
5661 }
5662 haystack += strlen("\r\n\r\n");
5663 } else if(currentAction->getLookingPlace() == CAction::E_LP_MSG) {
5664 haystack = msg;
5665 } else if(currentAction->getLookingPlace() == CAction::E_LP_VAR) {
5666 /* Get the input variable. */
5667 haystack = M_callVariableTable->getVar(currentAction->getVarInId())->getString();
5668 if (!haystack) {
5669 if (currentAction->getCheckIt() == true) {
5670 WARNING("Failed regexp match: variable $%d not set", currentAction->getVarInId());
5671 return(call::E_AR_HDR_NOT_FOUND);

Callers

nothing calls this directly

Calls 15

WARNINGFunction · 0.85
ERRORFunction · 0.85
ERROR_NOFunction · 0.85
sipp_customize_socketFunction · 0.85
gai_getsockaddrFunction · 0.85
reconnect_allowedFunction · 0.85
get_headerFunction · 0.85
verifyAuthHeaderFunction · 0.85
url_decodeFunction · 0.85
url_encodeFunction · 0.85
LOG_MSGFunction · 0.85
parse_dtmf_play_argsFunction · 0.85

Tested by

no test coverage detected