Module: kamailio
Branch: master
Commit: 0c710840f7a7aee7a27b3ffdbcb106d9e8e5bde1
URL:
https://github.com/kamailio/kamailio/commit/0c710840f7a7aee7a27b3ffdbcb106d…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2016-10-05T09:38:27+02:00
sca: add "server_address" parameter
* server address (sip:<host>[:port]) which will become the value of
Contact header filed for NOTIFY messages.
---
Modified: modules/sca/doc/sca_admin.xml
Modified: modules/sca/sca.c
Modified: modules/sca/sca.h
Modified: modules/sca/sca_notify.c
---
Diff:
https://github.com/kamailio/kamailio/commit/0c710840f7a7aee7a27b3ffdbcb106d…
Patch:
https://github.com/kamailio/kamailio/commit/0c710840f7a7aee7a27b3ffdbcb106d…
---
diff --git a/modules/sca/doc/sca_admin.xml b/modules/sca/doc/sca_admin.xml
index f024674..bf212a3 100644
--- a/modules/sca/doc/sca_admin.xml
+++ b/modules/sca/doc/sca_admin.xml
@@ -283,6 +283,27 @@ 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>
</section>
<section>
diff --git a/modules/sca/sca.c b/modules/sca/sca.c
index 30eabc9..1a39cdc 100644
--- a/modules/sca/sca.c
+++ b/modules/sca/sca.c
@@ -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},
@@ -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},
};
@@ -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);
}
diff --git a/modules/sca/sca.h b/modules/sca/sca.h
index 2c20e76..04d3c1e 100644
--- a/modules/sca/sca.h
+++ b/modules/sca/sca.h
@@ -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;
diff --git a/modules/sca/sca_notify.c b/modules/sca/sca_notify.c
index daa4e0c..a654fb9 100644
--- a/modules/sca/sca_notify.c
+++ b/modules/sca/sca_notify.c
@@ -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);