* Function to decompress a compressed message */
| 1684 | * Function to decompress a compressed message |
| 1685 | */ |
| 1686 | static int mc_decompress(struct sip_msg* msg) |
| 1687 | { |
| 1688 | #define HDRS_TO_SKIP 4 |
| 1689 | |
| 1690 | int i; |
| 1691 | int j; |
| 1692 | int rc; |
| 1693 | int algo=-1; |
| 1694 | int hdrs_algo=-1; |
| 1695 | int b64_required=-1; |
| 1696 | |
| 1697 | str msg_body; |
| 1698 | str msg_final; |
| 1699 | |
| 1700 | str b64_decode={NULL, 0}; |
| 1701 | str hdr_b64_decode={NULL,0}; |
| 1702 | str uncomp_body={NULL,0}; |
| 1703 | str uncomp_hdrs={NULL,0}; |
| 1704 | |
| 1705 | char *new_buf; |
| 1706 | |
| 1707 | unsigned long temp; |
| 1708 | |
| 1709 | /* hdr_vec allows to sort the headers. This will help skipping |
| 1710 | these headers when building the new message */ |
| 1711 | struct hdr_field *hf; |
| 1712 | struct hdr_field *hdr_vec[HDRS_TO_SKIP]; |
| 1713 | /*hdr_vec : 0 Content-Length |
| 1714 | 1 Comp-Hdrs |
| 1715 | 2 Headers-Algo |
| 1716 | 3 Content-Encoding*/ |
| 1717 | |
| 1718 | memset(hdr_vec, 0, HDRS_TO_SKIP * sizeof(struct hdr_field*)); |
| 1719 | |
| 1720 | if (parse_headers(msg, HDR_EOH_F, 0) != 0) { |
| 1721 | LM_ERR("failed to parse SIP message\n"); |
| 1722 | return -1; |
| 1723 | } |
| 1724 | |
| 1725 | /*If compressed with this module there are great chances that Content-Encoding is last*/ |
| 1726 | hdr_vec[3] = msg->last_header; |
| 1727 | |
| 1728 | if (hdr_vec[3] && !is_content_encoding(hdr_vec[3])) { |
| 1729 | hdr_vec[3] = NULL; |
| 1730 | for (hf = msg->headers; hf; hf = hf->next) { |
| 1731 | if (is_content_encoding(hf)) { |
| 1732 | hdr_vec[3] = hf; |
| 1733 | continue; |
| 1734 | } |
| 1735 | if (hf->type == HDR_OTHER_T && |
| 1736 | !strncasecmp(hf->name.s, COMP_HDRS,COMP_HDRS_LEN)) { |
| 1737 | hdr_vec[1] = hf; |
| 1738 | continue; |
| 1739 | } |
| 1740 | |
| 1741 | if (hf->type == HDR_OTHER_T && |
| 1742 | !strncasecmp(hf->name.s, HDRS_ENCODING, |
| 1743 | sizeof(HDRS_ENCODING)-1)) { |
nothing calls this directly
no test coverage detected