Module: kamailio Branch: master Commit: d0f46e8a9b3ed357057cc2b95b12fb7a58fbe73f URL: https://github.com/kamailio/kamailio/commit/d0f46e8a9b3ed357057cc2b95b12fb7a...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2020-04-07T17:58:02+02:00
siptrace: use the send socket also for duplication via sip
- it was ignored, being used only for duplication via hep
---
Modified: src/modules/siptrace/siptrace_send.c
---
Diff: https://github.com/kamailio/kamailio/commit/d0f46e8a9b3ed357057cc2b95b12fb7a... Patch: https://github.com/kamailio/kamailio/commit/d0f46e8a9b3ed357057cc2b95b12fb7a...
---
diff --git a/src/modules/siptrace/siptrace_send.c b/src/modules/siptrace/siptrace_send.c index fb0e9bd940..34492df946 100644 --- a/src/modules/siptrace/siptrace_send.c +++ b/src/modules/siptrace/siptrace_send.c @@ -277,13 +277,15 @@ int sip_trace_xheaders_free(struct _siptrace_data *sto) /** * */ -int trace_send_duplicate(char *buf, int len, struct dest_info *dst2) +int trace_send_duplicate(char *buf, int len, dest_info_t *dst2) { - struct dest_info dst; - struct proxy_l *p = NULL; + dest_info_t dst; + dest_info_t pdst; + proxy_l_t *p = NULL;
- if(buf == NULL || len <= 0) + if(buf == NULL || len <= 0) { return -1; + }
/* either modparam dup_uri or siptrace param dst2 */ if((trace_dup_uri_str.s == 0 || trace_dup_uri == NULL) && (dst2 == NULL)) { @@ -304,17 +306,39 @@ int trace_send_duplicate(char *buf, int len, struct dest_info *dst2) } hostent2su( &dst.to, &p->host, p->addr_idx, (p->port) ? p->port : SIP_PORT); + pdst = &dst; + } else { + pdst = dst2; + } + + if(pdst->send_sock == NULL) { + if(trace_send_sock_str.s) { + LM_DBG("send sock activated, grep for the sock_info\n"); + pdst->send_sock = grep_sock_info(&trace_send_sock_uri->host, + trace_send_sock_uri->port_no, + trace_send_sock_uri->proto); + if(!pdst->send_sock) { + LM_WARN("cannot grep socket info\n"); + } else { + LM_DBG("found socket while grep: [%.*s] [%.*s]\n", + pdst->send_sock->name.len, + pdst->send_sock->name.s, pdst->send_sock->address_str.len, + pdst->send_sock->address_str.s); + } + } + }
- dst.send_sock = get_send_socket(0, &dst.to, dst.proto); - if(dst.send_sock == 0) { - LM_ERR("can't forward to af %d, proto %d no corresponding" + if(pdst->send_sock == NULL) { + pdst->send_sock = get_send_socket(0, &pdst->to, pdst->proto); + if(pdst->send_sock == 0) { + LM_ERR("cannot forward to af %d, proto %d - no corresponding" " listening socket\n", - dst.to.s.sa_family, dst.proto); + pdst->to.s.sa_family, pdst->proto); goto error; } }
- if(msg_send((dst2) ? dst2 : &dst, buf, len) < 0) { + if(msg_send(pdst, buf, len) < 0) { LM_ERR("cannot send duplicate message\n"); goto error; }