Module: sip-router
Branch: admorten/sca
Commit: 0af64c92263b82dc4b487c4da5199c8b150b0517
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=0af64c9…
Author: Andrew Mortensen <admorten(a)umich.edu>
Committer: Andrew Mortensen <admorten(a)umich.edu>
Date: Mon Nov 26 16:50:43 2012 -0500
sca: eliminate need for "domain" modparam
- Extract domain to be used in idle appearance from subscription AoR instead.
---
modules_s/sca/sca.c | 9 --------
modules_s/sca/sca.h | 1 -
modules_s/sca/sca_call_info.c | 45 +++++++++++++---------------------------
3 files changed, 15 insertions(+), 40 deletions(-)
diff --git a/modules_s/sca/sca.c b/modules_s/sca/sca.c
index 4ba82f1..c002241 100644
--- a/modules_s/sca/sca.c
+++ b/modules_s/sca/sca.c
@@ -91,7 +91,6 @@ static rpc_export_t sca_rpc[] = {
};
/* EXPORTED PARAMETERS */
-str domain = STR_NULL;
str outbound_proxy = STR_NULL;
str db_url = STR_STATIC_INIT( DEFAULT_DB_URL );
str db_subs_table = STR_STATIC_INIT( "sca_subscriptions" );
@@ -103,7 +102,6 @@ int line_seize_max_expires = 15;
int purge_expired_interval = 120;
static param_export_t params[] = {
- { "domain", STR_PARAM, &domain.s },
{ "outbound_proxy", STR_PARAM, &outbound_proxy.s },
{ "db_url", STR_PARAM, &db_url.s },
{ "subs_table", STR_PARAM, &db_subs_table.s },
@@ -267,13 +265,6 @@ sca_set_config( sca_mod *scam )
return( -1 );
}
- if ( domain.s == NULL ) {
- LM_ERR( "SCA domain modparam is required in configuration script" );
- return( -1 );
- }
- domain.len = strlen( domain.s );
- scam->cfg->domain = &domain;
-
if ( outbound_proxy.s ) {
outbound_proxy.len = strlen( outbound_proxy.s );
scam->cfg->outbound_proxy = &outbound_proxy;
diff --git a/modules_s/sca/sca.h b/modules_s/sca/sca.h
index d241dce..c61bb52 100644
--- a/modules_s/sca/sca.h
+++ b/modules_s/sca/sca.h
@@ -30,7 +30,6 @@
#define SCA_H
struct _sca_config {
- str *domain;
str *outbound_proxy;
str *db_url;
str *subs_table;
diff --git a/modules_s/sca/sca_call_info.c b/modules_s/sca/sca_call_info.c
index 0e77076..593f286 100644
--- a/modules_s/sca/sca_call_info.c
+++ b/modules_s/sca/sca_call_info.c
@@ -206,46 +206,31 @@ done:
}
static int
-sca_call_info_header_length_for_idle_appearance( sca_mod *scam )
-{
- int given_length = 0;
-
- /* appearance-index=* */
- given_length += strlen( "*" );
-
- /* appearance-state=idle */
- given_length += SCA_APPEARANCE_STATE_STR_IDLE.len;
-
- given_length += scam->cfg->domain->len;
-
- return( sca_call_info_header_length( given_length ));
-}
-
- static int
-sca_call_info_build_idle_value( sca_mod *scam, char *hdrbuf, int maxlen )
+sca_call_info_build_idle_value( sca_mod *scam, str *aor,
+ char *hdrbuf, int maxlen )
{
+ str idle_domain = STR_NULL;
int len;
- if ( sca_call_info_header_length_for_idle_appearance( scam ) >= maxlen ) {
- LM_ERR( "Failed to add idle appearances: Call-Info header too long" );
+ if ( sca_call_info_domain_from_uri( aor, &idle_domain ) < 0 ) {
+ LM_ERR( "Failed to extract domain from %.*s for idle domain",
+ STR_FMT( aor ));
return( -1 );
}
-#ifdef notdef
- strcpy( hdrbuf, "<sip:" );
- len = strlen( "<sip:" );
-
- memcpy( hdrbuf + len, scam->cfg->domain->s, scam->cfg->domain->len
);
- len += scam->cfg->domain->len;
-#endif /* notdef */
-
/* the SCA_APPEARANCE_ strs' s member are literal C strings */
len = snprintf( hdrbuf, maxlen,
- "<sip:%s>;%s=*;%s=%s%s",
- scam->cfg->domain->s,
+ "<sip:%.*s>;%s=*;%s=%s%s",
+ STR_FMT( &idle_domain ),
SCA_APPEARANCE_INDEX_STR.s,
SCA_APPEARANCE_STATE_STR.s,
SCA_APPEARANCE_STATE_STR_IDLE.s, CRLF );
+ if ( len >= maxlen ) {
+ LM_ERR( "Failed to add idle appearance: Call-Info header too long" );
+ len = -1;
+
+ /* snprintf can also return negative. we catch that in the caller. */
+ }
return( len );
}
@@ -273,7 +258,7 @@ sca_call_info_build_header( sca_mod *scam, sca_subscription *sub,
/* line-seize NOTIFYs will contain only the seized appearance index */
if ( sub->event != SCA_EVENT_TYPE_LINE_SEIZE ) {
/* if not all appearances in use, add *-index idle */
- len = sca_call_info_build_idle_value( scam,
+ len = sca_call_info_build_idle_value( scam, &sub->target_aor,
hdrbuf + usedlen, maxlen - usedlen );
if ( len < 0 || len + usedlen >= maxlen ) {
LM_ERR( "Cannot build idle Call-Info value: buffer too small" );