* 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 */
| 720 | * return 0 success, 1 without P-Charge-Info, -1 failure |
| 721 | */ |
| 722 | int 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 |
no test coverage detected