Changeset 5109
- Timestamp:
- Jun 17, 2015 6:18:07 AM (9 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip-ua/sip_inv.h
r4985 r5109 479 479 * this to NULL, to let remote UAS specifies an offer. 480 480 * @param options The options argument is bitmask combination of SIP 481 * features in pjsip_inv_option senumeration.481 * features in pjsip_inv_option enumeration. 482 482 * @param p_inv On successful return, the invite session will be put 483 483 * in this argument. … … 616 616 * matches the offer. 617 617 * @param options The options argument is bitmask combination of SIP 618 * features in pjsip_inv_option senumeration.618 * features in pjsip_inv_option enumeration. 619 619 * @param p_inv Pointer to receive the newly created invite session. 620 620 * -
pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
r5104 r5109 1676 1676 } 1677 1677 1678 /* Utility to remove a string value from generic array header */ 1679 static void remove_val_from_array_hdr(pjsip_generic_array_hdr *arr_hdr, 1680 const pj_str_t *val) 1681 { 1682 unsigned i; 1683 for (i=0; i<arr_hdr->count; ++i) { 1684 if (pj_stricmp(&arr_hdr->values[i], val)==0) { 1685 pj_array_erase(arr_hdr->values, sizeof(arr_hdr->values[0]), 1686 arr_hdr->count, i); 1687 --arr_hdr->count; 1688 break; 1689 } 1690 } 1691 } 1692 1693 1694 /* Remove disabled extensions, e.g: timer & 100rel, from Allow/Supported 1695 * headers (see ticket #1858). 1696 */ 1697 static void cleanup_allow_sup_hdr(unsigned inv_option, 1698 pjsip_tx_data *tdata, 1699 pjsip_allow_hdr *allow_hdr, 1700 pjsip_supported_hdr *sup_hdr) 1701 { 1702 /* If all extensions are enabled, nothing to do */ 1703 if ((inv_option & PJSIP_INV_SUPPORT_100REL) && 1704 (inv_option & PJSIP_INV_SUPPORT_TIMER)) 1705 { 1706 return; 1707 } 1708 1709 if (!allow_hdr && tdata) { 1710 allow_hdr = (pjsip_allow_hdr*) pjsip_msg_find_hdr(tdata->msg, 1711 PJSIP_H_ALLOW, 1712 NULL); 1713 } 1714 if (!sup_hdr && tdata) { 1715 sup_hdr = (pjsip_supported_hdr*) pjsip_msg_find_hdr(tdata->msg, 1716 PJSIP_H_SUPPORTED, 1717 NULL); 1718 } 1719 1720 /* Remove "timer" from Supported header if Session-Timers is 1721 * disabled (https://trac.pjsip.org/repos/ticket/1761) 1722 */ 1723 if ((inv_option & PJSIP_INV_SUPPORT_TIMER) == 0 && sup_hdr) { 1724 const pj_str_t STR_TIMER = { "timer", 5 }; 1725 remove_val_from_array_hdr(sup_hdr, &STR_TIMER); 1726 } 1727 1728 if ((inv_option & PJSIP_INV_SUPPORT_100REL) == 0) { 1729 const pj_str_t STR_PRACK = { "PRACK", 5 }; 1730 const pj_str_t STR_100REL = { "100rel", 6 }; 1731 1732 if (allow_hdr) 1733 remove_val_from_array_hdr(allow_hdr, &STR_PRACK); 1734 if (sup_hdr) 1735 remove_val_from_array_hdr(sup_hdr, &STR_100REL); 1736 } 1737 } 1738 1678 1739 /* 1679 1740 * Create initial INVITE request. … … 1684 1745 pjsip_tx_data *tdata; 1685 1746 const pjsip_hdr *hdr; 1747 pjsip_allow_hdr *allow_hdr = NULL; 1748 pjsip_supported_hdr *sup_hdr = NULL; 1686 1749 pj_bool_t has_sdp; 1687 1750 pj_status_t status; … … 1751 1814 hdr = pjsip_endpt_get_capability(inv->dlg->endpt, PJSIP_H_ALLOW, NULL); 1752 1815 if (hdr) { 1753 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*) 1754 pjsip_hdr_shallow_clone(tdata->pool, hdr)); 1816 allow_hdr = (pjsip_allow_hdr*) 1817 pjsip_hdr_shallow_clone(tdata->pool, hdr); 1818 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)allow_hdr); 1755 1819 } 1756 1820 } … … 1759 1823 hdr = pjsip_endpt_get_capability(inv->dlg->endpt, PJSIP_H_SUPPORTED, NULL); 1760 1824 if (hdr) { 1761 pjsip_supported_hdr *h_sup; 1762 1763 h_sup = (pjsip_supported_hdr*) pjsip_hdr_clone(tdata->pool, hdr); 1764 /* Remove "timer" from Supported header if Session-Timers is 1765 * disabled (https://trac.pjsip.org/repos/ticket/1761) 1766 */ 1767 if ((inv->options & PJSIP_INV_SUPPORT_TIMER) == 0) { 1768 unsigned i; 1769 const pj_str_t STR_TIMER = { "timer", 5 }; 1770 for (i=0; i<h_sup->count; ++i) { 1771 if (pj_stricmp(&h_sup->values[i], &STR_TIMER)==0) { 1772 pj_array_erase(h_sup->values, sizeof(h_sup->values[0]), 1773 h_sup->count, i); 1774 --h_sup->count; 1775 break; 1776 } 1777 } 1778 } 1779 1780 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)h_sup); 1781 } 1825 sup_hdr = (pjsip_supported_hdr*) 1826 pjsip_hdr_shallow_clone(tdata->pool, hdr); 1827 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)sup_hdr); 1828 } 1829 1830 /* Cleanup Allow & Supported headers from disabled extensions */ 1831 cleanup_allow_sup_hdr(inv->options, NULL, allow_hdr, sup_hdr); 1782 1832 1783 1833 /* Add Require header. */ … … 2229 2279 } 2230 2280 2281 /* Cleanup Allow & Supported headers from disabled extensions */ 2282 cleanup_allow_sup_hdr(inv->options, tdata, NULL, NULL); 2283 2231 2284 /* Save this answer */ 2232 2285 inv->last_answer = tdata; … … 2292 2345 /* Invoke Session Timers */ 2293 2346 pjsip_timer_update_resp(inv, last_res); 2347 2348 /* Cleanup Allow & Supported headers from disabled extensions */ 2349 cleanup_allow_sup_hdr(inv->options, last_res, NULL, NULL); 2294 2350 2295 2351 *p_tdata = last_res; … … 2883 2939 pjmedia_sdp_session *sdp_copy; 2884 2940 const pjsip_hdr *hdr; 2941 pjsip_supported_hdr *sup_hdr = NULL; 2885 2942 pj_status_t status = PJ_SUCCESS; 2886 2943 … … 2958 3015 hdr = pjsip_endpt_get_capability(inv->dlg->endpt, PJSIP_H_SUPPORTED, NULL); 2959 3016 if (hdr) { 2960 pjsip_supported_hdr *h_sup; 2961 2962 h_sup = (pjsip_supported_hdr*) pjsip_hdr_clone(tdata->pool, hdr); 2963 /* Remove "timer" from Supported header if Session-Timers is 2964 * disabled (https://trac.pjsip.org/repos/ticket/1761) 2965 */ 2966 if ((inv->options & PJSIP_INV_SUPPORT_TIMER) == 0) { 2967 unsigned i; 2968 const pj_str_t STR_TIMER = { "timer", 5 }; 2969 for (i=0; i<h_sup->count; ++i) { 2970 if (pj_stricmp(&h_sup->values[i], &STR_TIMER)==0) { 2971 pj_array_erase(h_sup->values, sizeof(h_sup->values[0]), 2972 h_sup->count, i); 2973 --h_sup->count; 2974 break; 2975 } 2976 } 2977 } 2978 2979 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)h_sup); 3017 sup_hdr = (pjsip_supported_hdr*) 3018 pjsip_hdr_shallow_clone(tdata->pool, hdr); 3019 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)sup_hdr); 2980 3020 } 2981 3021 … … 2983 3023 if (status != PJ_SUCCESS) 2984 3024 goto on_error; 3025 3026 /* Cleanup Allow & Supported headers from disabled extensions */ 3027 cleanup_allow_sup_hdr(inv->options, NULL, NULL, sup_hdr); 2985 3028 2986 3029 /* Unlock dialog. */
Note: See TracChangeset
for help on using the changeset viewer.