comparison src/g23m-gprs/gmm/gmm_f.c @ 183:219afcfc6250

src/g23m-gprs: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 13 Oct 2016 04:24:13 +0000
parents
children
comparison
equal deleted inserted replaced
182:f02d0a0e1849 183:219afcfc6250
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GPRS (8441)
4 | Modul : $
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : This modul is part of the entity GRR and implements all
18 | procedures and functions as described in the
19 | SDL-documentation (-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23
24
25 #ifndef GMM_F_C
26 #define GMM_F_C
27 #endif
28
29 #define ENTITY_GMM
30
31 /*==== INCLUDES =============================================================*/
32
33 #include "typedefs.h" /* to get Condat data types */
34 #include "vsi.h" /* to get a lot of macros */
35 #include "macdef.h"
36 #include "gprs.h"
37 #include "gsm.h" /* to get a lot of macros */
38 #include "ccdapi.h" /* to get CCD API */
39 #include "cnf_gmm.h" /* to get cnf-definitions */
40 #include "mon_gmm.h" /* to get mon-definitions */
41 #include "prim.h" /* to get the definitions of used SAP and directions */
42 #include "gmm.h" /* to get the global entity definitions */
43
44 #include "gmm_f.h"
45 #include <stdlib.h> /* JK, delete warnings: to get rand() */
46
47 /*==== CONST ================================================================*/
48
49 /*==== DIAGNOSTICS ==========================================================*/
50
51 #ifndef TRACE_INFO /* only used in local environment */
52 # define TRACE_INFO(x)
53 #endif
54
55 #ifndef TRACE_COMMENT /* only used in local environment */
56 # define TRACE_COMMENT(x)
57 #endif
58
59
60 /*==== LOCAL VARS ===========================================================*/
61
62 /*==== PRIVATE FUNCTIONS ====================================================*/
63
64 /*==== PUBLIC FUNCTIONS =====================================================*/
65 /*
66 +------------------------------------------------------------------------------
67 | Function : gmm_set_current_tlli
68 +------------------------------------------------------------------------------
69 | Description : derives the current TLLI with the given TLLI type and saves
70 | the old TLLI
71 |
72 | Parameters : tlli_type - the wanted TLLI type
73 |
74 +------------------------------------------------------------------------------
75 */
76 GLOBAL void gmm_set_current_tlli ( T_TLLI_TYPE tlli_type )
77 {
78 GMM_TRACE_FUNCTION ("gmm_set_current_tlli");
79
80 gmm_data->tlli.old = gmm_data->tlli.current,
81 gmm_data->tlli.current = gmm_get_tlli ( tlli_type );
82
83 GMM_TRACE_GMM_DATA(GMM_DEBUG_PRINT_MASK_TLLI);
84
85 GMM_RETURN;
86 } /* gmm_set_current_tlli */
87
88
89 /*
90 +------------------------------------------------------------------------------
91 | Function : gmm_get_tlli
92 +------------------------------------------------------------------------------
93 | Description : returns the wanted TLLI
94 |
95 | Parameters : tlli_type - the wanted TLLI type
96 |
97 +------------------------------------------------------------------------------
98 */
99 GLOBAL ULONG gmm_get_tlli ( T_TLLI_TYPE tlli_type )
100 {
101 GMM_TRACE_FUNCTION ("gmm_get_tlli()");
102
103 /*
104 * the random tlli must be created
105 */
106
107 if ( GMMRR_TMSI_INVALID == gmm_data->ptmsi.current
108 /*
109 * the random tlli must be created
110 */
111
112 && tlli_type != RANDOM_TLLI
113 && tlli_type != CURRENT_TLLI )
114 {
115 gmm_data->ptmsi.current= GMMRR_TMSI_INVALID;
116 gmm_data->ptmsi.new_grr = GMMRR_TMSI_INVALID;
117 gmm_data->ptmsi.old = GMMRR_TMSI_INVALID;
118 gmm_data->tlli.current_type = INVALID_TLLI;
119 TRACE_0_OUT_PARA ("first tlli used");
120 GMM_RETURN_ ( LLGMM_TLLI_INVALID);
121 }
122 else
123 {
124 /* gmm_data->ptmsi.v_mid = TRUE; */
125
126 switch ( tlli_type )
127 {
128 case LOCAL_TLLI:
129 gmm_data->tlli.current_type = tlli_type;
130
131 gmm_data->tlli.current = gmm_data->ptmsi.current | LOCAL_TLLI_SET_MASK;
132 gmm_data->tlli.current &= LOCAL_TLLI_RES_MASK;
133 TRACE_0_OUT_PARA("local tlli used");
134 break;
135 case FOREIGN_TLLI:
136 gmm_data->tlli.current_type = tlli_type;
137
138 gmm_data->tlli.current = gmm_data->ptmsi.current | FOREIGN_TLLI_SET_MASK;
139 gmm_data->tlli.current &= FOREIGN_TLLI_RES_MASK;
140 TRACE_0_OUT_PARA ("foreign tlli used");
141 break;
142 case RANDOM_TLLI:
143 gmm_data->tlli.current_type = CURRENT_TLLI;
144
145 #ifdef _SIMULATION_
146 /* This number is a very random number */
147 gmm_data->ptmsi.current = 0x06081997L;
148 #else
149 gmm_data->ptmsi.current = (rand()<<16) +rand();
150 #endif
151
152 gmm_data->tlli.current = gmm_data->ptmsi.current | RANDOM_TLLI_SET_MASK;
153 gmm_data->tlli.current &= RANDOM_TLLI_RES_MASK;
154 gmm_data->ptmsi.current = GMMRR_TMSI_INVALID;
155 gmm_data->ptmsi.old = GMMRR_TMSI_INVALID;
156
157 TRACE_0_OUT_PARA ("random tlli used");
158 break;
159 case OLD_TLLI:
160 GMM_RETURN_ (gmm_data->tlli.old);
161 case CURRENT_TLLI:
162 GMM_RETURN_ (gmm_data->tlli.current)/*gmm_get_tlli ( gmm_data->tlli.current_type )*/;
163 case INVALID_TLLI:
164 TRACE_0_OUT_PARA ("first tlli used");
165 GMM_RETURN_ (LLGMM_TLLI_INVALID);
166 default:
167 TRACE_ERROR ("WRONG TLLI TYPE received");
168 break;
169 }
170 GMM_RETURN_ (gmm_data->tlli.current);
171 }
172 } /* gmm_get_tlli */
173
174 /*
175 +------------------------------------------------------------------------------
176 | Function : gmm_debug_do_print_gmm_data
177 +------------------------------------------------------------------------------
178 | Description : prints gmm data control block
179 |
180 | Parameters : print mask: select type of information to be printed
181 |
182 +------------------------------------------------------------------------------
183 */
184 GLOBAL void gmm_debug_do_print_gmm_data(GMM_DEBUG_PRINT_MASK_ENUM_TYPE print_mask)
185 {
186 /*
187 * COMMON
188 */
189 if (print_mask & GMM_DEBUG_PRINT_MASK_COMMON)
190 {
191 TRACE_1_DATA("* Version : %u", gmm_data->version);
192 TRACE_1_DATA("* Cipher : %u", gmm_data->cipher);
193 }
194 /*
195 * STATE
196 */
197 if (print_mask & GMM_DEBUG_PRINT_MASK_STATE)
198 {
199 #ifndef NTRACE
200 TRACE_1_DATA("* Kern State : %s", gmm_data->kern.state_name);
201 TRACE_1_DATA("* TX State : %s", gmm_data->tx.state_name);
202 TRACE_1_DATA("* RX State : %s", gmm_data->rx.state_name);
203 TRACE_1_DATA("* RDY State : %s", gmm_data->rdy.state_name);
204 TRACE_1_DATA("* SYNC State : %s", gmm_data->sync.state_name);
205 #endif
206 }
207 /*
208 * TLLI
209 */
210 if (print_mask & GMM_DEBUG_PRINT_MASK_TLLI)
211 {
212 TRACE_1_DATA("* TLLI current : %#x", gmm_data->tlli.current);
213 TRACE_1_DATA("* TLLI old : %#x", gmm_data->tlli.old);
214 switch (gmm_data->tlli.current_type)
215 {
216 case LOCAL_TLLI: TRACE_0_DATA("* TLLI type : LOCAL"); break;
217 case FOREIGN_TLLI: TRACE_0_DATA("* TLLI type : FOREIGN"); break;
218 case RANDOM_TLLI: TRACE_0_DATA("* TLLI type : RANDOM"); break;
219 case CURRENT_TLLI: TRACE_0_DATA("* TLLI type : CURRENT"); break;
220 case OLD_TLLI: TRACE_0_DATA("* TLLI type : OLD"); break;
221 case INVALID_TLLI: TRACE_0_DATA("* TLLI type : INVALID"); break;
222 default:
223 TRACE_1_DATA("* TLLI type : %u unknown!", gmm_data->tlli.current_type);
224 }
225 }
226 /*
227 * IMSI
228 */
229 if (print_mask & GMM_DEBUG_PRINT_MASK_IMSI)
230 {
231 TRACE_8_DATA("* IMSI[]: %1d %1d %1d %1d %1d %1d %1d %1d",
232 gmm_data->imsi.id[0], gmm_data->imsi.id[1],
233 gmm_data->imsi.id[2], gmm_data->imsi.id[3],
234 gmm_data->imsi.id[4], gmm_data->imsi.id[5],
235 gmm_data->imsi.id[6], gmm_data->imsi.id[7]);
236 TRACE_8_DATA("* IMSI[]: %1d %1d %1d %1d %1d %1d %1d %1d",
237 gmm_data->imsi.id[8], gmm_data->imsi.id[9],
238 gmm_data->imsi.id[10], gmm_data->imsi.id[11],
239 gmm_data->imsi.id[12], gmm_data->imsi.id[13],
240 gmm_data->imsi.id[14], gmm_data->imsi.id[15]);
241 }
242 /*
243 * P-TMSI
244 */
245 if (print_mask & GMM_DEBUG_PRINT_MASK_PTMSI)
246 {
247 TRACE_1_DATA("* PTMSI current: %#x", gmm_data->ptmsi.current);
248 TRACE_1_DATA("* PTMSI old : %#x", gmm_data->ptmsi.old);
249 TRACE_1_DATA("* PTMSI grr : %#x", gmm_data->ptmsi.new_grr);
250 }
251 /*
252 * CID
253 */
254 if (print_mask & GMM_DEBUG_PRINT_MASK_CID)
255 {
256 TRACE_0_DATA("* kern. cid rac lac mcc mnc");
257 TRACE_9_DATA("* cell_id %#6x %#6x %#6x %1x%1x%1x %1x%1x%1x",
258 gmm_data->kern.cell_id.cid,
259 gmm_data->kern.cell_id.rac,
260 gmm_data->kern.cell_id.lac,
261 gmm_data->kern.cell_id.plmn.mcc[0],
262 gmm_data->kern.cell_id.plmn.mcc[1],
263 gmm_data->kern.cell_id.plmn.mcc[2],
264 gmm_data->kern.cell_id.plmn.mnc[0],
265 gmm_data->kern.cell_id.plmn.mnc[1],
266 gmm_data->kern.cell_id.plmn.mnc[2]);
267 TRACE_9_DATA("* mm_cell_env %#6x %#6x %#6x %1x%1x%1x %1x%1x%1x",
268 gmm_data->kern.mm_cell_env.cid,
269 gmm_data->kern.mm_cell_env.rai.rac,
270 gmm_data->kern.mm_cell_env.rai.lac,
271 gmm_data->kern.mm_cell_env.rai.plmn.mcc[0],
272 gmm_data->kern.mm_cell_env.rai.plmn.mcc[1],
273 gmm_data->kern.mm_cell_env.rai.plmn.mcc[2],
274 gmm_data->kern.mm_cell_env.rai.plmn.mnc[0],
275 gmm_data->kern.mm_cell_env.rai.plmn.mnc[1],
276 gmm_data->kern.mm_cell_env.rai.plmn.mnc[2]);
277 TRACE_9_DATA("* sig_cell_info.env %#6x %#6x %#6x %1x%1x%1x %1x%1x%1x",
278 gmm_data->kern.sig_cell_info.env.cid,
279 gmm_data->kern.sig_cell_info.env.rai.rac,
280 gmm_data->kern.sig_cell_info.env.rai.lac,
281 gmm_data->kern.sig_cell_info.env.rai.plmn.mcc[0],
282 gmm_data->kern.sig_cell_info.env.rai.plmn.mcc[1],
283 gmm_data->kern.sig_cell_info.env.rai.plmn.mcc[2],
284 gmm_data->kern.sig_cell_info.env.rai.plmn.mnc[0],
285 gmm_data->kern.sig_cell_info.env.rai.plmn.mnc[1],
286 gmm_data->kern.sig_cell_info.env.rai.plmn.mnc[2]);
287 TRACE_9_DATA("* old_sig_cell_info.env %#6x %#6x %#6x %1x%1x%1x %1x%1x%1x",
288 gmm_data->kern.old_sig_cell_info.env.cid,
289 gmm_data->kern.old_sig_cell_info.env.rai.rac,
290 gmm_data->kern.old_sig_cell_info.env.rai.lac,
291 gmm_data->kern.old_sig_cell_info.env.rai.plmn.mcc[0],
292 gmm_data->kern.old_sig_cell_info.env.rai.plmn.mcc[1],
293 gmm_data->kern.old_sig_cell_info.env.rai.plmn.mcc[2],
294 gmm_data->kern.old_sig_cell_info.env.rai.plmn.mnc[0],
295 gmm_data->kern.old_sig_cell_info.env.rai.plmn.mnc[1],
296 gmm_data->kern.old_sig_cell_info.env.rai.plmn.mnc[2]);
297 TRACE_0_DATA("* sync. cid rac lac mcc mnc");
298 TRACE_8_DATA("* mm_cell_info %#6x ------ %#6x %1x%1x%1x %1x%1x%1x",
299 gmm_data->sync.mm_cell_info.cid,
300 gmm_data->sync.mm_cell_info.lac,
301 gmm_data->sync.mm_cell_info.plmn.mcc[0],
302 gmm_data->sync.mm_cell_info.plmn.mcc[1],
303 gmm_data->sync.mm_cell_info.plmn.mcc[2],
304 gmm_data->sync.mm_cell_info.plmn.mnc[0],
305 gmm_data->sync.mm_cell_info.plmn.mnc[1],
306 gmm_data->sync.mm_cell_info.plmn.mnc[2]);
307 TRACE_9_DATA("* grr_cell_info.cell_env %#6x %#6x %#6x %1x%1x%1x %1x%1x%1x",
308 gmm_data->sync.grr_cell_info.cell_env.cid,
309 gmm_data->sync.grr_cell_info.cell_env.rai.rac,
310 gmm_data->sync.grr_cell_info.cell_env.rai.lac,
311 gmm_data->sync.grr_cell_info.cell_env.rai.plmn.mcc[0],
312 gmm_data->sync.grr_cell_info.cell_env.rai.plmn.mcc[1],
313 gmm_data->sync.grr_cell_info.cell_env.rai.plmn.mcc[2],
314 gmm_data->sync.grr_cell_info.cell_env.rai.plmn.mnc[0],
315 gmm_data->sync.grr_cell_info.cell_env.rai.plmn.mnc[1],
316 gmm_data->sync.grr_cell_info.cell_env.rai.plmn.mnc[2]);
317 TRACE_9_DATA("* sig_cell_info.env %#6x %#6x %#6x %1x%1x%1x %1x%1x%1x",
318 gmm_data->sync.sig_cell_info.env.cid,
319 gmm_data->sync.sig_cell_info.env.rai.rac,
320 gmm_data->sync.sig_cell_info.env.rai.lac,
321 gmm_data->sync.sig_cell_info.env.rai.plmn.mcc[0],
322 gmm_data->sync.sig_cell_info.env.rai.plmn.mcc[1],
323 gmm_data->sync.sig_cell_info.env.rai.plmn.mcc[2],
324 gmm_data->sync.sig_cell_info.env.rai.plmn.mnc[0],
325 gmm_data->sync.sig_cell_info.env.rai.plmn.mnc[1],
326 gmm_data->sync.sig_cell_info.env.rai.plmn.mnc[2]);
327
328 TRACE_0_DATA("* kern.attach_cap. rac lac mcc mnc");
329 TRACE_8_DATA("* rai_accepted %#6x %#6x %1x%1x%1x %1x%1x%1x",
330 gmm_data->kern.attach_cap.rai_accepted.rac,
331 gmm_data->kern.attach_cap.rai_accepted.lac,
332 gmm_data->kern.attach_cap.rai_accepted.mcc[0],
333 gmm_data->kern.attach_cap.rai_accepted.mcc[1],
334 gmm_data->kern.attach_cap.rai_accepted.mcc[2],
335 gmm_data->kern.attach_cap.rai_accepted.mnc[0],
336 gmm_data->kern.attach_cap.rai_accepted.mnc[1],
337 gmm_data->kern.attach_cap.rai_accepted.mnc[2]);
338 }
339 /*
340 * RAI
341 */
342 /*
343 * KERN ATTACH CAPABILITIES
344 */
345 if (print_mask & GMM_DEBUG_PRINT_MASK_KERN_ATTACH)
346 {
347 }
348 }