]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-4708 add <param name="NDLB-allow-crypto-in-avp" value="true"/> to your sofia profi...
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 11 Oct 2012 15:36:07 +0000 (10:36 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 11 Oct 2012 15:36:07 +0000 (10:36 -0500)
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_reg.c

index dfd472e65d10ae04ab5082ae2365b9653b6d9bb1..aeef8ea43ff8659b8d77ea6f4f0a09c91c2e86eb 100644 (file)
@@ -283,7 +283,8 @@ typedef enum {
        PFLAG_NDLB_SENDRECV_IN_SESSION = (1 << 2),
        PFLAG_NDLB_ALLOW_BAD_IANANAME = (1 << 3),
        PFLAG_NDLB_ALLOW_NONDUP_SDP = (1 << 4),
-       PFLAG_NDLB_ALLOW_CRYPTO_IN_AVP = (1 << 5)
+       PFLAG_NDLB_ALLOW_CRYPTO_IN_AVP = (1 << 5),
+       PFLAG_NDLB_EXPIRES_IN_REGISTER_RESPONSE = (1 << 6)
 } sofia_NDLB_t;
 
 typedef enum {
index 7c1124383b4dc868ba6f1be5df19fa91d3f169f1..5199a2d2645b3ebd6a0af43ef0937da01c77420a 100644 (file)
@@ -3807,6 +3807,12 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
                                                } else {
                                                        profile->ndlb &= ~PFLAG_NDLB_ALLOW_BAD_IANANAME;
                                                }
+                                       } else if (!strcasecmp(var, "NDLB-expires-in-register-response")) {
+                                               if (switch_true(val)) {
+                                                       profile->ndlb |= PFLAG_NDLB_EXPIRES_IN_REGISTER_RESPONSE;
+                                               } else {
+                                                       profile->ndlb &= ~PFLAG_NDLB_EXPIRES_IN_REGISTER_RESPONSE;
+                                               }
                                        } else if (!strcasecmp(var, "NDLB-allow-crypto-in-avp")) {
                                                if (switch_true(val)) {
                                                        profile->ndlb |= PFLAG_NDLB_ALLOW_CRYPTO_IN_AVP;
@@ -4949,6 +4955,12 @@ switch_status_t config_sofia(int reload, char *profile_name)
                                                } else {
                                                        profile->ndlb &= ~PFLAG_NDLB_ALLOW_BAD_IANANAME;
                                                }
+                                       } else if (!strcasecmp(var, "NDLB-expires-in-register-response")) {
+                                               if (switch_true(val)) {
+                                                       profile->ndlb |= PFLAG_NDLB_EXPIRES_IN_REGISTER_RESPONSE;
+                                               } else {
+                                                       profile->ndlb &= ~PFLAG_NDLB_EXPIRES_IN_REGISTER_RESPONSE;
+                                               }
                                        } else if (!strcasecmp(var, "NDLB-allow-crypto-in-avp")) {
                                                if (switch_true(val)) {
                                                        profile->ndlb |= PFLAG_NDLB_ALLOW_CRYPTO_IN_AVP;
index 98299a784be344c49775d5a668b3f866d7534233..6a7febdbe006f9887c79246687fd60a30cff72f1 100644 (file)
@@ -1073,6 +1073,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
        const char *pres_on_reg = NULL;
        int send_pres = 0;
        int is_tls = 0, is_tcp = 0;
+       char expbuf[35] = "";
 
        if (v_event && *v_event) pres_on_reg = switch_event_get_header(*v_event, "send-presence-on-register");
 
@@ -1773,12 +1774,17 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
 
                /* generate and respond a 200 OK */
 
+               if ((profile->ndlb & PFLAG_NDLB_EXPIRES_IN_REGISTER_RESPONSE)) {
+                       switch_snprintf(expbuf, sizeof(expbuf), "%ld", exptime);
+               }
+
                if (mod_sofia_globals.reg_deny_binding_fetch_and_no_lookup) {
                        /* handle backwards compatibility - contacts will not be looked up but only copied from the request into the response
                           remove this condition later if nobody complains about the extra select of the below new behavior
                           also remove the parts in mod_sofia.h, sofia.c and sofia_reg.c that refer to reg_deny_binding_fetch_and_no_lookup */
                        nua_respond(nh, SIP_200_OK, TAG_IF(contact, SIPTAG_CONTACT(sip->sip_contact)), TAG_IF(path_val, SIPTAG_PATH_STR(path_val)),
-                                                   NUTAG_WITH_THIS_MSG(de->data->e_msg), SIPTAG_DATE_STR(date), TAG_END());
+                                               TAG_IF(!zstr(expbuf), SIPTAG_EXPIRES_STR(expbuf)),
+                                               NUTAG_WITH_THIS_MSG(de->data->e_msg), SIPTAG_DATE_STR(date), TAG_END());
  
                } else if ((contact_list = sofia_reg_find_reg_url_with_positive_expires_multi(profile, from_user, reg_host))) {
                        /* all + 1 tag_i elements initialized as NULL - last one implies TAG_END() */
@@ -1789,9 +1795,11 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
                                contact_tags[i].t_value = (tag_value_t) m->val;
                                ++i;
                        }
+                       
 
                        nua_respond(nh, SIP_200_OK, TAG_IF(path_val, SIPTAG_PATH_STR(path_val)),
-                                                   NUTAG_WITH_THIS_MSG(de->data->e_msg), SIPTAG_DATE_STR(date), TAG_NEXT(contact_tags));
+                                               TAG_IF(!zstr(expbuf), SIPTAG_EXPIRES_STR(expbuf)),
+                                               NUTAG_WITH_THIS_MSG(de->data->e_msg), SIPTAG_DATE_STR(date), TAG_NEXT(contact_tags));
 
                        switch_safe_free(contact_tags);
                        switch_console_free_matches(&contact_list);
@@ -1799,7 +1807,8 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
                } else {
                        /* respond without any contacts */
                        nua_respond(nh, SIP_200_OK, TAG_IF(path_val, SIPTAG_PATH_STR(path_val)),
-                                                   NUTAG_WITH_THIS_MSG(de->data->e_msg), SIPTAG_DATE_STR(date), TAG_END());
+                                               TAG_IF(!zstr(expbuf), SIPTAG_EXPIRES_STR(expbuf)),
+                                               NUTAG_WITH_THIS_MSG(de->data->e_msg), SIPTAG_DATE_STR(date), TAG_END());
                }