Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extend siptrace module tracing methods #1912

Merged
merged 14 commits into from Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 20 additions & 6 deletions src/modules/siptrace/siptrace.c
Expand Up @@ -67,6 +67,9 @@ MODULE_VERSION
((((_msg)->msg_flags & FL_SIPTRACE) == 0) \
|| ((_msg->flags & trace_flag) == 0))

#define is_null_pv(_str) \
(!str_strcmp(&_str, &null_pv_value_str))

struct tm_binds tmb;
struct dlg_binds dlgb;

Expand Down Expand Up @@ -133,6 +136,8 @@ static str totag_column = str_init("totag"); /* 11 */
static str siptrace_info_dlgkey = str_init("__siptrace_info_dlg_key__");
static str siptrace_info_avp_str = str_init("$avp(__siptrace_info_avp__)");

static str null_pv_value_str = str_init("<null>");

#define NR_KEYS 12
#define SIP_TRACE_TABLE_VERSION 4

Expand Down Expand Up @@ -732,7 +737,7 @@ static int fixup_siptrace(void **param, int param_no)

if (param_no == 1 || param_no == 2) {
/* correlation id */
return fixup_spve_spve(param, param_no);
return fixup_spve_all(param, param_no);
} else if (param_no == 3) {
/* tracing type; string only */
sflags.s = (char *)*param;
Expand Down Expand Up @@ -884,21 +889,30 @@ static int w_sip_trace2(sip_msg_t *msg, char *dest, char *correlation_id)

static int w_sip_trace3(sip_msg_t *msg, char *dest, char *correlation_id, char *trace_type_p)
{
str dup_uri_str = {0, 0};
str dup_uri_param_str = {0, 0};
str correlation_id_str = {0, 0};
dest_info_t dest_info;
enum siptrace_type_t trace_type;
siptrace_info_t* info;

if (dest) {
if(fixup_get_svalue(msg, (gparam_t *)dest, &dup_uri_str) != 0) {
if(fixup_get_svalue(msg, (gparam_t *)dest, &dup_uri_param_str) != 0) {
LM_ERR("unable to parse the dest URI string\n");
return -1;
}
}

/* if arg dest uri is null dup_uri_str will have length 0 and global dup_uri will be used */
if (parse_siptrace_uri(&dup_uri_str, &dest_info) < 0) {
if (dup_uri_param_str.s == 0 || (is_null_pv(dup_uri_param_str))) {
if (dup_uri_str.s == 0 || dup_uri_str.len == 0) {
LM_ERR("no duplicate_uri modparam nor duplicate uri sip_trace() argument provided!\n");
return -1;
}

dup_uri_param_str = dup_uri_str;
}

/* if arg dest uri is null dup_uri_param_str will have length 0 and global dup_uri will be used */
if (parse_siptrace_uri(&dup_uri_param_str, &dest_info) < 0) {
LM_ERR("failed to parse uri!\n");
return -1;
}
Expand Down Expand Up @@ -955,7 +969,7 @@ static int w_sip_trace3(sip_msg_t *msg, char *dest, char *correlation_id, char *
info->correlation_id = correlation_id_str;
if (dest) {
info->uriState = STRACE_RAW_URI;
info->u.dup_uri = dup_uri_str;
info->u.dup_uri = dup_uri_param_str;
} else {
info->uriState = STRACE_UNUSED_URI;
}
Expand Down
15 changes: 5 additions & 10 deletions src/modules/siptrace/siptrace_send.c
Expand Up @@ -266,12 +266,16 @@ int trace_send_duplicate(char *buf, int len, struct dest_info *dst2)
if(buf == NULL || len <= 0)
return -1;

if(dup_uri_str.s == 0 || dup_uri == NULL)
/* either modparam dup_uri or siptrace param dst2 */
if((dup_uri_str.s == 0 || dup_uri == NULL) && (dst2 == NULL)) {
LM_INFO("XXX: here s where we've got problems!\n");
return 0;
}

init_dest_info(&dst);

if(!dst2) {
LM_INFO("XXX: using default dup uri!\n");
/* create a temporary proxy from dst param */
dst.proto = PROTO_UDP;
p = mk_proxy(&dup_uri->host,
Expand All @@ -290,15 +294,6 @@ int trace_send_duplicate(char *buf, int len, struct dest_info *dst2)
dst.to.s.sa_family, dst.proto);
goto error;
}
} else {
/* create a temporary proxy to dup uri */
dst.proto = PROTO_UDP;
p = mk_proxy(&dup_uri->host,
(dup_uri->port_no) ? dup_uri->port_no : SIP_PORT, dst.proto);
if(p == 0) {
LM_ERR("bad host name in uri\n");
return -1;
}
}

if(msg_send((dst2) ? dst2 : &dst, buf, len) < 0) {
Expand Down