pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36597?usp=email )

Change subject: SIP_Templates: Make tag collisions harder
......................................................................

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
---
M asterisk/gen_links.sh
M asterisk/regen_makefile.sh
M library/SIP_Templates.ttcn
M sip/gen_links.sh
M sip/regen_makefile.sh
5 files changed, 23 insertions(+), 2 deletions(-)

Approvals:
  osmith: Looks good to me, approved
  laforge: Looks good to me, but someone else must approve
  Jenkins Builder: Verified




diff --git a/asterisk/gen_links.sh b/asterisk/gen_links.sh
index 97df3a2..c342e51 100755
--- a/asterisk/gen_links.sh
+++ b/asterisk/gen_links.sh
@@ -7,6 +7,7 @@
 DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src
 FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCInterface.cc TCCInterface_ip.h "
 FILES+="TCCOpenSecurity_Functions.ttcn TCCOpenSecurity.cc 
TCCOpenSecurity_Functions.hh "
+FILES+="TCCDateTime.cc TCCDateTime_Functions.ttcn"
 gen_links $DIR $FILES

 DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src
diff --git a/asterisk/regen_makefile.sh b/asterisk/regen_makefile.sh
index 1aa18ae..5d5538e 100755
--- a/asterisk/regen_makefile.sh
+++ b/asterisk/regen_makefile.sh
@@ -15,6 +15,7 @@
        TCCConversion.cc
        TCCInterface.cc
        TCCOpenSecurity.cc
+       TCCDateTime.cc
        TELNETasp_PT.cc
 "

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.
diff --git a/sip/gen_links.sh b/sip/gen_links.sh
index d12e23c..4c8456c 100755
--- a/sip/gen_links.sh
+++ b/sip/gen_links.sh
@@ -11,6 +11,7 @@
 DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src
 FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCInterface.cc TCCInterface_ip.h "
 FILES+="TCCOpenSecurity_Functions.ttcn TCCOpenSecurity.cc 
TCCOpenSecurity_Functions.hh "
+FILES+="TCCDateTime.cc TCCDateTime_Functions.ttcn"
 gen_links $DIR $FILES

 DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src
diff --git a/sip/regen_makefile.sh b/sip/regen_makefile.sh
index ecec62b..b737316 100755
--- a/sip/regen_makefile.sh
+++ b/sip/regen_makefile.sh
@@ -18,6 +18,7 @@
        TCCConversion.cc
        TCCInterface.cc
        TCCOpenSecurity.cc
+       TCCDateTime.cc
        TELNETasp_PT.cc
        UD_PT.cc
 "

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36597?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Iba26259fd48da1c2558451fe5f7014151d4935c8
Gerrit-Change-Number: 36597
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to