| 646 | |
| 647 | |
| 648 | int pv_set_sdp_line(struct sip_msg *msg, pv_param_t *param, |
| 649 | int op, pv_value_t *val) |
| 650 | { |
| 651 | struct sdp_pv_param *pvp = (struct sdp_pv_param *)param->pvn.u.dname; |
| 652 | struct sip_msg_body *sbody; |
| 653 | struct sdp_body_part_ops *ops; |
| 654 | struct body_part *body_part; |
| 655 | str body, dup_line, src_line; |
| 656 | int idx, insert = 0; |
| 657 | |
| 658 | if (!msg) |
| 659 | return -1; |
| 660 | |
| 661 | if (val && !(val->flags & PV_VAL_STR)) { |
| 662 | LM_ERR("refusing to set SDP line to non-string value (val flags: %d)\n", |
| 663 | val->flags); |
| 664 | return -1; |
| 665 | } |
| 666 | |
| 667 | if (msg->body_lumps) { |
| 668 | /* TODO: rebuild SDP body, clear the body lumps; assert lines_sz == 0 */ |
| 669 | } |
| 670 | |
| 671 | if (!have_sdp_ops(msg) || msg->sdp_ops->lines_sz == 0) { |
| 672 | if (parse_sip_body(msg)<0 || !(sbody=msg->body)) { |
| 673 | LM_ERR("current SIP message has no SDP body!\n"); |
| 674 | return -1; |
| 675 | } |
| 676 | |
| 677 | first_part_by_mime( &sbody->first, body_part, (TYPE_APPLICATION<<16)+SUBTYPE_SDP ); |
| 678 | if (!body_part) { |
| 679 | LM_ERR("current SIP message has a body, but no SDP part!\n"); |
| 680 | return -1; |
| 681 | } |
| 682 | |
| 683 | ops = msg->sdp_ops; |
| 684 | /* first time working with SDP ops => allocate DS */ |
| 685 | if (!ops && !(ops = msg->sdp_ops = mk_sdp_ops())) { |
| 686 | LM_ERR("oom\n"); |
| 687 | return -1; |
| 688 | } |
| 689 | |
| 690 | body = body_part->body; |
| 691 | if (ops->lines_sz == 0 && sdp_ops_parse_lines(ops, &body) != 0) { |
| 692 | LM_ERR("oom\n"); |
| 693 | return -1; |
| 694 | } |
| 695 | } else { |
| 696 | ops = msg->sdp_ops; |
| 697 | } |
| 698 | |
| 699 | idx = IDX(msg, &pvp->match_line.idx); |
| 700 | switch (param->pvi.type) { |
| 701 | case SDP_PV_IDX_INSERT: |
| 702 | insert = 1; |
| 703 | break; |
| 704 | |
| 705 | case SDP_PV_IDX_AINSERT: |
nothing calls this directly
no test coverage detected