static qvalue_t q_override_value;
/*! \brief
- * Process request that contained a star, in that case,
+ * Process request that contained a star (*) as a contact, in that case,
* we will remove all bindings with the given username
* from the usrloc and return 200 OK response
*/
* and insert all contacts from the message that have expires
* > 0
*/
-static inline int insert_contacts(struct sip_msg* _m, udomain_t* _d, str* _a, int _use_regid)
+static inline int insert_contacts(struct sip_msg* _m, udomain_t* _d, str* _a, int _use_regid, int novariation)
{
ucontact_info_t* ci;
urecord_t* r = NULL;
maxc = reg_get_crt_max_contacts();
for( num=0,r=0,ci=0 ; _c ; _c = get_next_contact(_c) ) {
/* calculate expires */
- calc_contact_expires(_m, _c->expires, &expires);
+ calc_contact_expires(_m, _c->expires, &expires, novariation);
/* Skip contacts with zero expires */
if (expires == 0)
continue;
for( ; _c ; _c = get_next_contact(_c) ) {
/* calculate expires */
- calc_contact_expires(_m, _c->expires, &e);
+ calc_contact_expires(_m, _c->expires, &e, 0);
ret = ul.get_ucontact_by_instance( _r, &_c->uri, ci, &cont);
if (ret==-1) {
* 3) If contact in usrloc exists and expires
* == 0, delete contact
*/
-static inline int update_contacts(struct sip_msg* _m, urecord_t* _r, int _mode, int _use_regid)
+static inline int update_contacts(struct sip_msg* _m, urecord_t* _r, int _mode, int _use_regid, int novariation)
{
ucontact_info_t *ci;
ucontact_t *c, *ptr, *ptr0;
updated=0;
for( ; _c ; _c = get_next_contact(_c) ) {
/* calculate expires */
- calc_contact_expires(_m, _c->expires, &expires);
+ calc_contact_expires(_m, _c->expires, &expires, novariation);
/* pack the contact info */
if ( (ci=pack_ci( 0, _c, expires, 0, _use_regid))==0 ) {
* contained some contact header fields
*/
static inline int add_contacts(struct sip_msg* _m, udomain_t* _d,
- str* _a, int _mode, int _use_regid)
+ str* _a, int _mode, int _use_regid, int novariation)
{
int res;
int ret;
}
if (res == 0) { /* Contacts found */
- if ((ret=update_contacts(_m, r, _mode, _use_regid)) < 0) {
+ if ((ret=update_contacts(_m, r, _mode, _use_regid, novariation)) < 0) {
build_contact(_m, r->contacts, &u->host);
ul.release_urecord(r);
ul.unlock_udomain(_d, _a);
build_contact(_m, r->contacts, &u->host);
ul.release_urecord(r);
} else {
- if (insert_contacts(_m, _d, _a, _use_regid) < 0) {
+ if (insert_contacts(_m, _d, _a, _use_regid, novariation) < 0) {
ul.unlock_udomain(_d, _a);
return -4;
}
param_t *params;
contact_t *contact;
int use_ob = 1, use_regid = 1;
+ int novariation = 0;
+
u = parse_to_uri(_m);
if(u==NULL)
}
mem_only = is_cflag_set(REG_SAVE_MEM_FL)?FL_MEM:FL_NONE;
+ novariation = is_cflag_set(REG_SAVE_NOVARIATION_FL)? 1:0;
if (c == 0) {
if (st) {
}
} else {
mode = is_cflag_set(REG_SAVE_REPL_FL)?1:0;
- if ((ret=add_contacts(_m, (udomain_t*)_d, &aor, mode, use_regid)) < 0)
+ if ((ret=add_contacts(_m, (udomain_t*)_d, &aor, mode, use_regid, novariation)) < 0)
goto error;
ret = (ret==0)?1:ret;
}
*/
static inline int randomize_expires( int expires, int range )
{
+ int range_min;
+
/* if no range is given just return expires */
- if(range == 0) return expires;
+ if(range == 0)
+ return expires;
- int range_min = expires - (float)range/100 * expires;
+ range_min = expires - (float)range/100 * expires;
return range_min + (float)(rand()%100)/100 * ( expires - range_min );
}
* 3) If the message contained no expires header field, use
* the default value
*/
-void calc_contact_expires(struct sip_msg* _m, param_t* _ep, int* _e)
+void calc_contact_expires(struct sip_msg* _m, param_t* _ep, int* _e, int novariation)
{
int range = 0;
+
if (!_ep || !_ep->body.len) {
*_e = get_expires_hf(_m);
if ( *_e != 0 )
{
- *_e = randomize_expires( *_e, range );
+ if (!novariation) {
+ *_e = randomize_expires( *_e, range );
+ }
if (*_e < cfg_get(registrar, registrar_cfg, min_expires)) {
*_e = cfg_get(registrar, registrar_cfg, min_expires);