Changeset 2951
- Timestamp:
- Oct 16, 2009 6:28:56 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
r2879 r2951 109 109 const pjmedia_sdp_session *local_sdp); 110 110 111 static pj_status_t handle_timer_response(pjsip_inv_session *inv, 112 const pjsip_rx_data *rdata, 113 pj_bool_t end_sess_on_failure); 114 111 115 static void (*inv_state_handler[])( pjsip_inv_session *inv, pjsip_event *e) = 112 116 { … … 478 482 } 479 483 484 /* This function will process Session Timer headers in received 485 * 2xx or 422 response of INVITE/UPDATE request. 486 */ 487 static pj_status_t handle_timer_response(pjsip_inv_session *inv, 488 const pjsip_rx_data *rdata, 489 pj_bool_t end_sess_on_failure) 490 { 491 pjsip_status_code st_code; 492 pj_status_t status; 493 494 status = pjsip_timer_process_resp(inv, rdata, &st_code); 495 if (status != PJ_SUCCESS && end_sess_on_failure) { 496 pjsip_tx_data *tdata; 497 pj_status_t status2; 498 499 status2 = pjsip_inv_end_session(inv, st_code, NULL, &tdata); 500 if (tdata && status2 == PJ_SUCCESS) 501 pjsip_inv_send_msg(inv, tdata); 502 } 503 504 return status; 505 } 506 480 507 /* 481 508 * Module on_rx_response(). … … 491 518 pjsip_inv_session *inv; 492 519 pjsip_msg *msg = rdata->msg_info.msg; 493 pj_status_t status;494 pjsip_status_code st_code;495 520 496 521 dlg = pjsip_rdata_get_dlg(rdata); … … 518 543 return PJ_TRUE; 519 544 520 }521 522 /* Pass response to timer session module */523 status = pjsip_timer_process_resp(inv, rdata, &st_code);524 if (status != PJ_SUCCESS) {525 pjsip_event e;526 pjsip_tx_data *tdata;527 528 PJSIP_EVENT_INIT_RX_MSG(e, rdata);529 inv_send_ack(inv, &e);530 531 status = pjsip_inv_end_session(inv, st_code, NULL, &tdata);532 if (tdata && status == PJ_SUCCESS)533 pjsip_inv_send_msg(inv, tdata);534 535 return PJ_TRUE;536 545 } 537 546 … … 2775 2784 /* Handle 401/407 challenge. */ 2776 2785 if (tsx->state == PJSIP_TSX_STATE_COMPLETED && 2777 (tsx->status_code == 401 || tsx->status_code == 407)) {2778 2786 (tsx->status_code == 401 || tsx->status_code == 407)) 2787 { 2779 2788 pjsip_tx_data *tdata; 2780 2789 … … 2799 2808 status = pjsip_inv_send_msg(inv, tdata); 2800 2809 } 2810 } 2811 2812 /* Process 422 response */ 2813 else if (tsx->state == PJSIP_TSX_STATE_COMPLETED && 2814 tsx->status_code == 422) 2815 { 2816 status = handle_timer_response(inv, e->body.tsx_state.src.rdata, 2817 PJ_FALSE); 2818 } 2801 2819 2802 2820 /* Process 2xx response */ 2803 }else if (tsx->state == PJSIP_TSX_STATE_COMPLETED &&2821 else if (tsx->state == PJSIP_TSX_STATE_COMPLETED && 2804 2822 tsx->status_code/100 == 2 && 2805 2823 e->body.tsx_state.src.rdata->msg_info.msg->body) 2806 2824 { 2825 status = handle_timer_response(inv, e->body.tsx_state.src.rdata, 2826 PJ_FALSE); 2807 2827 status = inv_check_sdp_in_incoming_msg(inv, tsx, 2808 e->body.tsx_state.src.rdata); 2809 2810 } else { 2811 /* Get/attach invite session's transaction data */ 2828 e->body.tsx_state.src.rdata); 2829 } 2830 2831 /* Get/attach invite session's transaction data */ 2832 else 2833 { 2812 2834 tsx_inv_data = (struct tsx_inv_data*)tsx->mod_data[mod_inv.mod.id]; 2813 2835 if (tsx_inv_data == NULL) { … … 2975 2997 * - resend request on 401 or 407 response. 2976 2998 * - terminate dialog on 408 and 481 response. 2999 * - resend request on 422 response. 2977 3000 */ 2978 3001 static pj_bool_t handle_uac_tsx_response(pjsip_inv_session *inv, … … 3055 3078 3056 3079 return PJ_TRUE; /* Handled */ 3080 } 3081 3082 /* Handle session timer 422 response. */ 3083 else if (tsx->state == PJSIP_TSX_STATE_COMPLETED && 3084 tsx->status_code == PJSIP_SC_SESSION_TIMER_TOO_SMALL) 3085 { 3086 handle_timer_response(inv, e->body.tsx_state.src.rdata, 3087 PJ_FALSE); 3088 3089 return PJ_TRUE; /* Handled */ 3057 3090 3058 3091 } else { … … 3142 3175 } 3143 3176 3177 } else if (tsx->state == PJSIP_TSX_STATE_COMPLETED && 3178 tsx->status_code == PJSIP_SC_SESSION_TIMER_TOO_SMALL) 3179 { 3180 /* Handle session timer 422 response: 3181 * Resend the request with requested session timer setting. 3182 */ 3183 status = handle_timer_response(inv, e->body.tsx_state.src.rdata, 3184 PJ_TRUE); 3185 3144 3186 } else if (PJSIP_IS_STATUS_IN_CLASS(tsx->status_code, 600)) { 3145 3187 /* Global error */ … … 3213 3255 case PJSIP_TSX_STATE_COMPLETED: 3214 3256 if (tsx->status_code/100 == 2) { 3215 3257 3216 3258 /* This should not happen. 3217 3259 * When transaction receives 2xx, it should be terminated 3218 3260 */ 3219 3261 pj_assert(0); 3262 3263 /* Process session timer response. */ 3264 status = handle_timer_response(inv, 3265 e->body.tsx_state.src.rdata, 3266 PJ_TRUE); 3267 if (status != PJ_SUCCESS) 3268 break; 3269 3220 3270 inv_set_state(inv, PJSIP_INV_STATE_CONNECTING, e); 3221 3271 … … 3235 3285 if (tsx->status_code/100 == 2) { 3236 3286 /* This must be receipt of 2xx response */ 3287 3288 /* Process session timer response. */ 3289 status = handle_timer_response(inv, 3290 e->body.tsx_state.src.rdata, 3291 PJ_TRUE); 3292 if (status != PJ_SUCCESS) 3293 break; 3237 3294 3238 3295 /* Set state to CONNECTING */ … … 3387 3444 inv_set_state(inv, PJSIP_INV_STATE_CONNECTING, e); 3388 3445 if (e->body.tsx_state.type == PJSIP_EVENT_RX_MSG) { 3446 pj_status_t status; 3447 3448 /* Process session timer response. */ 3449 status = handle_timer_response(inv, 3450 e->body.tsx_state.src.rdata, 3451 PJ_TRUE); 3452 if (status != PJ_SUCCESS) 3453 break; 3454 3389 3455 inv_check_sdp_in_incoming_msg(inv, tsx, 3390 3456 e->body.tsx_state.src.rdata); … … 3418 3484 3419 3485 if (e->body.tsx_state.type == PJSIP_EVENT_RX_MSG) { 3486 pj_status_t status; 3487 3488 /* Process session timer response. */ 3489 status = handle_timer_response(inv, 3490 e->body.tsx_state.src.rdata, 3491 PJ_TRUE); 3492 if (status != PJ_SUCCESS) 3493 break; 3494 3420 3495 inv_check_sdp_in_incoming_msg(inv, tsx, 3421 3496 e->body.tsx_state.src.rdata); … … 3886 3961 tsx->status_code/100 == 2) 3887 3962 { 3963 pj_status_t status; 3888 3964 3889 3965 /* Re-INVITE was accepted. */ 3966 3967 /* Process session timer response. */ 3968 status = handle_timer_response(inv, 3969 e->body.tsx_state.src.rdata, 3970 PJ_TRUE); 3971 if (status != PJ_SUCCESS) 3972 return; 3890 3973 3891 3974 /* Process SDP */ … … 3946 4029 } else if (tsx->role == PJSIP_ROLE_UAC) { 3947 4030 /* 3948 * Handle 401/407/408/481 response4031 * Handle 401/407/408/481/422 response 3949 4032 */ 3950 4033 handle_uac_tsx_response(inv, e); … … 3993 4076 } else if (tsx->role == PJSIP_ROLE_UAC) { 3994 4077 /* 3995 * Handle 401/407/408/481 response4078 * Handle 401/407/408/481/422 response 3996 4079 */ 3997 4080 handle_uac_tsx_response(inv, e);
Note: See TracChangeset
for help on using the changeset viewer.