| 1354 | |
| 1355 | |
| 1356 | int pv_set_sdp_session(struct sip_msg *msg, pv_param_t *param, |
| 1357 | int op, pv_value_t *val) |
| 1358 | { |
| 1359 | struct sdp_pv_param *pvp = (struct sdp_pv_param *)param->pvn.u.dname; |
| 1360 | struct sip_msg_body *sbody; |
| 1361 | struct sdp_body_part_ops *ops; |
| 1362 | struct body_part *body_part; |
| 1363 | str body, dup_line, src_line; |
| 1364 | int idx, insert = 0; |
| 1365 | |
| 1366 | if (!msg) |
| 1367 | return -1; |
| 1368 | |
| 1369 | if (val && !(val->flags & PV_VAL_STR)) { |
| 1370 | LM_ERR("refusing to set SDP line to non-string value (val flags: %d)\n", |
| 1371 | val->flags); |
| 1372 | return -1; |
| 1373 | } |
| 1374 | |
| 1375 | if (msg->body_lumps) { |
| 1376 | /* TODO: rebuild SDP body, clear the body lumps; assert lines_sz == 0 */ |
| 1377 | } |
| 1378 | |
| 1379 | if (!have_sdp_ops(msg) || msg->sdp_ops->lines_sz == 0) { |
| 1380 | if (parse_sip_body(msg)<0 || !(sbody=msg->body)) { |
| 1381 | LM_ERR("current SIP message has no SDP body!\n"); |
| 1382 | return -1; |
| 1383 | } |
| 1384 | |
| 1385 | first_part_by_mime( &sbody->first, body_part, (TYPE_APPLICATION<<16)+SUBTYPE_SDP ); |
| 1386 | if (!body_part) { |
| 1387 | LM_ERR("current SIP message has a body, but no SDP part!\n"); |
| 1388 | return -1; |
| 1389 | } |
| 1390 | |
| 1391 | ops = msg->sdp_ops; |
| 1392 | /* first time working with SDP ops => allocate DS */ |
| 1393 | if (!ops && !(ops = msg->sdp_ops = mk_sdp_ops())) { |
| 1394 | LM_ERR("oom\n"); |
| 1395 | return -1; |
| 1396 | } |
| 1397 | |
| 1398 | body = body_part->body; |
| 1399 | if (ops->lines_sz == 0 && sdp_ops_parse_lines(ops, &body) != 0) { |
| 1400 | LM_ERR("oom\n"); |
| 1401 | return -1; |
| 1402 | } |
| 1403 | } else { |
| 1404 | ops = msg->sdp_ops; |
| 1405 | } |
| 1406 | |
| 1407 | idx = IDX(msg, &pvp->match_line.idx); |
| 1408 | switch (param->pvi.type) { |
| 1409 | case SDP_PV_IDX_INSERT: |
| 1410 | insert = 1; |
| 1411 | break; |
| 1412 | |
| 1413 | case SDP_PV_IDX_AINSERT: |
nothing calls this directly
no test coverage detected