| 3108 | |
| 3109 | |
| 3110 | static int |
| 3111 | rtpe_test(struct rtpe_node *node, int isdisabled, int force) |
| 3112 | { |
| 3113 | bencode_buffer_t bencbuf; |
| 3114 | bencode_item_t *dict; |
| 3115 | bencode_item_t *resp; |
| 3116 | char *cp; |
| 3117 | int ret; |
| 3118 | |
| 3119 | if(node->rn_recheck_ticks == MI_MAX_RECHECK_TICKS){ |
| 3120 | LM_DBG("rtpe %s disabled for ever\n", node->rn_url.s); |
| 3121 | return 1; |
| 3122 | } |
| 3123 | if (force == 0) { |
| 3124 | if (isdisabled == 0) |
| 3125 | return 0; |
| 3126 | if (node->rn_recheck_ticks > get_ticks()) |
| 3127 | return 1; |
| 3128 | } |
| 3129 | |
| 3130 | if (bencode_buffer_init(&bencbuf)) { |
| 3131 | LM_ERR("could not initialized bencode_buffer_t\n"); |
| 3132 | return 1; |
| 3133 | } |
| 3134 | dict = bencode_dictionary(&bencbuf); |
| 3135 | bencode_dictionary_add_string(dict, "command", "ping"); |
| 3136 | if (bencbuf.error) |
| 3137 | goto benc_error; |
| 3138 | |
| 3139 | cp = send_rtpe_command(node, dict, &ret); |
| 3140 | if (!cp) { |
| 3141 | LM_ERR("proxy did not respond to ping\n"); |
| 3142 | goto error; |
| 3143 | } |
| 3144 | |
| 3145 | resp = bencode_decode_expect(&bencbuf, cp, ret, BENCODE_DICTIONARY); |
| 3146 | if (!resp || bencode_dictionary_get_strcmp(resp, "result", "pong")) { |
| 3147 | LM_ERR("proxy responded with invalid response\n"); |
| 3148 | goto error; |
| 3149 | } |
| 3150 | |
| 3151 | if (isdisabled) |
| 3152 | LM_DBG("rtpengine <%s> found, support for it %senabled\n", |
| 3153 | node->rn_url.s, force == 0 ? "re-" : ""); |
| 3154 | |
| 3155 | bencode_buffer_free(&bencbuf); |
| 3156 | return 0; |
| 3157 | |
| 3158 | benc_error: |
| 3159 | LM_ERR("out of memory - bencode failed\n"); |
| 3160 | error: |
| 3161 | bencode_buffer_free(&bencbuf); |
| 3162 | return 1; |
| 3163 | } |
| 3164 | |
| 3165 | #define RTPENGINE_BUF_SIZE 0x10000 |
| 3166 | #define OSIP_IOV_MAX 1024 |
no test coverage detected