Skip to content

Commit

Permalink
siptrace: use socket name for hep mirroring
Browse files Browse the repository at this point in the history
- GH #3174

(cherry picked from commit 30c6287)
  • Loading branch information
miconda committed Sep 14, 2022
1 parent e1deb70 commit 89fa867
Showing 1 changed file with 59 additions and 26 deletions.
85 changes: 59 additions & 26 deletions src/modules/siptrace/siptrace_hep.c
Expand Up @@ -187,15 +187,29 @@ int trace_send_hep3_duplicate(str *body, str *from, str *to,
dst_fin = dst2;
}

if(trace_send_sock_str.s) {
LM_DBG("send sock activated, grep for the sock_info\n");
si = grep_sock_info(&trace_send_sock_uri->host,
trace_send_sock_uri->port_no,
trace_send_sock_uri->proto);
si = NULL;
if(trace_send_sock_name_str.s) {
LM_DBG("send sock name activated - find the sock info\n");
if(trace_send_sock_info) {
si = trace_send_sock_info;
} else {
si = ksr_get_socket_by_name(&trace_send_sock_name_str);
}
} else if(trace_send_sock_str.s) {
LM_DBG("send sock addr activated - find the sock_info\n");
if(trace_send_sock_info) {
si = trace_send_sock_info;
} else {
si = grep_sock_info(&trace_send_sock_uri->host,
trace_send_sock_uri->port_no,
trace_send_sock_uri->proto);
}
}
if(trace_send_sock_name_str.s || trace_send_sock_str.s) {
if(!si) {
LM_WARN("cannot grep socket info\n");
LM_WARN("cannot find send socket info\n");
} else {
LM_DBG("found socket while grep: [%.*s] [%.*s]\n", si->name.len,
LM_DBG("found send socket: [%.*s] [%.*s]\n", si->name.len,
si->name.s, si->address_str.len, si->address_str.s);
dst_fin->send_sock = si;
}
Expand Down Expand Up @@ -304,15 +318,29 @@ int trace_send_hep2_duplicate(
dst_fin = dst2;
}

if(trace_send_sock_str.s) {
LM_DBG("send sock activated, grep for the sock_info\n");
si = grep_sock_info(&trace_send_sock_uri->host,
trace_send_sock_uri->port_no,
trace_send_sock_uri->proto);
si = NULL;
if(trace_send_sock_name_str.s) {
LM_DBG("send sock name activated - find the sock info\n");
if(trace_send_sock_info) {
si = trace_send_sock_info;
} else {
si = ksr_get_socket_by_name(&trace_send_sock_name_str);
}
} else if(trace_send_sock_str.s) {
LM_DBG("send sock addr activated - find the sock info\n");
if(trace_send_sock_info) {
si = trace_send_sock_info;
} else {
si = grep_sock_info(&trace_send_sock_uri->host,
trace_send_sock_uri->port_no,
trace_send_sock_uri->proto);
}
}
if(trace_send_sock_name_str.s || trace_send_sock_str.s) {
if(!si) {
LM_WARN("cannot grep socket info\n");
LM_WARN("cannot find send socket info\n");
} else {
LM_DBG("found socket while grep: [%.*s] [%.*s]\n", si->name.len,
LM_DBG("found send socket: [%.*s] [%.*s]\n", si->name.len,
si->name.s, si->address_str.len, si->address_str.s);
dst_fin->send_sock = si;
}
Expand Down Expand Up @@ -536,6 +564,7 @@ int hlog(struct sip_msg *msg, str *correlationid, str *message)
struct timezone tz;
struct dest_info dst;
struct proxy_l *p = NULL;
struct socket_info *si;

if(!correlationid) {
if(msg->callid == NULL && ((parse_headers(msg, HDR_CALLID_F, 0) == -1)
Expand Down Expand Up @@ -587,27 +616,31 @@ int hlog(struct sip_msg *msg, str *correlationid, str *message)
free_proxy(p); /* frees only p content, not p itself */
pkg_free(p);

si = NULL;
if(trace_send_sock_name_str.s) {
if(!trace_send_sock_info) {
trace_send_sock_info = ksr_get_socket_by_name(&trace_send_sock_name_str);
LM_DBG("send sock name activated - find the sock info\n");
if(trace_send_sock_info) {
si = trace_send_sock_info;
} else {
si = ksr_get_socket_by_name(&trace_send_sock_name_str);
}
dst.send_sock = trace_send_sock_info;
} else if(trace_send_sock_str.s) {
LM_DBG("send sock activated - find the sock info\n");
LM_DBG("send sock addr activated - find the sock info\n");
if(trace_send_sock_info) {
dst.send_sock = trace_send_sock_info;
si = trace_send_sock_info;
} else {
dst.send_sock = grep_sock_info(&trace_send_sock_uri->host,
si = grep_sock_info(&trace_send_sock_uri->host,
trace_send_sock_uri->port_no,
trace_send_sock_uri->proto);
}
if(!dst.send_sock) {
LM_WARN("local socket not found for: [%.*s]\n",
trace_send_sock_str.len, trace_send_sock_str.s);
}
if(trace_send_sock_name_str.s || trace_send_sock_str.s) {
if(!si) {
LM_WARN("cannot find send socket info\n");
} else {
LM_DBG("using local send socket: [%.*s] [%.*s]\n",
dst.send_sock->name.len, dst.send_sock->name.s,
dst.send_sock->address_str.len, dst.send_sock->address_str.s);
LM_DBG("found send socket: [%.*s] [%.*s]\n", si->name.len,
si->name.s, si->address_str.len, si->address_str.s);
dst.send_sock = si;
}
}

Expand Down

0 comments on commit 89fa867

Please sign in to comment.