* Report OSP usage * param msg SIP message * param whorelease Who releases the call first, 0 orig, 1 term * param ignore2 * return MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure */
| 506 | * return MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure |
| 507 | */ |
| 508 | int ospReportUsage( |
| 509 | struct sip_msg* msg, |
| 510 | int* whorelease) |
| 511 | { |
| 512 | OSPE_RELEASE release; |
| 513 | char* tmp; |
| 514 | char* token; |
| 515 | char parameters[OSP_HEADERBUF_SIZE]; |
| 516 | OSPT_CALL_ID* callid = NULL; |
| 517 | int result = MODULE_RETURNCODE_FALSE; |
| 518 | |
| 519 | ospGetCallId(msg, &callid); |
| 520 | |
| 521 | if (callid != NULL) { |
| 522 | /* Who releases the call first, 0 orig, 1 term */ |
| 523 | release = *whorelease; |
| 524 | if (((release != OSPC_RELEASE_SOURCE) && (release != OSPC_RELEASE_DESTINATION))) { |
| 525 | release = OSPC_RELEASE_UNKNOWN; |
| 526 | } |
| 527 | LM_DBG("who releases the call first '%d'\n", release); |
| 528 | |
| 529 | if (ospGetRouteParam(msg, parameters, sizeof(parameters)) == 0) { |
| 530 | for (token = strtok_r(parameters, ";", &tmp); |
| 531 | token; |
| 532 | token = strtok_r(NULL, ";", &tmp)) |
| 533 | { |
| 534 | if ((strncmp(token, OSP_ORIG_COOKIE, strlen(OSP_ORIG_COOKIE)) == 0) && |
| 535 | (token[strlen(OSP_ORIG_COOKIE)] == '=')) |
| 536 | { |
| 537 | LM_INFO("report orig duration for call_id '%.*s'\n", |
| 538 | callid->Length, |
| 539 | callid->Value); |
| 540 | ospReportUsageFromCookie(msg, token + strlen(OSP_ORIG_COOKIE) + 1, callid, release, OSPC_ROLE_SOURCE); |
| 541 | result = MODULE_RETURNCODE_TRUE; |
| 542 | } else if ((strncmp(token, OSP_TERM_COOKIE, strlen(OSP_TERM_COOKIE)) == 0) && |
| 543 | (token[strlen(OSP_TERM_COOKIE)] == '=')) |
| 544 | { |
| 545 | LM_INFO("report term duration for call_id '%.*s'\n", |
| 546 | callid->Length, |
| 547 | callid->Value); |
| 548 | ospReportUsageFromCookie(msg, token + strlen(OSP_TERM_COOKIE) + 1, callid, release, OSPC_ROLE_DESTINATION); |
| 549 | result = MODULE_RETURNCODE_TRUE; |
| 550 | } else { |
| 551 | LM_DBG("ignoring parameter '%s'\n", token); |
| 552 | } |
| 553 | } |
| 554 | } |
| 555 | |
| 556 | if (result == MODULE_RETURNCODE_FALSE) { |
| 557 | LM_DBG("without orig or term OSP information\n"); |
| 558 | LM_INFO("report other duration for call_id '%.*s'\n", |
| 559 | callid->Length, |
| 560 | callid->Value); |
| 561 | ospReportUsageFromCookie(msg, NULL, callid, release, OSPC_ROLE_SOURCE); |
| 562 | result = MODULE_RETURNCODE_TRUE; |
| 563 | } |
| 564 | |
| 565 | OSPPCallIdDelete(&callid); |
nothing calls this directly
no test coverage detected