diff -r 8f552d1cd671 -r 67e813202d53 opensips/opensips.patch.reg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/opensips/opensips.patch.reg Wed Sep 21 14:04:16 2011 +0200 @@ -0,0 +1,85 @@ +Index: modules/registrar/save.c +diff -Nau modules/registrar/save.c.orig modules/registrar/save.c +--- modules/registrar/save.c.orig 2008-08-03 15:53:57.000000000 +0200 ++++ modules/registrar/save.c 2009-03-24 21:44:46.182865192 +0100 +@@ -76,7 +76,7 @@ + struct save_ctx { + unsigned int flags; + str aor; +- unsigned int max_contacts; ++ int max_contacts; + }; + + +@@ -388,7 +388,7 @@ + if (e == 0) + continue; + +- if (_sctx->max_contacts && (num >= _sctx->max_contacts)) { ++ if (_sctx->max_contacts && (num >= abs(_sctx->max_contacts))) { + if (_sctx->flags®_SAVE_FORCE_REG_FLAG) { + /* we are overflowing the number of maximum contacts, + so remove the first (oldest) one to prevent this */ +@@ -494,6 +494,7 @@ + contact_t* _c, struct save_ctx *_sctx) + { + ucontact_info_t *ci; ++ ucontact_t *ucon = 0; + ucontact_t* c; + int e; + unsigned int cflags; +@@ -554,7 +555,7 @@ + continue; + + /* we need to add a new contact -> too many ?? */ +- if (_sctx->max_contacts && num>=_sctx->max_contacts) { ++ if (_sctx->max_contacts && num>=abs(_sctx->max_contacts)) { + if (_sctx->flags®_SAVE_FORCE_REG_FLAG) { + /* we are overflowing the number of maximum contacts, + so remove the first (oldest) one to prevent this */ +@@ -581,6 +582,23 @@ + goto error; + } + ++ /* remove matching contacts or matching Call-ID headers before */ ++ /* inserting a new one if indicated by a negative max_contacts */ ++ if (_sctx->max_contacts < 0) { ++ for (ucon = _r->contacts; ucon; ucon = ucon->next) { ++ if (((ci->callid->len == ucon->callid.len) && \ ++ !memcmp(ci->callid->s, ucon->callid.s, ci->callid->len)) \ ++ || \ ++ ((_c->uri.len==ucon->c.len) && \ ++ !memcmp(_c->uri.s, ucon->c.s, _c->len))) { ++ if (ul.delete_ucontact(_r, ucon) < 0) { ++ rerrno = R_UL_DEL_C; ++ LM_ERR("failed to delete contact\n"); ++ goto error; ++ } ++ } ++ } ++ } + if (ul.insert_ucontact( _r, &_c->uri, ci, &c) < 0) { + rerrno = R_UL_INS_C; + LM_ERR("failed to insert contact\n"); +Index: modules/registrar/sip_msg.c +diff -Nau modules/registrar/sip_msg.c.orig modules/registrar/sip_msg.c +--- modules/registrar/sip_msg.c.orig 2008-08-03 15:53:57.000000000 +0200 ++++ modules/registrar/sip_msg.c 2009-03-24 21:44:46.182865192 +0100 +@@ -137,7 +137,7 @@ + /* Message without contacts is OK */ + if (_m->contact == 0) return 0; + +- if (((contact_body_t*)_m->contact->parsed)->star == 1) { ++ 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) { +@@ -167,7 +167,7 @@ + p = _m->contact->next; + while(p) { + if (p->type == HDR_CONTACT_T) { +- if (((contact_body_t*)p->parsed)->star == 1) { ++ if (((contact_body_t*)p->parsed)->star == -1) { + rerrno = R_STAR_CONT; + return 1; + }