MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / rtpe_test

Function rtpe_test

modules/rtpengine/rtpengine.c:3110–3163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3108
3109
3110static int
3111rtpe_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
3158benc_error:
3159 LM_ERR("out of memory - bencode failed\n");
3160error:
3161 bencode_buffer_free(&bencbuf);
3162 return 1;
3163}
3164
3165#define RTPENGINE_BUF_SIZE 0x10000
3166#define OSIP_IOV_MAX 1024

Callers 4

rtpengine_timerFunction · 0.85
connect_rtpenginesFunction · 0.85
get_rtpe_nodeFunction · 0.85
rtpe_function_callFunction · 0.85

Calls 8

get_ticksFunction · 0.85
bencode_buffer_initFunction · 0.85
bencode_dictionaryFunction · 0.85
send_rtpe_commandFunction · 0.85
bencode_decode_expectFunction · 0.85
bencode_buffer_freeFunction · 0.85

Tested by

no test coverage detected