| 116 | |
| 117 | |
| 118 | int pv_set_sdp(struct sip_msg *msg, pv_param_t *param, |
| 119 | int op, pv_value_t *val) |
| 120 | { |
| 121 | struct sdp_body_part_ops *ops; |
| 122 | int null_before = 0; |
| 123 | |
| 124 | if (!msg || !param) { |
| 125 | LM_ERR("bad parameters\n"); |
| 126 | return -1; |
| 127 | } |
| 128 | |
| 129 | if (!msg->sdp_ops) { |
| 130 | ops = msg->sdp_ops = mk_sdp_ops(); |
| 131 | if (!ops) { |
| 132 | LM_ERR("oom\n"); |
| 133 | return -1; |
| 134 | } |
| 135 | } else { |
| 136 | ops = msg->sdp_ops; |
| 137 | } |
| 138 | |
| 139 | if (!val) { |
| 140 | LM_ERR("sdp-set: NULL\n"); |
| 141 | ops->flags |= SDP_OPS_FL_NULL; |
| 142 | ops->flags &= ~SDP_OPS_FL_DIRTY; |
| 143 | if (msg->body) { |
| 144 | free_sip_body(msg->body); |
| 145 | msg->body = NULL; |
| 146 | } |
| 147 | free_sdp_ops_lines(ops); |
| 148 | pkg_free(ops->rebuilt_sdp.s); |
| 149 | ops->rebuilt_sdp.s = NULL; |
| 150 | |
| 151 | } else { |
| 152 | LM_ERR("sdp-set: non-NULL!\n"); |
| 153 | |
| 154 | if (!(val->flags & PV_VAL_STR) || val->rs.len <= 0) { |
| 155 | LM_ERR("non-empty str value required to set SDP body\n"); |
| 156 | goto error; |
| 157 | } |
| 158 | |
| 159 | if (pkg_str_sync(&ops->sdp, &val->rs) != 0) { |
| 160 | LM_ERR("oom\n"); |
| 161 | return -1; |
| 162 | } |
| 163 | |
| 164 | if (ops->flags & SDP_OPS_FL_NULL) { |
| 165 | null_before = 1; |
| 166 | ops->flags &= ~SDP_OPS_FL_NULL; |
| 167 | } |
| 168 | |
| 169 | if (msg->body) { |
| 170 | free_sip_body(msg->body); |
| 171 | msg->body = NULL; |
| 172 | } |
| 173 | |
| 174 | if (parse_sip_body(msg) != 0) { |
| 175 | LM_ERR("bad body provided (%.*s ...), refusing to set in SIP msg\n", |
nothing calls this directly
no test coverage detected