Changeset 5195
- Timestamp:
- Nov 6, 2015 7:55:38 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip-simple/evsub.c
r5178 r5195 254 254 255 255 /* Static vars. */ 256 static const pj_str_t STR_EVENT = { "Event", 5 }; 257 static const pj_str_t STR_EVENT_S = { "o", 1 }; 258 static const pj_str_t STR_SUB_STATE = { "Subscription-State", 18 }; 259 static const pj_str_t STR_TERMINATED = { "terminated", 10 }; 260 static const pj_str_t STR_ACTIVE = { "active", 6 }; 261 static const pj_str_t STR_PENDING = { "pending", 7 }; 262 static const pj_str_t STR_TIMEOUT = { "timeout", 7}; 256 static const pj_str_t STR_EVENT = { "Event", 5 }; 257 static const pj_str_t STR_EVENT_S = { "o", 1 }; 258 static const pj_str_t STR_SUB_STATE = { "Subscription-State", 18 }; 259 static const pj_str_t STR_TERMINATED = { "terminated", 10 }; 260 static const pj_str_t STR_ACTIVE = { "active", 6 }; 261 static const pj_str_t STR_PENDING = { "pending", 7 }; 262 static const pj_str_t STR_TIMEOUT = { "timeout", 7}; 263 static const pj_str_t STR_RETRY_AFTER = { "Retry-After", 11 }; 263 264 264 265 … … 2157 2158 } else if (pjsip_method_cmp(&tsx->method, &pjsip_notify_method)==0) { 2158 2159 2159 /* Handle authentication */ 2160 /* Handle authentication */ 2160 2161 if (tsx->state == PJSIP_TSX_STATE_COMPLETED && 2161 2162 (tsx->status_code==401 || tsx->status_code==407)) 2162 { 2163 pjsip_rx_data *rdata = event->body.tsx_state.src.rdata; 2163 { 2164 2164 pjsip_tx_data *tdata; 2165 2165 pj_status_t status; 2166 2167 status = pjsip_auth_clt_reinit_req( &sub->dlg->auth_sess, rdata, 2168 tsx->last_tx, &tdata); 2166 pjsip_rx_data *rdata = event->body.tsx_state.src.rdata; 2167 2168 status = pjsip_auth_clt_reinit_req(&sub->dlg->auth_sess, rdata, 2169 tsx->last_tx, &tdata); 2169 2170 if (status == PJ_SUCCESS) 2170 status = pjsip_dlg_send_request( sub->dlg, tdata, -1, NULL);2171 status = pjsip_dlg_send_request(sub->dlg, tdata, -1, NULL); 2171 2172 2172 2173 if (status != PJ_SUCCESS) { 2173 2174 /* Can't authenticate. Terminate session (?) */ 2174 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, NULL, 2175 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, NULL, 2175 2176 &tsx->status_text); 2176 2177 return; … … 2178 2179 2179 2180 } 2180 /* 2181 * Terminate event usage if we receive 481, 408, and 7 class 2182 * responses. 2183 */ 2184 if (sub->state != PJSIP_EVSUB_STATE_TERMINATED && 2185 (tsx->status_code==481 || tsx->status_code==408 || 2186 tsx->status_code/100 == 7)) 2187 { 2188 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, event, 2189 &tsx->status_text); 2181 2182 if (sub->state == PJSIP_EVSUB_STATE_TERMINATED) 2190 2183 return; 2191 } 2192 2184 2185 /* NOTIFY failure check */ 2186 if (tsx->status_code/100 != 2) { 2187 pj_bool_t should_terminate_sub = PJ_FALSE; 2188 2189 if (event->body.tsx_state.type == PJSIP_EVENT_RX_MSG) { 2190 if (tsx->status_code == 481) { 2191 should_terminate_sub = PJ_TRUE; 2192 } else { 2193 pjsip_retry_after_hdr *retry_after; 2194 pjsip_rx_data *rdata = event->body.tsx_state.src.rdata;; 2195 pjsip_msg *msg = rdata->msg_info.msg; 2196 2197 retry_after = (pjsip_retry_after_hdr*) 2198 pjsip_msg_find_hdr_by_name(msg, &STR_RETRY_AFTER, NULL); 2199 2200 if (!retry_after) { 2201 should_terminate_sub = PJ_TRUE; 2202 } 2203 } 2204 } else if (event->body.tsx_state.type == PJSIP_EVENT_TIMER) { 2205 if (tsx->status_code == 408) { 2206 should_terminate_sub = PJ_TRUE; 2207 } 2208 } 2209 2210 /* 2211 * Terminate event usage if we receive non 2xx without retry_after 2212 * parameter, 481, 408 responses. 2213 */ 2214 if (should_terminate_sub) { 2215 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, event, 2216 &tsx->status_text); 2217 return; 2218 } 2219 } 2193 2220 } else { 2194 2221
Note: See TracChangeset
for help on using the changeset viewer.