Hi,
Has anybody else noticed that sems occasionally generates non-unique via
branches like branch=z9hG4bKkdtiWajG if the proxy in front of sems does
parallel forking?
As I see in core/sip/trans_layer.cpp it's taking into accounting callid,
cseq and timestamp. The timestamp has microseconds resolution so I'm not
sure where the problem is coming from.. maybe hashlittle produces weak
hash? We use sems version 1.4.1 on debian squeeze.
void compute_branch(char* branch/*[8]*/, const cstring& callid, const
cstring& cseq)
{
unsigned int hl=0;
unsigned int hh=0;
timeval tv;
gettimeofday(&tv,NULL);
hh = hl = tv.tv_sec + tv.tv_usec;
hl = hashlittle(callid.s,callid.len,hl);
hh = hashlittle(cseq.s,cseq.len,hh);
compute_tag(branch,hl,hh);
}
char _tag_lookup[] = {
'a','b','c','d','e','f','g','h',
'i','j','k','l','m','n','o','p',
'q','r','s','t','u','v','w','x',
'y','z','A','B','C','D','E','F',
'G','H','I','J','K','L','M','N',
'O','P','Q','R','S','T','U','V',
'W','X','Y','Z','0','1','2','3',
'4','5','6','7','8','9','.','~'
};
inline void compute_tag(char* tag, unsigned int hl, unsigned int hh)
{
hl += hh >> 16;
hh &= 0xFFFF;
tag[0] = _tag_lookup[hl&0x3F];
tag[1] = _tag_lookup[(hl >> 6)&0x3F];
tag[2] = _tag_lookup[(hl >> 12)&0x3F];
tag[3] = _tag_lookup[(hl >> 18)&0x3F];
tag[4] = _tag_lookup[(hl >> 24)&0x3F];
tag[5] = _tag_lookup[(hl >> 30)&((hh << 2) & 0x3F)];
tag[6] = _tag_lookup[(hh >> 4)&0x3F];
tag[7] = _tag_lookup[(hh >> 10)&0x3F];
}
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev