comparison gsm-fw/g23m-aci/aci/psa_smsp.c @ 775:eedbf248bac0

gsm-fw/g23m-aci subtree: initial import from LoCosto source
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 12 Oct 2014 01:45:14 +0000
parents
children d976884e0b07
comparison
equal deleted inserted replaced
774:40a721fd9854 775:eedbf248bac0
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : PSA_SMSP
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 defines the processing functions for the
18 | primitives send to the protocol stack adapter by
19 | short message service.
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef PSA_SMSP_C
24 #define PSA_SMSP_C
25 #endif
26
27 #include "aci_all.h"
28
29 /*==== INCLUDES ===================================================*/
30 #include "aci_cmh.h"
31 #include "ati_cmd.h"
32 #include "aci_cmd.h"
33
34
35 #ifdef FAX_AND_DATA
36 #include "aci_fd.h"
37 #endif /* of #ifdef FAX_AND_DATA */
38
39 #include "aci.h"
40 #include "psa.h"
41 #include "psa_sms.h"
42 #include "cmh.h"
43 #include "cmh_sms.h"
44 #include "aoc.h"
45 #ifdef SIM_PERS
46 #include "general.h" // inluded for UINT8 compilation error in sec_drv.h
47 #include "sec_drv.h"
48 #include "aci_ext_pers.h"
49 #include "aci_slock.h"
50 #endif
51
52 #ifdef GPRS
53 #include "dti.h"
54 #include "dti_conn_mng.h"
55 #include "dti_cntrl_mng.h"
56 #include "gaci.h"
57 #include "gaci_cmh.h"
58 #include "psa_sm.h"
59
60 #include "cmh_sm.h"
61 #endif /* GPRS */
62 /*==== CONSTANTS ==================================================*/
63
64
65 /*==== TYPES ======================================================*/
66
67
68 /*==== EXPORT =====================================================*/
69
70
71 /*==== VARIABLES ==================================================*/
72 #ifndef PIN_LEN
73 #define PIN_LEN (8)
74 #endif
75 #ifdef SIM_PERS_OTA
76 #define CTRL_KEY_LEN (PIN_LEN+1)
77 #define SMS_DATA_IDX 41
78 #define IMEI_DATA_IDX 73
79
80 EXTERN T_SEC_DRV_CONFIGURATION *cfg_data ;
81 #endif
82
83 /*==== FUNCTIONS ==================================================*/
84 #ifdef SIM_PERS_OTA
85 void psa_mnsms_OTA_decode_ind ( T_MNSMS_OTA_MESSAGE_IND * );
86 #endif
87 /*
88 +-------------------------------------------------------------------+
89 | PROJECT : GSM-PS (6147) MODULE : PSA_SMSP |
90 | ROUTINE : psa_mnsms_message_ind |
91 +-------------------------------------------------------------------+
92
93 PURPOSE : processes the MNSMS_MESSAGE_IND primitive send by SMS.
94 this indicates an incoming SMS.
95
96 */
97
98 GLOBAL void psa_mnsms_message_ind
99 ( T_MNSMS_MESSAGE_IND *mnsms_message_ind )
100 {
101 /* (was psa_mnsms_alert_ind) */
102 TRACE_FUNCTION ("psa_mnsms_message_ind()");
103
104
105 if (smsShrdPrm.smsStat EQ SMS_STATE_INITIALISING)
106 {
107 TRACE_FUNCTION ("SMS_STATE_INITIALISING");
108 cmhSMS_SMSInitState(mnsms_message_ind);
109 }
110 else
111 {
112 #ifdef FF_CPHS_REL4
113 if(!cmhSMS_chk_SpclMsg( mnsms_message_ind ))
114 {
115 #endif
116 if (mnsms_message_ind->rec_num EQ SMS_RECORD_NOT_EXIST)
117 {
118 #ifdef FF_CPHS
119 if ( !cmhSMS_voice_mail_ind( &(mnsms_message_ind->sms_sdu)) )
120 #endif /* FF_CPHS */
121 cmhSMS_SMSDeliver (mnsms_message_ind);
122 }
123 else
124 {
125 /*
126 * Incoming SMS may modify the Advice of Charge Parameters
127 *
128 * Read them again
129 */
130 aoc_sms ();
131
132 #ifdef FF_CPHS
133 cmhSMS_voice_mail_ind( &(mnsms_message_ind->sms_sdu));
134 #endif /* FF_CPHS */
135 cmhSMS_SMSMemory (mnsms_message_ind);
136 }
137 #ifdef FF_CPHS_REL4
138 }
139 #endif
140 }
141 /*
142 *-------------------------------------------------------------------
143 * free the primitive buffer
144 *-------------------------------------------------------------------
145 */
146 PFREE (mnsms_message_ind);
147 }
148
149 /*
150 +-------------------------------------------------------------------+
151 | PROJECT : GSM-PS (6147) MODULE : PSA_SMSP |
152 | ROUTINE : psa_mnsms_report_ind |
153 +-------------------------------------------------------------------+
154
155 PURPOSE : processes the MNSMS_REPORT_IND primitive send by SMS.
156 this indicates the state of the SMS Entity.
157
158 */
159
160 GLOBAL void psa_mnsms_report_ind
161 ( T_MNSMS_REPORT_IND *mnsms_report_ind )
162 {
163
164 TRACE_FUNCTION ("psa_mnsms_report_ind()");
165
166 cmhSMS_Result(mnsms_report_ind);
167
168 /*
169 *-------------------------------------------------------------------
170 * free the primitive buffer
171 *-------------------------------------------------------------------
172 */
173 PFREE (mnsms_report_ind);
174
175 }
176
177 /*
178 +-------------------------------------------------------------------+
179 | PROJECT : GSM-PS (6147) MODULE : PSA_SMSP |
180 | ROUTINE : psa_mnsms_status_ind |
181 +-------------------------------------------------------------------+
182
183 PURPOSE : processes the MNSMS_STATUS_IND primitive send by SMS.
184 this indicates an incoming SMS status message.
185
186 */
187
188 GLOBAL void psa_mnsms_status_ind ( T_MNSMS_STATUS_IND *mnsms_status_ind )
189 {
190 TRACE_FUNCTION ("psa_mnsms_status_ind()");
191
192 cmhSMS_SMSStatRpt (mnsms_status_ind);
193
194 /*
195 *-------------------------------------------------------------------
196 * free the primitive buffer
197 *-------------------------------------------------------------------
198 */
199 PFREE (mnsms_status_ind);
200 }
201
202 /*
203 +-------------------------------------------------------------------+
204 | PROJECT : GSM-PS (6147) MODULE : PSA_SMSP |
205 | ROUTINE : psa_mnsms_delete_cnf |
206 +-------------------------------------------------------------------+
207
208 PURPOSE : processes the MNSMS_DELETE_CNF primitive send by SMS.
209
210 */
211
212 GLOBAL void psa_mnsms_delete_cnf ( T_MNSMS_DELETE_CNF *mnsms_delete_cnf )
213 {
214 TRACE_FUNCTION ("psa_mnsms_delete_cnf()");
215
216 cmhSMS_SMSDelCnf (mnsms_delete_cnf);
217
218 /*
219 *-------------------------------------------------------------------
220 * free the primitive buffer
221 *-------------------------------------------------------------------
222 */
223 PFREE (mnsms_delete_cnf);
224 }
225
226 /*
227 +-------------------------------------------------------------------+
228 | PROJECT : GSM-PS (6147) MODULE : PSA_SMSP |
229 | ROUTINE : psa_mnsms_read_cnf |
230 +-------------------------------------------------------------------+
231
232 PURPOSE : processes the MNSMS_READ_CNF primitive send by SMS.
233
234 */
235
236 GLOBAL void psa_mnsms_read_cnf ( T_MNSMS_READ_CNF *mnsms_read_cnf )
237 {
238 TRACE_FUNCTION ("psa_mnsms_read_cnf()");
239
240 cmhSMS_SMRead (mnsms_read_cnf);
241
242 /*
243 *-------------------------------------------------------------------
244 * free the primitive buffer
245 *-------------------------------------------------------------------
246 */
247 PFREE (mnsms_read_cnf);
248 }
249
250 /*
251 +-------------------------------------------------------------------+
252 | PROJECT : GSM-PS (6147) MODULE : PSA_SMSP |
253 | ROUTINE : psa_mnsms_store_cnf |
254 +-------------------------------------------------------------------+
255
256 PURPOSE : processes the MNSMS_STORE_CNF primitive send by SMS.
257
258 */
259
260 GLOBAL void psa_mnsms_store_cnf ( T_MNSMS_STORE_CNF *mnsms_store_cnf )
261 {
262 TRACE_FUNCTION ("psa_mnsms_store_cnf()");
263
264 cmhSMS_SMSStoCnf(mnsms_store_cnf);
265
266 /*
267 *-------------------------------------------------------------------
268 * free the primitive buffer
269 *-------------------------------------------------------------------
270 */
271 PFREE (mnsms_store_cnf);
272 }
273
274 /*
275 +-------------------------------------------------------------------+
276 | PROJECT : GSM-PS (6147) MODULE : PSA_SMSP |
277 | ROUTINE : psa_mnsms_submit_cnf |
278 +-------------------------------------------------------------------+
279
280 PURPOSE : processes the MNSMS_SUBMIT_CNF primitive send by SMS.
281
282 */
283
284 GLOBAL void psa_mnsms_submit_cnf ( T_MNSMS_SUBMIT_CNF *mnsms_submit_cnf )
285 {
286 TRACE_FUNCTION ("psa_mnsms_submit_cnf()");
287
288 cmhSMS_SMSSbmCnf(mnsms_submit_cnf);
289
290 /*
291 *-------------------------------------------------------------------
292 * free the primitive buffer
293 *-------------------------------------------------------------------
294 */
295 PFREE (mnsms_submit_cnf);
296 }
297
298 /*
299 +-------------------------------------------------------------------+
300 | PROJECT : GSM-PS (6147) MODULE : PSA_SMSP |
301 | ROUTINE : psa_mnsms_command_cnf |
302 +-------------------------------------------------------------------+
303
304 PURPOSE : processes the MNSMS_COMMAND_CNF primitive send by SMS.
305
306 */
307
308 GLOBAL void psa_mnsms_command_cnf ( T_MNSMS_COMMAND_CNF *mnsms_command_cnf )
309 {
310 TRACE_FUNCTION ("psa_mnsms_command_cnf()");
311
312 cmhSMS_SMSCmdCnf(mnsms_command_cnf);
313
314 /*
315 *-------------------------------------------------------------------
316 * free the primitive buffer
317 *-------------------------------------------------------------------
318 */
319 PFREE (mnsms_command_cnf);
320 }
321
322 /*
323 +-------------------------------------------------------------------+
324 | PROJECT : GSM-PS (6147) MODULE : PSA_SMSP |
325 | ROUTINE : psa_mnsms_error_ind |
326 +-------------------------------------------------------------------+
327
328 PURPOSE : processes the MNSMS_ERROR_IND primitive send by SMS.
329
330 */
331
332 GLOBAL void psa_mnsms_error_ind ( T_MNSMS_ERROR_IND *mnsms_error_ind )
333 {
334 TRACE_FUNCTION ("psa_mnsms_error_ind()");
335
336 cmhSMS_SMSErrorInd(mnsms_error_ind);
337
338 /*
339 *-------------------------------------------------------------------
340 * free the primitive buffer
341 *-------------------------------------------------------------------
342 */
343 PFREE (mnsms_error_ind);
344 }
345
346 #ifdef TI_PS_FF_AT_P_CMD_CPRSM
347 /*
348 +-------------------------------------------------------------------+
349 | PROJECT : GSM-PS (6147) MODULE : PSA_SMSP |
350 | ROUTINE : psa_mnsms_resume_cnf |
351 +-------------------------------------------------------------------+
352
353 PURPOSE : processes the MNSMS_RESUME_CNF primitive send by SMS.
354 This confirms that the receiving of has been SMS is
355 activated.
356
357 */
358
359 GLOBAL void psa_mnsms_resume_cnf ( T_MNSMS_RESUME_CNF *mnsms_resume_cnf )
360 {
361 TRACE_FUNCTION ("psa_mnsms_resume_cnf()");
362
363 /* inform command handler */
364 cmhSMS_SMSResumeCnf(mnsms_resume_cnf);
365
366 /*
367 *-------------------------------------------------------------------
368 * free the primitive buffer
369 *-------------------------------------------------------------------
370 */
371 PFREE(mnsms_resume_cnf);
372 }
373
374 /*
375 +-------------------------------------------------------------------+
376 | PROJECT : GSM-PS (6147) MODULE : PSA_SMSP |
377 | ROUTINE : psa_mnsms_query_cnf |
378 +-------------------------------------------------------------------+
379
380 PURPOSE : processes the MNSMS_TEST_CNF primitive send by SMS.
381 This confirms that the receiving of has been SMS is
382 activated.
383
384 */
385
386 GLOBAL void psa_mnsms_query_cnf ( T_MNSMS_QUERY_CNF *mnsms_query_cnf)
387 {
388 TRACE_FUNCTION ("psa_mnsms_query_cnf()");
389
390 /* inform command handler */
391 cmhSMS_SMSQueryCnf( mnsms_query_cnf );
392
393 /*
394 *-------------------------------------------------------------------
395 * free the primitive buffer
396 *-------------------------------------------------------------------
397 */
398 PFREE(mnsms_query_cnf);
399 }
400 #endif /* TI_PS_FF_AT_P_CMD_RDLB */
401
402 #if defined (GPRS) AND defined (DTI)
403 /*
404 +-------------------------------------------------------------------+
405 | PROJECT : GSM-PS (6147) MODULE : PSA_SMSP |
406 | ROUTINE : psa_mnsms_info_cnf |
407 +-------------------------------------------------------------------+
408
409 PURPOSE : processes the MNSMS_MO_SERV_CNF primitive send by SMS.
410 this confirms the requested SMS message service.
411
412 */
413
414 GLOBAL void psa_mnsms_mo_serv_cnf
415 ( T_MNSMS_MO_SERV_CNF *mnsms_mo_serv_cnf )
416 {
417
418 TRACE_FUNCTION ("psa_mnsms_mo_serv_cnf()");
419
420 /*
421 *-------------------------------------------------------------------
422 * update sms parameters and notify ACI
423 *-------------------------------------------------------------------
424 */
425
426 cmhSM_sms_service_changed( mnsms_mo_serv_cnf->mo_sms_serv );
427
428 /*
429 *-------------------------------------------------------------------
430 * free the primitive buffer
431 *-------------------------------------------------------------------
432 */
433 PFREE (mnsms_mo_serv_cnf);
434
435 }
436 #endif /* GPRS */
437
438 GLOBAL void psa_mnsms_OTA_message_ind ( T_MNSMS_OTA_MESSAGE_IND *mnsms_ota_message_ind )
439 {
440 switch (mnsms_ota_message_ind->tp_pid)
441 {
442 #ifdef SIM_PERS_OTA
443 case ACI_PID_ME_DEPERSON :
444 psa_mnsms_OTA_decode_ind(mnsms_ota_message_ind);
445 break;
446 #endif
447 default: TRACE_ERROR ("INVALID PID");
448 break ;
449 }
450 }
451
452 #ifdef SIM_PERS_OTA
453
454 /*
455 +------------------------------------------------------------------------------
456 | Function : psa_mnsms_OTA_decode_ind
457 +------------------------------------------------------------------------------
458 | Description : processes the MNSMS_OTA_DECODE_IND primitive
459 |
460 | Parameters : mnsms_ota_decode_ind - primitive
461 |
462 | Return : void
463 |
464 +------------------------------------------------------------------------------
465 */
466
467 void psa_mnsms_OTA_decode_ind ( T_MNSMS_OTA_MESSAGE_IND *mnsms_ota_message_ind )
468 {
469 T_SIMLOCK_TYPE lcktype;
470 UBYTE ctrl_key[CTRL_KEY_LEN];
471 UBYTE mismatch_key[CTRL_KEY_LEN] = {0x46,0x46,0x46,0x46,0x46,0x46,0x46,0x46,0};
472 UBYTE imei[16];
473 UBYTE imeiBufPtrd[CL_IMEI_SIZE], imeiBufPtrc[16];
474 UBYTE data[20];
475 T_ACI_SM_DATA sm_data;
476 UBYTE ret_status = 0;
477 T_SIMLOCK_STATUS status;
478 UINT i = 0,i2=0, ctr;
479
480 TRACE_FUNCTION ("psa_mnsms_OTA_decode_ind()");
481
482 if((mnsms_ota_message_ind->tp_ud.data NEQ NULL) AND (mnsms_ota_message_ind->tp_ud.length NEQ 0))
483 {
484 cmhSMS_expdSmsPp ( 0,
485 mnsms_ota_message_ind->tp_dcs,
486 mnsms_ota_message_ind->tp_ud.data,
487 mnsms_ota_message_ind->tp_ud.length,
488 sm_data .data,
489 &sm_data.len );
490
491 memcpy(imei , (sm_data.data+ IMEI_DATA_IDX-1),(CL_IMEI_SIZE*2));
492
493 cl_get_imeisv(CL_IMEI_SIZE, imeiBufPtrd, CL_IMEI_GET_STORED_IMEI);
494
495 for (i = 0, i2 = 0; i < CL_IMEI_SIZE; i++, i2+=2)
496 {
497 imeiBufPtrc[i2] = ((imeiBufPtrd[i] & 0xf0) >> 4) + '0' ;
498 imeiBufPtrc[i2+1] = (imeiBufPtrd[i] & 0x0f) + '0' ;
499 }
500 /* Compare 14 digits since 15th and 16th digits are SVN which is not known to NW (see TS 23.003 [3]) */
501 if(memcmp(imei,imeiBufPtrc,(CL_IMEI_SIZE*2)-2 ) EQ 0)
502 {
503 /*Extract the values from the SMS user data*/
504
505 memset(ctrl_key,0,CTRL_KEY_LEN);
506
507 aci_ext_personalisation_init();
508
509 for(lcktype=SIMLOCK_NETWORK,ctr=SMS_DATA_IDX-1; lcktype<=SIMLOCK_CORPORATE;lcktype++,ctr+=PIN_LEN)
510 {
511 strncpy ( (char *) ctrl_key, (char*)(sm_data.data +ctr), PIN_LEN);
512 ctrl_key[PIN_LEN] = '\0';
513 if (memcmp ((char *)ctrl_key,mismatch_key,PIN_LEN) EQ 0)
514 ret_status |= aci_ext_personalisation_get_status(lcktype);
515 else
516 {
517 status = aci_slock_unlock(lcktype, (char *) ctrl_key);
518 if( status EQ SIMLOCK_FAIL)
519 ret_status |= aci_ext_personalisation_get_status(lcktype);
520 else
521 ret_status |= status;
522 }
523 if(lcktype NEQ SIMLOCK_CORPORATE)
524 ret_status <<= 2;
525 }
526 aci_ext_personalisation_free();
527
528 }
529 else
530 ret_status = 0xff;
531
532
533 for (i=0;i<(CL_IMEI_SIZE*2);i++)
534 {
535 data[i] = imei[i];
536 }
537 data[15] = 0; /*As the IMEI is 15 digits long (see TS 23.003 [3]),
538 the sixteenth digit present here is ignored by the network during the
539 de-personalization procedure and should be set to zero.*/
540 data[16] = ((ret_status & 0xC0)>>6);
541 data[17]= ((ret_status & 0x30) >>4);
542 data[18]= ((ret_status & 0x0C) >> 2);
543 data[19]= ret_status & 0x03;
544
545 {
546 PALLOC (mnsms_OTA_message_res, MNSMS_OTA_MESSAGE_RES);
547 cmhSMS_rdcSmsPp ( 0,
548 mnsms_ota_message_ind->tp_dcs,
549 ( UBYTE * ) data, 20,
550 mnsms_OTA_message_res->data, &mnsms_OTA_message_res->packedlen); //Convert the Octets to septets
551 mnsms_OTA_message_res->tp_dcs = mnsms_ota_message_ind->tp_dcs ;
552 mnsms_OTA_message_res->len = 20;
553 #ifdef TI_PS_HCOMM_CHANGE
554 PSEND (_hCommSMS, mnsms_OTA_message_res);
555 #else
556 PSEND (hCommSMS, mnsms_OTA_message_res);
557 #endif
558 }
559 }
560 PFREE (mnsms_ota_message_ind);
561 }
562 #endif //SIM_PERS_OTA
563
564
565 /*
566 +-------------------------------------------------------------------+
567 | PROJECT : GSM-PS (6147) MODULE : PSA_SMSP |
568 | ROUTINE : psa_mnsms_retrans_cnf |
569 +-------------------------------------------------------------------+
570
571 PURPOSE : processes the MNSMS_RETRANS_CNF primitive send by SMS.
572
573 */
574 #ifdef REL99
575 GLOBAL void psa_mnsms_retrans_cnf ( T_MNSMS_RETRANS_CNF *mnsms_retrans_cnf )
576 {
577 TRACE_FUNCTION ("psa_mnsms_retrans_cnf()");
578
579 cmhSMS_SMSRetransCnf(mnsms_retrans_cnf);
580
581 /*
582 *-------------------------------------------------------------------
583 * free the primitive buffer
584 *-------------------------------------------------------------------
585 */
586 PFREE (mnsms_retrans_cnf);
587 }
588
589 /*
590 +-------------------------------------------------------------------+
591 | PROJECT : GSM-PS (6147) MODULE : PSA_SMSP |
592 | ROUTINE : psa_mnsms_send_prog_ind |
593 +-------------------------------------------------------------------+
594
595 PURPOSE : processes the MNSMS_SEND_PROG_IND primitive send by SMS.
596
597 */
598
599 GLOBAL void psa_mnsms_send_prog_ind ( T_MNSMS_SEND_PROG_IND *mnsms_send_prog_ind )
600 {
601 TRACE_FUNCTION ("psa_mnsms_send_prog_ind()");
602
603 cmhSMS_SMSSendProgInd(mnsms_send_prog_ind);
604
605 /*
606 *-------------------------------------------------------------------
607 * free the primitive buffer
608 *-------------------------------------------------------------------
609 */
610 PFREE (mnsms_send_prog_ind);
611 }
612 #endif /* REL99 */
613
614 /*==== EOF =========================================================*/