Changeset 2859
- Timestamp:
- Aug 11, 2009 4:26:20 PM (15 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r2858 r2859 839 839 840 840 case OPT_TIMER_SE: /** session timer session expiration */ 841 cur_acc->timer_se = pj_strtoul(pj_cstr(&tmp, pj_optarg));842 if (cur_acc->timer_se < 90) {841 cur_acc->timer_setting.sess_expires = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 842 if (cur_acc->timer_setting.min_se < 90) { 843 843 PJ_LOG(1,(THIS_FILE, 844 844 "Error: invalid value for --timer-se " … … 846 846 return PJ_EINVAL; 847 847 } 848 cfg->cfg.timer_se = cur_acc->timer_se;848 cfg->cfg.timer_setting.sess_expires = cur_acc->timer_setting.sess_expires; 849 849 break; 850 850 851 851 case OPT_TIMER_MIN_SE: /** session timer minimum session expiration */ 852 cur_acc->timer_ min_se = pj_strtoul(pj_cstr(&tmp, pj_optarg));853 if (cur_acc->timer_ min_se < 90) {852 cur_acc->timer_setting.min_se = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 853 if (cur_acc->timer_setting.min_se < 90) { 854 854 PJ_LOG(1,(THIS_FILE, 855 855 "Error: invalid value for --timer-min-se " … … 857 857 return PJ_EINVAL; 858 858 } 859 cfg->cfg.timer_ min_se = cur_acc->timer_min_se;859 cfg->cfg.timer_setting.min_se = cur_acc->timer_setting.min_se; 860 860 break; 861 861 -
pjproject/trunk/pjsip-apps/src/python/_pjsua.h
r2858 r2859 1735 1735 obj->require_100rel = cfg->require_100rel; 1736 1736 obj->require_timer = cfg->require_timer; 1737 obj->timer_se = cfg->timer_se ;1738 obj->timer_min_se = cfg->timer_ min_se;1737 obj->timer_se = cfg->timer_setting.sess_expires; 1738 obj->timer_min_se = cfg->timer_setting.min_se; 1739 1739 obj->allow_contact_rewrite = cfg->allow_contact_rewrite; 1740 1740 obj->ka_interval = cfg->ka_interval; … … 1784 1784 cfg->require_100rel = obj->require_100rel; 1785 1785 cfg->require_timer = obj->require_timer; 1786 cfg->timer_se = obj->timer_se;1787 cfg->timer_ min_se = obj->timer_min_se;1786 cfg->timer_setting.sess_expires = obj->timer_se; 1787 cfg->timer_setting.min_se = obj->timer_min_se; 1788 1788 cfg->allow_contact_rewrite = obj->allow_contact_rewrite; 1789 1789 cfg->ka_interval = obj->ka_interval; -
pjproject/trunk/pjsip/include/pjsip-ua/sip_timer.h
r2858 r2859 126 126 * @return PJ_SUCCESS on successful. 127 127 */ 128 PJ_DECL(pj_status_t) pjsip_timer_ default_setting(pjsip_timer_setting *setting);128 PJ_DECL(pj_status_t) pjsip_timer_setting_default(pjsip_timer_setting *setting); 129 129 130 130 … … 192 192 * @param inv The invite session. 193 193 * @param rdata Incoming response data. 194 * @param st_code Output buffer to store corresponding SIP status code 195 * when function returning non-PJ_SUCCESS. 194 196 * 195 197 * @return PJ_SUCCESS on successful. 196 198 */ 197 199 PJ_DECL(pj_status_t) pjsip_timer_process_resp(pjsip_inv_session *inv, 198 const pjsip_rx_data *rdata); 200 const pjsip_rx_data *rdata, 201 pjsip_status_code *st_code); 199 202 200 203 … … 208 211 * @param inv The invite session. 209 212 * @param rdata Incoming INVITE or UPDATE request. 213 * @param st_code Output buffer to store corresponding SIP status code 214 * when function returning non-PJ_SUCCESS. 210 215 * 211 216 * @return PJ_SUCCESS on successful. 212 217 */ 213 218 PJ_DECL(pj_status_t) pjsip_timer_process_req(pjsip_inv_session *inv, 214 const pjsip_rx_data *rdata); 219 const pjsip_rx_data *rdata, 220 pjsip_status_code *st_code); 215 221 216 222 -
pjproject/trunk/pjsip/include/pjsip/sip_config.h
r2858 r2859 884 884 885 885 886 /** 887 * Default session interval for Session Timer (RFC 4028) extension, in 888 * seconds. As specified in RFC 4028 Section 4, this value must not be 889 * less than the absolute minimum for the Session-Expires header field 890 * 90 seconds, and the recommended value is 1800 seconds. 891 * 892 * Default: 1800 seconds 893 */ 894 #ifndef PJSIP_SESS_TIMER_DEF_SE 895 # define PJSIP_SESS_TIMER_DEF_SE 1800 896 #endif 897 898 886 899 PJ_END_DECL 887 900 -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r2858 r2859 937 937 938 938 /** 939 * Specify session expiration period of Session Timers, in seconds.939 * Specify Session Timer settings, see #pjsip_timer_setting. 940 940 * Note that this setting can be further customized in account 941 941 * configuration (#pjsua_acc_config). 942 * 943 * Default: 1800 (seconds) 944 */ 945 unsigned timer_se; 946 947 /** 948 * Specify minimum session expiration period of Session Timers, 949 * in seconds. Note that this setting can be further customized in 950 * account configuration (#pjsua_acc_config). 951 * 952 * Default: 90 (seconds) 953 */ 954 unsigned timer_min_se; 942 */ 943 pjsip_timer_setting timer_setting; 955 944 956 945 /** … … 1734 1723 1735 1724 /** 1736 * Specify session expiration period of Session Timers, in seconds, 1737 * for this account. 1738 * 1739 * Default: 1800 (seconds) 1740 */ 1741 unsigned timer_se; 1742 1743 /** 1744 * Specify minimum session expiration period of Session Timers, 1745 * in seconds, for this account. 1746 * 1747 * Default: 90 (seconds) 1748 */ 1749 unsigned timer_min_se; 1725 * Specify Session Timer settings, see #pjsip_timer_setting. 1726 */ 1727 pjsip_timer_setting timer_setting; 1750 1728 1751 1729 /** -
pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
r2858 r2859 485 485 pjsip_msg *msg = rdata->msg_info.msg; 486 486 pj_status_t status; 487 pjsip_status_code st_code; 487 488 488 489 dlg = pjsip_rdata_get_dlg(rdata); … … 513 514 514 515 /* Pass response to timer session module */ 515 status = pjsip_timer_process_resp(inv, rdata );516 status = pjsip_timer_process_resp(inv, rdata, &st_code); 516 517 if (status != PJ_SUCCESS) { 517 518 pjsip_event e; … … 521 522 inv_send_ack(inv, &e); 522 523 523 status = pjsip_inv_end_session(inv, PJSIP_ERRNO_TO_SIP_STATUS(status), 524 NULL, &tdata); 524 status = pjsip_inv_end_session(inv, st_code, NULL, &tdata); 525 525 if (tdata && status == PJ_SUCCESS) 526 526 pjsip_inv_send_msg(inv, tdata); … … 975 975 if ( ((*options & PJSIP_INV_REQUIRE_100REL)!=0 && 976 976 (rem_option & PJSIP_INV_SUPPORT_100REL)==0) || 977 ((*options & PJSIP_INV_REQUIRE_ 100REL)!=0 &&978 (rem_option & PJSIP_INV_SUPPORT_ 100REL)==0))977 ((*options & PJSIP_INV_REQUIRE_TIMER)!=0 && 978 (rem_option & PJSIP_INV_SUPPORT_TIMER)==0)) 979 979 { 980 980 code = PJSIP_SC_EXTENSION_REQUIRED; … … 1756 1756 pjsip_tx_data *tdata; 1757 1757 pj_status_t status; 1758 pjsip_status_code st_code2; 1758 1759 1759 1760 /* Verify arguments. */ … … 1772 1773 1773 1774 /* Invoke Session Timers module */ 1774 status = pjsip_timer_process_req(inv, rdata );1775 status = pjsip_timer_process_req(inv, rdata, &st_code2); 1775 1776 if (status != PJ_SUCCESS) { 1776 1777 pj_status_t status2; 1777 1778 1778 status2 = pjsip_dlg_modify_response(inv->dlg, tdata, 1779 PJSIP_ERRNO_TO_SIP_STATUS(status), 1780 NULL); 1779 status2 = pjsip_dlg_modify_response(inv->dlg, tdata, st_code2, NULL); 1781 1780 if (status2 != PJ_SUCCESS) { 1782 1781 pjsip_tx_data_dec_ref(tdata); … … 2639 2638 pj_status_t status; 2640 2639 pjsip_tx_data *tdata = NULL; 2640 pjsip_status_code st_code; 2641 2641 2642 2642 /* Invoke Session Timers module */ 2643 status = pjsip_timer_process_req(inv, rdata );2643 status = pjsip_timer_process_req(inv, rdata, &st_code); 2644 2644 if (status != PJ_SUCCESS) { 2645 status = pjsip_dlg_create_response(inv->dlg, rdata, 2646 PJSIP_ERRNO_TO_SIP_STATUS(status), 2645 status = pjsip_dlg_create_response(inv->dlg, rdata, st_code, 2647 2646 NULL, &tdata); 2648 2647 goto on_return; … … 3660 3659 pjsip_tx_data *tdata; 3661 3660 pj_status_t status; 3661 pjsip_status_code st_code; 3662 3662 3663 3663 /* Check if we have INVITE pending. */ … … 3683 3683 3684 3684 /* Process session timers headers in the re-INVITE */ 3685 status = pjsip_timer_process_req(inv, rdata );3685 status = pjsip_timer_process_req(inv, rdata, &st_code); 3686 3686 if (status != PJ_SUCCESS) { 3687 status = pjsip_dlg_create_response(inv->dlg, rdata, 3688 PJSIP_ERRNO_TO_SIP_STATUS(status), 3689 NULL, &tdata); 3687 status = pjsip_dlg_create_response(inv->dlg, rdata, st_code, 3688 NULL, &tdata); 3690 3689 if (status != PJ_SUCCESS) 3691 3690 return; -
pjproject/trunk/pjsip/src/pjsip-ua/sip_timer.c
r2858 r2859 28 28 29 29 30 /* Constant valuesof Session Timers */30 /* Constant of Session Timers */ 31 31 #define ABS_MIN_SE 90 /* Absolute Min-SE, in seconds */ 32 #define DEF_SE 1800 /* Default SE, in seconds */33 32 34 33 … … 61 60 pj_bool_t use_update; /**< Use UPDATE method to 62 61 refresh the session */ 62 pjsip_role_e role; /**< Role in last INVITE/ 63 UPDATE transaction. */ 63 64 64 65 } pjsip_timer; … … 121 122 const pj_str_t *hname = pjsip_use_compact_form? &hdr->sname : &hdr->name; 122 123 124 /* Print header name and value */ 125 if ((endbuf - p) < (hname->slen + 16)) 126 return -1; 127 123 128 copy_advance(p, (*hname)); 124 129 *p++ = ':'; … … 128 133 p += printed; 129 134 130 if (hdr->refresher.slen && (endbuf-p) > (hdr->refresher.slen + 2)) 135 /* Print 'refresher' param */ 136 if (hdr->refresher.slen) 131 137 { 138 if ((endbuf - p) < (STR_REFRESHER.slen + 2 + hdr->refresher.slen)) 139 return -1; 140 132 141 *p++ = ';'; 133 142 copy_advance(p, STR_REFRESHER); … … 136 145 } 137 146 147 /* Print generic params */ 138 148 printed = pjsip_param_print_on(&hdr->other_param, p, endbuf-p, 139 149 &pc->pjsip_TOKEN_SPEC, … … 177 187 const pjsip_parser_const_t *pc = pjsip_parser_const(); 178 188 189 /* Print header name and value */ 190 if ((endbuf - p) < (hdr->name.slen + 16)) 191 return -1; 192 179 193 copy_advance(p, hdr->name); 180 194 *p++ = ':'; … … 184 198 p += printed; 185 199 200 /* Print generic params */ 186 201 printed = pjsip_param_print_on(&hdr->other_param, p, endbuf-p, 187 202 &pc->pjsip_TOKEN_SPEC, … … 324 339 /* Check our role */ 325 340 as_refresher = 326 (inv->timer->refresher == TR_UAC && inv-> role == PJSIP_ROLE_UAC) ||327 (inv->timer->refresher == TR_UAS && inv-> role == PJSIP_ROLE_UAS);341 (inv->timer->refresher == TR_UAC && inv->timer->role == PJSIP_ROLE_UAC) || 342 (inv->timer->refresher == TR_UAS && inv->timer->role == PJSIP_ROLE_UAS); 328 343 329 344 /* Do action based on role, refresher or refreshee */ … … 418 433 419 434 /* Set delay based on role, refresher or refreshee */ 420 if ((timer->refresher == TR_UAC && inv-> role == PJSIP_ROLE_UAC) ||421 (timer->refresher == TR_UAS && inv-> role == PJSIP_ROLE_UAS))435 if ((timer->refresher == TR_UAC && inv->timer->role == PJSIP_ROLE_UAC) || 436 (timer->refresher == TR_UAS && inv->timer->role == PJSIP_ROLE_UAS)) 422 437 { 423 438 /* Next refresh, the delay is half of session expire */ … … 488 503 * Initialize Session Timers setting with default values. 489 504 */ 490 PJ_DEF(pj_status_t) pjsip_timer_ default_setting(pjsip_timer_setting *setting)505 PJ_DEF(pj_status_t) pjsip_timer_setting_default(pjsip_timer_setting *setting) 491 506 { 492 507 pj_bzero(setting, sizeof(pjsip_timer_setting)); 493 508 494 setting->sess_expires = DEF_SE;509 setting->sess_expires = PJSIP_SESS_TIMER_DEF_SE; 495 510 setting->min_se = ABS_MIN_SE; 496 511 … … 527 542 pj_memcpy(s, setting, sizeof(*s)); 528 543 } else { 529 pjsip_timer_ default_setting(s);544 pjsip_timer_setting_default(s); 530 545 } 531 546 … … 605 620 */ 606 621 PJ_DEF(pj_status_t) pjsip_timer_process_resp(pjsip_inv_session *inv, 607 const pjsip_rx_data *rdata) 622 const pjsip_rx_data *rdata, 623 pjsip_status_code *st_code) 608 624 { 609 625 const pjsip_msg *msg; 610 626 611 PJ_ASSERT_RETURN(inv && rdata, PJ_EINVAL); 627 PJ_ASSERT_ON_FAIL(inv && rdata, 628 {if(st_code)*st_code=PJSIP_SC_INTERNAL_SERVER_ERROR;return PJ_EINVAL;}); 612 629 613 630 /* Check if Session Timers is supported */ … … 705 722 */ 706 723 if (inv->options & PJSIP_INV_REQUIRE_TIMER) { 724 if (st_code) 725 *st_code = PJSIP_SC_EXTENSION_REQUIRED; 707 726 pjsip_timer_end_session(inv); 708 727 return PJSIP_ERRNO_FROM_SIP_STATUS( … … 727 746 se_hdr->sess_expires < inv->timer->setting.min_se) 728 747 { 748 if (st_code) 749 *st_code = PJSIP_SC_SESSION_TIMER_TOO_SMALL; 729 750 pjsip_timer_end_session(inv); 730 751 return PJSIP_ERRNO_FROM_SIP_STATUS( … … 758 779 PJ_TODO(CHECK_IF_REMOTE_SUPPORT_UPDATE); 759 780 781 /* Remember our role in this transaction */ 782 inv->timer->role = PJSIP_ROLE_UAC; 783 760 784 /* Finally, set active flag and start the Session Timers */ 761 785 inv->timer->active = PJ_TRUE; … … 770 794 */ 771 795 PJ_DEF(pj_status_t) pjsip_timer_process_req(pjsip_inv_session *inv, 772 const pjsip_rx_data *rdata) 796 const pjsip_rx_data *rdata, 797 pjsip_status_code *st_code) 773 798 { 774 799 pjsip_min_se_hdr *min_se_hdr; … … 777 802 unsigned min_se; 778 803 779 PJ_ASSERT_RETURN(inv && rdata, PJ_EINVAL); 804 PJ_ASSERT_ON_FAIL(inv && rdata, 805 {if(st_code)*st_code=PJSIP_SC_INTERNAL_SERVER_ERROR;return PJ_EINVAL;}); 780 806 781 807 /* Check if Session Timers is supported */ … … 828 854 * (or 90 seconds if Min-SE is not set). 829 855 */ 830 if (se_hdr && se_hdr->sess_expires < min_se) 856 if (se_hdr && se_hdr->sess_expires < min_se) { 857 if (st_code) 858 *st_code = PJSIP_SC_SESSION_TIMER_TOO_SMALL; 831 859 return PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_SESSION_TIMER_TOO_SMALL); 860 } 832 861 833 862 /* Update SE. Note that there is a case that SE is not available in the … … 882 911 if (msg->line.status.code/100 == 2) 883 912 { 884 /* Add Session-Expires header and start the timer */885 913 if (inv->timer && inv->timer->active) { 914 /* Remember our role in this transaction */ 915 inv->timer->role = PJSIP_ROLE_UAS; 916 917 /* Add Session-Expires header and start the timer */ 886 918 add_timer_headers(inv, tdata, PJ_TRUE, PJ_FALSE); 887 919 start_timer(inv); -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r2858 r2859 493 493 494 494 /* Init Session Timers */ 495 { 496 pjsip_timer_setting timer_setting; 497 498 pjsip_timer_default_setting(&timer_setting); 499 timer_setting.sess_expires = acc->cfg.timer_se; 500 timer_setting.min_se = acc->cfg.timer_min_se; 501 502 status = pjsip_timer_init_session(inv, &timer_setting); 503 if (status != PJ_SUCCESS) { 504 pjsua_perror(THIS_FILE, "Session Timer init failed", status); 505 goto on_error; 506 } 495 status = pjsip_timer_init_session(inv, &acc->cfg.timer_setting); 496 if (status != PJ_SUCCESS) { 497 pjsua_perror(THIS_FILE, "Session Timer init failed", status); 498 goto on_error; 507 499 } 508 500 … … 917 909 918 910 /* Init Session Timers */ 919 { 920 pjsip_timer_setting timer_setting; 921 922 pjsip_timer_default_setting(&timer_setting); 923 timer_setting.sess_expires = pjsua_var.acc[acc_id].cfg.timer_se; 924 timer_setting.min_se = pjsua_var.acc[acc_id].cfg.timer_min_se; 925 926 status = pjsip_timer_init_session(inv, &timer_setting); 927 if (status != PJ_SUCCESS) { 928 pjsua_perror(THIS_FILE, "Session Timer init failed", status); 929 status = pjsip_inv_end_session(inv, PJSIP_SC_INTERNAL_SERVER_ERROR, 930 NULL, &response); 931 if (status == PJ_SUCCESS && response) 932 status = pjsip_inv_send_msg(inv, response); 933 934 pjsua_media_channel_deinit(call->index); 935 936 PJSUA_UNLOCK(); 937 return PJ_TRUE; 938 } 911 status = pjsip_timer_init_session(inv, 912 &pjsua_var.acc[acc_id].cfg.timer_setting); 913 if (status != PJ_SUCCESS) { 914 pjsua_perror(THIS_FILE, "Session Timer init failed", status); 915 status = pjsip_inv_end_session(inv, PJSIP_SC_INTERNAL_SERVER_ERROR, 916 NULL, &response); 917 if (status == PJ_SUCCESS && response) 918 status = pjsip_inv_send_msg(inv, response); 919 920 pjsua_media_channel_deinit(call->index); 921 922 PJSUA_UNLOCK(); 923 return PJ_TRUE; 939 924 } 940 925 … … 979 964 } else { 980 965 pjsip_inv_send_msg(inv, response); 981 pjsip_inv_terminate(inv, PJSIP_ERRNO_TO_SIP_STATUS(status),966 pjsip_inv_terminate(inv, response->msg->line.status.code, 982 967 PJ_FALSE); 983 968 } -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r2858 r2859 88 88 PJ_DEF(void) pjsua_config_default(pjsua_config *cfg) 89 89 { 90 pjsip_timer_setting timer_setting;91 92 90 pj_bzero(cfg, sizeof(*cfg)); 93 91 … … 102 100 cfg->hangup_forked_call = PJ_TRUE; 103 101 104 pjsip_timer_default_setting(&timer_setting); 105 cfg->timer_se = timer_setting.sess_expires; 106 cfg->timer_min_se = timer_setting.min_se; 102 pjsip_timer_setting_default(&cfg->timer_setting); 107 103 } 108 104 … … 158 154 cfg->require_100rel = pjsua_var.ua_cfg.require_100rel; 159 155 cfg->require_timer = pjsua_var.ua_cfg.require_timer; 160 cfg->timer_se = pjsua_var.ua_cfg.timer_se; 161 cfg->timer_min_se = pjsua_var.ua_cfg.timer_min_se; 156 cfg->timer_setting = pjsua_var.ua_cfg.timer_setting; 162 157 cfg->ka_interval = 15; 163 158 cfg->ka_data = pj_str("\r\n");
Note: See TracChangeset
for help on using the changeset viewer.