Changeset 131
- Timestamp:
- Feb 2, 2006 9:15:34 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_util.c
r127 r131 1195 1195 pjsip_tx_data *tdata; 1196 1196 1197 /* Verify arguments. */ 1198 PJ_ASSERT_RETURN(endpt && rdata, PJ_EINVAL); 1199 PJ_ASSERT_RETURN(rdata->msg_info.msg->type == PJSIP_REQUEST_MSG, 1200 PJSIP_ENOTREQUESTMSG); 1201 1202 /* Check that no UAS transaction has been created for this request. 1203 * If UAS transaction has been created for this request, application 1204 * MUST send the response statefully using that transaction. 1205 */ 1206 PJ_ASSERT_RETURN(pjsip_rdata_get_tsx(rdata)==NULL, PJ_EINVALIDOP); 1207 1197 1208 /* Create response message */ 1198 1209 status = pjsip_endpt_create_response( endpt, rdata, st_code, st_text, … … 1233 1244 } 1234 1245 1246 1247 /* 1248 * Send response statefully. 1249 */ 1250 PJ_DEF(pj_status_t) pjsip_endpt_respond( pjsip_endpoint *endpt, 1251 pjsip_module *tsx_user, 1252 pjsip_rx_data *rdata, 1253 int st_code, 1254 const pj_str_t *st_text, 1255 const pjsip_hdr *hdr_list, 1256 const pjsip_msg_body *body, 1257 pjsip_transaction **p_tsx ) 1258 { 1259 pj_status_t status; 1260 pjsip_tx_data *tdata; 1261 pjsip_transaction *tsx; 1262 1263 /* Validate arguments. */ 1264 PJ_ASSERT_RETURN(endpt && rdata, PJ_EINVAL); 1265 1266 if (p_tsx) *p_tsx = NULL; 1267 1268 /* Create response message */ 1269 status = pjsip_endpt_create_response( endpt, rdata, st_code, st_text, 1270 &tdata); 1271 if (status != PJ_SUCCESS) 1272 return status; 1273 1274 /* Add the message headers, if any */ 1275 if (hdr_list) { 1276 const pjsip_hdr *hdr = hdr_list->next; 1277 while (hdr != hdr_list) { 1278 pjsip_msg_add_hdr( tdata->msg, pjsip_hdr_clone(tdata->pool, hdr) ); 1279 hdr = hdr->next; 1280 } 1281 } 1282 1283 /* Add the message body, if any. */ 1284 if (body) { 1285 tdata->msg->body = pj_pool_alloc(tdata->pool, sizeof(pjsip_msg_body)); 1286 status = pjsip_msg_body_clone( tdata->pool, tdata->msg->body, body ); 1287 if (status != PJ_SUCCESS) { 1288 pjsip_tx_data_dec_ref(tdata); 1289 return status; 1290 } 1291 } 1292 1293 /* Create UAS transaction. */ 1294 status = pjsip_tsx_create_uas(tsx_user, rdata, &tsx); 1295 if (status != PJ_SUCCESS) { 1296 pjsip_tx_data_dec_ref(tdata); 1297 return status; 1298 } 1299 1300 /* Send the message. */ 1301 status = pjsip_tsx_send_msg(tsx, tdata); 1302 if (status != PJ_SUCCESS) { 1303 pjsip_tx_data_dec_ref(tdata); 1304 } else { 1305 *p_tsx = tsx; 1306 } 1307 1308 return status; 1309 } 1310 1311 1235 1312 /* 1236 1313 * Get the event string from the event ID.
Note: See TracChangeset
for help on using the changeset viewer.