| 2870 | } |
| 2871 | |
| 2872 | static bencode_item_t *rtpe_function_call(bencode_buffer_t *bencbuf, struct sip_msg *msg, |
| 2873 | enum rtpe_operation op, str *flags_str, str *body_in, pv_spec_t *spvar, |
| 2874 | struct rtpe_set *set, str *snode, bencode_item_t *extra_dict) |
| 2875 | { |
| 2876 | struct ng_flags_parse ng_flags; |
| 2877 | bencode_item_t *resp; |
| 2878 | str error; |
| 2879 | struct rtpe_node *node, *failed_node; |
| 2880 | char *cp, *err = NULL; |
| 2881 | pv_value_t val, socket_val; |
| 2882 | struct rtpe_ignore_node *ignore_list = NULL; |
| 2883 | int ret, forced_socket; |
| 2884 | memset(&ng_flags, 0, sizeof(ng_flags)); |
| 2885 | error.len = 0; |
| 2886 | error.s = ""; |
| 2887 | |
| 2888 | /*** get & init basic stuff needed ***/ |
| 2889 | if (rtpe_function_call_prepare(bencbuf, msg, op, &ng_flags, flags_str, body_in, extra_dict,&err) < 0) |
| 2890 | goto error; |
| 2891 | |
| 2892 | /*** set can be passed into this routine. If it is NULL, then attempt to determine it. ***/ |
| 2893 | if (!set) { |
| 2894 | if ((set=rtpe_ctx_set_get())==NULL) |
| 2895 | set = *default_rtpe_set; |
| 2896 | } |
| 2897 | |
| 2898 | /*** If the spvar "sock_var" has been specified, parse it into a (socket_val) STR variable ***/ |
| 2899 | memset(&socket_val, 0, sizeof(pv_value_t)); |
| 2900 | if (spvar) |
| 2901 | pv_get_spec_value(msg, spvar, &socket_val); |
| 2902 | forced_socket = socket_val.rs.len > 0; |
| 2903 | |
| 2904 | failed_node = NULL; |
| 2905 | |
| 2906 | RTPE_START_READ(); |
| 2907 | do { |
| 2908 | /* |
| 2909 | * Many rtpengine_* commands allow a "sock_var" to be specified by the script writer. |
| 2910 | * The "sock_var" will be populated by the rtpengine_* command with the RTPEngine that |
| 2911 | * was chosen for the operation. |
| 2912 | * |
| 2913 | * The "sock_var" can be used by subsequent rtpengine_* commands to direct the command |
| 2914 | * toward a specific RTPEngine instance. |
| 2915 | */ |
| 2916 | if (spvar && (socket_val.rs.len > 0)) { |
| 2917 | LM_DBG("Sending command [%d] to RTPEngine socket: [%.*s] set id: [%d]\n", op, (int)(socket_val.rs.len), (char *)(socket_val.rs.s), set->id_set); |
| 2918 | node = lookup_rtpe_node(set, &socket_val.rs); |
| 2919 | socket_val.rs.s = NULL; |
| 2920 | socket_val.rs.len = 0; |
| 2921 | if (node && ((node->rn_disabled = rtpe_test(node, node->rn_disabled, 0)) || |
| 2922 | rtpe_is_ignore_node(ignore_list, node))) { |
| 2923 | LM_DBG("RTPEngine socket [%.*s] is not available\n", |
| 2924 | node->rn_url.len, node->rn_url.s); |
| 2925 | node = NULL; |
| 2926 | } |
| 2927 | |
| 2928 | if (node == NULL && op == OP_OFFER) |
| 2929 | node = select_rtpe_node(ng_flags.call_id, set, ignore_list); |
no test coverage detected