opensips/opensips.patch.reg

changeset 377
67e813202d53
child 382
b972dc20871f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/opensips/opensips.patch.reg	Wed Sep 21 14:04:16 2011 +0200
     1.3 @@ -0,0 +1,85 @@
     1.4 +Index: modules/registrar/save.c
     1.5 +diff -Nau modules/registrar/save.c.orig modules/registrar/save.c
     1.6 +--- modules/registrar/save.c.orig	2008-08-03 15:53:57.000000000 +0200
     1.7 ++++ modules/registrar/save.c	2009-03-24 21:44:46.182865192 +0100
     1.8 +@@ -76,7 +76,7 @@
     1.9 + struct save_ctx {
    1.10 + 	unsigned int flags;
    1.11 + 	str aor;
    1.12 +-	unsigned int max_contacts;
    1.13 ++	int max_contacts;
    1.14 + };
    1.15 + 
    1.16 + 
    1.17 +@@ -388,7 +388,7 @@
    1.18 + 		if (e == 0)
    1.19 + 			continue;
    1.20 + 
    1.21 +-		if (_sctx->max_contacts && (num >= _sctx->max_contacts)) {
    1.22 ++		if (_sctx->max_contacts && (num >= abs(_sctx->max_contacts))) {
    1.23 + 			if (_sctx->flags&REG_SAVE_FORCE_REG_FLAG) {
    1.24 + 				/* we are overflowing the number of maximum contacts,
    1.25 + 				   so remove the first (oldest) one to prevent this */
    1.26 +@@ -494,6 +494,7 @@
    1.27 + 										contact_t* _c, struct save_ctx *_sctx)
    1.28 + {
    1.29 + 	ucontact_info_t *ci;
    1.30 ++	ucontact_t *ucon = 0;
    1.31 + 	ucontact_t* c;
    1.32 + 	int e;
    1.33 + 	unsigned int cflags;
    1.34 +@@ -554,7 +555,7 @@
    1.35 + 				continue;
    1.36 + 
    1.37 + 			/* we need to add a new contact -> too many ?? */
    1.38 +-			if (_sctx->max_contacts && num>=_sctx->max_contacts) {
    1.39 ++			if (_sctx->max_contacts && num>=abs(_sctx->max_contacts)) {
    1.40 + 				if (_sctx->flags&REG_SAVE_FORCE_REG_FLAG) {
    1.41 + 					/* we are overflowing the number of maximum contacts,
    1.42 + 					   so remove the first (oldest) one to prevent this */
    1.43 +@@ -581,6 +582,23 @@
    1.44 + 				goto error;
    1.45 + 			}
    1.46 + 
    1.47 ++			/* remove matching contacts or matching Call-ID headers before */
    1.48 ++			/* inserting a new one if indicated by a negative max_contacts */
    1.49 ++			if (_sctx->max_contacts < 0) {
    1.50 ++				for (ucon = _r->contacts; ucon; ucon = ucon->next) {
    1.51 ++					if (((ci->callid->len == ucon->callid.len) && \
    1.52 ++						!memcmp(ci->callid->s, ucon->callid.s, ci->callid->len)) \
    1.53 ++						|| \
    1.54 ++						((_c->uri.len==ucon->c.len) && \
    1.55 ++						!memcmp(_c->uri.s, ucon->c.s, _c->len))) {
    1.56 ++						if (ul.delete_ucontact(_r, ucon) < 0) {
    1.57 ++							rerrno = R_UL_DEL_C;
    1.58 ++							LM_ERR("failed to delete contact\n");
    1.59 ++							goto error;
    1.60 ++						}
    1.61 ++					} 
    1.62 ++				} 
    1.63 ++			} 
    1.64 + 			if (ul.insert_ucontact( _r, &_c->uri, ci, &c) < 0) {
    1.65 + 				rerrno = R_UL_INS_C;
    1.66 + 				LM_ERR("failed to insert contact\n");
    1.67 +Index: modules/registrar/sip_msg.c
    1.68 +diff -Nau modules/registrar/sip_msg.c.orig modules/registrar/sip_msg.c
    1.69 +--- modules/registrar/sip_msg.c.orig	2008-08-03 15:53:57.000000000 +0200
    1.70 ++++ modules/registrar/sip_msg.c	2009-03-24 21:44:46.182865192 +0100
    1.71 +@@ -137,7 +137,7 @@
    1.72 + 	/* Message without contacts is OK */
    1.73 + 	if (_m->contact == 0) return 0;
    1.74 + 	
    1.75 +-	if (((contact_body_t*)_m->contact->parsed)->star == 1) {
    1.76 ++	if (((contact_body_t*)_m->contact->parsed)->star == -1) {
    1.77 + 		/* The first Contact HF is star */
    1.78 + 		/* Expires must be zero */
    1.79 + 		if (get_expires_hf(_m) > 0) {
    1.80 +@@ -167,7 +167,7 @@
    1.81 + 		p = _m->contact->next;
    1.82 + 		while(p) {
    1.83 + 			if (p->type == HDR_CONTACT_T) {
    1.84 +-				if (((contact_body_t*)p->parsed)->star == 1) {
    1.85 ++				if (((contact_body_t*)p->parsed)->star == -1) {
    1.86 + 					rerrno = R_STAR_CONT;
    1.87 + 					return 1;
    1.88 + 				}

mercurial