comparison src/g23m-gsm/mm/mm_forp.c @ 104:27a4235405c6

src/g23m-gsm: import from LoCosto source
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 04 Oct 2016 18:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
103:76d139c7a25e 104:27a4235405c6
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (8410)
4 | Modul : MM_FORP
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 defines the functions for the formatter
18 | capability of the module Mobility Management.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef MM_FORP_C
23 #define MM_FORP_C
24
25 #define ENTITY_MM
26
27 /*==== INCLUDES ===================================================*/
28 #if defined (NEW_FRAME)
29
30 #include <string.h>
31 #include <stdlib.h>
32 #include <stddef.h>
33 #include "typedefs.h"
34 #include "pcm.h"
35 #include "pconst.cdg"
36 #include "mconst.cdg"
37 #include "message.h"
38 #include "ccdapi.h"
39 #include "vsi.h"
40 #include "custom.h"
41 #include "gsm.h"
42 #include "prim.h"
43 #include "cnf_mm.h"
44 #include "mon_mm.h"
45 #include "pei.h"
46 #include "tok.h"
47 #include "mm.h"
48
49 #else
50
51 #include <string.h>
52 #include <stdlib.h>
53 #include <stddef.h>
54 #include "stddefs.h"
55 #include "pcm.h"
56 #include "pconst.cdg"
57 #include "mconst.cdg"
58 #include "message.h"
59 #include "ccdapi.h"
60 #include "custom.h"
61 #include "gsm.h"
62 #include "prim.h"
63 #include "cnf_mm.h"
64 #include "mon_mm.h"
65 #include "vsi.h"
66 #include "pei.h"
67 #include "tok.h"
68 #include "mm.h"
69
70 #endif
71
72 /*==== EXPORT =====================================================*/
73
74 /*==== PRIVAT =====================================================*/
75
76 /*==== VARIABLES ==================================================*/
77
78 /*==== FUNCTIONS ==================================================*/
79
80 /*==== TEST =====================================================*/
81
82 /*
83 * -------------------------------------------------------------------
84 * PRIMITIVE Processing functions
85 * -------------------------------------------------------------------
86 */
87
88
89 #if 0
90 /*
91 +--------------------------------------------------------------------+
92 | PROJECT : GSM-PS (6147) MODULE : MM_FOR |
93 | STATE : code ROUTINE : for_init_mm_data |
94 +--------------------------------------------------------------------+
95
96 PURPOSE : Initialize the MM data for the module formatter.
97 This function is not referenced.
98
99 */
100
101 GLOBAL void for_init_mm_data (void)
102 {
103 TRACE_FUNCTION ("for_init_mm_data()");
104 }
105 #endif /* #if 0 */
106
107 /*
108 +--------------------------------------------------------------------+
109 | PROJECT : GSM-PS (6147) MODULE : MM_FOR |
110 | STATE : code ROUTINE : for_rr_data_ind |
111 +--------------------------------------------------------------------+
112
113 PURPOSE : Process the primitive RR_DATA_IND.
114
115 */
116
117 GLOBAL void for_rr_data_ind (T_RR_DATA_IND *rr_data_ind_org)
118 {
119 GET_INSTANCE_DATA;
120 UBYTE pd;
121 UBYTE ti;
122 U8 *payload;
123 U16 length;
124 /* Implements Measure#32: Row 14,...,24 */
125 PPASS (rr_data_ind_org, rr_data_ind, RR_DATA_IND);
126
127 TRACE_FUNCTION ("for_rr_data_ind()");
128 mm_data->error = 0;
129
130 GET_PD (rr_data_ind->sdu, pd);
131 GET_TI (rr_data_ind->sdu, ti);
132
133 if (pd EQ PD_MM)
134 {
135 if (! ti)
136 {
137 T_mob_class_2 mob_class_2;
138
139 csf_read_mobile_class_2 (&mob_class_2);
140
141 rr_data_ind->sdu.l_buf -= 8;
142 rr_data_ind->sdu.o_buf += 8;
143
144 if (ccd_decodeMsg (CCDENT_MM,
145 DOWNLINK,
146 (T_MSGBUF *) &rr_data_ind->sdu,
147 (UBYTE *) _decodedMsg,
148 NOT_PRESENT_8BIT) NEQ ccdOK)
149 {
150 U16 parlist [6];
151 U8 ccd_err;
152
153 memset (parlist,0, sizeof (parlist));
154 ccd_err = ccd_getFirstError (CCDENT_MM, parlist);
155
156 /*
157 * Error Handling
158 */
159
160 do /* Read errors */
161 {
162 switch (ccd_err)
163 {
164 case ERR_INVALID_MID: /* ignore message & send STATUS #97 */
165 mm_for_set_error (RC_MESSAGE_TYPE_NOT_IMPLEM);
166 break;
167 case ERR_MSG_LEN: /* will be activated soon by CCD; agreemen in RR
168 if decoding was continued outside MSG-buffer it
169 should be handled as mand. IE missing */
170 case ERR_MAND_ELEM_MISS: /* ignore message & send STATUS #96 */
171 case ERR_COMPREH_REQUIRED: /* ignore message & send STATUS #96 */
172 mm_for_set_error (RC_INVALID_MAND_MESSAGE);
173 break;
174 #if defined (WIN32) /* This part is interesting only in implementation
175 and testing; may be included if specific handling
176 for specific errors is required in future releases */
177 case ERR_IE_NOT_EXPECTED: /* ignore IE */
178 case ERR_IE_SEQUENCE: /* ignore IE */
179 case ERR_MAX_IE_EXCEED: /* ignore IE */
180 TRACE_EVENT_P1 ("IE ignored, CCD error code = %u", ccd_err);
181 break;
182 case ERR_PATTERN_MISMATCH:
183 case ERR_INVALID_TYPE:
184 TRACE_EVENT_P1 ("MNC decoding erroneous = %u", ccd_err);
185 break;
186 #endif /* #if defined (WIN32) */
187 default:
188 #if defined (WIN32)
189 TRACE_EVENT_P1 ("Unexpected warnings/errors = %u", ccd_err);
190 #endif /* #if defined (WIN32) */
191 break; /* No or non-interesting error */
192 }
193 ccd_err = ccd_getNextError (CCDENT_MM, parlist);
194 } while ( ccd_err NEQ ERR_NO_MORE_ERROR
195 AND !mm_check_critical_error() );
196 } /* if (ccd_ ... */
197
198 if (!mm_check_critical_error())
199 {
200 /* Implements Measure#32: Row 14,...,24 */
201 payload = &(rr_data_ind->sdu.buf[0]); /* beginning of buffer */
202 payload += ((rr_data_ind->sdu.o_buf) >> 3) - 1; /* plus offset (bytes) */
203 length = ((rr_data_ind->sdu.l_buf) >> 3) + 1; /* length (bytes, bits / 8) */
204
205
206
207 /* Implements Measure#32: Row 14,...,24 */
208 switch (_decodedMsg[0])
209 {
210 case D_AUTH_REJ:
211 TRACE_BINDUMP( mm_handle,
212 TC_USER4,
213 "Down Link: AUTHENTICATION REJECT",
214 payload,
215 length);
216 break;
217
218 case D_AUTH_REQ:
219 TRACE_BINDUMP( mm_handle,
220 TC_USER4,
221 "Down Link: AUTHENTICATION REQUEST",
222 payload,
223 length);
224 break;
225
226 case D_CM_SERV_ACCEPT:
227 TRACE_BINDUMP( mm_handle,
228 TC_USER4,
229 "Down Link: CM SERV ACCEPT",
230 payload,
231 length);
232 break;
233
234 case D_ABORT:
235 TRACE_BINDUMP( mm_handle,
236 TC_USER4,
237 "Down Link: ABORT",
238 payload,
239 length);
240 break;
241
242 case D_CM_SERV_REJ:
243 TRACE_BINDUMP( mm_handle,
244 TC_USER4,
245 "Down Link: CM SERVICE REJECT",
246 payload,
247 length);
248 break;
249
250 case D_IDENT_REQ:
251 TRACE_BINDUMP( mm_handle,
252 TC_USER4,
253 "Down Link: IDENTITY REQUEST",
254 payload,
255 length);
256 break;
257
258 case D_LOC_UPD_ACCEPT:
259 TRACE_BINDUMP( mm_handle,
260 TC_USER4,
261 "Down Link: LOC UPDATE ACCEPT",
262 payload,
263 length);
264 break;
265
266 case D_LOC_UPD_REJ:
267 TRACE_BINDUMP( mm_handle,
268 TC_USER4,
269 "Down Link: LOC UPDATE REJECT",
270 payload,
271 length);
272 break;
273
274 case B_MM_STATUS:
275 TRACE_BINDUMP( mm_handle,
276 TC_USER4,
277 "Down Link: MM STATUS",
278 payload,
279 length);
280 break;
281
282 case D_TMSI_REALLOC_CMD:
283 TRACE_BINDUMP( mm_handle,
284 TC_USER4,
285 "Down Link: TMSI REALLOC COMMAND",
286 payload,
287 length);
288 break;
289
290 case D_CM_SERVICE_PROMPT:
291 TRACE_BINDUMP( mm_handle,
292 TC_USER4,
293 "Down Link: CM SERVICE PROMPT",
294 payload,
295 length);
296 break;
297
298 case D_MM_INFORMATION:
299 TRACE_BINDUMP( mm_handle,
300 TC_USER4,
301 "Down Link: MM INFORMATION",
302 payload,
303 length);
304 break;
305
306 default:
307 /*
308 * message is unknown; if this happens, AIM does not match
309 * implementation
310 */
311 mm_for_set_error(RC_MESSAGE_TYPE_NOT_IMPLEM);
312 break;
313 } /* switch */
314 switch (_decodedMsg[0])
315 {
316 case D_AUTH_REJ:
317 mm_auth_rej ();
318 break;
319
320 case D_AUTH_REQ:
321 mm_auth_req ((T_D_AUTH_REQ *)_decodedMsg);
322 break;
323
324 case D_CM_SERV_ACCEPT:
325 mm_cm_serv_accept ();
326 break;
327
328 case D_ABORT:
329 mm_abort ((T_D_ABORT *)_decodedMsg);
330 break;
331
332 case D_CM_SERV_REJ:
333 mm_cm_serv_rej (MSG(D_CM_SERV_REJ));
334 break;
335
336 case D_IDENT_REQ:
337 mm_ident_req ((T_D_IDENT_REQ *)_decodedMsg);
338 break;
339
340 case D_LOC_UPD_ACCEPT:
341 mm_loc_upd_acc (MSG(D_LOC_UPD_ACCEPT));
342 break;
343
344 case D_LOC_UPD_REJ:
345 mm_lup_rej (MSG(D_LOC_UPD_REJ));
346 break;
347
348 case B_MM_STATUS:
349 mm_mm_status ();
350 break;
351
352 case D_TMSI_REALLOC_CMD:
353 mm_tmsi_realloc_cmd (MSG(D_TMSI_REALLOC_CMD));
354 break;
355
356 case D_CM_SERVICE_PROMPT:
357 mm_cm_service_prompt (MSG(D_CM_SERVICE_PROMPT));
358 break;
359
360 case D_MM_INFORMATION:
361 mm_mm_information (MSG(D_MM_INFORMATION));
362 break;
363
364 default:
365 /*
366 * message is unknown; if this happens, AIM does not match
367 * implementation
368 */
369 mm_for_set_error(RC_MESSAGE_TYPE_NOT_IMPLEM);
370 break;
371 } /* switch */
372 } /* if (!mm_check_critical_error() */
373 } /* if !ti */
374 } /* if pd EQ PD_MM */
375 else
376 {
377 if (ti >= 8)
378 ti -= 8;
379 else
380 ti += 8;
381 mm_cm_message (pd, ti, rr_data_ind);
382 return;
383 } /* else if pd EQ PD_MM */
384
385 mm_send_status_on_error(); /* handles critical errors preventing AIM from processing */
386 PFREE (rr_data_ind); /* the message pointer should be freed here */
387 }
388
389 #endif