]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add disable-transfer and disable-register params to sofia profiles
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 7 Mar 2008 14:36:08 +0000 (14:36 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 7 Mar 2008 14:36:08 +0000 (14:36 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7807 d0543943-73ff-0310-b7d9-9358b9ac24b2

conf/sip_profiles/default.xml
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_reg.c

index 03d458c18071a6d5875c4b34c6887213449ebae9..5a8bdb44e5c93a6e869b6bc39bb6103ef15fbb5c 100644 (file)
     <!--<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>
 
index ce688e170fd138630130772e51b6e6d295a8be6b..15a94b1248740e2a6557c85fc3fd13dcdbfd09e5 100644 (file)
@@ -112,6 +112,11 @@ struct sip_alias_node {
 
 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),
@@ -269,6 +274,7 @@ struct sofia_profile {
        int dtmf_duration;
        unsigned int flags;
        unsigned int pflags;
+       unsigned int mflags;
        unsigned int ndlb;
        uint32_t max_calls;
        uint32_t nonce_ttl;
index c2c7a4656db00691d1b1c279ebdbce95e6dcc465..d8f3e8abee8bb65f995e9a9da528efb6fd1945c1 100644 (file)
@@ -537,8 +537,8 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
                                   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 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
                                                                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_status_t config_sofia(int reload, char *profile_name)
                                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 @@ switch_status_t config_sofia(int reload, char *profile_name)
                                                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 @@ switch_status_t config_sofia(int reload, char *profile_name)
                                                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 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
        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;
index b33cdf2b22282e3875e9a5822acd4c52c04cddee..075c08a7ec944d2c06a8c92114a982f18ffa93b8 100644 (file)
@@ -637,6 +637,11 @@ void sofia_reg_handle_sip_i_register(nua_t * nua, sofia_profile_t *profile, nua_
 {
        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");