SIP: generate seq_nr within allowed range

Change-Id: Iea5f4568af1bd795db57d2b77e82d976edc9e337
This commit is contained in:
Pau Espin 2024-03-28 20:20:46 +01:00 committed by pespin
parent 3f216c5cee
commit 6052a342fe
2 changed files with 11 additions and 2 deletions

View File

@ -1,6 +1,7 @@
module SIP_Templates {
import from SIPmsg_Types all;
import from Osmocom_Types all;
/* wrapper type to encapsulate the Addr_Union + parameter list used in From, To. ... */
type record SipAddr {
@ -409,5 +410,13 @@ template PDU_SIP_Response tr_SIP_Response( template CallidString call_id,
}
/* RFC 3261 8.1.1.5:
* "The sequence number value MUST be expressible as a 32-bit unsigned integer
* and MUST be less than 2**31."
*/
function f_sip_rand_seq_nr() return integer {
/* 2**31 = 2147483648 */
return f_rnd_int(2147483648)
}
}

View File

@ -101,13 +101,13 @@ private function f_CallPars_compute(inout CallPars cp) {
if (cp.is_mo) {
cp.comp.sip_url_ext := valueof(ts_SipAddr(cp.called, mp_local_host, 5060));
cp.comp.sip_url_gsm := valueof(ts_SipAddr(cp.calling, mp_osmosip_host, 5060));
cp.mncc_call_id := f_rnd_int(429496725);
cp.mncc_call_id := f_sip_rand_seq_nr();
} else {
cp.comp.sip_url_ext := valueof(ts_SipAddr(cp.calling, mp_local_host, 5060));
cp.comp.sip_url_gsm := valueof(ts_SipAddr(cp.called, mp_osmosip_host, 5060));
cp.comp.sip_call_id := hex2str(f_rnd_hexstring(15));
}
cp.comp.sip_seq_nr := f_rnd_int(4294967295);
cp.comp.sip_seq_nr := f_sip_rand_seq_nr();
cp.comp.sip_body := "";
}