Changeset 500 for pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
- Timestamp:
- Jun 13, 2006 10:21:23 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
r376 r500 159 159 160 160 /* 161 * Set cause code. 162 */ 163 void inv_set_cause(pjsip_inv_session *inv, int cause_code, 164 const pj_str_t *cause_text) 165 { 166 if (cause_code > inv->cause) { 167 inv->cause = cause_code; 168 if (cause_text) 169 pj_strdup(inv->pool, &inv->cause_text, cause_text); 170 else if (cause_code/100 == 2) 171 inv->cause_text = pj_str("Normal call clearing"); 172 else 173 inv->cause_text = *pjsip_get_status_text(cause_code); 174 } 175 } 176 177 178 179 /* 161 180 * Send ACK for 2xx response. 162 181 */ … … 899 918 900 919 /* Set cause. */ 901 inv ->cause = st_code;920 inv_set_cause(inv, st_code, NULL); 902 921 903 922 /* Forcefully terminate the session if state is not DISCONNECTED */ … … 1388 1407 1389 1408 /* Set cause code. */ 1390 i f (inv->cause==0) inv->cause = st_code;1409 inv_set_cause(inv, st_code, st_text); 1391 1410 1392 1411 /* Create appropriate message. */ … … 1698 1717 1699 1718 if (inv->state != PJSIP_INV_STATE_DISCONNECTED) { 1700 i f (inv->cause==0) inv->cause=PJSIP_SC_OK;1719 inv_set_cause(inv, PJSIP_SC_OK, NULL); 1701 1720 inv_set_state(inv, PJSIP_INV_STATE_DISCONNECTED, e); 1702 1721 } … … 1714 1733 1715 1734 if (e->body.tsx_state.type != PJSIP_EVENT_RX_MSG) { 1716 i f (inv->cause==0) inv->cause=PJSIP_SC_OK;1735 inv_set_cause(inv, PJSIP_SC_OK, NULL); 1717 1736 inv_set_state(inv, PJSIP_INV_STATE_DISCONNECTED, e); 1718 1737 return; … … 1734 1753 * End the session anyway. 1735 1754 */ 1736 i f (inv->cause==0) inv->cause=PJSIP_SC_OK;1755 inv_set_cause(inv, PJSIP_SC_OK, NULL); 1737 1756 inv_set_state(inv, PJSIP_INV_STATE_DISCONNECTED, e); 1738 1757 … … 1745 1764 1746 1765 /* End the session. */ 1747 i f (inv->cause==0) inv->cause=PJSIP_SC_OK;1766 inv_set_cause(inv, PJSIP_SC_OK, NULL); 1748 1767 inv_set_state(inv, PJSIP_INV_STATE_DISCONNECTED, e); 1749 1768 } … … 1863 1882 * End the session. 1864 1883 */ 1865 i f (inv->cause==0) inv->cause = tsx->status_code;1884 inv_set_cause(inv, tsx->status_code, &tsx->status_text); 1866 1885 inv_set_state(inv, PJSIP_INV_STATE_DISCONNECTED, e); 1867 1886 … … 1878 1897 } else { 1879 1898 1880 i f (inv->cause==0) inv->cause = tsx->status_code;1899 inv_set_cause(inv, tsx->status_code, &tsx->status_text); 1881 1900 inv_set_state(inv, PJSIP_INV_STATE_DISCONNECTED, e); 1882 1901 … … 1906 1925 1907 1926 } else { 1908 i f (inv->cause==0) inv->cause = tsx->status_code;1927 inv_set_cause(inv, tsx->status_code, &tsx->status_text); 1909 1928 inv_set_state(inv, PJSIP_INV_STATE_DISCONNECTED, e); 1910 1929 } … … 1927 1946 tsx->status_code == PJSIP_SC_REQUEST_TIMEOUT || 1928 1947 tsx->status_code == PJSIP_SC_TSX_TIMEOUT || 1929 PJSIP_SC_TSX_TRANSPORT_ERROR)1948 tsx->status_code == PJSIP_SC_TSX_TRANSPORT_ERROR) 1930 1949 { 1931 i f (inv->cause==0) inv->cause = tsx->status_code;1950 inv_set_cause(inv, tsx->status_code, &tsx->status_text); 1932 1951 inv_set_state(inv, PJSIP_INV_STATE_DISCONNECTED, e); 1933 1952 } … … 1973 1992 inv_set_state(inv, PJSIP_INV_STATE_CONNECTING, e); 1974 1993 } else { 1975 i f (inv->cause==0) inv->cause = tsx->status_code;1994 inv_set_cause(inv, tsx->status_code, &tsx->status_text); 1976 1995 inv_set_state(inv, PJSIP_INV_STATE_DISCONNECTED, e); 1977 1996 } … … 1983 2002 * response) 1984 2003 */ 1985 i f (inv->cause==0) inv->cause = tsx->status_code;2004 inv_set_cause(inv, tsx->status_code, &tsx->status_text); 1986 2005 inv_set_state(inv, PJSIP_INV_STATE_DISCONNECTED, e); 1987 2006 break; … … 2045 2064 2046 2065 } else { 2047 i f (inv->cause==0) inv->cause = tsx->status_code;2066 inv_set_cause(inv, tsx->status_code, &tsx->status_text); 2048 2067 inv_set_state(inv, PJSIP_INV_STATE_DISCONNECTED, e); 2049 2068 } … … 2079 2098 2080 2099 } else { 2081 i f (inv->cause==0) inv->cause = tsx->status_code;2100 inv_set_cause(inv, tsx->status_code, &tsx->status_text); 2082 2101 inv_set_state(inv, PJSIP_INV_STATE_DISCONNECTED, e); 2083 2102 } … … 2113 2132 tsx->status_code == PJSIP_SC_REQUEST_TIMEOUT || 2114 2133 tsx->status_code == PJSIP_SC_TSX_TIMEOUT || 2115 PJSIP_SC_TSX_TRANSPORT_ERROR)2134 tsx->status_code == PJSIP_SC_TSX_TRANSPORT_ERROR) 2116 2135 { 2117 i f (inv->cause==0) inv->cause = tsx->status_code;2136 inv_set_cause(inv, tsx->status_code, &tsx->status_text); 2118 2137 inv_set_state(inv, PJSIP_INV_STATE_DISCONNECTED, e); 2119 2138 } … … 2149 2168 */ 2150 2169 if (tsx->status_code/100 != 2) { 2151 i f (inv->cause==0) inv->cause = tsx->status_code;2170 inv_set_cause(inv, tsx->status_code, &tsx->status_text); 2152 2171 inv_set_state(inv, PJSIP_INV_STATE_DISCONNECTED, e); 2153 2172 } … … 2341 2360 * Handle responses that terminates dialog. 2342 2361 */ 2343 i f (inv->cause==0) inv->cause = tsx->status_code;2362 inv_set_cause(inv, tsx->status_code, &tsx->status_text); 2344 2363 inv_set_state(inv, PJSIP_INV_STATE_DISCONNECTED, e); 2345 2364 }
Note: See TracChangeset
for help on using the changeset viewer.