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

sca: add "server_address" parameter #812

Merged
merged 1 commit into from
Oct 5, 2016
Merged
Show file tree
Hide file tree
Changes from all 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
21 changes: 21 additions & 0 deletions modules/sca/doc/sca_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,27 @@ modparam( "sca", "db_update_interval", 120 )
...
modparam("sca", "onhold_bflag", 15)
...
</programlisting>
</example>
</section>

<section id="sca.p.server_address">
<title><varname>server_address</varname> (string)</title>
<para>
The server address which will become the value of Contact header filed
for NOTIFY messages.
</para>
<para>
<emphasis>
Default value is "" (disabled).
</emphasis>
</para>
<example>
<title>Set <varname>server_address</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("sca", "server_address", "sip:10.10.10.10:5060")
...
</programlisting>
</example>
</section>
Expand Down
6 changes: 6 additions & 0 deletions modules/sca/sca.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ int call_info_max_expires = 3600;
int line_seize_max_expires = 15;
int purge_expired_interval = 120;
int onhold_bflag = -1;
str server_address = STR_NULL;

static param_export_t params[] = {
{"outbound_proxy", PARAM_STR, &outbound_proxy},
Expand All @@ -149,6 +150,7 @@ static param_export_t params[] = {
{"line_seize_max_expires", INT_PARAM, &line_seize_max_expires},
{"purge_expired_interval", INT_PARAM, &purge_expired_interval},
{"onhold_bflag", INT_PARAM, &onhold_bflag},
{"server_address", PARAM_STR, &server_address},
{NULL, 0, NULL},
};

Expand Down Expand Up @@ -287,6 +289,10 @@ static int sca_set_config(sca_mod *scam)
}
scam->cfg->onhold_bflag = onhold_bflag;

if (server_address.s) {
scam->cfg->server_address = &server_address;
}

return (0);
}

Expand Down
1 change: 1 addition & 0 deletions modules/sca/sca.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct _sca_config {
int line_seize_max_expires;
int purge_expired_interval;
int onhold_bflag;
str *server_address;
};
typedef struct _sca_config sca_config;

Expand Down
14 changes: 11 additions & 3 deletions modules/sca/sca_notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,23 @@ static int sca_notify_append_contact_header(sca_subscription *sub, char *hdrbuf,
int maxlen)
{
int len = strlen("Contact: ");
str *orig = NULL;

if (len + sub->target_aor.len + strlen(CRLF) >= maxlen) {
if (sca->cfg->server_address != NULL) {
orig = sca->cfg->server_address;
}
else {
orig = &sub->target_aor;
}

if (len + orig->len + strlen(CRLF) >= maxlen) {
LM_ERR("Cannot append Contact header: buffer too small\n");
return (-1);
}

memcpy(hdrbuf, "Contact: ", len);
memcpy(hdrbuf + len, sub->target_aor.s, sub->target_aor.len);
len += sub->target_aor.len;
memcpy(hdrbuf + len, orig->s, orig->len);
len += orig->len;
memcpy(hdrbuf + len, CRLF, strlen(CRLF));
len += strlen(CRLF);

Expand Down