From a800a5fc5c801b862d58e03aed8de717fa1cc4e7 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 11 Oct 2012 10:36:07 -0500 Subject: [PATCH] FS-4708 add to your sofia profile and it should set the header --- src/mod/endpoints/mod_sofia/mod_sofia.h | 3 ++- src/mod/endpoints/mod_sofia/sofia.c | 12 ++++++++++++ src/mod/endpoints/mod_sofia/sofia_reg.c | 15 ++++++++++++--- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index dfd472e65d..aeef8ea43f 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -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 { diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 7c1124383b..5199a2d264 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -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; diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 98299a784b..6a7febdbe0 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -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()); }