| module L3_Common { |
| |
| import from Osmocom_Types all; |
| import from General_Types all; |
| |
| type record AuthVector { |
| OCT16 rand, |
| OCT4 sres, |
| OCT8 kc |
| /* FIXME: 3G elements */ |
| } |
| |
| private function f_rnd_oct(integer len) return octetstring { |
| var integer i; |
| var octetstring res; |
| for (i := 0; i < len; i := i + 1) { |
| res[i] := int2oct(float2int(rnd()*256.0), 1); |
| } |
| return res; |
| } |
| |
| function f_gen_auth_vec_2g() return AuthVector { |
| var AuthVector vec; |
| vec.rand := f_rnd_oct(16); |
| vec.sres := f_rnd_oct(4); |
| vec.kc := f_rnd_oct(8); |
| return vec; |
| } |
| |
| /* 3GPP TS 23.003 2.6 */ |
| type enumerated TlliType { |
| TLLI_LOCAL, |
| TLLI_FOREIGN, |
| TLLI_RANDOM, |
| TLLI_AUXILIARY, |
| TLLI_RESERVED, |
| TLLI_G_RNTI, |
| TLLI_RAND_G_RNTI |
| } |
| |
| /* 3GPP TS 23.003 2.6 */ |
| function f_gprs_tlli_type(OCT4 tlli) return TlliType { |
| var bitstring tllib := oct2bit(tlli); |
| if (substr(tllib, 0, 2) == '11'B) { |
| return TLLI_LOCAL; |
| } else if (substr(tllib, 0, 2) == '10'B) { |
| return TLLI_FOREIGN; |
| } else if (substr(tllib, 0, 5) == '01111'B) { |
| return TLLI_RANDOM; |
| } else if (substr(tllib, 0, 4) == '0110'B) { |
| return TLLI_RESERVED; |
| } else if (substr(tllib, 0, 3) == '010'B) { |
| return TLLI_RESERVED; |
| } else if (substr(tllib, 0, 4) == '0000'B) { |
| return TLLI_G_RNTI; |
| } else if (substr(tllib, 0, 4) == '0001'B) { |
| return TLLI_RAND_G_RNTI; |
| } else { |
| setverdict(fail, "Unknonw TLLI Type ", tllib); |
| self.stop; |
| } |
| } |
| |
| function f_gprs_tlli_random() return OCT4 { |
| var OCT4 tlli := f_rnd_octstring(4); |
| return tlli or4b 'c0000000'O; |
| } |
| |
| |
| |
| } |