diff --git a/modules/ims_registrar_scscf/doc/ims_registrar_scscf_admin.xml b/modules/ims_registrar_scscf/doc/ims_registrar_scscf_admin.xml index e80d6d0d82b..76a0f35e9b8 100644 --- a/modules/ims_registrar_scscf/doc/ims_registrar_scscf_admin.xml +++ b/modules/ims_registrar_scscf/doc/ims_registrar_scscf_admin.xml @@ -67,10 +67,9 @@ contact parameters, this value will be used for newly created S-CSCF usrloc records. The parameter contains number of second to expire (for example use 3600 for one hour). If it is set to a lower value than the - min_expires parameter then it will be ignored. This - parameter can be modified via ser config framework. A random value in a - specific interval can be selected by using the default_expires_range - parameter + min_expires parameter then it will be ignored. This parameter can be + modified via ser config framework. A random value in a specific interval + can be selected by using the default_expires_range parameter Default value is 3600. @@ -87,14 +86,13 @@ default_expires_range (int) This parameter specifies that the expiry used for newly created - S-CSCF usrloc records are not fixed(when default_expires - applies), but a random value in the intervalrdq - [default_expires-default_expires_range%, - default_expires+default_expires_range%]. The value is between 0 - and 100 and represent the maximim percentage from default_expires that - will be substracted or added when computing the value. Default in 0, - meaning default_expires is left unmodified. This parameter can be - modified via ser config framework. + S-CSCF usrloc records are not fixed(when default_expires applies), but a + random value in the intervalrdq [default_expires-default_expires_range%, + default_expires+default_expires_range%]. The value is between 0 and 100 + and represent the maximim percentage from default_expires that will be + substracted or added when computing the value. Default in 0, meaning + default_expires is left unmodified. This parameter can be modified via + ser config framework. Default value is 0. @@ -144,21 +142,23 @@ ... - +
subscription_default_expires (int) If the processed message contains neither Expires HFs nor expires - contact parameters, this value will be used for newly created subscriptions. - The parameter contains number of second to expire (for example use 3600 for one hour). - If it is set to a lower value than the subscription_min_expires parameter - then it will be ignored. A random value in a specific interval can be selected - by using the subscription_expires_range parameter + contact parameters, this value will be used for newly created + subscriptions. The parameter contains number of second to expire (for + example use 3600 for one hour). If it is set to a lower value than the + subscription_min_expires parameter then it will be ignored. A random + value in a specific interval can be selected by using the + subscription_expires_range parameter Default value is 3600. - Set <varname>subscription_default_expires</varname> parameter + Set <varname>subscription_default_expires</varname> + parameter ... modparam("ims_registrar_scscf", "subscription_default_expires", 3600) @@ -170,19 +170,20 @@ subscription_expires_range (int) This parameter specifies that the expiry used for newly created - subscriptions are not fixed(when subscription_default_expires - applies), but a random value in the interval + subscriptions are not fixed(when subscription_default_expires applies), + but a random value in the interval [subscription_default_expires-subscription_expires_range%, - subscription_default_expires+subscription_expires_range%]. - The value is between 0 and 100 and represent the maximim percentage - from subscription_default_expires that will be substracted or added when - computing the value. Default in 0, meaning subscription_default_expires is - left unmodified. + subscription_default_expires+subscription_expires_range%]. The value is + between 0 and 100 and represent the maximim percentage from + subscription_default_expires that will be substracted or added when + computing the value. Default in 0, meaning subscription_default_expires + is left unmodified. Default value is 0. - Set <varname>subscription_expires_range </varname>parameter + Set <varname>subscription_expires_range + </varname>parameter ... modparam("ims_registrar_scscf", "subscription_expires_range", 30) # +- 30% from subscription_expires_range @@ -193,14 +194,15 @@
subscription_min_expires (int) - The minimum expires value of a subscription, values lower than this - minimum will be automatically set to the minimum. Value 0 disables the - checking. + The minimum expires value of a subscription, values lower than + this minimum will be automatically set to the minimum. Value 0 disables + the checking. Default value is 10. - Set <varname>subscription_min_expires</varname>parameter + Set + <varname>subscription_min_expires</varname>parameter ... modparam("subscription_min_expires", "min_expires", 1800) @@ -211,14 +213,15 @@
subscription_max_expires (int) - The maximum expires value of a subscription, values higher than this - maximum will be automatically set to the maximum. Value 0 disables the - checking. + The maximum expires value of a subscription, values higher than + this maximum will be automatically set to the maximum. Value 0 disables + the checking. Default value is 1000000. - Set <varname>subscription_max_expires</varname>parameter + Set + <varname>subscription_max_expires</varname>parameter ... modparam("ims_registrar_scscf", "subscription_max_expires", 3600) @@ -386,12 +389,12 @@ ...
- +
user_data_always (integer) - If specified this will make the S-CSCF always request user - data from HSS. + If specified this will make the S-CSCF always request user data + from HSS. Default value is 0 (disabled) @@ -404,7 +407,6 @@
-
@@ -513,6 +515,46 @@ switch ($retcode) {
+
+ <function + moreinfo="none">lookup_path_to_contact(uri)</function> + + This function take a URI and tries to find the contact in usrloc. + If the contact is found and has a path set, then a path header is added + to the SIP message so it can be loose routed. + + Meaning of the parameters is as follows: + + + + uri - URI of contact to lookup + + + + Return codes: + + + + 1 - Success + + + + -1 - Failure + + + + This function can be used from REQUEST_ROUTE, FAILURE_ROUTE + + + <function>lookup</function> usage + + ... +lookup_path_to_contact($ruri); +... + + +
+
<function moreinfo="none">unregister(domain)</function> diff --git a/modules/ims_registrar_scscf/lookup.c b/modules/ims_registrar_scscf/lookup.c index 8c67598422a..b3b58a94c21 100644 --- a/modules/ims_registrar_scscf/lookup.c +++ b/modules/ims_registrar_scscf/lookup.c @@ -123,6 +123,10 @@ int lookup(struct sip_msg* _m, udomain_t* _d) { ret = -3; goto done; } + if (set_path_vector(_m, &ptr->path) < 0) { + LM_ERR("failed to set path vector\n"); + return -1; + } if (set_dst_uri(_m, &path_dst) < 0) { LM_ERR("failed to set dst_uri of Path\n"); ret = -3; @@ -177,6 +181,41 @@ int lookup(struct sip_msg* _m, udomain_t* _d) { return ret; } +int lookup_path_to_contact(struct sip_msg* _m, char* contact_uri) { + ucontact_t* contact; + str s_contact_uri; + str path_dst; + + if (get_str_fparam(&s_contact_uri, _m, (fparam_t*) contact_uri) < 0) { + LM_ERR("failed to get RURI\n"); + return -1; + } + LM_DBG("Looking up contact [%.*s]\n", s_contact_uri.len, s_contact_uri.s); + + if (ul.get_ucontact(NULL, &s_contact_uri, 0, 0, 0, &contact) == 0) { //get_contact returns with lock + LM_DBG("CONTACT FOUND and path is [%.*s]\n", contact->path.len, contact->path.s); + + if (get_path_dst_uri(&contact->path, &path_dst) < 0) { + LM_ERR("failed to get dst_uri for Path\n"); + return -1; + } + if (set_path_vector(_m, &contact->path) < 0) { + LM_ERR("failed to set path vector\n"); + return -1; + } + if (set_dst_uri(_m, &path_dst) < 0) { + LM_ERR("failed to set dst_uri of Path\n"); + return -1; + } + + ul.release_ucontact(contact); + return 1; + } + + LM_DBG("no contact found for [%.*s]\n", s_contact_uri.len, s_contact_uri.s); + return -1; +} + /*! \brief the impu_registered() function * Return true if the AOR in the To Header is registered */ diff --git a/modules/ims_registrar_scscf/lookup.h b/modules/ims_registrar_scscf/lookup.h index 68a7e0e4624..daf731bf268 100644 --- a/modules/ims_registrar_scscf/lookup.h +++ b/modules/ims_registrar_scscf/lookup.h @@ -40,7 +40,7 @@ * Lookup a contact in usrloc and rewrite R-URI if found */ int lookup(struct sip_msg* _m, udomain_t* _d); - +int lookup_path_to_contact(struct sip_msg* _m, char* contact_uri); /*! \brief * Return true if the AOR in the Request-URI is registered, diff --git a/modules/ims_registrar_scscf/reg_mod.c b/modules/ims_registrar_scscf/reg_mod.c index d412e3769b9..87ec202670a 100644 --- a/modules/ims_registrar_scscf/reg_mod.c +++ b/modules/ims_registrar_scscf/reg_mod.c @@ -113,6 +113,7 @@ static void mod_destroy(void); static int w_save(struct sip_msg* _m, char * _route, char* _d, char* mode, char* _cflags); static int w_assign_server_unreg(struct sip_msg* _m, char* _route, char* _d, char* _direction); static int w_lookup(struct sip_msg* _m, char* _d, char* _p2); +static int w_lookup_path_to_contact(struct sip_msg* _m, char* contact_uri); /*! \brief Fixup functions */ static int domain_fixup(void** param, int param_no); @@ -190,6 +191,7 @@ static pv_export_t mod_pvs[] = { static cmd_export_t cmds[] = { {"save", (cmd_function) w_save, 2, assign_save_fixup3_async, 0, REQUEST_ROUTE | ONREPLY_ROUTE}, {"lookup", (cmd_function) w_lookup, 1, domain_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE}, + {"lookup_path_to_contact", (cmd_function) w_lookup_path_to_contact, 1, fixup_var_str_12, 0, REQUEST_ROUTE}, {"term_impu_registered", (cmd_function) term_impu_registered, 1, domain_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE}, {"impu_registered", (cmd_function) impu_registered, 1, domain_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE}, {"assign_server_unreg", (cmd_function) w_assign_server_unreg, 3, assign_save_fixup3_async, 0, REQUEST_ROUTE}, @@ -533,6 +535,10 @@ static int w_assign_server_unreg(struct sip_msg* _m, char* _route, char* _d, cha } +static int w_lookup_path_to_contact(struct sip_msg* _m, char* contact_uri) { + return lookup_path_to_contact(_m, contact_uri); +} + /*! \brief * Wrapper to lookup(location) */