SIP_Templates: Make tag collisions harder
It was spotted during some test runs that the same tag was assigned to 2
different components. Let's make this way more difficult by adding some
time to it. Asterisk uses longer strings for instance, since 32bits is
the minimum.
Change-Id: Iba26259fd48da1c2558451fe5f7014151d4935c8
diff --git a/library/SIP_Templates.ttcn b/library/SIP_Templates.ttcn
index be07196..e115bb7 100644
--- a/library/SIP_Templates.ttcn
+++ b/library/SIP_Templates.ttcn
@@ -3,6 +3,7 @@
import from SIPmsg_Types all;
import from TCCConversion_Functions all;
import from TCCOpenSecurity_Functions all;
+import from TCCDateTime_Functions all;
import from Native_Functions all;
import from Osmocom_Types all;
import from Misc_Helpers all;
@@ -1151,10 +1152,12 @@
req.msgHeader.cSeq.seqNumber := f_sip_next_seq_nr(valueof(req.msgHeader.cSeq.seqNumber));
}
-/* Tags shall have at least 32 bit of randomness */
function f_sip_rand_tag() return charstring {
+ /* Tags shall have at least 32 bit of randomness */
var integer rnd_int := f_rnd_int(4294967296);
- return hex2str(int2hex(rnd_int, 8));
+ /* Make collisions harder by appending time to the final string: */
+ var integer ts_int := f_time_ms() mod 4294967296;
+ return hex2str(int2hex(rnd_int, 8)) & "-" & hex2str(int2hex(ts_int, 8));
}
/* Generate a "branch" tag value.