]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add nonce TTL option to sofia to decide when nonce is stale
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 23 Jan 2007 22:04:05 +0000 (22:04 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 23 Jan 2007 22:04:05 +0000 (22:04 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4046 d0543943-73ff-0310-b7d9-9358b9ac24b2

conf/sofia.conf.xml
src/mod/endpoints/mod_sofia/mod_sofia.c

index 2933754efa405951aeeff6ae322010fb40760279..0fa1506a6489ba01336ae0989461514874183473 100644 (file)
@@ -36,6 +36,9 @@
        <!--  comment the next line and uncomment one or both of the other 2 lines for call authentication -->
        <param name="accept-blind-reg" value="true"/>
 
+       <!--TTL for nonce in sip auth-->
+       <param name="nonce-ttl" value="60"/>
+
        <!--<param name="auth-calls" value="true"/>-->
        <!-- on authed calls, authenticate *all* the packets not just invite -->
        <!--<param name="auth-all-packets" value="true"/>-->
index 3ffcd1a035de1972f0b6cfd7952581f426f13beb..c3b5f01a3fb1877f401e28d981af3916dc58ee6a 100644 (file)
@@ -242,6 +242,7 @@ struct sofia_profile {
        unsigned int flags;
        unsigned int pflags;
        uint32_t max_calls;
+    uint32_t nonce_ttl;
        nua_t *nua;
        switch_memory_pool_t *pool;
        su_root_t *s_root;
@@ -2574,7 +2575,7 @@ static void sip_i_state(int status,
                                                tagi_t tags[])
         
 {
-       char *l_sdp = NULL, *r_sdp = NULL;
+       const char *l_sdp = NULL, *r_sdp = NULL;
        int offer_recv = 0, answer_recv = 0, offer_sent = 0, answer_sent = 0;
        int ss_state = nua_callstate_init;
        switch_channel_t *channel = NULL;
@@ -2627,9 +2628,9 @@ static void sip_i_state(int status,
 
                if (r_sdp) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Remote SDP:\n%s\n", r_sdp);                    
-                       tech_pvt->remote_sdp_str = switch_core_session_strdup(session, r_sdp);
-                       switch_channel_set_variable(channel, SWITCH_R_SDP_VARIABLE, r_sdp);
-                       pass_sdp(tech_pvt, r_sdp);
+                       tech_pvt->remote_sdp_str = switch_core_session_strdup(session, (char *)r_sdp);
+                       switch_channel_set_variable(channel, SWITCH_R_SDP_VARIABLE, (char *)r_sdp);
+                       pass_sdp(tech_pvt, (char *)r_sdp);
 
                }
        }
@@ -2679,7 +2680,7 @@ static void sip_i_state(int status,
                                        }
                     goto done;
                                } else if (!switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
-                    if (tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
+                    if (tech_media(tech_pvt, (char *)r_sdp) != SWITCH_STATUS_SUCCESS) {
                         switch_channel_set_variable(channel, "endpoint_disposition", "CODEC NEGOTIATION ERROR");
                         nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
                     }
@@ -3138,7 +3139,7 @@ static uint8_t handle_register(nua_t *nua,
                                  from_host,
                                  a1_hash,
                                  uuid_str,
-                                 time(NULL) + 60);
+                                 time(NULL) + profile->nonce_ttl);
                        auth_str = switch_mprintf("Digest realm=\"%q\", nonce=\"%q\",%s algorithm=MD5, qop=\"auth\"", from_host, uuid_str, 
                                                                                          stale ? " stale=\"true\"," : "");
 
@@ -4952,6 +4953,8 @@ static switch_status_t config_sofia(int reload)
                                                if (switch_true(val)) {
                                                        profile->pflags |= PFLAG_AUTH_CALLS;
                                                }
+                                       } else if (!strcasecmp(var, "nonce-ttl")) {
+                        profile->nonce_ttl = atoi(val);
                                        } else if (!strcasecmp(var, "accept-blind-reg")) {
                                                if (switch_true(val)) {
                                                        profile->pflags |= PFLAG_BLIND_REG;
@@ -5001,6 +5004,11 @@ static switch_status_t config_sofia(int reload)
                                        }
                                }
 
+                if (profile->nonce_ttl < 60) {
+                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting nonce TTL to 60 seconds\n");
+                    profile->nonce_ttl = 60;
+                }
+
                                if (switch_test_flag(profile, TFLAG_TIMER) && !profile->timer_name) {
                                        profile->timer_name = switch_core_strdup(profile->pool, "soft");                        
                                }