blob: c964963c0b7519691ec357f309269bddf603fc68 [file] [log] [blame]
Harald Welte143f1f52009-10-26 20:38:37 +01001according to GSM 05.02:
2
3general parameters from CCCH:
4* CA cell allocation of ARFCN's (System Information / BCCH)
5* FN: TDMA frame number (t1,t2,t3') in SCH
6
7specific parameters from channel assignment:
8* MA: mobile allocation, defines set of ARFCN's, up to 64
9* MAIO: index
10* HSN: hopping sequence generator number (0..64)
11
12
13hopping sequence generation (6.2.3):
14
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020015uint8_t rntable[114] = {
Harald Welte143f1f52009-10-26 20:38:37 +010016 48, 98, 63, 1, 36, 95, 78, 102, 94, 73,
17 0, 64, 25, 81, 76, 59, 124, 23, 104, 100,
18 101, 47, 118, 85, 18, 56, 96, 86, 54, 2,
19 80, 34, 127, 13, 6, 89, 57, 103, 12, 74,
20 55, 111, 75, 38, 109, 71, 112, 29, 11, 88,
21 87, 19, 3, 68, 110, 26, 33, 31, 8, 45,
22 82, 58, 40, 107, 32, 5, 106, 92, 62, 67,
23 77, 108, 122, 37, 60, 66, 121, 42, 51, 126,
24 117, 114, 4, 90, 43, 52, 53, 113, 120, 72,
25 16, 49, 7, 79, 119, 61, 22, 84, 9, 97,
26 125, 99, 17, 123
27};
28
29/* mai=0 represents lowest ARFCN in the MA */
30
31
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020032uint8_t hopping_mai(uint8_t hsn, uint32_t fn, uint8_t maio,
33 uint8_t t1, uint8_t t2, uint8_t t3_)
Harald Welte143f1f52009-10-26 20:38:37 +010034{
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020035 uint8_t mai;
Harald Welte143f1f52009-10-26 20:38:37 +010036
37 if (hsn == 0) /* cyclic hopping */
38 mai = (fn + maio) % n;
39 else {
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020040 uint32_t m, m_, t_, s;
Harald Welte143f1f52009-10-26 20:38:37 +010041
42 m = t2 + rntable[(hsn xor (t1 % 64)) + t3];
43 m_ = m % (2^NBIN);
44 t_ = t3 % (2^NBIN);
45 if (m_ < n then)
46 s = m_;
47 else
48 s = (m_ + t_) % n;
49 mai = (s + maio) % n;
50 }
51
52 return mai;
53}
54