Changeset 1463 for pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
- Timestamp:
- Sep 30, 2007 4:50:27 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
r1417 r1463 18 18 */ 19 19 #include <pjsip-ua/sip_inv.h> 20 #include <pjsip-ua/sip_100rel.h> 20 21 #include <pjsip/sip_module.h> 21 22 #include <pjsip/sip_endpoint.h> … … 32 33 33 34 34 #define THIS_FILE "sip_inv ite_session.c"35 #define THIS_FILE "sip_inv.c" 35 36 36 37 static const char *inv_state_names[] = … … 306 307 inv->invite_tsx->status_code); 307 308 inv->invite_tsx = NULL; 309 if (inv->last_answer) { 310 pjsip_tx_data_dec_ref(inv->last_answer); 311 inv->last_answer = NULL; 312 } 308 313 } 309 314 … … 396 401 * value as the INVITE (see http://www.pjsip.org/trac/ticket/113) 397 402 */ 398 if (tsx->state>=PJSIP_TSX_STATE_CONFIRMED && tsx == inv->invite_tsx) 403 if (tsx->state>=PJSIP_TSX_STATE_CONFIRMED && tsx == inv->invite_tsx) { 399 404 inv->invite_tsx = NULL; 405 if (inv->last_answer) { 406 pjsip_tx_data_dec_ref(inv->last_answer); 407 inv->last_answer = NULL; 408 } 409 } 400 410 } 401 411 … … 482 492 if (options & PJSIP_INV_REQUIRE_100REL) 483 493 options |= PJSIP_INV_SUPPORT_100REL; 494 495 #if !PJSIP_HAS_100REL 496 /* options cannot specify 100rel if 100rel is disabled */ 497 PJ_ASSERT_RETURN( 498 (options & (PJSIP_INV_REQUIRE_100REL | PJSIP_INV_SUPPORT_100REL))==0, 499 PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_BAD_EXTENSION)); 500 501 #endif 484 502 485 503 if (options & PJSIP_INV_REQUIRE_TIMER) … … 520 538 /* Increment dialog session */ 521 539 pjsip_dlg_inc_session(dlg, &mod_inv.mod); 540 541 #if PJSIP_HAS_100REL 542 /* Create 100rel handler */ 543 pjsip_100rel_attach(inv); 544 #endif 522 545 523 546 /* Done */ … … 830 853 } 831 854 855 /* If remote Require something that we support, make us Require 856 * that feature too. 857 */ 858 if (rem_option & PJSIP_INV_REQUIRE_100REL) { 859 pj_assert(*options & PJSIP_INV_SUPPORT_100REL); 860 *options |= PJSIP_INV_REQUIRE_100REL; 861 } 862 if (rem_option & PJSIP_INV_REQUIRE_TIMER) { 863 pj_assert(*options & PJSIP_INV_SUPPORT_TIMER); 864 *options |= PJSIP_INV_REQUIRE_TIMER; 865 } 866 832 867 on_return: 833 868 … … 908 943 if (options & PJSIP_INV_REQUIRE_100REL) 909 944 options |= PJSIP_INV_SUPPORT_100REL; 945 946 #if !PJSIP_HAS_100REL 947 /* options cannot specify 100rel if 100rel is disabled */ 948 PJ_ASSERT_RETURN( 949 (options & (PJSIP_INV_REQUIRE_100REL | PJSIP_INV_SUPPORT_100REL))==0, 950 PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_BAD_EXTENSION)); 951 952 #endif 910 953 911 954 if (options & PJSIP_INV_REQUIRE_TIMER) … … 978 1021 inv->invite_tsx->mod_data[mod_inv.mod.id] = tsx_inv_data; 979 1022 1023 #if PJSIP_HAS_100REL 1024 /* Create 100rel handler */ 1025 if (inv->options & PJSIP_INV_REQUIRE_100REL) { 1026 pjsip_100rel_attach(inv); 1027 } 1028 #endif 1029 980 1030 /* Done */ 981 1031 pjsip_dlg_dec_lock(dlg); … … 1169 1219 1170 1220 /* Add Require header. */ 1171 PJ_TODO(INVITE_ADD_REQUIRE_HEADER); 1221 if (inv->options & PJSIP_INV_REQUIRE_100REL) { 1222 const pj_str_t HREQ = { "Require", 7 }; 1223 const pj_str_t tag_100rel = { "100rel", 6 }; 1224 pjsip_generic_string_hdr *hreq; 1225 1226 hreq = pjsip_generic_string_hdr_create(tdata->pool, &HREQ, 1227 &tag_100rel); 1228 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*) hreq); 1229 } 1172 1230 1173 1231 /* Done. */ … … 1453 1511 } 1454 1512 1513 /* Save this answer */ 1514 inv->last_answer = tdata; 1515 pjsip_tx_data_add_ref(inv->last_answer); 1516 PJ_LOG(5,(inv->dlg->obj_name, "Initial answer %s", 1517 pjsip_tx_data_get_info(inv->last_answer))); 1518 1455 1519 *p_tdata = tdata; 1456 1520 … … 1480 1544 PJ_ASSERT_RETURN(inv->invite_tsx, PJ_EBUG); 1481 1545 1482 /* INVITE transaction MUST have transmitted a response (e.g. 100)*/1483 PJ_ASSERT_RETURN(inv-> invite_tsx->last_tx, PJ_EINVALIDOP);1546 /* Must have created an answer before */ 1547 PJ_ASSERT_RETURN(inv->last_answer, PJ_EINVALIDOP); 1484 1548 1485 1549 pjsip_dlg_inc_lock(inv->dlg); 1486 1550 1487 1551 /* Modify last response. */ 1488 last_res = inv-> invite_tsx->last_tx;1552 last_res = inv->last_answer; 1489 1553 status = pjsip_dlg_modify_response(inv->dlg, last_res, st_code, st_text); 1490 1554 if (status != PJ_SUCCESS) 1491 1555 goto on_return; 1492 1556 1557 /* For non-2xx final response, strip message body */ 1558 if (st_code >= 300) { 1559 last_res->msg->body = NULL; 1560 } 1493 1561 1494 1562 /* Process SDP in answer */ … … 1765 1833 PJ_EINVALIDOP); 1766 1834 1767 status = pjsip_dlg_send_response(inv->dlg, inv->invite_tsx, tdata); 1835 #if PJSIP_HAS_100REL 1836 if (inv->options & PJSIP_INV_REQUIRE_100REL) { 1837 status = pjsip_100rel_tx_response(inv, tdata); 1838 } else 1839 #endif 1840 { 1841 status = pjsip_dlg_send_response(inv->dlg, inv->invite_tsx, tdata); 1842 } 1843 1768 1844 if (status != PJ_SUCCESS) 1769 1845 return status; … … 2043 2119 inv->state = PJSIP_INV_STATE_NULL; 2044 2120 inv->invite_tsx = NULL; 2121 if (inv->last_answer) { 2122 pjsip_tx_data_dec_ref(inv->last_answer); 2123 inv->last_answer = NULL; 2124 } 2045 2125 2046 2126 /* Send the request. */
Note: See TracChangeset
for help on using the changeset viewer.