| 2682 | static void pkg_free_wrapper(void *p) { pkg_free(p); } |
| 2683 | |
| 2684 | static int rtpe_function_call_prepare(bencode_buffer_t *bencbuf, struct sip_msg *msg, enum rtpe_operation op, |
| 2685 | struct ng_flags_parse *ng_flags, str *flags_str, str *body_in, bencode_item_t *extra_dict, char **err) |
| 2686 | { |
| 2687 | bencode_item_t *item; |
| 2688 | str viabranch; |
| 2689 | int ret, flags_exist = 0, callid_exist = 0, from_tag_exist = 0, to_tag_exist = 0; |
| 2690 | str flags_nt = {0,0}; |
| 2691 | |
| 2692 | if (bencode_buffer_init(bencbuf)) { |
| 2693 | LM_ERR("could not initialize bencode_buffer_t\n"); |
| 2694 | return -1; |
| 2695 | } |
| 2696 | |
| 2697 | if (!extra_dict) { |
| 2698 | ng_flags->dict = bencode_dictionary(bencbuf); |
| 2699 | } else { |
| 2700 | ng_flags->dict = extra_dict; |
| 2701 | |
| 2702 | ng_flags->flags = bencode_dictionary_get(ng_flags->dict, "flags"); |
| 2703 | if (ng_flags->flags) |
| 2704 | flags_exist = 1; |
| 2705 | bencode_dictionary_get_str(ng_flags->dict, "call-id", &ng_flags->call_id); |
| 2706 | bencode_dictionary_get_str(ng_flags->dict, "from-tag", &ng_flags->from_tag); |
| 2707 | bencode_dictionary_get_str(ng_flags->dict, "to-tag", &ng_flags->to_tag); |
| 2708 | if (ng_flags->call_id.len) |
| 2709 | callid_exist = 1; |
| 2710 | if (ng_flags->from_tag.len) |
| 2711 | from_tag_exist = 1; |
| 2712 | if (ng_flags->to_tag.len) |
| 2713 | to_tag_exist = 1; |
| 2714 | } |
| 2715 | if (!flags_exist) |
| 2716 | ng_flags->flags = bencode_list(bencbuf); |
| 2717 | if (op == OP_OFFER || op == OP_ANSWER) { |
| 2718 | ng_flags->direction = bencode_list(bencbuf); |
| 2719 | ng_flags->replace = bencode_list(bencbuf); |
| 2720 | ng_flags->rtcp_mux = bencode_list(bencbuf); |
| 2721 | |
| 2722 | bencode_dictionary_add_str(ng_flags->dict, "sdp", body_in); |
| 2723 | } else if (op == OP_SUBSCRIBE_ANSWER) { |
| 2724 | bencode_dictionary_add_str(ng_flags->dict, "sdp", body_in); |
| 2725 | } |
| 2726 | |
| 2727 | /*** parse flags & build dictionary ***/ |
| 2728 | |
| 2729 | ng_flags->to = (op == OP_DELETE) ? 0 : 1; |
| 2730 | |
| 2731 | if (flags_str && pkg_nt_str_dup(&flags_nt, flags_str) < 0) { |
| 2732 | *err = "No more pkg mem"; |
| 2733 | goto error; |
| 2734 | } |
| 2735 | |
| 2736 | if (parse_flags(ng_flags, msg, &op, flags_nt.s)) { |
| 2737 | *err = "could not parse flags"; |
| 2738 | goto error; |
| 2739 | } |
| 2740 | |
| 2741 | if (!ng_flags->call_id.len && |
no test coverage detected