MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / ospGetNpParam

Function ospGetNpParam

modules/osp/sipheader.c:1626–1699  ·  view source on GitHub ↗

* Get number portability parameter from Request-Line * param msg SIP message * param rn Routing number * param rnbufsize Size of rn buffer * param cic Carrier identification code * param cicbufsize Size of cic buffer * param npdi NP database dip indicator * return 0 success, 1 not use NP or without NP parameters, -1 failure */

Source from the content-addressed store, hash-verified

1624 * return 0 success, 1 not use NP or without NP parameters, -1 failure
1625 */
1626int ospGetNpParam(
1627 struct sip_msg* msg,
1628 char* rn,
1629 int rnbufsize,
1630 char* cic,
1631 int cicbufsize,
1632 int* npdi)
1633{
1634 str sv;
1635 param_hooks_t phooks;
1636 param_t* params = NULL;
1637 param_t* pit;
1638 int result = -1;
1639
1640 if (((rn != NULL) && (rnbufsize > 0)) && ((cic != NULL) && (cicbufsize > 0)) && (npdi != NULL)) {
1641 rn[0] = '\0';
1642 cic[0] = '\0';
1643 *npdi = 0;
1644
1645 if (_osp_use_np != 0) {
1646 if (parse_sip_msg_uri(msg) >= 0) {
1647 switch (msg->parsed_uri.type) {
1648 case TEL_URI_T:
1649 case TELS_URI_T:
1650 sv = msg->parsed_uri.params;
1651 break;
1652 case ERROR_URI_T:
1653 case SIP_URI_T:
1654 case SIPS_URI_T:
1655 default:
1656 sv = msg->parsed_uri.user;
1657 break;
1658 }
1659 if (parse_params(&sv, CLASS_ANY, &phooks, &params) == 0) {
1660 for (pit = params; pit; pit = pit->next) {
1661 if ((pit->name.len == OSP_RN_SIZE) &&
1662 (strncasecmp(pit->name.s, OSP_RN_NAME, OSP_RN_SIZE) == 0) &&
1663 (rn[0] == '\0'))
1664 {
1665 ospCopyStrToBuffer(&pit->body, rn, rnbufsize);
1666 } else if ((pit->name.len == OSP_CIC_SIZE) &&
1667 (strncasecmp(pit->name.s, OSP_CIC_NAME, OSP_CIC_SIZE) == 0) &&
1668 (cic[0] == '\0'))
1669 {
1670 ospCopyStrToBuffer(&pit->body, cic, cicbufsize);
1671 } else if ((pit->name.len == OSP_NPDI_SIZE) &&
1672 (strncasecmp(pit->name.s, OSP_NPDI_NAME, OSP_NPDI_SIZE) == 0))
1673 {
1674 *npdi = 1;
1675 }
1676 }
1677 if (params != NULL) {
1678 free_params(params);
1679 }
1680 }
1681 if ((rn[0] != '\0') || (cic[0] != '\0') || (*npdi != 0)) {
1682 result = 0;
1683 } else {

Callers 1

ospRequestRoutingFunction · 0.85

Calls 4

parse_sip_msg_uriFunction · 0.85
parse_paramsFunction · 0.85
ospCopyStrToBufferFunction · 0.85
free_paramsFunction · 0.85

Tested by

no test coverage detected