comparison g23m/condat/ms/src/aci/cmh_gmms.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
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 module implements the set fuinctions related to the
18 | protocol stack adapter for GPRS mobility management ( GMM ).
19 +-----------------------------------------------------------------------------
20 */
21
22 #if defined (GPRS) && defined (DTI)
23
24 #ifndef CMH_GMMS_C
25 #define CMH_GMMS_C
26 #endif
27
28 #include "aci_all.h"
29
30 /*==== INCLUDES ===================================================*/
31 #include "dti.h" /* functionality of the dti library */
32 #include "aci_cmh.h"
33
34 #include "dti_conn_mng.h"
35
36 #include "gaci.h"
37 #include "gaci_cmh.h"
38 #include "psa.h"
39 #include "psa_gmm.h"
40 #include "psa_sm.h"
41 #ifdef FAX_AND_DATA
42 /* #include "aci_fd.h" */
43 #endif
44 #include "phb.h"
45 #include "cmh.h"
46 #include "cmh_gmm.h"
47 #include "cmh_sm.h"
48
49 /*==== CONSTANTS ==================================================*/
50
51 /*==== EXPORT =====================================================*/
52
53 /*==== VARIABLES ==================================================*/
54
55 /*==== FUNCTIONS ==================================================*/
56 GLOBAL T_ACI_RETURN sAT_PlusCGATT ( T_ACI_CMD_SRC srcId, T_CGATT_STATE state );
57 GLOBAL T_ACI_RETURN sAT_PlusCGCLASS ( T_ACI_CMD_SRC srcId, T_CGCLASS_CLASS m_class );
58
59 GLOBAL T_ACI_RETURN sAT_PercentCGAATT ( T_ACI_CMD_SRC srcId, T_CGAATT_ATTACH_MODE att_m, T_CGAATT_DETACH_MODE det_m);
60 GLOBAL T_ACI_RETURN sAT_PercentCGCLASS ( T_ACI_CMD_SRC srcId, T_PERCENT_CGCLASS m_class );
61
62 /*
63 +--------------------------------------------------------------------+
64 | PROJECT : GPRS (8441) MODULE : CMH_GMMQ |
65 | STATE : finished ROUTINE : sAT_PlusCGATT |
66 +--------------------------------------------------------------------+
67
68 PURPOSE : This is the functional counterpart to the +CGATT= GPRS AT
69 command which sets current GACI service state.
70
71 Fails if illegal new state requested. Returns complete if
72 already in existing state, otherwise signals GACI SEM to
73 attach or detach GACI as appropriate.
74
75 (Un)succesful completion of attach/detach is signalled by
76 means of a GACI callback.
77 */
78
79 GLOBAL T_ACI_RETURN sAT_PlusCGATT ( T_ACI_CMD_SRC srcId, T_CGATT_STATE state )
80 {
81 T_ACI_RETURN retCd; /* holds return code */
82
83 TRACE_FUNCTION ("sAT_PlusCGATT()");
84
85 /*
86 *-------------------------------------------------------------------
87 * check command source
88 *-------------------------------------------------------------------
89 */
90 if(!cmh_IsVldCmdSrc (srcId))
91 {
92 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
93 return( AT_FAIL );
94 }
95
96 /*
97 *-------------------------------------------------------------------
98 * check entity status
99 *-------------------------------------------------------------------
100 */
101 if( gmmEntStat.curCmd NEQ AT_CMD_NONE )
102
103 return( AT_BUSY );
104
105 /*
106 *-------------------------------------------------------------------
107 * check first command argument
108 *-------------------------------------------------------------------
109 */
110 if ( state < CGATT_STATE_OMITTED || state >= CGATT_STATE_INVALID )
111 {
112 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
113 return( AT_FAIL );
114 }
115 if (pb_get_fdn_mode () EQ FDN_ENABLE AND state EQ CGATT_STATE_ATTACHED)
116 {
117 if (pb_check_fdn (0, (const UBYTE *)"*99#") NEQ PHB_OK)
118 {
119 TRACE_EVENT("sAT_PlusCGATT: Entry not found in FDN, GPRS not allowed.");
120 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow);
121 return (AT_FAIL);
122 }
123 TRACE_EVENT("sAT_PlusCGATT: Entry found in FDN, GPRS allowed.");
124 }
125
126 /*
127 *-------------------------------------------------------------------
128 * process parameter
129 *-------------------------------------------------------------------
130 */
131 switch ( state )
132 {
133 case CGATT_STATE_OMITTED:
134 switch ( cmhGMM_Get_state() )
135 {
136 case AS_ATTACHED:
137 case AS_SUSPENTED:
138 state = CGATT_STATE_DETACHED;
139 break;
140 case AS_DETACHED:
141 state = CGATT_STATE_ATTACHED;
142 break;
143 case AS_ATTACHING:
144 case AS_DETACHING:
145 return AT_BUSY;
146 case AS_INVALID_STATE:
147 case AS_MOBILE_OFF:
148 default:
149 return AT_FAIL;
150 }
151
152 retCd = sAT_PlusCGATT(srcId, state);
153 break;
154 case CGATT_STATE_ATTACHED:
155 /*
156 * A class CC mobile can not attach GPRS
157 */
158 if ( gmmShrdPrm.mobile_class EQ GMMREG_CLASS_CC )
159 {
160 return AT_FAIL;
161 }
162
163 switch(gmmShrdPrm.current_attach_type)
164 {
165 case GMMREG_AT_GPRS:
166 case GMMREG_AT_COMB:
167 TRACE_EVENT("Already attached, attach not necessary.");
168 retCd = AT_CMPL;
169 break;
170 case GMMREG_AT_IMSI:
171 TRACE_EVENT("GSM already attached, initiating combined attach.");
172 gmmEntStat.curCmd = AT_CMD_CGATT;
173 gmmEntStat.entOwn = srcId;
174 gmmShrdPrm.last_attach_type = gmmShrdPrm.current_attach_type;
175 gmmShrdPrm.requested_attach_type = GMMREG_AT_COMB;
176 gmmShrdPrm.requested_mobile_class = gmmShrdPrm.mobile_class;
177
178 psaGMM_Attach( gmmShrdPrm.requested_mobile_class,
179 gmmShrdPrm.requested_attach_type,
180 gmmShrdPrm.service_mode);
181
182 retCd = AT_EXCT;
183 break;
184 case ATTACH_TYPE_DETACHED:
185 TRACE_EVENT("Mobile is detached, initiating GPRS attach.");
186 gmmEntStat.curCmd = AT_CMD_CGATT;
187 gmmEntStat.entOwn = srcId;
188 gmmShrdPrm.last_attach_type = gmmShrdPrm.current_attach_type;
189 gmmShrdPrm.requested_attach_type = GMMREG_AT_GPRS;
190 gmmShrdPrm.requested_mobile_class = gmmShrdPrm.mobile_class;
191
192 psaGMM_Attach( gmmShrdPrm.requested_mobile_class,
193 gmmShrdPrm.requested_attach_type,
194 gmmShrdPrm.service_mode);
195
196 retCd = AT_EXCT;
197 break;
198 default:
199 retCd = AT_FAIL;
200 break;
201 }
202 break;
203 case CGATT_STATE_DETACHED:
204 switch ( cmhGMM_Get_state() )
205 {
206 case AS_DETACHED:
207 retCd = AT_CMPL;
208 break;
209 case AS_ATTACHING:
210 case AS_DETACHING:
211 retCd = AT_BUSY;
212 break;
213 default:
214 gmmEntStat.curCmd = AT_CMD_CGATT;
215 gmmEntStat.entOwn = srcId;
216
217 psaGMM_Detach( GMMREG_DT_GPRS );
218
219 retCd = AT_EXCT;
220 break;
221 }
222 break;
223 case CGATT_STATE_INVALID:
224 default:
225 retCd = AT_FAIL;
226 break;
227 }
228
229 return retCd;
230 }
231
232 /*
233 +--------------------------------------------------------------------+
234 | PROJECT : GPRS (8441) MODULE : CMH_GMMQ |
235 | STATE : finished ROUTINE : sAT_PlusCGCLASS |
236 +--------------------------------------------------------------------+
237
238 PURPOSE : This is the functional counterpart to the +CGCLASS= GPRS AT
239 command which sets the specified GPRS mobile class.
240 */
241
242 GLOBAL T_ACI_RETURN sAT_PlusCGCLASS ( T_ACI_CMD_SRC srcId, T_CGCLASS_CLASS m_class )
243 {
244 USHORT mobile_class;
245
246 TRACE_FUNCTION ("sAT_PlusCGCLASS()");
247
248 /*
249 *-------------------------------------------------------------------
250 * check command source
251 *-------------------------------------------------------------------
252 */
253 if(!cmh_IsVldCmdSrc (srcId))
254 {
255 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
256 return( AT_FAIL );
257 }
258
259 /*
260 *-------------------------------------------------------------------
261 * check entity status
262 *-------------------------------------------------------------------
263 */
264 if( gmmEntStat.curCmd NEQ AT_CMD_NONE )
265
266 return( AT_BUSY );
267
268 if (pb_get_fdn_mode () EQ FDN_ENABLE && m_class NEQ CGCLASS_CLASS_CC)
269 {
270 if (pb_check_fdn (0, (const UBYTE *)"*99#") NEQ PHB_OK)
271 {
272 TRACE_EVENT("sAT_PlusCGCLASS: Entry not found in FDN, GPRS not allowed.");
273 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow);
274 return (AT_FAIL);
275 }
276 TRACE_EVENT("sAT_PlusCGCLASS: Entry found in FDN, GPRS allowed.");
277 }
278
279
280 /*
281 *-------------------------------------------------------------------
282 * process parameter
283 *-------------------------------------------------------------------
284 */
285 switch ( m_class )
286 {
287 case CGCLASS_CLASS_A: /* mobile class A (highest) */
288 mobile_class = GMMREG_CLASS_A;
289 break;
290 case CGCLASS_CLASS_B: /* mobile class B (if necessary consider NET III) */
291 mobile_class = GMMREG_CLASS_BG;
292 break;
293 case CGCLASS_CLASS_CG: /* mobile class CG (GPRS only mode) */
294 mobile_class = GMMREG_CLASS_CG;
295 break;
296 case CGCLASS_CLASS_CC: /* mobile class CC (circuit switched only mode - lowest) */
297 mobile_class = GMMREG_CLASS_CC;
298 break;
299 case CGCLASS_CLASS_OMITTED:
300 mobile_class = gmmShrdPrm.mobile_class;
301 break;
302 case CGCLASS_CLASS_MAX:
303 default: /*bad user command */
304 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
305 return AT_FAIL;
306 }
307
308 gmmEntStat.entOwn = srcId;
309 gmmEntStat.curCmd = AT_CMD_CGCLASS;
310
311 return cmhGMM_attach((UBYTE) mobile_class );
312 }
313
314
315 /*
316 +--------------------------------------------------------------------+
317 | PROJECT : GPRS (8441) MODULE : CMH_GMMQ |
318 | STATE : finished ROUTINE : sAT_PercentCGAATT |
319 +--------------------------------------------------------------------+
320
321 PURPOSE : This command set the mode of automatic attach / detach.
322 */
323
324 GLOBAL T_ACI_RETURN sAT_PercentCGAATT ( T_ACI_CMD_SRC srcId, T_CGAATT_ATTACH_MODE att_m, T_CGAATT_DETACH_MODE det_m )
325 {
326
327 TRACE_FUNCTION ("sAT_PercentCGAATT()");
328
329 /*
330 *-------------------------------------------------------------------
331 * check entity status
332 *-------------------------------------------------------------------
333 */
334 if( gmmEntStat.curCmd NEQ AT_CMD_NONE )
335
336 return( AT_BUSY );
337
338 /*
339 *-------------------------------------------------------------------
340 * check first command argument
341 *-------------------------------------------------------------------
342 */
343 if ( att_m < CGAATT_ATTACH_MODE_OMITTED || att_m >= CGAATT_ATTACH_MODE_INVALID )
344 {
345 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
346 return( AT_FAIL );
347 }
348
349 if ( det_m < CGAATT_DETACH_MODE_OMITTED || det_m >= CGAATT_DETACH_MODE_INVALID )
350 {
351 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
352 return( AT_FAIL );
353 }
354
355 if ( att_m EQ CGAATT_ATTACH_MODE_OMITTED )
356 att_m = automatic_attach_mode;
357
358 if ( det_m EQ CGAATT_DETACH_MODE_OMITTED )
359 det_m = automatic_detach_mode;
360
361 /*
362 *-------------------------------------------------------------------
363 * set parameter
364 *-------------------------------------------------------------------
365 */
366
367 automatic_attach_mode = att_m;
368 automatic_detach_mode = det_m;
369
370 return AT_CMPL;
371 }
372
373 /*
374 +--------------------------------------------------------------------+
375 | PROJECT : GPRS (8441) MODULE : CMH_GMMQ |
376 | STATE : finished ROUTINE : sAT_PercentCGMM |
377 +--------------------------------------------------------------------+
378
379 PURPOSE : This command configurates GMM.
380 CIPHER_ON = 1 / OFF = 0
381 TLLI_TWICE = 1 / STANDARD = 0
382 */
383
384 GLOBAL T_ACI_RETURN sAT_PercentCGMM ( T_ACI_CMD_SRC srcId, UBYTE cipher_on,
385 UBYTE tlli_handling )
386 {
387 TRACE_FUNCTION ("sAT_PercentCGMM()");
388
389 /*
390 *-------------------------------------------------------------------
391 * check entity status
392 *-------------------------------------------------------------------
393 */
394 if( gmmEntStat.curCmd NEQ AT_CMD_NONE )
395
396 return( AT_BUSY );
397
398 /*
399 *-------------------------------------------------------------------
400 * check command arguments
401 *-------------------------------------------------------------------
402 */
403 if ( cipher_on NEQ 1 /*GMMREG_CIPHER_ON*/
404 AND cipher_on NEQ 0 /*GMMREG_CIPHER_OFF*/ )
405 {
406 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
407 return( AT_FAIL );
408 }
409
410 if ( tlli_handling NEQ GMMREG_TLLI_STANDARD
411 AND tlli_handling NEQ GMMREG_TLLI_TWICE )
412 {
413 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
414 return( AT_FAIL );
415 }
416
417 /* default value for tlli_handling */
418 if ( tlli_handling EQ NOT_PRESENT_8BIT )
419 tlli_handling = GMMREG_TLLI_STANDARD;
420
421 psaGMM_Config_req( cipher_on, tlli_handling );
422 return AT_CMPL;
423 }
424
425 /*
426 +--------------------------------------------------------------------+
427 | PROJECT : GPRS (8441) MODULE : CMH_GMMQ |
428 | STATE : finished ROUTINE : sAT_PlusCGCLASS |
429 +--------------------------------------------------------------------+
430
431 PURPOSE : This is the functional counterpart to the %CGCLASS= GPRS AT
432 command which sets the specified GPRS mobile class.
433 */
434
435 GLOBAL T_ACI_RETURN sAT_PercentCGCLASS ( T_ACI_CMD_SRC srcId, T_PERCENT_CGCLASS m_class )
436 {
437 USHORT mobile_class;
438
439 TRACE_FUNCTION ("sAT_PercentCGCLASS()");
440
441 /*
442 *-------------------------------------------------------------------
443 * check command source
444 *-------------------------------------------------------------------
445 */
446 if(!cmh_IsVldCmdSrc (srcId))
447 {
448 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
449 return( AT_FAIL );
450 }
451
452 /*
453 *-------------------------------------------------------------------
454 * check entity status
455 *-------------------------------------------------------------------
456 */
457 if( gmmEntStat.curCmd NEQ AT_CMD_NONE )
458
459 return( AT_BUSY );
460
461 if (pb_get_fdn_mode () EQ FDN_ENABLE && m_class NEQ PERCENT_CGCLASS_CC)
462 {
463 if (pb_check_fdn (0, (const UBYTE *)"*99#") NEQ PHB_OK)
464 {
465 TRACE_EVENT("sAT_PercentCGCLASS: Entry not found in FDN, GPRS not allowed.");
466 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow);
467 return (AT_FAIL);
468 }
469 TRACE_EVENT("sAT_PercentCGCLASS: Entry found in FDN, GPRS allowed.");
470 }
471
472 /*
473 *-------------------------------------------------------------------
474 * process parameter
475 *-------------------------------------------------------------------
476 */
477 switch ( m_class )
478 {
479 case PERCENT_CGCLASS_A: /* mobile class A (highest) */
480 mobile_class = GMMREG_CLASS_A;
481 break;
482 case PERCENT_CGCLASS_B: /* mobile class B */
483 mobile_class = GMMREG_CLASS_B;
484 break;
485 case PERCENT_CGCLASS_BG: /* mobile class BG */
486 mobile_class = GMMREG_CLASS_BG;
487 break;
488 case PERCENT_CGCLASS_BC: /* mobile class BC */
489 mobile_class = GMMREG_CLASS_BC;
490 break;
491 case PERCENT_CGCLASS_BX: /* mobile class BX */
492 mobile_class = cmhSM_isContextActive() ? GMMREG_CLASS_BG : GMMREG_CLASS_BC;
493 break;
494 case PERCENT_CGCLASS_CG: /* mobile class CG (GPRS only mode) */
495 mobile_class = GMMREG_CLASS_CG;
496 break;
497 case PERCENT_CGCLASS_CC: /* mobile class CC (circuit switched only mode - lowest) */
498 mobile_class = GMMREG_CLASS_CC;
499 break;
500 case PERCENT_CGCLASS_OMITTED:
501 mobile_class = gmmShrdPrm.mobile_class;
502 break;
503 case PERCENT_CGCLASS_MAX:
504 default: /*bad user command */
505 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
506 return AT_FAIL;
507 }
508
509 gmmEntStat.entOwn = srcId;
510 gmmEntStat.curCmd = AT_CMD_CGCLASS;
511
512 gaciMobileClass.requested = m_class;
513
514 return cmhGMM_attach((UBYTE) mobile_class );
515 }
516
517 #endif /* GPRS */
518 /*==== EOF ========================================================*/