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

Function ospGetPciHost

modules/osp/sipheader.c:722–767  ·  view source on GitHub ↗

* Get host part from P-Charge-Info header * param msg SIP message * param host Host part of P-Charge-Info header * param bufsize Size of fromuser buffer * return 0 success, 1 without P-Charge-Info, -1 failure */

Source from the content-addressed store, hash-verified

720 * return 0 success, 1 without P-Charge-Info, -1 failure
721 */
722int ospGetPciHost(
723 struct sip_msg* msg,
724 char* pcihost,
725 int bufsize)
726{
727 struct to_body body;
728 struct to_body* pci = NULL;
729 struct hdr_field* hf;
730 struct sip_uri uri;
731 int result = -1;
732
733 if ((pcihost != NULL) && (bufsize > 0)) {
734 pcihost[0] = '\0';
735 if (parse_headers(msg, HDR_EOH_F, 0) == 0) {
736 hf = get_header_by_name(msg, PCHARGEINFO, strlen(PCHARGEINFO));
737 if (hf) {
738 if (!(pci = hf->parsed)) {
739 pci = &body;
740 parse_to(hf->body.s, hf->body.s + hf->body.len + 1, pci);
741 }
742 if (pci->error != PARSE_ERROR) {
743 if (parse_uri(pci->uri.s, pci->uri.len, &uri) == 0) {
744 ospCopyStrToBuffer(&uri.host, pcihost, bufsize);
745 result = 0;
746 } else {
747 LM_ERR("failed to parse P-Charge-Info uri\n");
748 }
749 if (pci == &body) {
750 free_to_params(pci);
751 }
752 } else {
753 LM_ERR("bad P-Charge-Info header\n");
754 }
755 } else {
756 LM_DBG("without P-Charge-Info header\n");
757 result = 1;
758 }
759 } else {
760 LM_ERR("failed to parse message\n");
761 }
762 } else {
763 LM_ERR("bad parameters to parse user part from PAI\n");
764 }
765
766 return result;
767}
768
769/*
770 * Get number and domain from Diversion header

Callers 2

ospReportUsageFromCookieFunction · 0.85
ospRequestRoutingFunction · 0.85

Calls 5

get_header_by_nameFunction · 0.85
parse_toFunction · 0.85
parse_uriFunction · 0.85
ospCopyStrToBufferFunction · 0.85
free_to_paramsFunction · 0.85

Tested by

no test coverage detected