comparison g23m-aci/aci/psa_smsp.c @ 0:75a11d740a02

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