Wed, 08 Feb 2012 20:07:00 +0200
Update version, adapt patch, correct PID writing, correct build on newer
FreeBSD releases, and most importantly introduce new patch to try to
avoid segfault caused by multiple network interfaces with the same (or
no) address. This is common when configuring bridges and tunnels.
michael@377 | 1 | Index: modules/registrar/save.c |
michael@377 | 2 | diff -Nau modules/registrar/save.c.orig modules/registrar/save.c |
michael@377 | 3 | --- modules/registrar/save.c.orig 2008-08-03 15:53:57.000000000 +0200 |
michael@377 | 4 | +++ modules/registrar/save.c 2009-03-24 21:44:46.182865192 +0100 |
michael@547 | 5 | @@ -77,7 +77,7 @@ |
michael@377 | 6 | struct save_ctx { |
michael@377 | 7 | unsigned int flags; |
michael@377 | 8 | str aor; |
michael@377 | 9 | - unsigned int max_contacts; |
michael@377 | 10 | + int max_contacts; |
michael@377 | 11 | }; |
michael@377 | 12 | |
michael@377 | 13 | |
michael@547 | 14 | @@ -394,7 +394,7 @@ |
michael@377 | 15 | if (e == 0) |
michael@377 | 16 | continue; |
michael@377 | 17 | |
michael@377 | 18 | - if (_sctx->max_contacts && (num >= _sctx->max_contacts)) { |
michael@377 | 19 | + if (_sctx->max_contacts && (num >= abs(_sctx->max_contacts))) { |
michael@377 | 20 | if (_sctx->flags®_SAVE_FORCE_REG_FLAG) { |
michael@377 | 21 | /* we are overflowing the number of maximum contacts, |
michael@377 | 22 | so remove the first (oldest) one to prevent this */ |
michael@547 | 23 | @@ -501,6 +501,7 @@ |
michael@377 | 24 | contact_t* _c, struct save_ctx *_sctx) |
michael@377 | 25 | { |
michael@377 | 26 | ucontact_info_t *ci; |
michael@377 | 27 | + ucontact_t *ucon = 0; |
michael@377 | 28 | ucontact_t* c; |
michael@377 | 29 | int e; |
michael@377 | 30 | unsigned int cflags; |
michael@547 | 31 | @@ -561,7 +562,7 @@ |
michael@377 | 32 | continue; |
michael@377 | 33 | |
michael@377 | 34 | /* we need to add a new contact -> too many ?? */ |
michael@377 | 35 | - if (_sctx->max_contacts && num>=_sctx->max_contacts) { |
michael@377 | 36 | + if (_sctx->max_contacts && num>=abs(_sctx->max_contacts)) { |
michael@377 | 37 | if (_sctx->flags®_SAVE_FORCE_REG_FLAG) { |
michael@377 | 38 | /* we are overflowing the number of maximum contacts, |
michael@377 | 39 | so remove the first (oldest) one to prevent this */ |
michael@547 | 40 | @@ -588,6 +589,23 @@ |
michael@377 | 41 | goto error; |
michael@377 | 42 | } |
michael@377 | 43 | |
michael@377 | 44 | + /* remove matching contacts or matching Call-ID headers before */ |
michael@377 | 45 | + /* inserting a new one if indicated by a negative max_contacts */ |
michael@377 | 46 | + if (_sctx->max_contacts < 0) { |
michael@377 | 47 | + for (ucon = _r->contacts; ucon; ucon = ucon->next) { |
michael@377 | 48 | + if (((ci->callid->len == ucon->callid.len) && \ |
michael@377 | 49 | + !memcmp(ci->callid->s, ucon->callid.s, ci->callid->len)) \ |
michael@377 | 50 | + || \ |
michael@377 | 51 | + ((_c->uri.len==ucon->c.len) && \ |
michael@377 | 52 | + !memcmp(_c->uri.s, ucon->c.s, _c->len))) { |
michael@377 | 53 | + if (ul.delete_ucontact(_r, ucon) < 0) { |
michael@377 | 54 | + rerrno = R_UL_DEL_C; |
michael@377 | 55 | + LM_ERR("failed to delete contact\n"); |
michael@377 | 56 | + goto error; |
michael@377 | 57 | + } |
michael@377 | 58 | + } |
michael@377 | 59 | + } |
michael@377 | 60 | + } |
michael@377 | 61 | if (ul.insert_ucontact( _r, &_c->uri, ci, &c) < 0) { |
michael@377 | 62 | rerrno = R_UL_INS_C; |
michael@377 | 63 | LM_ERR("failed to insert contact\n"); |
michael@377 | 64 | Index: modules/registrar/sip_msg.c |
michael@377 | 65 | diff -Nau modules/registrar/sip_msg.c.orig modules/registrar/sip_msg.c |
michael@377 | 66 | --- modules/registrar/sip_msg.c.orig 2008-08-03 15:53:57.000000000 +0200 |
michael@377 | 67 | +++ modules/registrar/sip_msg.c 2009-03-24 21:44:46.182865192 +0100 |
michael@377 | 68 | @@ -137,7 +137,7 @@ |
michael@377 | 69 | /* Message without contacts is OK */ |
michael@377 | 70 | if (_m->contact == 0) return 0; |
michael@377 | 71 | |
michael@377 | 72 | - if (((contact_body_t*)_m->contact->parsed)->star == 1) { |
michael@377 | 73 | + if (((contact_body_t*)_m->contact->parsed)->star == -1) { |
michael@377 | 74 | /* The first Contact HF is star */ |
michael@377 | 75 | /* Expires must be zero */ |
michael@377 | 76 | if (get_expires_hf(_m) > 0) { |
michael@377 | 77 | @@ -167,7 +167,7 @@ |
michael@377 | 78 | p = _m->contact->next; |
michael@377 | 79 | while(p) { |
michael@377 | 80 | if (p->type == HDR_CONTACT_T) { |
michael@377 | 81 | - if (((contact_body_t*)p->parsed)->star == 1) { |
michael@377 | 82 | + if (((contact_body_t*)p->parsed)->star == -1) { |
michael@377 | 83 | rerrno = R_STAR_CONT; |
michael@377 | 84 | return 1; |
michael@377 | 85 | } |