comparison gsm-fw/g23m-gsm/ss/ss_for.c @ 673:2f7df7a314f8

gsm-fw/g23m-gsm subtree: initial import from LoCosto source
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 28 Sep 2014 23:20:04 +0000
parents
children 20a2e453564c
comparison
equal deleted inserted replaced
672:0dc6f9e8e980 673:2f7df7a314f8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : SS_FOR
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 supplementary services.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef SS_FOR_C
23 #define SS_FOR_C
24
25 #define ENTITY_SS
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_ss.h"
44 #include "mon_ss.h"
45 #include "pei.h"
46 #include "tok.h"
47 #include "ss.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_ss.h"
64 #include "mon_ss.h"
65 #include "vsi.h"
66 #include "pei.h"
67 #include "tok.h"
68 #include "ss.h"
69
70 #endif
71
72 /*==== EXPORT =====================================================*/
73
74 /*==== PRIVAT =====================================================*/
75
76 /*==== VARIABLES ==================================================*/
77 #ifdef TI_PS_HCOMM_CHANGE
78 #if defined (NEW_FRAME)
79 EXTERN T_HANDLE ss_handle;
80 #endif
81 #else
82 #if defined (NEW_FRAME)
83 EXTERN T_HANDLE hCommMM; /* MM Communication */
84 EXTERN T_HANDLE ss_handle;
85 #else
86 EXTERN T_VSI_CHANDLE hCommMM; /* MM Communication */
87 #endif
88 #endif /* TI_PS_HCOMM_CHANGE */
89
90 #if !defined (SHARED_CCD_BUF)
91 GLOBAL UBYTE _decodedMsg[MAX_MSTRUCT_LEN_SS];
92 #else
93 GLOBAL UBYTE * _decodedMsg;
94 #endif
95 #ifdef SS_TEST
96 EXTERN UBYTE trc[];
97 #endif
98
99 /*==== FUNCTIONS ==================================================*/
100
101 /*
102 * -------------------------------------------------------------------
103 * Procedures
104 * -------------------------------------------------------------------
105 */
106
107 /*
108 +-----------------------------------------------------------------------+
109 | PROJECT : GSM-PS (6147) MODULE : SS_FOR |
110 | STATE : code ROUTINE : for_mmss_establish_n_data_ind |
111 +-----------------------------------------------------------------------+
112
113 PURPOSE : This common routine process the primitives MMSS_ESTATBLISH_IND
114 and MMSS_DATA_IND
115
116 */
117
118
119 LOCAL void for_mmss_establish_n_data_ind(T_PRIM *prim)
120 {
121 GET_INSTANCE_DATA;
122
123 CHAR *msg_type;
124 BOOL invalid_msg = FALSE;
125 T_sdu *sdu;
126
127 TRACE_FUNCTION ("for_mmss_establish_n_data_ind()");
128
129 if(prim->custom.opc EQ MMSS_ESTABLISH_IND)
130 {
131 sdu = &((T_MMSS_ESTABLISH_IND *)P2D(prim))->sdu;
132 ss_data->est_flag = TRUE;
133 }
134 else
135 {
136 sdu = &((T_MMSS_DATA_IND *)P2D(prim))->sdu;
137 ss_data->est_flag = FALSE;
138 }
139
140 if ((ss_data->ti & 7) NEQ 7)
141 {
142 sdu->o_buf += 8;
143 sdu->l_buf -= 8;
144
145 CCD_START;
146
147 if(ccd_decodeMsg (CCDENT_SS,
148 DOWNLINK,
149 (T_MSGBUF *) sdu,
150 (UBYTE *) _decodedMsg,
151 NOT_PRESENT_8BIT) NEQ ccdOK )
152 {
153 USHORT parlist[6];
154 UBYTE prev_err;
155 UBYTE ccd_err;
156 memset (parlist,0, sizeof (parlist));
157 ccd_err = ccd_getFirstError (CCDENT_SS, parlist);
158 /*
159 * Error Handling
160 */
161 ss_data->error = CAUSE_UNSPECIFIED; /*Normal*/
162 do /* Read errors */
163 {
164 switch (ccd_err)
165 {
166 case ERR_INVALID_MID: /* Send RELEASE REQUEST message with cause #97 */
167 /*TS TS 24.010 Section 3.7.4 */
168 send_rel_comp(CAUSE_MESSAGE_TYPE_NOT_IMPLEM);
169 PFREE(P2D(prim));
170 CCD_END;
171 return;
172
173 case ERR_COMPREH_REQUIRED: /* comprehension required */
174 case ERR_MAND_ELEM_MISS: /* Mandatory elements missing */
175 case ERR_MSG_LEN: /* Message Length exceeds its limit */
176 /*TS TS 24.010 Section 3.7.5 */
177 ss_data->error = CAUSE_INVALID_MAND_INFO;
178 break;
179
180 #if defined (WIN32)
181 /* This part is interesting only in implementation and testing; may be
182 * included if specific handling for specific errors is required in
183 * future releases
184 */
185 case ERR_IE_NOT_EXPECTED:
186 TRACE_ERROR("CCD ERROR: IE not expected. properly an R99 optional element like cell notification, eplmn, or t3302");
187 break;
188
189 case ERR_IE_SEQUENCE:
190 TRACE_EVENT_P1("Wrong sequence of IE, CCD error code = %u", ccd_err);
191 break;
192
193 case ERR_MAX_IE_EXCEED:
194 TRACE_EVENT_P1("Maximum amount of repeatable IE has exceeded, CCD error code = %u", ccd_err);
195 break;
196
197 case ERR_MAX_REPEAT:
198 TRACE_EVENT_P1("A repeatable IE occurs too often in the message, CCD error code = %u", ccd_err);
199 break;
200
201 case ERR_PATTERN_MISMATCH:
202 case ERR_INVALID_TYPE:
203 TRACE_EVENT_P1 ("MNC decoding erroneous = %u", ccd_err);
204 break;
205 #endif /* #if defined (WIN32) */
206 default:
207 #if defined (WIN32)
208 TRACE_EVENT_P1 ("Unexpected warnings/errors = %u", ccd_err);
209 #endif /* #if defined (WIN32) */
210 break; /* No or non-interesting error */
211 }
212 prev_err = ccd_err;
213 ccd_err = ccd_getNextError (CCDENT_SS, parlist);
214 }while ( prev_err NEQ ERR_NO_MORE_ERROR
215 AND !ss_check_critical_error(ss_data->error) );
216 }
217
218 switch (_decodedMsg[0])
219 {
220 case D_SS_FACILITY:
221 ss_d_ss_facility ();
222 msg_type = "D_SS_FACILITY";
223 break;
224 case D_SS_REGISTER:
225 ss_d_ss_register ();
226 msg_type = "D_SS_REGISTER";
227 break;
228 case B_SS_REL_COMP:
229 ss_b_ss_rel_comp ();
230 msg_type = "B_SS_REL_COMP";
231 break;
232 default:
233 /* This should NOT be reached */
234 TRACE_FUNCTION("**UNKNOWN MESSAGE ID**");
235 msg_type = "UNKNOWN MESSAGE";
236 invalid_msg = TRUE;
237 break;
238 }
239 if(!invalid_msg)
240 {
241 TRACE_BINDUMP( ss_handle,
242 TC_USER4,
243 msg_type,
244 (&(sdu->buf[0]))+(((sdu->o_buf)>>3) -1),
245 (((sdu->l_buf)>>3) +1));
246 }
247
248 CCD_END;
249 }
250 else if(prim->custom.opc EQ MMSS_ESTABLISH_IND)
251 {
252 /* Establishment with a reserved TI. Release the MM connection */
253 PALLOC (mmss_release_req, MMSS_RELEASE_REQ); /* T_MMSS_RELEASE_REQ */
254 mmss_release_req->ti = ss_data->ti;
255 PSENDX (MM, mmss_release_req);
256 }
257
258 PFREE(P2D(prim));
259 }
260
261
262
263 /*
264 * -------------------------------------------------------------------
265 * PRIMITIVE Processing functions
266 * -------------------------------------------------------------------
267 */
268
269
270 /*
271 +--------------------------------------------------------------------+
272 | PROJECT : GSM-PS (6147) MODULE : SS_FOR |
273 | STATE : code ROUTINE : for_mmss_establish_ind |
274 +--------------------------------------------------------------------+
275
276 PURPOSE : Process the primitive MMSS_ESTATBLISH_IND.
277
278 */
279
280 GLOBAL void for_mmss_establish_ind (T_MMSS_ESTABLISH_IND *mmss_establish_ind_org)
281 {
282 GET_INSTANCE_DATA;
283
284 /* Enable the PCO to correctly decode the message */
285 PPASS (mmss_establish_ind_org, mmss_establish_ind, MMSS_ESTABLISH_IND);
286
287 TRACE_FUNCTION ("for_mmss_establish_ind()");
288
289 GET_PD (mmss_establish_ind->sdu, ss_data->pd);
290 GET_TI (mmss_establish_ind->sdu, ss_data->ti);
291
292 ss_data->ti += ((ss_data->ti > 7) ? -8 : 8);
293
294 for_mmss_establish_n_data_ind((T_PRIM *)D2P(mmss_establish_ind));
295 }
296
297 /*
298 +--------------------------------------------------------------------+
299 | PROJECT : GSM-PS (6147) MODULE : SS_FOR |
300 | STATE : code ROUTINE : for_mmss_data_ind |
301 +--------------------------------------------------------------------+
302
303 PURPOSE : Process the primitive MMSS_DATA_IND.
304
305 */
306
307 GLOBAL void for_mmss_data_ind (T_MMSS_DATA_IND *mmss_data_ind_org)
308 {
309 GET_INSTANCE_DATA;
310
311 /* Enable the PCO to correctly decode the message */
312 PPASS (mmss_data_ind_org, mmss_data_ind, MMSS_DATA_IND);
313
314 TRACE_FUNCTION ("for_mmss_data_ind()");
315
316 GET_PD (mmss_data_ind->sdu, ss_data->pd);
317 GET_TI (mmss_data_ind->sdu, ss_data->ti);
318
319 ss_data->ti += ((ss_data->ti > 7) ? -8 : 8);
320
321 for_mmss_establish_n_data_ind((T_PRIM *)D2P(mmss_data_ind));
322 }
323
324 /*
325 * -------------------------------------------------------------------
326 * SIGNAL Processing functions
327 * -------------------------------------------------------------------
328 */
329
330 /*
331 +--------------------------------------------------------------------+
332 | PROJECT : GSM-PS (6147) MODULE : SS_FOR |
333 | STATE : code ROUTINE : ss_for_data_req |
334 +--------------------------------------------------------------------+
335
336 PURPOSE : Process the signal DATA_REQ.
337
338 */
339
340 GLOBAL void ss_for_data_req (USHORT bit_size_message)
341 {
342 GET_INSTANCE_DATA;
343 CHAR *msg_type;
344 BOOL invalid_msg = FALSE;
345 PALLOC_SDU (mmss_data_req, MMSS_DATA_REQ, bit_size_message);
346
347 TRACE_FUNCTION ("ss_for_data_req()");
348
349 mmss_data_req->sdu.l_buf = bit_size_message;
350 mmss_data_req->sdu.o_buf = ENCODE_OFFSET;
351
352 if (ccd_codeMsg (CCDENT_SS,
353 UPLINK,
354 (T_MSGBUF *) &mmss_data_req->sdu,
355 (UBYTE *) _decodedMsg,
356 NOT_PRESENT_8BIT)
357 EQ ccdOK)
358 {
359 SET_PD (mmss_data_req->sdu, PD_SS);
360 SET_TI (mmss_data_req->sdu, ss_data->ti);
361
362 mmss_data_req->sdu.o_buf -= 8;
363 mmss_data_req->sdu.l_buf += 8;
364
365 /* Trace Bindump() for uplink messages.
366 * called from mnss_facility_req / mnss_end_req / mnss_esatblish_req etc
367 */
368 switch (_decodedMsg[0])
369 {
370 case U_SS_FACILITY:
371 msg_type = "U_SS_FACILITY";
372 break;
373 case U_SS_REGISTER:
374 msg_type = "U_SS_REGISTER";
375 break;
376 case B_SS_REL_COMP:
377 msg_type = "B_SS_REL_COMP";
378 break;
379 default:
380 TRACE_FUNCTION("**UNKNOWN MESSAGE ID**");
381 msg_type = "UNKNOWN MESSAGE";
382 invalid_msg = TRUE;
383 break;
384 }
385 if(!invalid_msg)
386 {
387 TRACE_BINDUMP( ss_handle,
388 TC_USER4,
389 msg_type,
390 (&(mmss_data_req->sdu.buf[0]))+(((mmss_data_req->sdu.o_buf)>>3) -1),
391 (((mmss_data_req->sdu.l_buf)>>3) +1));
392 }
393
394 PSENDX (MM, mmss_data_req);
395 }
396 else
397 {
398 PFREE (mmss_data_req);
399 }
400 }
401
402 #endif /* #ifndef SS_FOR_C */