Index: modules/usrloc/urecord.c =================================================================== --- modules/usrloc/urecord.c (revision 8040) +++ modules/usrloc/urecord.c (working copy) @@ -550,3 +550,12 @@ } +/* similar to get_ucontact, but does not use callid and cseq + to be used from MI functions where we have only contact */ +int get_simple_ucontact(urecord_t* _r, str* _c, struct ucontact** _co) +{ + *_co = contact_match( _r->contacts, _c); + return (*_co)?0:1; +} + + Index: modules/usrloc/ul_mi.c =================================================================== --- modules/usrloc/ul_mi.c (revision 8040) +++ modules/usrloc/ul_mi.c (working copy) @@ -292,7 +292,7 @@ } contact = &node->next->next->value; - ret = get_ucontact( rec, contact, &mi_ul_cid, MI_UL_CSEQ+1, &con); + ret = get_simple_ucontact( rec, contact, &con); if (ret < 0) { unlock_udomain( dom, aor); return 0; @@ -503,23 +503,26 @@ goto lock_error; c = 0; } else { - if (get_ucontact( r, contact, &mi_ul_cid, MI_UL_CSEQ+1, &c) < 0) + if (get_simple_ucontact( r, contact, &c) < 0) goto lock_error; } get_act_time(); - ci.callid = &mi_ul_cid; ci.user_agent = &mi_ul_ua; - ci.cseq = MI_UL_CSEQ; /* 0 expires means permanent contact */ if (ci.expires!=0) ci.expires += act_time; if (c) { + /* update contact record */ + ci.cseq = c->cseq; if (update_ucontact( r, c, &ci) < 0) goto release_error; } else { + /* new contact record */ + ci.callid = &mi_ul_cid; + ci.cseq = MI_UL_CSEQ; if ( insert_ucontact( r, contact, &ci, &c) < 0 ) goto release_error; } Index: modules/usrloc/urecord.h =================================================================== --- modules/usrloc/urecord.h (revision 8040) +++ modules/usrloc/urecord.h (working copy) @@ -139,6 +139,8 @@ struct ucontact** _co); int get_ucontact(urecord_t* _r, str* _c, str* _callid, int _cseq, struct ucontact** _co); +int get_simple_ucontact(urecord_t* _r, str* _c, struct ucontact** _co); + #endif /* URECORD_H */