Skip to content

Commit

Permalink
Fix extended Call-ID in B2B
Browse files Browse the repository at this point in the history
The old CallID format did not ensure unicity across time, so we include now time info into the callid.
Closes  #783 .
  • Loading branch information
bogdan-iancu committed Mar 31, 2016
1 parent 6459085 commit 6018192
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions modules/b2b_entities/dlg.c
Expand Up @@ -257,7 +257,7 @@ str* b2b_htable_insert(b2b_table table, b2b_dlg_t* dlg, int hash_index, int src,
return b2b_key;
}

/* key format : B2B.hash_index.local_index *
/* key format : B2B.hash_index.local_index.timestamp *
*/

int b2b_parse_key(str* key, unsigned int* hash_index, unsigned int* local_index)
Expand Down Expand Up @@ -292,12 +292,20 @@ int b2b_parse_key(str* key, unsigned int* hash_index, unsigned int* local_index)

p++;
s.s = p;
s.len = key->s + key->len - s.s;
p= strchr(s.s, '.');
if(p == NULL || ((p-s.s) > key->len) )
{
LM_DBG("Wrong format for b2b key\n");
return -1;
}

s.len = p - s.s;
if(str2int(&s, local_index)< 0)
{
LM_DBG("Wrong format for b2b key\n");
return -1;
}
/* we do not really care about the third part of the key */

LM_DBG("hash_index = [%d] - local_index= [%d]\n", *hash_index, *local_index);

Expand All @@ -310,7 +318,8 @@ str* b2b_generate_key(unsigned int hash_index, unsigned int local_index)
str* b2b_key;
int len;

len = sprintf(buf, "%s.%d.%d", b2b_key_prefix.s, hash_index, local_index);
len = sprintf(buf, "%s.%d.%d.%ld",
b2b_key_prefix.s, hash_index, local_index, startup_time+get_ticks());

b2b_key = (str*)pkg_malloc(sizeof(str)+ len);
if(b2b_key== NULL)
Expand Down
2 changes: 1 addition & 1 deletion modules/b2b_entities/dlg.h
Expand Up @@ -43,7 +43,7 @@

#define DLG_ESTABLISHED 1

#define B2B_MAX_KEY_SIZE (B2B_MAX_PREFIX_LEN + 5*3 + 40)
#define B2B_MAX_KEY_SIZE (B2B_MAX_PREFIX_LEN+4+10+10+INT2STR_MAX_LEN)


enum b2b_entity_type {B2B_SERVER=0, B2B_CLIENT, B2B_NONE};
Expand Down

0 comments on commit 6018192

Please sign in to comment.