瀏覽代碼

Merge pull request #812 from linuxmaniac/vseva/2387

sca: add "server_address" parameter
Victor Seva 9 年之前
父節點
當前提交
17c79903b0
共有 4 個文件被更改,包括 39 次插入3 次删除
  1. 21 0
      modules/sca/doc/sca_admin.xml
  2. 6 0
      modules/sca/sca.c
  3. 1 0
      modules/sca/sca.h
  4. 11 3
      modules/sca/sca_notify.c

+ 21 - 0
modules/sca/doc/sca_admin.xml

@@ -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>

+ 6 - 0
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);
 }
 

+ 1 - 0
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;
 

+ 11 - 3
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);