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

Function send_rtpe_command

modules/rtpengine/rtpengine.c:3168–3334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3166#define OSIP_IOV_MAX 1024
3167
3168static char *
3169send_rtpe_command(struct rtpe_node *node, bencode_item_t *dict, int *outlen)
3170{
3171 struct sockaddr_un addr;
3172 int fd, len, i, vcnt;
3173 int max_vcnt=OSIP_IOV_MAX;
3174 char *cp;
3175 static char buf[RTPENGINE_BUF_SIZE];
3176 struct pollfd fds[1];
3177 struct iovec *v;
3178
3179 v = bencode_iovec(dict, &vcnt, 1, 0);
3180 if (!v) {
3181 LM_ERR("error converting bencode to iovec\n");
3182 return NULL;
3183 }
3184#ifdef IOV_MAX
3185 if (IOV_MAX < OSIP_IOV_MAX)
3186 max_vcnt = IOV_MAX;
3187#endif
3188 vcnt++; /* add the cookie */
3189
3190 if (vcnt > max_vcnt) {
3191 int i, vec_len = 0;
3192 /* use buf if possible :) */
3193 for (i = max_vcnt - 1; i < vcnt; i++)
3194 vec_len += v[i].iov_len;
3195 /* use buf, error otherwise */
3196 if (vec_len > RTPENGINE_BUF_SIZE) {
3197 LM_ERR("Command too big %d - max %d\n", vec_len, RTPENGINE_BUF_SIZE);
3198 return NULL;
3199 }
3200 cp = buf;
3201 for (i = max_vcnt - 1; i < vcnt; i++) {
3202 memcpy(cp, v[i].iov_base, v[i].iov_len);
3203 cp += v[i].iov_len;
3204 }
3205 i = max_vcnt - 1;
3206 v[i].iov_len = vec_len;
3207 v[i].iov_base = buf;
3208 /* finally solve the problem */
3209 vcnt = max_vcnt;
3210 }
3211
3212 len = 0;
3213 cp = buf;
3214 if (node->rn_umode == 0) {
3215 memset(&addr, 0, sizeof(addr));
3216 addr.sun_family = AF_LOCAL;
3217 strncpy(addr.sun_path, node->rn_address,
3218 sizeof(addr.sun_path) - 1);
3219#ifdef HAVE_SOCKADDR_SA_LEN
3220 addr.sun_len = strlen(addr.sun_path);
3221#endif
3222
3223 fd = socket(AF_LOCAL, SOCK_STREAM, 0);
3224 if (fd < 0) {
3225 LM_ERR("can't create socket\n");

Callers 2

rtpe_function_callFunction · 0.85
rtpe_testFunction · 0.85

Calls 5

bencode_iovecFunction · 0.85
get_ticksFunction · 0.85
rtpengine_connect_nodeFunction · 0.85
gencookieFunction · 0.70

Tested by

no test coverage detected