Changeset 4924
- Timestamp:
- Sep 17, 2014 12:11:45 PM (10 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_config.h
r4899 r4924 1209 1209 #endif 1210 1210 1211 /** 1212 * Specify whether to accept INVITE/re-INVITE with unknown content type, 1213 * by default the stack will reject this type of message as specified in 1214 * RFC3261 section 8.2.3. 1215 * Application that wishes to process the body could set this to PJ_TRUE, 1216 * be informed that SDP offer/answer will still be present. 1217 * 1218 * Default: PJ_FALSE 1219 */ 1220 #ifndef PJSIP_INV_ACCEPT_UNKNOWN_BODY 1221 # define PJSIP_INV_ACCEPT_UNKNOWN_BODY PJ_FALSE 1222 #endif 1211 1223 1212 1224 PJ_END_DECL -
pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
r4900 r4924 4738 4738 4739 4739 if (status != PJ_SUCCESS) { 4740 4741 /* Not Acceptable */ 4742 const pjsip_hdr *accept; 4743 4744 /* The incoming SDP is unacceptable. If the SDP negotiator 4745 * state has just been changed, i.e: DONE -> REMOTE_OFFER, 4746 * revert it back. 4747 */ 4748 if (pjmedia_sdp_neg_get_state(inv->neg) == 4749 PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER) 4740 pj_bool_t reject_message = PJ_TRUE; 4741 4742 if (status == PJMEDIA_SDP_EINSDP) 4750 4743 { 4751 pjmedia_sdp_neg_cancel_offer(inv->neg); 4744 sdp_info = pjsip_rdata_get_sdp_info(rdata); 4745 if (sdp_info->body.ptr == NULL && 4746 PJSIP_INV_ACCEPT_UNKNOWN_BODY) 4747 { 4748 /* Message body is not "application/sdp" */ 4749 reject_message = PJ_FALSE; 4750 } 4752 4751 } 4753 4752 4754 status = pjsip_dlg_create_response(inv->dlg, rdata, 4755 488, NULL, &tdata); 4756 if (status != PJ_SUCCESS) 4753 if (reject_message) { 4754 /* Not Acceptable */ 4755 const pjsip_hdr *accept; 4756 4757 /* The incoming SDP is unacceptable. If the SDP negotiator 4758 * state has just been changed, i.e: DONE -> REMOTE_OFFER, 4759 * revert it back. 4760 */ 4761 if (pjmedia_sdp_neg_get_state(inv->neg) == 4762 PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER) 4763 { 4764 pjmedia_sdp_neg_cancel_offer(inv->neg); 4765 } 4766 4767 status = pjsip_dlg_create_response(inv->dlg, rdata, 4768 (status == PJMEDIA_SDP_EINSDP)?415:488, 4769 NULL, &tdata); 4770 4771 if (status != PJ_SUCCESS) 4772 return; 4773 4774 4775 accept = pjsip_endpt_get_capability(dlg->endpt, 4776 PJSIP_H_ACCEPT, 4777 NULL); 4778 if (accept) { 4779 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*) 4780 pjsip_hdr_clone(tdata->pool, accept)); 4781 } 4782 4783 status = pjsip_dlg_send_response(dlg, tsx, tdata); 4784 4757 4785 return; 4758 4759 4760 accept = pjsip_endpt_get_capability(dlg->endpt, PJSIP_H_ACCEPT,4761 NULL);4762 if (accept) {4763 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)4764 pjsip_hdr_clone(tdata->pool, accept));4765 4786 } 4766 4767 status = pjsip_dlg_send_response(dlg, tsx, tdata);4768 4769 return;4770 4787 } 4771 4788 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r4923 r4924 1200 1200 1201 1201 status = sdp_info->sdp_err; 1202 if (status==PJ_SUCCESS && sdp_info->sdp==NULL) 1203 status = PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_NOT_ACCEPTABLE); 1202 if (status==PJ_SUCCESS && sdp_info->sdp==NULL && 1203 !PJSIP_INV_ACCEPT_UNKNOWN_BODY) 1204 { 1205 if (sdp_info->body.ptr == NULL) { 1206 status = PJSIP_ERRNO_FROM_SIP_STATUS( 1207 PJSIP_SC_UNSUPPORTED_MEDIA_TYPE); 1208 } else { 1209 status = PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_NOT_ACCEPTABLE); 1210 } 1211 } 1204 1212 1205 1213 if (status != PJ_SUCCESS) { 1206 const pj_str_t reason = pj_str("Bad SDP");1207 1214 pjsip_hdr hdr_list; 1208 pjsip_warning_hdr *w; 1209 1210 pjsua_perror(THIS_FILE, "Bad SDP in incoming INVITE", 1211 status); 1212 1213 w = pjsip_warning_hdr_create_from_status(rdata->tp_info.pool, 1214 pjsip_endpt_name(pjsua_var.endpt), 1215 status); 1216 pj_list_init(&hdr_list); 1217 pj_list_push_back(&hdr_list, w); 1218 1219 pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 400, 1220 &reason, &hdr_list, NULL, NULL); 1215 1216 /* Check if body really contains SDP. */ 1217 if (sdp_info->body.ptr == NULL) { 1218 /* Couldn't find "application/sdp" */ 1219 pjsip_accept_hdr *acc; 1220 1221 pjsua_perror(THIS_FILE, "Unknown Content-Type in incoming "\ 1222 "INVITE", status); 1223 1224 /* Add Accept header to response */ 1225 acc = pjsip_accept_hdr_create(rdata->tp_info.pool); 1226 PJ_ASSERT_RETURN(acc, PJ_ENOMEM); 1227 acc->values[acc->count++] = pj_str("application/sdp"); 1228 pj_list_init(&hdr_list); 1229 pj_list_push_back(&hdr_list, acc); 1230 1231 pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 1232 PJSIP_SC_UNSUPPORTED_MEDIA_TYPE, 1233 NULL, &hdr_list, NULL, NULL); 1234 } else { 1235 const pj_str_t reason = pj_str("Bad SDP"); 1236 pjsip_warning_hdr *w; 1237 1238 pjsua_perror(THIS_FILE, "Bad SDP in incoming INVITE", 1239 status); 1240 1241 w = pjsip_warning_hdr_create_from_status(rdata->tp_info.pool, 1242 pjsip_endpt_name(pjsua_var.endpt), 1243 status); 1244 pj_list_init(&hdr_list); 1245 pj_list_push_back(&hdr_list, w); 1246 1247 pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 400, 1248 &reason, &hdr_list, NULL, NULL); 1249 } 1221 1250 goto on_return; 1222 1251 } … … 1225 1254 * checks will be done in pjsip_inv_verify_request2() below. 1226 1255 */ 1227 if ( offer->media_count==0) {1256 if ((offer) && (offer->media_count==0)) { 1228 1257 const pj_str_t reason = pj_str("Missing media in SDP"); 1229 1258 pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 400, &reason,
Note: See TracChangeset
for help on using the changeset viewer.