| 3480 | } |
| 3481 | |
| 3482 | enum async_ret_code resume_async_send_rtpe_command(int fd, struct sip_msg *msg, void *_param) |
| 3483 | { |
| 3484 | int len = 0, cookielen = 0; |
| 3485 | static char buf[0x10000]; |
| 3486 | char* cp = buf; |
| 3487 | bencode_item_t *dict; |
| 3488 | str oldbody = { 0, 0 }; |
| 3489 | str newbody; |
| 3490 | struct lump *anchor; |
| 3491 | pv_value_t val; |
| 3492 | struct rtpe_ctx *ctx; |
| 3493 | rtpe_async_param *param = (rtpe_async_param *)_param; |
| 3494 | |
| 3495 | LM_DBG("Need to resume async rtpe call \n"); |
| 3496 | |
| 3497 | if (param->node->rn_umode == 0) { |
| 3498 | do { |
| 3499 | len = read(fd, buf, sizeof(buf) - 1); |
| 3500 | } while (len == -1 && errno == EINTR); |
| 3501 | close(fd); |
| 3502 | if (len <= 0) { |
| 3503 | LM_ERR("can't read reply from a RTP Engine\n"); |
| 3504 | goto error; |
| 3505 | } |
| 3506 | } else { |
| 3507 | /* UDP got triggered, wait for 1second max to read now */ |
| 3508 | struct timeval tv; |
| 3509 | tv.tv_sec = 1; |
| 3510 | tv.tv_usec = 0; |
| 3511 | setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv); |
| 3512 | |
| 3513 | len = recv(fd, buf, sizeof(buf)-1, 0); |
| 3514 | if (len <= 0) { |
| 3515 | LM_ERR("can't read reply from a RTP Engine (%d, %d)\n", len, errno); |
| 3516 | RTPE_IO_ERROR_CLOSE(param->node->idx); |
| 3517 | goto error; |
| 3518 | } |
| 3519 | cookielen = strlen(param->cookie); |
| 3520 | if (len >= (cookielen - 1) && |
| 3521 | memcmp(buf, param->cookie, (cookielen - 1)) == 0) { |
| 3522 | len -= (cookielen - 1); |
| 3523 | cp += (cookielen - 1); |
| 3524 | if (len != 0) { |
| 3525 | len--; |
| 3526 | cp++; |
| 3527 | } |
| 3528 | } else { |
| 3529 | LM_ERR("read reply from a RTP Ending FD %d. Cookie does NOT match (%.*s <> %.*s)\n", |
| 3530 | fd, cookielen - 1, param->cookie, cookielen - 1, buf); |
| 3531 | goto error; |
| 3532 | } |
| 3533 | } |
| 3534 | |
| 3535 | /* store the value of the selected node */ |
| 3536 | if (param->spvar) { |
| 3537 | memset(&val, 0, sizeof(pv_value_t)); |
| 3538 | val.flags = PV_VAL_STR; |
| 3539 | val.rs = param->node->rn_url; |
nothing calls this directly
no test coverage detected