if trust-address flag is not set in rtpengine_offer, "the RTP proxy
ignores address in the SDP and uses source address of the SIP message as
media address which is passed to the RTP proxy".
if there is another, e.g. a loadbalancer, proxy in front of the proxy,
source address of SIP message is not correct media address. it thus
looks to me that a new media-address= flag would be needed, where media
address is taken from if the flag is present.
any comments? it is ok if i try to add media-address= flag?
-- juha
Hi list,
I've figured out that in master expires distribution works only with
Expires header, not with per-contact expires value. So quick fix attached.
--
Best regards,
Alekzander Spiridonov
Module: sip-router
Branch: master
Commit: ba0cf0014908645e6b17b6e305e2e1ae4235a94f
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ba0cf00…
Author: Alekzander Spiridonov <sipidronov(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Aug 22 05:20:42 2014 -0700
registrar: randomize expires value received from UAC
---
modules/registrar/doc/registrar_admin.xml | 11 ++--
modules/registrar/sip_msg.c | 77 ++++++++++++++++-------------
2 files changed, 48 insertions(+), 40 deletions(-)
diff --git a/modules/registrar/doc/registrar_admin.xml b/modules/registrar/doc/registrar_admin.xml
index 4cd2053..992e5fb 100644
--- a/modules/registrar/doc/registrar_admin.xml
+++ b/modules/registrar/doc/registrar_admin.xml
@@ -157,10 +157,9 @@ modparam("registrar", "default_expires", 1800)
<title><varname>default_expires_range</varname> (integer)</title>
<para>
This parameter specifies that the expiry used for newly created usrloc records
- are not fixed(when <quote>default_expires</quote> applies), but a random value in the interval
- <quote>[default_expires-default_expires_range%, default_expires+default_expires_range%]</quote>.
- 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
+ are not fixed, but a random value in the interval <quote>[default_expires-default_expires_range%, default_expires]</quote>.
+ The value is between 0 and 100 and represent the maximim percentage from expires that
+ will be substracted when computing the value. Default in 0, meaning default_expires
is left unmodified. This parameter can be modified via ser config framework.
</para>
<para>
@@ -181,8 +180,8 @@ modparam("registrar", "default_expires_range", 30) # +- 30% from default_expires
<title><varname>expires_range</varname> (integer)</title>
<para>
Similar to default_expires_range, but it applies to the incoming expires
- value and it only lowers the value. Default in 0, meaning the expires
- is left unmodified. This parameter can be modified via config framework.
+ value. Default in 0, meaning the expires is left unmodified.
+ This parameter can be modified via config framework.
</para>
<para>
<emphasis>
diff --git a/modules/registrar/sip_msg.c b/modules/registrar/sip_msg.c
index 19ea3df..f5a84f2 100644
--- a/modules/registrar/sip_msg.c
+++ b/modules/registrar/sip_msg.c
@@ -44,45 +44,37 @@
static struct hdr_field* act_contact;
-/*! \brief
- * Return an expire value in the range [ default_expires - range%, default_expires + range% ]
+/* \brief
+ * Return randomized expires between expires-range% and expires.
+ * RFC allows only value less or equal to the one provided by UAC.
*/
-static inline int get_expire_val(void)
+static inline int randomize_expires( int expires, int range )
{
- int expires = cfg_get(registrar, registrar_cfg, default_expires);
- int range = cfg_get(registrar, registrar_cfg, default_expires_range);
- /* if no range is given just return default_expires */
- if(range == 0) return expires;
- /* select a random value in the range */
- return expires - (float)range/100 * expires + (float)(rand()%100)/100 * 2 * (float)range/100 * expires;
+ /* if no range is given just return expires */
+ if(range == 0) return expires;
+
+ int range_min = expires - (float)range/100 * expires;
+
+ return range_min + (float)(rand()%100)/100 * ( expires - range_min );
}
/*! \brief
* Return value of Expires header field
- * if the HF exists converted to absolute
- * time, if the HF doesn't exist, returns
- * default value;
+ * if the HF exists, if the HF doesn't exist,
+ * returns -1;
*/
static inline int get_expires_hf(struct sip_msg* _m)
{
exp_body_t* p;
- int range;
+
if (_m->expires) {
p = (exp_body_t*)_m->expires->parsed;
if (p->valid) {
- if (p->val != 0) {
- range = cfg_get(registrar, registrar_cfg, default_expires_range);
- if(likely(range==0))
- return p->val + act_time;
- return p->val + act_time - (float)range/100 * p->val
- + ((float)(rand()%100)/100) * ((float)range/100 * p->val);
- } else return 0;
- } else {
- return act_time + get_expire_val();
+ return p->val;
}
- } else
- return act_time + get_expire_val();
+ }
+ return -1;
}
@@ -159,7 +151,7 @@ int check_contacts(struct sip_msg* _m, int* _s)
if (((contact_body_t*)_m->contact->parsed)->star == 1) {
/* The first Contact HF is star */
/* Expires must be zero */
- if (get_expires_hf(_m) > 0) {
+ if (get_expires_hf(_m) != 0) {
rerrno = R_STAR_EXP;
return 1;
}
@@ -252,22 +244,39 @@ contact_t* get_next_contact(contact_t* _c)
*/
void calc_contact_expires(struct sip_msg* _m, param_t* _ep, int* _e)
{
+ int range = 0;
if (!_ep || !_ep->body.len) {
- *_e = get_expires_hf(_m);
+ *_e = get_expires_hf(_m);
+
+ if ( *_e < 0 ) {
+ *_e = cfg_get(registrar, registrar_cfg, default_expires);
+ range = cfg_get(registrar, registrar_cfg, default_expires_range);
+ } else {
+ range = cfg_get(registrar, registrar_cfg, expires_range);
+ }
} else {
if (str2int(&_ep->body, (unsigned int*)_e) < 0) {
- *_e = get_expire_val();
+ *_e = cfg_get(registrar, registrar_cfg, default_expires);
+ range = cfg_get(registrar, registrar_cfg, default_expires_range);
+ } else {
+ range = cfg_get(registrar, registrar_cfg, expires_range);
}
- /* Convert to absolute value */
- if (*_e != 0) *_e += act_time;
}
- if ((*_e != 0) && ((*_e - act_time) < cfg_get(registrar, registrar_cfg, min_expires))) {
- *_e = cfg_get(registrar, registrar_cfg, min_expires) + act_time;
- }
+ if ( *_e != 0 )
+ {
+ *_e = randomize_expires( *_e, range );
+
+ if (*_e < cfg_get(registrar, registrar_cfg, min_expires)) {
+ *_e = cfg_get(registrar, registrar_cfg, min_expires);
+ }
+
+ if (cfg_get(registrar, registrar_cfg, max_expires) && (*_e > cfg_get(registrar, registrar_cfg, max_expires))) {
+ *_e = cfg_get(registrar, registrar_cfg, max_expires);
+ }
- if ((*_e != 0) && cfg_get(registrar, registrar_cfg, max_expires) && ((*_e - act_time) > cfg_get(registrar, registrar_cfg, max_expires))) {
- *_e = cfg_get(registrar, registrar_cfg, max_expires) + act_time;
+ /* Convert to absolute value */
+ *_e += act_time;
}
}
Hi list,
I'd like to propose a patch that allows user to limit the number of items
that appears in dst_avp after ds_select_dst or ds_select_domain call.
There are some use cases when one could have couple of dst sets and would
like to failover from the first to another without checking all items but
have just 3 or 4 of them dead in a row.
What do you think about that?
--
Best regards,
Alekzander Spiridonov
Hello. I have construction Asterisk --> Kamailio --> Providers
My provisers registered with UAC modure and stored at UACREG table.
Problem scenario is:
I ring from asterisk to provider
Asterisk --> Kamailio --> Providers
Call from asterisk come to kamailio with
furi(Asterisk_clinet_local_number@asterisk)
turi(external_number@kamailio)
Then, to forward INVITE to provider that Needed I use some manipulations to
choose provider (it does not matter, it is only sql_queryes to some
tables), and then modify invite with this code:
#$var(prov) - my.provider.ip
#$var(trunk) - name_of_trunk
uac_replace_from("sip:$var(trunk)@$var(prov)");
$rd=$var(prov);
$rp="5060";
$td=$var(prov);
remove_hf("Contact");
append_hf("Contact:<$var(trunk)@my.kamailio.domain:5068>\n","Contact");
#Then I get from database varibles to set it at failure route whet it needs
to auth
#modparam("uac","auth_realm_avp","$avp(s:realm)")
#modparam("uac","auth_username_avp","avp(s:uname)")
#modparam("uac","auth_password_avp","$avp(s:passwd))")
sql_pvquery("ca","select auth_username, auth_password, realm from uacreg
where auth_username='$var(trunk)'","$avp(uname), $avp(passwd),
$avp(realm)");
So -after this manipulation I have write packet, that goes to my provider.
Then Provier sends me 407 answer and packet goes to failure_route
if (t_check_status("401|407")){
xlog("L_INFO", "Reply from provider on failure: $rs");
pv_printf("$avp(s:uname)","$var(uname)");
pv_printf("$avp(s:passwd)","$var(passwd)");
pv_printf("$avp(s:realm)","$var(realm)");
avp_print();
uac_auth();
xlog("L_INFO", "UAC_AUTH(): $rs");
t_relay();
}
After that Call fails. When I look at at syslog I see that avp parametrs
succesfull sets: INFO: avpops [avpops_impl.c:1484]: ops_print_avp():
p=0x7f63acec0650, flags=0x0113 INFO: avpops [avpops_impl.c:1488]:
ops_print_avp(): #011#011#011name=<realm> INFO: avpops
[avpops_impl.c:1496]: ops_print_avp(): #011#011#011val_str=<0 / 1> INFO:
avpops [avpops_impl.c:1484]: ops_print_avp(): p=0x7f63acebe1a8,
flags=0x0113 INFO: avpops [avpops_impl.c:1488]: ops_print_avp():
#011#011#011name=<passwd> INFO: avpops [avpops_impl.c:1496]:
ops_print_avp(): #011#011#011val_str=<0 / 1> INFO: avpops
[avpops_impl.c:1484]: ops_print_avp(): p=0x7f63ace697a8, flags=0x0113 INFO:
avpops [avpops_impl.c:1488]: ops_print_avp(): #011#011#011name=<uname>
INFO: avpops [avpops_impl.c:1496]: ops_print_avp(): #011#011#011val_str=<0
/ 1> INFO: avpops [avpops_impl.c:1484]: ops_print_avp(): p=0x7f63acec0240,
flags=0x0113 INFO: avpops [avpops_impl.c:1488]: ops_print_avp():
#011#011#011name=<realm> INFO: avpops [avpops_impl.c:1496]:
ops_print_avp(): #011#011#011val_str=<my.provider.com / 15> INFO: avpops
[avpops_impl.c:1484]: ops_print_avp(): p=0x7f63acec0308, flags=0x0113 INFO:
avpops [avpops_impl.c:1488]: ops_print_avp(): #011#011#011name=<passwd>
INFO: avpops [avpops_impl.c:1496]: ops_print_avp():
#011#011#011val_str=<mYPa$$wd / 8> INFO: avpops [avpops_impl.c:1484]:
ops_print_avp(): p=0x7f63acea3d40, flags=0x0113 INFO: avpops
[avpops_impl.c:1488]: ops_print_avp(): #011#011#011name=<uname> INFO:
avpops [avpops_impl.c:1496]: ops_print_avp(): #011#011#011val_str=<myTrunk/
16>
But Next I see:
ERROR <script> : AUTH_UAC(): <null>
As I see AUTH_UAC() don`t want to set Auth parameters.
My question is Why?
Thanks!
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
The following task has a new comment added:
FS#460 - dispatcher doesn't loadbalance correctly if one target is offline
User who did this - Daniel-Constantin Mierla (miconda)
----------
I expect that the selection of the next hop is done based on initial size of the set (hash-id % set-size). It would require to keep another value with the size of 'active next hops' (hash-id % number-of-active-next-hops) -- but then it also requires a way to count the 'current' index int the active-next-hops.
Perhaps this can be introduced as an option to the module -- when enabled, instead of simply picking next-hops[hash-id % number-of-active-next-hops], it will walk the next-hops array from beginning and count the active ones until it get to the value of hash-id % number-of-active-next-hops.
----------
More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=460#comment1603
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.