[Freeswitch-svn] [commit] r7807 - in freeswitch/trunk: conf/sip_profiles src/mod/endpoints/mod_sofia
Freeswitch SVN
anthm at freeswitch.org
Fri Mar 7 09:36:08 EST 2008
Author: anthm
Date: Fri Mar 7 09:36:08 2008
New Revision: 7807
Modified:
freeswitch/trunk/conf/sip_profiles/default.xml
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
Log:
add disable-transfer and disable-register params to sofia profiles
Modified: freeswitch/trunk/conf/sip_profiles/default.xml
==============================================================================
--- freeswitch/trunk/conf/sip_profiles/default.xml (original)
+++ freeswitch/trunk/conf/sip_profiles/default.xml Fri Mar 7 09:36:08 2008
@@ -100,6 +100,9 @@
<!--<param name="alias" value="sip:10.0.1.251:5555"/>-->
<!--all inbound reg will look in this domain for the users -->
<!--<param name="force-register-domain" value="cluecon.com"/>-->
+ <!-- disable register and transfer which may be undesirable in a public switch -->
+ <!--<param name="disable-transfer" value="true"/>-->
+ <!--<param name="disable-register" value="true"/>-->
</settings>
</profile>
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Fri Mar 7 09:36:08 2008
@@ -113,6 +113,11 @@
typedef struct sip_alias_node sip_alias_node_t;
typedef enum {
+ MFLAG_REFER = (1 << 0),
+ MFLAG_REGISTER = (1 << 1)
+} MFLAGS;
+
+typedef enum {
PFLAG_AUTH_CALLS = (1 << 0),
PFLAG_BLIND_REG = (1 << 1),
PFLAG_AUTH_ALL = (1 << 2),
@@ -269,6 +274,7 @@
int dtmf_duration;
unsigned int flags;
unsigned int pflags;
+ unsigned int mflags;
unsigned int ndlb;
uint32_t max_calls;
uint32_t nonce_ttl;
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Fri Mar 7 09:36:08 2008
@@ -537,8 +537,8 @@
NUTAG_APPL_METHOD("INFO"),
NUTAG_AUTOANSWER(0),
NUTAG_AUTOALERT(0),
- NUTAG_ALLOW("REGISTER"),
- NUTAG_ALLOW("REFER"),
+ TAG_IF((profile->mflags & MFLAG_REGISTER), NUTAG_ALLOW("REGISTER")),
+ TAG_IF((profile->mflags & MFLAG_REFER), NUTAG_ALLOW("REFER")),
NUTAG_ALLOW("INFO"),
NUTAG_ALLOW("NOTIFY"),
NUTAG_ALLOW_EVENTS("talk"),
@@ -565,16 +565,16 @@
NUTAG_URL(node->url), TAG_END()); /* Last tag should always finish the sequence */
nua_set_params(node->nua,
- NUTAG_APPL_METHOD("OPTIONS"),
- NUTAG_EARLY_MEDIA(1),
- NUTAG_AUTOANSWER(0),
- NUTAG_AUTOALERT(0),
- NUTAG_ALLOW("REGISTER"),
- NUTAG_ALLOW("REFER"),
- NUTAG_ALLOW("INFO"),
- TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW("PUBLISH")),
- TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ENABLEMESSAGE(1)),
- SIPTAG_SUPPORTED_STR("100rel, precondition"), SIPTAG_USER_AGENT_STR(profile->user_agent), TAG_END());
+ NUTAG_APPL_METHOD("OPTIONS"),
+ NUTAG_EARLY_MEDIA(1),
+ NUTAG_AUTOANSWER(0),
+ NUTAG_AUTOALERT(0),
+ TAG_IF((profile->mflags & MFLAG_REGISTER), NUTAG_ALLOW("REGISTER")),
+ TAG_IF((profile->mflags & MFLAG_REFER), NUTAG_ALLOW("REFER")),
+ NUTAG_ALLOW("INFO"),
+ TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW("PUBLISH")),
+ TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ENABLEMESSAGE(1)),
+ SIPTAG_SUPPORTED_STR("100rel, precondition"), SIPTAG_USER_AGENT_STR(profile->user_agent), TAG_END());
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "activated db for %s\n", profile->name);
@@ -1007,7 +1007,8 @@
switch_mutex_init(&profile->flag_mutex, SWITCH_MUTEX_NESTED, profile->pool);
profile->dtmf_duration = 100;
profile->tls_version = 0;
-
+ profile->mflags = MFLAG_REFER | MFLAG_REGISTER;
+
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
@@ -1045,6 +1046,8 @@
profile->record_template = switch_core_strdup(profile->pool, val);;
} else if (!strcasecmp(var, "inbound-no-media") && switch_true(val)) {
switch_set_flag(profile, TFLAG_INB_NOMEDIA);
+ } else if (!strcasecmp(var, "inbound-bypass-media") && switch_true(val)) {
+ switch_set_flag(profile, TFLAG_INB_NOMEDIA);
} else if (!strcasecmp(var, "inbound-late-negotiation") && switch_true(val)) {
switch_set_flag(profile, TFLAG_LATE_NEGOTIATION);
} else if (!strcasecmp(var, "inbound-proxy-media") && switch_true(val)) {
@@ -1114,6 +1117,10 @@
if (v >= 0) {
profile->rtp_hold_timeout_sec = v;
}
+ } else if (!strcasecmp(var, "disable-transfer") && switch_true(val)) {
+ profile->mflags &= ~MFLAG_REFER;
+ } else if (!strcasecmp(var, "disable-register") && switch_true(val)) {
+ profile->mflags &= ~MFLAG_REGISTER;
} else if (!strcasecmp(var, "manage-presence")) {
if (switch_true(val)) {
profile->pflags |= PFLAG_PRESENCE;
@@ -1974,6 +1981,11 @@
char *full_ref_by = NULL;
char *full_ref_to = NULL;
+ if (profile->mflags & MFLAG_REFER) {
+ nua_respond(nh, SIP_403_FORBIDDEN, NUTAG_WITH_THIS(nua), TAG_END());
+ goto done;
+ }
+
if (!sip->sip_cseq || !(etmp = switch_mprintf("refer;id=%u", sip->sip_cseq->cs_seq))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
goto done;
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Fri Mar 7 09:36:08 2008
@@ -637,6 +637,11 @@
{
char key[128] = "";
switch_event_t *v_event = NULL;
+
+ if (profile->mflags & MFLAG_REFER) {
+ nua_respond(nh, SIP_403_FORBIDDEN, NUTAG_WITH_THIS(nua), TAG_END());
+ goto end;
+ }
if (!sip || !sip->sip_request || !sip->sip_request->rq_method_name) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received an invalid packet!\n");
More information about the Freeswitch-svn
mailing list