Changeset 500 for pjproject/trunk
- Timestamp:
- Jun 13, 2006 10:21:23 PM (18 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip-ua/sip_inv.h
r324 r500 167 167 struct pjsip_inv_session 168 168 { 169 char obj_name[PJ_MAX_OBJ_NAME]; /**< Log identification .*/169 char obj_name[PJ_MAX_OBJ_NAME]; /**< Log identification */ 170 170 pj_pool_t *pool; /**< Dialog's pool. */ 171 171 pjsip_inv_state state; /**< Invite sess state. */ 172 172 pjsip_status_code cause; /**< Disconnect cause. */ 173 pj_str_t cause_text; /**< Cause text. */ 173 174 pj_bool_t notify; /**< Internal. */ 174 175 pjsip_dialog *dlg; /**< Underlying dialog. */ -
pjproject/trunk/pjsip/include/pjsip/sip_transaction.h
r253 r500 83 83 */ 84 84 int status_code; /**< Last status code seen. */ 85 pj_str_t status_text; /**< Last reason phrase. */ 85 86 pjsip_tsx_state_e state; /**< State. */ 86 87 int handle_200resp; /**< UAS 200/INVITE retrsm.*/ -
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 } -
pjproject/trunk/pjsip/src/pjsip/sip_transaction.c
r491 r500 1327 1327 1328 1328 /* 1329 * Set transaction status code and reason. 1330 */ 1331 static tsx_set_status_code(pjsip_transaction *tsx, 1332 int code, const pj_str_t *reason) 1333 { 1334 tsx->status_code = code; 1335 if (reason) 1336 pj_strdup(tsx->pool, &tsx->status_text, reason); 1337 else 1338 tsx->status_text = *pjsip_get_status_text(code); 1339 } 1340 1341 1342 /* 1329 1343 * Forcely terminate transaction. 1330 1344 */ … … 1342 1356 1343 1357 lock_tsx(tsx, &lck); 1344 tsx ->status_code = code;1358 tsx_set_status_code(tsx, code, NULL); 1345 1359 tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED, PJSIP_EVENT_USER, NULL); 1346 1360 unlock_tsx(tsx, &lck); … … 1492 1506 if (!*cont) { 1493 1507 char errmsg[PJ_ERR_MSG_SIZE]; 1508 pj_str_t err; 1494 1509 1495 1510 tsx->transport_err = -sent; 1511 1512 err =pj_strerror(-sent, errmsg, sizeof(errmsg)); 1496 1513 1497 1514 PJ_LOG(4,(tsx->obj_name, 1498 1515 "Failed to send %s! err=%d (%s)", 1499 1516 pjsip_tx_data_get_info(send_state->tdata), -sent, 1500 pj_strerror(-sent, errmsg, sizeof(errmsg)).ptr));1517 errmsg)); 1501 1518 1502 1519 /* Clear pending transport flag. */ … … 1507 1524 1508 1525 /* Terminate transaction, if it's not already terminated. */ 1509 tsx ->status_code = PJSIP_SC_TSX_TRANSPORT_ERROR;1526 tsx_set_status_code(tsx, PJSIP_SC_TSX_TRANSPORT_ERROR, &err); 1510 1527 if (tsx->state != PJSIP_TSX_STATE_TERMINATED && 1511 1528 tsx->state != PJSIP_TSX_STATE_DESTROYED) … … 1538 1555 struct tsx_lock_data lck; 1539 1556 char errmsg[PJ_ERR_MSG_SIZE]; 1557 pj_str_t err; 1540 1558 1541 1559 tsx->transport_err = -sent; 1542 1560 1561 err = pj_strerror(-sent, errmsg, sizeof(errmsg)); 1562 1543 1563 PJ_LOG(4,(tsx->obj_name, "Transport failed to send %s! Err=%d (%s)", 1544 pjsip_tx_data_get_info(tdata), -sent, 1545 pj_strerror(-sent, errmsg, sizeof(errmsg)).ptr)); 1564 pjsip_tx_data_get_info(tdata), -sent, errmsg)); 1546 1565 1547 1566 lock_tsx(tsx, &lck); … … 1552 1571 1553 1572 /* Terminate transaction. */ 1554 tsx ->status_code = PJSIP_SC_TSX_TRANSPORT_ERROR;1573 tsx_set_status_code(tsx, PJSIP_SC_TSX_TRANSPORT_ERROR, &err); 1555 1574 tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED, 1556 1575 PJSIP_EVENT_TRANSPORT_ERROR, tdata ); … … 1622 1641 1623 1642 char errmsg[PJ_ERR_MSG_SIZE]; 1643 pj_str_t err; 1624 1644 1625 1645 if (status == PJ_SUCCESS) { … … 1631 1651 * Treat this as permanent transport error. 1632 1652 */ 1653 err = pj_strerror(status, errmsg, sizeof(errmsg)); 1654 1633 1655 PJ_LOG(4,(tsx->obj_name, 1634 1656 "Transport error, terminating transaction. " 1635 1657 "Err=%d (%s)", 1636 status, 1637 pj_strerror(status, errmsg, sizeof(errmsg)).ptr)); 1638 1639 tsx->status_code = PJSIP_SC_TSX_TRANSPORT_ERROR; 1658 status, errmsg)); 1659 1660 tsx_set_status_code(tsx, PJSIP_SC_TSX_TRANSPORT_ERROR, &err); 1640 1661 tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED, 1641 1662 PJSIP_EVENT_TRANSPORT_ERROR, NULL ); … … 1860 1881 1861 1882 /* Set status code */ 1862 tsx ->status_code = PJSIP_SC_TSX_TIMEOUT;1883 tsx_set_status_code(tsx, PJSIP_SC_TSX_TIMEOUT, NULL); 1863 1884 1864 1885 /* Inform TU. */ … … 2002 2023 2003 2024 /* Update last status */ 2004 tsx->status_code = msg->line.status.code; 2025 tsx_set_status_code(tsx, msg->line.status.code, 2026 &msg->line.status.reason); 2005 2027 2006 2028 /* Discard the saved last response (it will be updated later as … … 2164 2186 pj_assert(!"Should not happen(?)"); 2165 2187 2166 tsx ->status_code = PJSIP_SC_TSX_TIMEOUT;2188 tsx_set_status_code(tsx, PJSIP_SC_TSX_TIMEOUT, NULL); 2167 2189 2168 2190 tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED, … … 2211 2233 } 2212 2234 2213 tsx->status_code = msg->line.status.code; 2235 tsx_set_status_code(tsx, msg->line.status.code, 2236 &msg->line.status.reason); 2237 2214 2238 } else { 2215 tsx ->status_code = PJSIP_SC_TSX_TIMEOUT;2239 tsx_set_status_code(tsx, PJSIP_SC_TSX_TIMEOUT, NULL); 2216 2240 } 2217 2241 … … 2441 2465 */ 2442 2466 2443 tsx ->status_code = PJSIP_SC_TSX_TIMEOUT;2467 tsx_set_status_code(tsx, PJSIP_SC_TSX_TIMEOUT, NULL); 2444 2468 2445 2469 tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED,
Note: See TracChangeset
for help on using the changeset viewer.