FreeCalypso > hg > freecalypso-citrine
comparison g23m-gsm/sms/sms_tlp.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-F&D (8411) | |
4 | Modul : SMS_TLP | |
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 transfer layer | |
18 | capability of the module Short Message Service. | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 #ifndef SMS_TLP_C | |
22 #define SMS_TLP_C | |
23 | |
24 #include "config.h" | |
25 #include "fixedconf.h" | |
26 #include "condat-features.h" | |
27 | |
28 #define ENTITY_SMS | |
29 | |
30 /*==== INCLUDES ===================================================*/ | |
31 | |
32 #include <string.h> | |
33 #include <stdlib.h> | |
34 #include <stddef.h> | |
35 #include "typedefs.h" | |
36 #include "pcm.h" | |
37 #include "vsi.h" | |
38 #include "custom.h" | |
39 #include "gsm.h" | |
40 #include "message.h" | |
41 #include "ccdapi.h" | |
42 #include "prim.h" | |
43 #include "cus_sms.h" | |
44 #include "cnf_sms.h" | |
45 #include "mon_sms.h" | |
46 #include "pei.h" | |
47 #include "tok.h" | |
48 #include "sms.h" | |
49 #include "gdi.h" | |
50 #include "sms_em.h" | |
51 | |
52 /*==== EXPORT =====================================================*/ | |
53 | |
54 /*==== PRIVAT =====================================================*/ | |
55 | |
56 /*==== VARIABLES ==================================================*/ | |
57 | |
58 /*==== TEST =======================================================*/ | |
59 | |
60 /*==== FUNCTIONS ==================================================*/ | |
61 | |
62 /* Implements Measure# 7 */ | |
63 /* | |
64 +------------------------------------------------------------------------------+ | |
65 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
66 | STATE : code ROUTINE : tl_sim_rd_record_update_state | | |
67 +------------------------------------------------------------------------------+ | |
68 | |
69 PURPOSE : This routine process primitive SIM_READ_RECORD_CONF for the | |
70 cases MMI_FIND_FIRST and MMI_FIND_NEXT | |
71 | |
72 */ | |
73 | |
74 LOCAL BOOL tl_sim_rd_record_update_state(T_SIM_READ_RECORD_CNF *read_cnf) | |
75 { | |
76 GET_INSTANCE_DATA; | |
77 TRACE_FUNCTION("tl_sim_rd_record_update_state()"); | |
78 | |
79 if ((GET_STATE(STATE_MMI) EQ MMI_FIND_FIRST | |
80 AND sms_data->sim_mem_update) | |
81 OR (GET_STATE(STATE_MMI) EQ MMI_STATE_UPDATE | |
82 AND sms_data->sim_mem_update)) | |
83 { | |
84 /* | |
85 * Either the SMS record has been changed or both the SMS record | |
86 * and the SMS status have been changed | |
87 */ | |
88 PFREE (read_cnf); | |
89 sms_data->stored_mmi_state = MMI_IDLE; | |
90 return TRUE; /* return; */ | |
91 } | |
92 else if (GET_STATE(STATE_MMI) EQ MMI_STATE_UPDATE) | |
93 { | |
94 /* | |
95 * Only SMS record's status has been changed. | |
96 */ | |
97 sms_data->stored_read_cnf = read_cnf; | |
98 return TRUE; /* return; */ | |
99 } | |
100 sms_data->stored_mmi_state = MMI_IDLE; | |
101 | |
102 return FALSE; | |
103 } | |
104 | |
105 | |
106 /* | |
107 +--------------------------------------------------------------------+ | |
108 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
109 | STATE : code ROUTINE : tl_init | | |
110 +--------------------------------------------------------------------+ | |
111 | |
112 PURPOSE : Initialize the transfer layer. | |
113 | |
114 */ | |
115 | |
116 GLOBAL void tl_init () | |
117 { | |
118 GET_INSTANCE_DATA; | |
119 | |
120 TRACE_FUNCTION ("tl_init()"); | |
121 | |
122 SMS_ENT_STATE(sms_data) = SMS_STATE_NOT_AVAILABLE; | |
123 | |
124 memset (sms_data->data, 0, sizeof (sms_data->data)); | |
125 | |
126 /* This is only for simulation tests*/ | |
127 sms_data->data[INST_MO].ti = 6; | |
128 | |
129 SMS_SIM_MEM_AVAIL(sms_data) = TRUE; | |
130 SMS_MEM_CFG(sms_data) = MEM_SM; | |
131 SMS_MT_HANDLING(sms_data) = MT_DEF; | |
132 SMS_ST_REPORT(sms_data) = DS0; | |
133 SMS_SIM_PHASE(sms_data) = PHASE_2_SIM; | |
134 SMS_MT_ACK_MODE(sms_data) = SMS_MHC_DEF; | |
135 SMS_NETWORK(sms_data) = NW_SIM_NONE; | |
136 | |
137 sms_data->init_done = FALSE; | |
138 | |
139 SMS_SIM_PROP(sms_data).status_field = sms_data->sim_status_field; | |
140 SMS_SIM_PROP(sms_data).pid_field = sms_data->sim_pid_field; | |
141 SMS_SIM_PROP(sms_data).mem_type = MEM_SM; | |
142 SMS_SIM_PROP(sms_data).max_record = 0; | |
143 SMS_SIM_PROP(sms_data).any_valid = FALSE; | |
144 /* SMS_ME_PROP(sms_data).status_and_pid = sms_data->me_status_field; */ | |
145 /* SMS_ME_PROP(sms_data).status_and_pid = sms_data->me_pid_field; */ | |
146 SMS_ME_PROP(sms_data).status_field = NULL; | |
147 SMS_ME_PROP(sms_data).pid_field = NULL; | |
148 SMS_ME_PROP(sms_data).mem_type = MEM_ME; | |
149 SMS_ME_PROP(sms_data).max_record = 0; | |
150 SMS_ME_PROP(sms_data).any_valid = FALSE; | |
151 sms_data->sim_mem_update = FALSE; | |
152 #ifdef SIM_TOOLKIT | |
153 sms_data->download_sms = FALSE; | |
154 sms_data->file_update_ind = NULL; | |
155 sms_data->stored_mmi_state = MMI_IDLE; | |
156 sms_data->stored_read_cnf = NULL; | |
157 #endif | |
158 SMS_RP_RCVD(sms_data) = NULL; | |
159 #ifdef FF_CPHS | |
160 SMS_CPHS(sms_data) = FALSE; | |
161 #endif | |
162 #ifdef GPRS | |
163 SMS_ROUTE_PREF(sms_data) = GPRS_SMS_CCT_ONLY; | |
164 #endif | |
165 sms_data->pr_cntrl.delivery_state = SMS_DELIVER_STATUS_RESUME; | |
166 sms_data->concat_cntrl.concatenation = FALSE; | |
167 } | |
168 | |
169 /* | |
170 +--------------------------------------------------------------------+ | |
171 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
172 | STATE : code ROUTINE : tl_sim_abort_to_mmi | | |
173 +--------------------------------------------------------------------+ | |
174 | |
175 PURPOSE : Abort a SIM related SMS command to MMI. | |
176 | |
177 */ | |
178 | |
179 LOCAL void tl_sim_abort_to_mmi (USHORT error) | |
180 { | |
181 GET_INSTANCE_DATA; | |
182 switch (GET_STATE (STATE_MMI)) | |
183 { | |
184 case MMI_REPLACE: | |
185 #ifdef REL99 | |
186 if(SMS_INST.failed_msg_retx EQ FALSE) | |
187 { | |
188 #endif | |
189 | |
190 tl_mnsms_submit_cnf (SMS_INST.act_mem, SMS_INST.act_record, | |
191 SMS_INST.tp_mr_ret, error, NULL); | |
192 #ifdef REL99 | |
193 } | |
194 else | |
195 { | |
196 tl_mnsms_retrans_cnf (SMS_INST.act_mem, SMS_INST.act_record, | |
197 SMS_INST.tp_mr_ret, error, NULL); | |
198 } | |
199 #endif | |
200 break; | |
201 case MMI_READ: | |
202 tl_mnsms_read_cnf (SMS_INST.act_mem, | |
203 SMS_INST.act_record, NULL, error); | |
204 break; | |
205 case MMI_WRITE: | |
206 tl_mnsms_store_cnf (SMS_INST.act_mem, SMS_INST.act_record, error); | |
207 break; | |
208 case MMI_DELETE: | |
209 tl_mnsms_delete_cnf (SMS_INST.act_mem, SMS_INST.act_record, 0, error); | |
210 break; | |
211 default: | |
212 break; | |
213 } | |
214 if (sms_data->access_fifo[1] EQ ACCESS_BY_MMI) | |
215 { | |
216 sms_data->access_fifo[1] = ACCESS_EMPTY; | |
217 } | |
218 else if (sms_data->access_fifo[0] EQ ACCESS_BY_MMI) | |
219 { | |
220 sms_data->access_fifo[0] = ACCESS_EMPTY; | |
221 } | |
222 SET_STATE (STATE_MMI, MMI_IDLE); | |
223 #ifdef SIM_TOOLKIT | |
224 if (sms_data->file_update_ind NEQ NULL) | |
225 { | |
226 T_SIM_FILE_UPDATE_IND *file_update_ind = sms_data->file_update_ind; | |
227 sms_data->file_update_ind = NULL; | |
228 tl_sim_file_update_ind (file_update_ind); | |
229 } | |
230 if (sms_data->stored_read_cnf NEQ NULL) | |
231 { | |
232 /* | |
233 * Resets the stored MMI state & read_cnf primitive | |
234 */ | |
235 sms_data->stored_mmi_state = MMI_IDLE; | |
236 PFREE (sms_data->stored_read_cnf); | |
237 sms_data->stored_read_cnf = NULL; | |
238 } | |
239 #endif | |
240 } | |
241 | |
242 /*---- PRIMITIVES --------------------------------------------------*/ | |
243 | |
244 /* | |
245 +--------------------------------------------------------------------+ | |
246 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
247 | STATE : code ROUTINE : tl_mnsms_configure_req | | |
248 +--------------------------------------------------------------------+ | |
249 | |
250 PURPOSE : Process the primitive MNSMS_CONFIGURE_REQ. | |
251 | |
252 */ | |
253 | |
254 GLOBAL void tl_mnsms_configure_req (T_MNSMS_CONFIGURE_REQ *configure_req) | |
255 { | |
256 register T_SMS_DATA *sms_data = GET_SMS_INSTANCE (0); | |
257 | |
258 TRACE_FUNCTION ("tl_mnsms_configure_req()"); | |
259 | |
260 if (sms_data) | |
261 { | |
262 sms_data->mem3 = configure_req->pref_mem_3; | |
263 sms_data->mt = (configure_req->mt < MT_DEF)? configure_req->mt: | |
264 MT_DEF; | |
265 sms_data->ds = configure_req->ds; | |
266 sms_data->mhc = configure_req->mhc; | |
267 | |
268 /* | |
269 * If CMMS mode is enabled, store the current value of cmms_mode in sms_data | |
270 */ | |
271 if(configure_req->v_cmms_mode) | |
272 { | |
273 sms_data->cmms_mode = configure_req->cmms_mode; | |
274 } | |
275 | |
276 /* | |
277 * For CMMS if user has set the value for TMMS timer then store that | |
278 * value in sms_data | |
279 */ | |
280 if(configure_req->v_tmms_val) | |
281 { | |
282 sms_data->timer_values[TMMS] = configure_req->tmms_val; | |
283 } | |
284 } | |
285 PFREE (configure_req); | |
286 } | |
287 | |
288 /* | |
289 +--------------------------------------------------------------------+ | |
290 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
291 | STATE : code ROUTINE : tl_mnsms_mo_serv_req | | |
292 +--------------------------------------------------------------------+ | |
293 | |
294 PURPOSE : Process the primitive MNSMS_MO_SERV_REQ. | |
295 (set preferred destination (GPRS/GSM) for MO SM) | |
296 | |
297 */ | |
298 #if defined GPRS | |
299 GLOBAL void tl_mnsms_mo_serv_req (T_MNSMS_MO_SERV_REQ *mo_serv_req) | |
300 { | |
301 GET_INSTANCE_DATA; | |
302 | |
303 TRACE_FUNCTION ("tl_mnsms_mo_serv_req()"); | |
304 /* | |
305 * send MNSMS_MO_SERV_CNF with configured pref. dst | |
306 */ | |
307 { | |
308 PALLOC (mo_serv_cnf, MNSMS_MO_SERV_CNF); | |
309 memset (mo_serv_cnf, 0, sizeof (T_MNSMS_MO_SERV_CNF)); | |
310 | |
311 if (sms_data) /*lint !e774 always True*/ | |
312 { | |
313 sms_data->mo_dst_pref = mo_serv_req->mo_sms_serv; | |
314 mo_serv_cnf->mo_sms_serv = sms_data->mo_dst_pref; | |
315 | |
316 TRACE_EVENT_P1("MO Path: %d", sms_data->mo_dst_pref); | |
317 } | |
318 else | |
319 { | |
320 mo_serv_cnf->mo_sms_serv = NOT_PRESENT_8BIT; | |
321 } | |
322 PSENDX (MMI, mo_serv_cnf); | |
323 } | |
324 PFREE (mo_serv_req); | |
325 } | |
326 #endif /* GPRS */ | |
327 | |
328 /* | |
329 +--------------------------------------------------------------------+ | |
330 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
331 | STATE : code ROUTINE : tl_mnsms_command_cnf | | |
332 +--------------------------------------------------------------------+ | |
333 | |
334 PURPOSE : Generate a response to the primitive MNSMS_COMMAND_REQ. | |
335 */ | |
336 | |
337 GLOBAL void tl_mnsms_command_cnf (UBYTE tp_mr, | |
338 USHORT cause, | |
339 T_sms_sdu *sms_sdu) | |
340 { | |
341 PALLOC (command_cnf, MNSMS_COMMAND_CNF); | |
342 | |
343 command_cnf->tp_mr = tp_mr; | |
344 command_cnf->cause = cause; | |
345 | |
346 if (sms_sdu NEQ NULL) | |
347 memcpy (&command_cnf->sms_sdu, sms_sdu, sizeof (T_sms_sdu)); | |
348 else | |
349 memset (&command_cnf->sms_sdu, 0, sizeof (T_sms_sdu)); | |
350 | |
351 PSENDX (MMI, command_cnf); | |
352 } | |
353 | |
354 /* | |
355 +--------------------------------------------------------------------+ | |
356 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
357 | STATE : code ROUTINE : tl_mnsms_command_req | | |
358 +--------------------------------------------------------------------+ | |
359 | |
360 PURPOSE : Process the primitive MNSMS_COMMAND_REQ. | |
361 | |
362 */ | |
363 | |
364 GLOBAL void tl_mnsms_command_req (T_MNSMS_COMMAND_REQ *command_req) | |
365 { | |
366 register T_SMS_DATA *sms_data = GET_SMS_INSTANCE (0); | |
367 | |
368 TRACE_FUNCTION ("tl_mnsms_command_req()"); | |
369 | |
370 if (sms_data) | |
371 { | |
372 switch (SMS_INST_GET_STATE (STATE_TL)) | |
373 { | |
374 case TL_IDLE: | |
375 if (sms_timer_check(TRAM)) | |
376 { | |
377 tl_mnsms_command_cnf (NOT_PRESENT_8BIT, SMS_CAUSE_ENTITY_BUSY, NULL); | |
378 } | |
379 else | |
380 { | |
381 #ifdef REL99 | |
382 SMS_INST.failed_msg_retx = FALSE; | |
383 if(command_req->auto_rep_flag EQ AUTO_REP_FLAG_ENABLED) | |
384 { | |
385 SMS_INST.tl_retx = 0; | |
386 } | |
387 else | |
388 { | |
389 /* Set to the max value so that retransmission will not be done */ | |
390 SMS_INST.tl_retx = TL_MAX_RETANS; | |
391 } | |
392 #endif | |
393 /* | |
394 * save sdu | |
395 */ | |
396 if (SMS_SDU(sms_data) NEQ NULL) | |
397 { | |
398 MFREE (SMS_SDU(sms_data)); | |
399 } | |
400 MALLOC (SMS_SDU(sms_data), sizeof(T_sms_sdu)); | |
401 memcpy (SMS_SDU(sms_data), &command_req->sms_sdu, sizeof(T_sms_sdu)); | |
402 /* | |
403 * TL state transition TL_ESTABLISH | |
404 * EST state transition EST_CMD | |
405 */ | |
406 SMS_INST_SET_STATE (STATE_TL, TL_ESTABLISH); | |
407 SET_STATE (STATE_EST, EST_CMD); | |
408 /* | |
409 * establish connection | |
410 */ | |
411 tl_establish_connection(TRUE); | |
412 } | |
413 break; | |
414 | |
415 default: | |
416 tl_mnsms_command_cnf (NOT_PRESENT_8BIT, SMS_CAUSE_ENTITY_BUSY, NULL); | |
417 } | |
418 } | |
419 else | |
420 { | |
421 tl_mnsms_command_cnf (NOT_PRESENT_8BIT, SMS_CAUSE_ENTITY_BUSY, NULL); | |
422 } | |
423 PFREE (command_req); | |
424 } | |
425 | |
426 /* | |
427 +--------------------------------------------------------------------+ | |
428 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
429 | STATE : code ROUTINE : tl_mnsms_delete_cnf | | |
430 +--------------------------------------------------------------------+ | |
431 | |
432 PURPOSE : Generate a response to the primitive MNSMS_DELETE_REQ. | |
433 */ | |
434 | |
435 GLOBAL void tl_mnsms_delete_cnf (UBYTE mem_type, | |
436 UBYTE record, | |
437 UBYTE next_rec, | |
438 USHORT error) | |
439 { | |
440 PALLOC (delete_cnf, MNSMS_DELETE_CNF); | |
441 | |
442 delete_cnf->mem_type = mem_type; | |
443 delete_cnf->rec_num = record; | |
444 delete_cnf->cause = error; | |
445 delete_cnf->delete_rec_next = next_rec; | |
446 | |
447 SMS_EM_DELETE_SHORT_MESSAGE; | |
448 | |
449 PSENDX (MMI, delete_cnf); | |
450 } | |
451 | |
452 /* | |
453 +--------------------------------------------------------------------+ | |
454 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
455 | STATE : code ROUTINE : tl_mnsms_delete_req | | |
456 +--------------------------------------------------------------------+ | |
457 | |
458 PURPOSE : Process the primitive MNSMS_DELETE_REQ. | |
459 | |
460 */ | |
461 | |
462 GLOBAL void tl_mnsms_delete_req (T_MNSMS_DELETE_REQ *delete_req) | |
463 { | |
464 register T_SMS_DATA *sms_data = GET_SMS_INSTANCE(0); | |
465 UBYTE rec_num; | |
466 | |
467 TRACE_FUNCTION ("tl_mnsms_delete_req()"); | |
468 | |
469 #ifdef REL99 | |
470 /* Check if the last failed message is getting deleted */ | |
471 if( ( delete_req->rec_num EQ SMS_INST.failed_msg_rec_num) AND | |
472 ( delete_req->mem_type EQ SMS_INST.failed_msg_mem ) AND | |
473 SMS_DATA_REQ(sms_data) NEQ NULL ) | |
474 { | |
475 PFREE (SMS_DATA_REQ(sms_data)); | |
476 SMS_DATA_REQ(sms_data) = NULL; | |
477 } | |
478 #endif | |
479 | |
480 if (sms_data NEQ NULL) | |
481 { | |
482 switch (SMS_INST_GET_STATE (STATE_TL)) | |
483 { | |
484 case TL_IDLE: | |
485 switch (delete_req->mem_type) | |
486 { | |
487 case MEM_ME: | |
488 /* | |
489 * Mobile Equipment Memory | |
490 */ | |
491 if(delete_req->delete_status NEQ CMGD_DEL_INDEX) | |
492 { | |
493 if(delete_req->rec_num EQ 0) | |
494 { | |
495 /* Status value is given. Find the first record satisfying this status value */ | |
496 rec_num = tl_search_record_for_delete (&SMS_ME_PROP(sms_data), 1, | |
497 delete_req->delete_status); | |
498 if(rec_num EQ SMS_RECORD_NOT_EXIST) | |
499 { | |
500 tl_mnsms_delete_cnf (delete_req->mem_type, 0, 0, SIM_NO_ERROR); | |
501 break; | |
502 } | |
503 } | |
504 else | |
505 { | |
506 if(delete_req->rec_num > sms_data->me_backup.max_record) | |
507 { | |
508 tl_mnsms_delete_cnf (delete_req->mem_type, delete_req->rec_num, 0, | |
509 (USHORT)((SMS_ME_PROP(sms_data).max_record EQ 0)? | |
510 SMS_CAUSE_MEM_FAIL: SMS_CAUSE_INV_INDEX)); | |
511 break; | |
512 } | |
513 else | |
514 { | |
515 /* Use the record number that ACI has given */ | |
516 rec_num = delete_req->rec_num; | |
517 } | |
518 } | |
519 } | |
520 else | |
521 { | |
522 /* There should be a valid rec_num */ | |
523 if(delete_req->rec_num EQ 0 || delete_req->rec_num > sms_data->me_backup.max_record) | |
524 { | |
525 tl_mnsms_delete_cnf (delete_req->mem_type, delete_req->rec_num, 0, | |
526 (USHORT)((SMS_ME_PROP(sms_data).max_record EQ 0)? | |
527 SMS_CAUSE_MEM_FAIL: SMS_CAUSE_INV_INDEX)); | |
528 break; | |
529 } | |
530 else | |
531 { | |
532 rec_num = delete_req->rec_num; | |
533 } | |
534 } | |
535 | |
536 if (tl_get_status (&SMS_ME_PROP(sms_data), rec_num-1) & 1) | |
537 { | |
538 /* | |
539 * entry is used | |
540 */ | |
541 UBYTE data[SIZE_EF_SMS]; | |
542 UBYTE next_rec_num = 0; | |
543 | |
544 data[0] = 0; | |
545 memset (&data[1], 0xFF, SIZE_EF_SMS-1); | |
546 tl_store_status (&SMS_ME_PROP(sms_data), rec_num-1, SIM_SMS_FREE); | |
547 /* Implements Measure#32: Row 95 */ | |
548 pcm_WriteRecord ((UBYTE *)ef_sms_id, rec_num, | |
549 SIZE_EF_SMS, data); | |
550 | |
551 TRACE_EVENT_P1 ("mem cap avail %d", sms_data->mem_cap_avail); | |
552 | |
553 if (!sms_data->mem_cap_avail) | |
554 { | |
555 SMS_SEL_MEM(sms_data) = delete_req->mem_type; | |
556 SMS_SEL_REC(sms_data) = delete_req->rec_num; | |
557 | |
558 GET_MO_INSTANCE(sms_data); | |
559 /* | |
560 * TL state transition TL_ESTABLISH | |
561 * EST state transition EST_SMMA | |
562 * MMI state transition MMI_DELETE | |
563 * | |
564 */ | |
565 SET_STATE (STATE_MMI, MMI_DELETE); | |
566 SET_STATE (STATE_EST, EST_SMMA); | |
567 SMS_INST_SET_STATE (STATE_TL, TL_ESTABLISH); | |
568 /* | |
569 * 1st shot | |
570 */ | |
571 SMS_INST.retrans = FALSE; | |
572 /* | |
573 * establish connection | |
574 */ | |
575 tl_establish_connection(FALSE); | |
576 /* | |
577 * wait for processing of RP-SMMA | |
578 */ | |
579 PFREE (delete_req); | |
580 return; | |
581 } | |
582 | |
583 if(delete_req->delete_status NEQ CMGD_DEL_INDEX) | |
584 { | |
585 /* Status value is given. Find the next record satisfying this status value */ | |
586 next_rec_num = tl_search_record_for_delete (&SMS_ME_PROP(sms_data), rec_num, | |
587 delete_req->delete_status); | |
588 } | |
589 | |
590 tl_mnsms_delete_cnf (delete_req->mem_type, rec_num, next_rec_num, SIM_NO_ERROR); | |
591 } | |
592 else | |
593 { | |
594 tl_mnsms_delete_cnf (delete_req->mem_type, rec_num, 0, SMS_CAUSE_INV_INDEX); | |
595 } | |
596 | |
597 break; | |
598 | |
599 case MEM_SM: | |
600 /* | |
601 * SIM memory | |
602 */ | |
603 if(delete_req->delete_status NEQ CMGD_DEL_INDEX) | |
604 { | |
605 if(delete_req->rec_num EQ 0) | |
606 { | |
607 /* Status value is given. Find the first record satisfying this status value */ | |
608 rec_num = tl_search_record_for_delete (&SMS_SIM_PROP(sms_data), 1, | |
609 delete_req->delete_status); | |
610 | |
611 if(rec_num EQ SMS_RECORD_NOT_EXIST) | |
612 { | |
613 tl_mnsms_delete_cnf (delete_req->mem_type, 0, 0, SIM_NO_ERROR); | |
614 break; | |
615 } | |
616 | |
617 } | |
618 else | |
619 { | |
620 if(delete_req->rec_num > sms_data->sim_backup.max_record) | |
621 { | |
622 tl_mnsms_delete_cnf (delete_req->mem_type, delete_req->rec_num, 0, | |
623 SMS_CAUSE_INV_INDEX); | |
624 break; | |
625 } | |
626 else | |
627 { | |
628 /* Use the record number that he has given */ | |
629 rec_num = delete_req->rec_num; | |
630 } | |
631 } | |
632 } | |
633 else | |
634 { | |
635 /* There should be a valid rec_num */ | |
636 if(delete_req->rec_num EQ 0 || delete_req->rec_num > sms_data->sim_backup.max_record) | |
637 { | |
638 tl_mnsms_delete_cnf (delete_req->mem_type, delete_req->rec_num, 0, | |
639 SMS_CAUSE_INV_INDEX); | |
640 break; | |
641 } | |
642 else | |
643 { | |
644 rec_num = delete_req->rec_num; | |
645 } | |
646 } | |
647 | |
648 if (tl_get_status (&SMS_SIM_PROP(sms_data), rec_num-1) & 1) | |
649 { | |
650 /* | |
651 * entry is used | |
652 */ | |
653 SMS_SEL_MEM(sms_data) = delete_req->mem_type; | |
654 SMS_SEL_REC(sms_data) = rec_num; | |
655 SMS_REC_STATUS(sms_data) = delete_req->delete_status; | |
656 | |
657 tl_set_access_fifo (ACCESS_BY_MMI); | |
658 SET_STATE (STATE_MMI, MMI_DELETE); | |
659 SMS_INST_SET_STATE (STATE_TL, TL_OTHER); | |
660 tl_sim_update_req (rec_num, SMS_RECORD_FREE, NULL); | |
661 } | |
662 else | |
663 { | |
664 tl_mnsms_delete_cnf (delete_req->mem_type, rec_num, 0, SMS_CAUSE_INV_INDEX); | |
665 } | |
666 break; | |
667 | |
668 case MEM_SR: | |
669 tl_mnsms_delete_cnf (delete_req->mem_type, delete_req->rec_num, 0, | |
670 SMS_CAUSE_MEM_FAIL); | |
671 break; | |
672 | |
673 default: | |
674 tl_mnsms_delete_cnf (delete_req->mem_type, delete_req->rec_num, 0, | |
675 SMS_CAUSE_PARAM_WRONG); | |
676 break; | |
677 } | |
678 break; | |
679 | |
680 default: | |
681 tl_mnsms_delete_cnf (delete_req->mem_type, delete_req->rec_num, 0, | |
682 SMS_CAUSE_ENTITY_BUSY); | |
683 break; | |
684 } | |
685 } | |
686 else | |
687 tl_mnsms_delete_cnf (delete_req->mem_type, delete_req->rec_num, 0, | |
688 SMS_CAUSE_ENTITY_BUSY); | |
689 PFREE (delete_req); | |
690 } | |
691 | |
692 /* | |
693 +--------------------------------------------------------------------+ | |
694 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
695 | STATE : code ROUTINE : tl_mnsms_read_cnf | | |
696 +--------------------------------------------------------------------+ | |
697 | |
698 PURPOSE : Generate an error response to the primitive | |
699 MNSMS_READ_REQ. | |
700 */ | |
701 | |
702 GLOBAL void tl_mnsms_read_cnf (UBYTE mem_type, | |
703 UBYTE record, | |
704 UBYTE *data, | |
705 USHORT error) | |
706 { | |
707 GET_INSTANCE_DATA; | |
708 PALLOC (read_cnf, MNSMS_READ_CNF); /* T_MNSMS_READ_CNF */ | |
709 | |
710 read_cnf->mem_type = mem_type; | |
711 read_cnf->rec_num = record; | |
712 switch (mem_type) | |
713 { | |
714 case MEM_SM: | |
715 if (sms_data->init_done) | |
716 { | |
717 read_cnf->rec_next = tl_search_record (&SMS_SIM_PROP(sms_data), | |
718 (USHORT)(record + 1), | |
719 SMS_REC_STATUS(sms_data)); | |
720 read_cnf->rec_max = SMS_SIM_PROP(sms_data).max_record; | |
721 } | |
722 else | |
723 { | |
724 read_cnf->rec_next = SMS_RECORD_NOT_EXIST; | |
725 read_cnf->rec_max = SMS_RECORD_NOT_EXIST; | |
726 } | |
727 break; | |
728 case MEM_ME: | |
729 read_cnf->rec_next = tl_search_record (&SMS_ME_PROP(sms_data), | |
730 (USHORT)(record + 1), | |
731 SMS_REC_STATUS(sms_data)); | |
732 read_cnf->rec_max = SMS_ME_PROP(sms_data).max_record; | |
733 break; | |
734 default: | |
735 read_cnf->rec_next = SMS_RECORD_NOT_EXIST; | |
736 read_cnf->rec_max = SMS_RECORD_NOT_EXIST; | |
737 break; | |
738 } | |
739 read_cnf->cause = error; | |
740 read_cnf->rec_status = SMS_RECORD_NOT_EXIST; /* ffs */ | |
741 | |
742 if (data NEQ NULL) | |
743 { | |
744 read_cnf->status = data[0]; | |
745 read_cnf->sms_sdu.l_buf = SIM_PDU_BIT_LEN; | |
746 read_cnf->sms_sdu.o_buf = 0; | |
747 memcpy (read_cnf->sms_sdu.buf, &data[1], SIM_PDU_LEN); | |
748 tl_adjust_message_len (SMS_VT_SIM_PDU, (BUF_tpdu *)&read_cnf->sms_sdu); | |
749 } | |
750 else | |
751 { | |
752 if (record EQ SMS_RECORD_NOT_EXIST) | |
753 { | |
754 read_cnf->status = SMS_RECORD_FREE; | |
755 } | |
756 else | |
757 { | |
758 switch (mem_type) | |
759 { | |
760 case MEM_ME: | |
761 read_cnf->status = tl_get_status (&SMS_ME_PROP(sms_data), record-1); | |
762 break; | |
763 case MEM_SM: | |
764 read_cnf->status = tl_get_status (&SMS_SIM_PROP(sms_data), record-1); | |
765 break; | |
766 default: | |
767 read_cnf->status = SMS_RECORD_FREE; | |
768 break; | |
769 } | |
770 } | |
771 memset (&read_cnf->sms_sdu, 0, sizeof(T_sms_sdu)); | |
772 } | |
773 PSENDX (MMI, read_cnf); | |
774 } | |
775 | |
776 /* | |
777 +--------------------------------------------------------------------+ | |
778 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
779 | STATE : code ROUTINE : tl_mnsms_read_req | | |
780 +--------------------------------------------------------------------+ | |
781 | |
782 PURPOSE : Process the primitive MNSMS_READ_REQ. | |
783 | |
784 */ | |
785 | |
786 GLOBAL void tl_mnsms_read_req (T_MNSMS_READ_REQ *read_req) | |
787 { | |
788 register T_SMS_DATA *sms_data = GET_SMS_INSTANCE(0); | |
789 | |
790 TRACE_FUNCTION ("tl_mnsms_read_req()"); | |
791 | |
792 if (sms_data) | |
793 { | |
794 switch (SMS_INST_GET_STATE (STATE_TL)) | |
795 { | |
796 case TL_IDLE: | |
797 SMS_READ_MODE(sms_data) = read_req->read_mode; | |
798 switch (read_req->mem_type) | |
799 { | |
800 case MEM_ME: /* Mobile Equipment Memory */ | |
801 tl_read_me_memory (read_req->rec_num, | |
802 read_req->status); | |
803 break; | |
804 case MEM_SM: /* SIM memory */ | |
805 if (sms_data->init_done) | |
806 { | |
807 tl_read_sim_memory (read_req->rec_num, | |
808 read_req->status); | |
809 } | |
810 else | |
811 { | |
812 tl_mnsms_read_cnf (read_req->mem_type, | |
813 read_req->rec_num, NULL, SMS_CAUSE_ENTITY_BUSY); | |
814 } | |
815 break; | |
816 case MEM_SR: | |
817 tl_mnsms_read_cnf (read_req->mem_type, | |
818 read_req->rec_num, NULL, | |
819 SMS_CAUSE_MEM_FAIL); | |
820 break; | |
821 default: | |
822 tl_mnsms_read_cnf (read_req->mem_type, | |
823 read_req->rec_num, NULL, | |
824 SMS_CAUSE_PARAM_WRONG); | |
825 break; | |
826 } | |
827 break; | |
828 | |
829 default: | |
830 tl_mnsms_read_cnf (read_req->mem_type, | |
831 read_req->rec_num, NULL, SMS_CAUSE_ENTITY_BUSY); | |
832 break; | |
833 } | |
834 } | |
835 else | |
836 tl_mnsms_read_cnf (read_req->mem_type, | |
837 read_req->rec_num, NULL, SMS_CAUSE_ENTITY_BUSY); | |
838 | |
839 PFREE (read_req); | |
840 } | |
841 | |
842 /* | |
843 +--------------------------------------------------------------------+ | |
844 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
845 | STATE : code ROUTINE : tl_mnsms_store_cnf | | |
846 +--------------------------------------------------------------------+ | |
847 | |
848 PURPOSE : Generate a response to the primitive MNSMS_STORE_REQ. | |
849 */ | |
850 | |
851 GLOBAL void tl_mnsms_store_cnf (UBYTE mem_type, | |
852 UBYTE record, | |
853 USHORT error) | |
854 { | |
855 PALLOC (store_cnf, MNSMS_STORE_CNF); | |
856 | |
857 store_cnf->mem_type = mem_type; | |
858 store_cnf->rec_num = record; | |
859 store_cnf->cause = error; | |
860 | |
861 PSENDX (MMI, store_cnf); | |
862 } | |
863 | |
864 /* | |
865 +--------------------------------------------------------------------+ | |
866 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
867 | STATE : code ROUTINE : tl_mnsms_store_req | | |
868 +--------------------------------------------------------------------+ | |
869 | |
870 PURPOSE : Process the primitive MNSMS_STORE_REQ. | |
871 | |
872 */ | |
873 | |
874 GLOBAL void tl_mnsms_store_req (T_MNSMS_STORE_REQ *store_req) | |
875 { | |
876 USHORT index; | |
877 UBYTE dummy; | |
878 int byte_len; | |
879 BOOL mem_full = FALSE; | |
880 register T_SMS_DATA *sms_data = GET_SMS_INSTANCE(0); | |
881 | |
882 TRACE_FUNCTION ("tl_mnsms_store_req()"); | |
883 | |
884 #ifdef REL99 | |
885 /* Check if the last failed message is getting replaced */ | |
886 if( ( store_req->condx NEQ SMS_CONDX_OVR_NON ) AND | |
887 ( store_req->rec_num EQ SMS_INST.failed_msg_rec_num ) AND | |
888 ( store_req->mem_type EQ SMS_INST.failed_msg_mem ) AND | |
889 SMS_DATA_REQ(sms_data) NEQ NULL ) | |
890 { | |
891 PFREE (SMS_DATA_REQ(sms_data)); | |
892 SMS_DATA_REQ(sms_data) = NULL; | |
893 } | |
894 #endif | |
895 | |
896 if (sms_data NEQ NULL) | |
897 { | |
898 switch (SMS_INST_GET_STATE (STATE_TL)) | |
899 { | |
900 case TL_IDLE: | |
901 if (tl_check_status_value (store_req->status) EQ NOT_PRESENT_8BIT) | |
902 { /* invalid status value */ | |
903 tl_mnsms_store_cnf (store_req->mem_type, store_req->rec_num, | |
904 SMS_CAUSE_PARAM_WRONG); | |
905 break; | |
906 } | |
907 switch (store_req->mem_type) | |
908 { | |
909 case MEM_SM: | |
910 if (store_req->rec_num EQ SMS_RECORD_NOT_EXIST) | |
911 { | |
912 if ((index = tl_get_free_space (MEM_SM)) EQ 0) | |
913 mem_full = TRUE; | |
914 | |
915 SMS_EM_SET_CHANGE_FLAG_1; | |
916 | |
917 } | |
918 else | |
919 { | |
920 if (store_req->rec_num > SMS_SIM_PROP(sms_data).max_record) | |
921 index = 0; | |
922 else if (store_req->condx EQ SMS_CONDX_OVR_NON) | |
923 { | |
924 if ((tl_get_status (&SMS_SIM_PROP(sms_data), store_req->rec_num-1) & 1) | |
925 EQ SMS_RECORD_FREE) | |
926 index = store_req->rec_num; | |
927 else | |
928 index = 0; | |
929 } | |
930 else if (store_req->condx EQ SMS_CONDX_OVR_MO) | |
931 { | |
932 switch (tl_get_status (&SMS_SIM_PROP(sms_data), store_req->rec_num-1) & 7) | |
933 { | |
934 case SMS_RECORD_STO_UNSENT: | |
935 case SMS_RECORD_STO_SENT: | |
936 index = store_req->rec_num; | |
937 break; | |
938 | |
939 default: | |
940 index = 0; | |
941 break; | |
942 } | |
943 } | |
944 else | |
945 index = store_req->rec_num; | |
946 | |
947 SMS_EM_SET_CHANGE_FLAG_2; | |
948 | |
949 } | |
950 break; | |
951 | |
952 case MEM_ME: | |
953 if (store_req->rec_num EQ SMS_RECORD_NOT_EXIST) | |
954 { | |
955 if ((index = tl_get_free_space (MEM_ME)) EQ 0) | |
956 mem_full = TRUE; | |
957 | |
958 | |
959 SMS_EM_SET_CHANGE_FLAG_1; | |
960 | |
961 } | |
962 else | |
963 { | |
964 if (store_req->condx EQ SMS_CONDX_OVR_NON) | |
965 { | |
966 if ((tl_get_status (&SMS_ME_PROP(sms_data), store_req->rec_num-1) & 1) | |
967 EQ SMS_RECORD_FREE) | |
968 index = store_req->rec_num; | |
969 else | |
970 index = 0; | |
971 } | |
972 else if (store_req->condx EQ SMS_CONDX_OVR_MO) | |
973 { | |
974 switch (tl_get_status (&SMS_ME_PROP(sms_data), store_req->rec_num-1) & 7) | |
975 { | |
976 case SMS_RECORD_STO_UNSENT: | |
977 case SMS_RECORD_STO_SENT: | |
978 index = store_req->rec_num; | |
979 break; | |
980 | |
981 default: | |
982 index = 0; | |
983 break; | |
984 } | |
985 } | |
986 else | |
987 index = store_req->rec_num; | |
988 | |
989 SMS_EM_SET_CHANGE_FLAG_2; | |
990 | |
991 } | |
992 break; | |
993 | |
994 case MEM_SR: | |
995 tl_mnsms_store_cnf (store_req->mem_type, store_req->rec_num, | |
996 SMS_CAUSE_MEM_FAIL); | |
997 PFREE (store_req); | |
998 return; | |
999 | |
1000 default: | |
1001 tl_mnsms_store_cnf (store_req->mem_type, store_req->rec_num, | |
1002 SMS_CAUSE_PARAM_WRONG); | |
1003 PFREE (store_req); | |
1004 return; | |
1005 } | |
1006 if (index > 0) | |
1007 { | |
1008 /* | |
1009 * storage available | |
1010 */ | |
1011 byte_len = (int)store_req->sms_sdu.l_buf >> 3; | |
1012 | |
1013 if (store_req->mem_type EQ MEM_SM) | |
1014 { | |
1015 /* | |
1016 * SIM card memory | |
1017 */ | |
1018 tl_store_status (&SMS_SIM_PROP(sms_data), index-1, SIM_SMS_PENDING); | |
1019 SMS_REC_STATUS(sms_data) = store_req->status; | |
1020 tl_get_pid_dcs (store_req->status, | |
1021 &store_req->sms_sdu, | |
1022 &SMS_PID(sms_data), | |
1023 &dummy); | |
1024 | |
1025 memset (&store_req->sms_sdu.buf[byte_len], | |
1026 NOT_PRESENT_8BIT, | |
1027 (SIM_LENGTH_SMS_RECORD-1) - byte_len); | |
1028 | |
1029 tl_set_access_fifo (ACCESS_BY_MMI); | |
1030 SET_STATE (STATE_MMI, MMI_WRITE); | |
1031 SMS_INST_SET_STATE (STATE_TL, TL_OTHER); | |
1032 tl_sim_update_req ((UBYTE)index, store_req->status, | |
1033 store_req->sms_sdu.buf); | |
1034 break; | |
1035 } | |
1036 else | |
1037 { | |
1038 /* | |
1039 * memory type is mobile memory | |
1040 */ | |
1041 UBYTE data[SIZE_EF_SMS]; | |
1042 | |
1043 data[0] = store_req->status; | |
1044 memcpy (&data[1], store_req->sms_sdu.buf, byte_len); | |
1045 memset (&data[byte_len + 1], | |
1046 NOT_PRESENT_8BIT, | |
1047 (SIM_LENGTH_SMS_RECORD-1) - byte_len); | |
1048 | |
1049 /* Implements Measure#32: Row 97 */ | |
1050 if (pcm_WriteRecord ((UBYTE *)ef_sms_id, index, | |
1051 SIZE_EF_SMS, data) EQ PCM_OK) | |
1052 { | |
1053 UBYTE pid; | |
1054 | |
1055 SMS_EM_STORE_MO_SHORT_MESSAGE; | |
1056 | |
1057 SMS_EM_CHANGE_SHORT_MESSAGE; | |
1058 | |
1059 tl_store_status (&SMS_ME_PROP(sms_data), index-1, store_req->status); | |
1060 tl_get_pid_dcs (store_req->status, | |
1061 &store_req->sms_sdu, | |
1062 &pid, | |
1063 &dummy); | |
1064 tl_store_pid (&SMS_ME_PROP(sms_data), index-1, pid); | |
1065 tl_mnsms_store_cnf (store_req->mem_type, (UBYTE)index, | |
1066 SMS_NO_ERROR); | |
1067 } | |
1068 else | |
1069 tl_mnsms_store_cnf (store_req->mem_type, (UBYTE)index, | |
1070 SMS_CAUSE_MEM_FAIL); | |
1071 } | |
1072 } | |
1073 else | |
1074 tl_mnsms_store_cnf (store_req->mem_type, store_req->rec_num, | |
1075 (USHORT)((mem_full)? SMS_CAUSE_MEM_FULL: | |
1076 SMS_CAUSE_INV_INDEX)); | |
1077 break; | |
1078 | |
1079 default: | |
1080 tl_mnsms_store_cnf (store_req->mem_type, store_req->rec_num, | |
1081 SMS_CAUSE_ENTITY_BUSY); | |
1082 break; | |
1083 } | |
1084 } | |
1085 else | |
1086 tl_mnsms_store_cnf (store_req->mem_type, store_req->rec_num, | |
1087 SMS_CAUSE_ENTITY_BUSY); | |
1088 | |
1089 PFREE (store_req); | |
1090 } | |
1091 | |
1092 /* | |
1093 +--------------------------------------------------------------------+ | |
1094 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
1095 | STATE : code ROUTINE : tl_mnsms_submit_cnf | | |
1096 +--------------------------------------------------------------------+ | |
1097 | |
1098 PURPOSE : Generate a response to the primitive MNSMS_SUBMIT_REQ. | |
1099 */ | |
1100 | |
1101 GLOBAL void tl_mnsms_submit_cnf (UBYTE mem_type, | |
1102 UBYTE record, | |
1103 UBYTE tp_mr, | |
1104 USHORT cause, | |
1105 T_sms_sdu *sms_sdu) | |
1106 { | |
1107 PALLOC (submit_cnf, MNSMS_SUBMIT_CNF); | |
1108 | |
1109 TRACE_EVENT_P1 ("cause = %04x", cause); | |
1110 | |
1111 submit_cnf->mem_type = mem_type; | |
1112 submit_cnf->rec_num = record; | |
1113 submit_cnf->tp_mr = tp_mr; | |
1114 submit_cnf->cause = cause; | |
1115 | |
1116 if (sms_sdu NEQ NULL) | |
1117 memcpy (&submit_cnf->sms_sdu, sms_sdu, sizeof (T_sms_sdu)); | |
1118 else | |
1119 memset (&submit_cnf->sms_sdu, 0, sizeof (T_sms_sdu)); | |
1120 | |
1121 PSENDX (MMI, submit_cnf); | |
1122 } | |
1123 | |
1124 /* | |
1125 +--------------------------------------------------------------------+ | |
1126 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
1127 | STATE : code ROUTINE : tl_mnsms_submit_req | | |
1128 +--------------------------------------------------------------------+ | |
1129 | |
1130 PURPOSE : Process the primitive MNSMS_SUBMIT_REQ. | |
1131 */ | |
1132 | |
1133 | |
1134 GLOBAL void tl_mnsms_submit_req (T_MNSMS_SUBMIT_REQ *submit_req) | |
1135 { | |
1136 UBYTE ti; | |
1137 register T_SMS_DATA *sms_data = GET_SMS_INSTANCE(0); | |
1138 | |
1139 TRACE_FUNCTION ("tl_mnsms_submit_req()"); | |
1140 | |
1141 TRACE_EVENT_P2 ("mem_type = %02X, rec_num = %02X", | |
1142 submit_req->mem_type, submit_req->rec_num); | |
1143 | |
1144 if (sms_data) | |
1145 { | |
1146 switch (SMS_INST_GET_STATE (STATE_TL)) | |
1147 { | |
1148 case TL_SEND_CONTD: | |
1149 /* | |
1150 * stop timer TLCT | |
1151 */ | |
1152 sms_timer_stop(TLCT); | |
1153 /* | |
1154 * stop timer TMMS | |
1155 */ | |
1156 sms_timer_stop(TMMS); | |
1157 | |
1158 case TL_IDLE: | |
1159 if (sms_timer_check(TRAM)) | |
1160 { | |
1161 /* | |
1162 * MNSMS_SUBMIT_CNF | |
1163 */ | |
1164 tl_mnsms_submit_cnf (submit_req->mem_type, submit_req->rec_num, | |
1165 NOT_PRESENT_8BIT, SMS_CAUSE_ENTITY_BUSY, NULL); | |
1166 break; | |
1167 } | |
1168 /* | |
1169 * save submit request with sms sdu | |
1170 */ | |
1171 SMS_SEL_MEM(sms_data) = submit_req->mem_type; | |
1172 SMS_SEL_REC(sms_data) = submit_req->rec_num; | |
1173 SMS_CONDX(sms_data) = submit_req->condx; | |
1174 SMS_MODIFY(sms_data) = submit_req->modify; | |
1175 | |
1176 if (SMS_SDU(sms_data) NEQ NULL) | |
1177 { | |
1178 MFREE (SMS_SDU(sms_data)); | |
1179 } | |
1180 MALLOC (SMS_SDU(sms_data), sizeof(T_sms_sdu)); | |
1181 memcpy (SMS_SDU(sms_data), &submit_req->sms_sdu, sizeof(T_sms_sdu)); | |
1182 /* | |
1183 * check whether concatenated | |
1184 */ | |
1185 if (!tl_concat_check(SMS_SDU(sms_data))) | |
1186 { | |
1187 /* | |
1188 * error understanding the sdu | |
1189 */ | |
1190 TRACE_ERROR ("error with concat sim pdu"); | |
1191 /* | |
1192 * negative response MNSMS_SUBMIT_CNF | |
1193 */ | |
1194 tl_mnsms_submit_cnf (submit_req->mem_type, submit_req->rec_num, | |
1195 NOT_PRESENT_8BIT, SMS_CAUSE_PARAM_WRONG, NULL); | |
1196 /* | |
1197 * Send MNSMS_REPORT_IND if cmms_mode is equal 1or 2 | |
1198 */ | |
1199 if(CMMS_ACTIVE) | |
1200 { | |
1201 tl_mnsms_cmms_end_ind(); | |
1202 } | |
1203 /* | |
1204 * give up | |
1205 */ | |
1206 MFREE (SMS_SDU(sms_data)); | |
1207 PFREE (submit_req); | |
1208 return; | |
1209 } | |
1210 #ifdef REL99 | |
1211 /* Check whether MO msg is sent thru retransmission request. Initially False */ | |
1212 SMS_INST.failed_msg_retx = FALSE; | |
1213 if(submit_req->auto_rep_flag EQ AUTO_REP_FLAG_ENABLED) | |
1214 { | |
1215 SMS_INST.tl_retx = 0; | |
1216 } | |
1217 else | |
1218 { | |
1219 /* Set to the max value so that retransmission will not be done */ | |
1220 SMS_INST.tl_retx = TL_MAX_RETANS; | |
1221 } | |
1222 #endif | |
1223 | |
1224 | |
1225 /* | |
1226 * TL state transition TL_ESTABLISH | |
1227 * EST state transition EST_SEND | |
1228 */ | |
1229 SMS_INST_SET_STATE (STATE_TL, TL_ESTABLISH); | |
1230 SET_STATE (STATE_EST, EST_SEND); | |
1231 /* | |
1232 * establish connection | |
1233 */ | |
1234 ti = SMS_INST.ti; | |
1235 tl_establish_connection(TRUE); | |
1236 /* | |
1237 * concat control: if needed, release previous connection | |
1238 */ | |
1239 if ((sms_data->concat_cntrl.concatenation EQ TRUE) AND | |
1240 (sms_data->concat_cntrl.release_pending EQ TRUE)) | |
1241 { | |
1242 sms_data->concat_cntrl.release_pending = FALSE; | |
1243 /* | |
1244 * RL_RELEASE_REQ ==> | |
1245 */ | |
1246 rl_release_req(ti); | |
1247 /* | |
1248 * check for end of concatenation | |
1249 */ | |
1250 if (sms_data->concat_cntrl.end EQ TRUE) | |
1251 { | |
1252 /* | |
1253 * end of concatenation | |
1254 */ | |
1255 sms_data->concat_cntrl.concatenation = FALSE; | |
1256 } | |
1257 break; | |
1258 } | |
1259 /* | |
1260 * cmms control: if needed, release previous connection | |
1261 */ | |
1262 if(sms_data->cmms_release_pending EQ TRUE) | |
1263 { | |
1264 sms_data->cmms_release_pending = FALSE; | |
1265 /* | |
1266 * Release the previous active MM connection | |
1267 */ | |
1268 rl_release_req(ti); | |
1269 } | |
1270 break; | |
1271 | |
1272 default: | |
1273 /* | |
1274 * MNSMS_SUBMIT_CNF | |
1275 */ | |
1276 tl_mnsms_submit_cnf (submit_req->mem_type, submit_req->rec_num, | |
1277 NOT_PRESENT_8BIT, SMS_CAUSE_ENTITY_BUSY, NULL); | |
1278 } | |
1279 } | |
1280 else | |
1281 { | |
1282 /* | |
1283 * MNSMS_SUBMIT_CNF | |
1284 */ | |
1285 tl_mnsms_submit_cnf (submit_req->mem_type, submit_req->rec_num, | |
1286 NOT_PRESENT_8BIT, SMS_CAUSE_ENTITY_BUSY, NULL); | |
1287 } | |
1288 PFREE (submit_req); | |
1289 } | |
1290 | |
1291 | |
1292 /* | |
1293 +--------------------------------------------------------------------+ | |
1294 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
1295 | STATE : code ROUTINE : tl_mnsms_error_ind | | |
1296 +--------------------------------------------------------------------+ | |
1297 | |
1298 PURPOSE : Build and send the primitive MNSMS_ERROR_IND. | |
1299 */ | |
1300 | |
1301 GLOBAL void tl_mnsms_error_ind (USHORT error) | |
1302 { | |
1303 PALLOC (error_ind, MNSMS_ERROR_IND); | |
1304 | |
1305 error_ind->cause = error; | |
1306 | |
1307 PSENDX (MMI, error_ind); | |
1308 } | |
1309 | |
1310 /* | |
1311 +--------------------------------------------------------------------+ | |
1312 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
1313 | STATE : code ROUTINE : tl_mnsms_ack_res | | |
1314 +--------------------------------------------------------------------+ | |
1315 | |
1316 PURPOSE : Process the primitive MNSMS_ACK_RES. | |
1317 */ | |
1318 | |
1319 GLOBAL void tl_mnsms_ack_res (T_MNSMS_ACK_RES *ack_res) | |
1320 { | |
1321 GET_INSTANCE_DATA; | |
1322 | |
1323 TRACE_FUNCTION ("tl_mnsms_ack_res()"); | |
1324 | |
1325 if (sms_data) /*lint !e774 always True*/ | |
1326 { | |
1327 GET_MT_INSTANCE(sms_data); /* MT operation */ | |
1328 | |
1329 if (SMS_MT_ACK_MODE(sms_data) NEQ SMS_MHC_PH2PLUS) | |
1330 { | |
1331 tl_mnsms_error_ind (SMS_CAUSE_OPER_NOT_ALLW); | |
1332 } | |
1333 else switch (SMS_INST_GET_STATE (STATE_TL)) | |
1334 { | |
1335 case TL_RECEIVE: | |
1336 if (sms_timer_check(TR2M)) | |
1337 { | |
1338 T_rp_user_data *rp_ud; | |
1339 int sdu_ofs; | |
1340 MALLOC (rp_ud, sizeof(T_rp_user_data)); | |
1341 | |
1342 CCD_START; | |
1343 | |
1344 sdu_ofs = ack_res->sms_sdu.buf[ack_res->sms_sdu.o_buf >> 3] + 1; | |
1345 rp_ud->tpdu.o_tpdu = 0; | |
1346 if (ack_res->sms_sdu.l_buf >= (sdu_ofs << 3) + 2) /* TP-MTI present */ | |
1347 { | |
1348 rp_ud->tpdu.l_tpdu = ack_res->sms_sdu.l_buf - (sdu_ofs << 3); | |
1349 memcpy (rp_ud->tpdu.b_tpdu, &ack_res->sms_sdu.buf[sdu_ofs], | |
1350 rp_ud->tpdu.l_tpdu >> 3); | |
1351 rp_ud->tp_mti = rp_ud->tpdu.b_tpdu[0] & 3; | |
1352 rp_ud->v_tpdu = TRUE; | |
1353 } | |
1354 else | |
1355 { | |
1356 rp_ud->tpdu.l_tpdu = 0; | |
1357 rp_ud->tp_mti = NOT_PRESENT_8BIT; | |
1358 rp_ud->v_tpdu = FALSE; | |
1359 } | |
1360 if (ack_res->resp EQ SMS_RP_ACK) | |
1361 rl_report_req_ack (rp_ud); | |
1362 else | |
1363 { | |
1364 if (!rp_ud->v_tpdu) | |
1365 { | |
1366 rp_ud->tp_mti = rp_ud->tpdu.b_tpdu[0] = SMS_DELIVER_REPORT; | |
1367 rp_ud->tpdu.b_tpdu[1] = SMS_FCS_UNSPECIFIED; /* TP-FCS */ | |
1368 rp_ud->tpdu.b_tpdu[2] = 0; /* TP-PI */ | |
1369 rp_ud->tpdu.l_tpdu = 24; /* 3 bytes */ | |
1370 rp_ud->v_tpdu = TRUE; | |
1371 } | |
1372 rl_report_req_error (SMS_RP_CS_PROTOCOL_ERROR, rp_ud); | |
1373 /* | |
1374 * RL_RELEASE_REQ ==> | |
1375 */ | |
1376 rl_release_req(SMS_INST.ti); | |
1377 } | |
1378 CCD_END; | |
1379 MFREE (rp_ud); | |
1380 | |
1381 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
1382 break; | |
1383 } | |
1384 /*FALLTHROUGH*/ /*lint -fallthrough*/ | |
1385 default: | |
1386 tl_mnsms_error_ind (SMS_CAUSE_UNEXP_CNMA); | |
1387 break; | |
1388 } | |
1389 } | |
1390 PFREE (ack_res); | |
1391 } | |
1392 | |
1393 /* | |
1394 +--------------------------------------------------------------------+ | |
1395 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
1396 | STATE : code ROUTINE : tl_mnsms_pause_req | | |
1397 +--------------------------------------------------------------------+ | |
1398 | |
1399 PURPOSE : Process the primitive MNSMS_PAUSE_REQ. | |
1400 */ | |
1401 GLOBAL void tl_mnsms_pause_req (T_MNSMS_PAUSE_REQ *pause_req) | |
1402 { | |
1403 | |
1404 TRACE_FUNCTION ("tl_mnsms_pause_req()"); | |
1405 | |
1406 tl_pause(); | |
1407 | |
1408 PFREE (pause_req); | |
1409 } | |
1410 | |
1411 /* | |
1412 +--------------------------------------------------------------------+ | |
1413 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
1414 | STATE : code ROUTINE : tl_mnsms_resume_req | | |
1415 +--------------------------------------------------------------------+ | |
1416 | |
1417 PURPOSE : Process the primitive MNSMS_RESUME_REQ. | |
1418 */ | |
1419 GLOBAL void tl_mnsms_resume_req (T_MNSMS_RESUME_REQ *resume_req) | |
1420 { | |
1421 | |
1422 TRACE_FUNCTION ("tl_mnsms_resume_req()"); | |
1423 | |
1424 tl_resume(); | |
1425 | |
1426 PFREE (resume_req); | |
1427 } | |
1428 | |
1429 /* | |
1430 +--------------------------------------------------------------------+ | |
1431 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
1432 | STATE : code ROUTINE : tl_mnsms_query_req | | |
1433 +--------------------------------------------------------------------+ | |
1434 | |
1435 PURPOSE : Process the primitive MNSMS_QUERY_REQ. | |
1436 */ | |
1437 GLOBAL void tl_mnsms_query_req (T_MNSMS_QUERY_REQ *query_req) | |
1438 { | |
1439 | |
1440 TRACE_FUNCTION ("tl_mnsms_query_req()"); | |
1441 | |
1442 switch (query_req->query_type) | |
1443 { | |
1444 case SMS_QUERY_DELIVER_STATUS: | |
1445 tl_query_deliver_status(); | |
1446 break; | |
1447 default: | |
1448 TRACE_ERROR("sms query type unknown!"); | |
1449 } | |
1450 | |
1451 PFREE (query_req); | |
1452 } | |
1453 | |
1454 /* | |
1455 +--------------------------------------------------------------------+ | |
1456 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
1457 | STATE : code ROUTINE : tl_mnsms_resume_cnf | | |
1458 +--------------------------------------------------------------------+ | |
1459 | |
1460 PURPOSE : Generate a response to the primitive MNSMS_RESUME_REQ. | |
1461 */ | |
1462 | |
1463 GLOBAL void tl_mnsms_resume_cnf ( USHORT cause ) | |
1464 { | |
1465 PALLOC (resume_cnf, MNSMS_RESUME_CNF); | |
1466 | |
1467 resume_cnf->cause = cause; | |
1468 | |
1469 PSENDX (MMI, resume_cnf); | |
1470 } | |
1471 | |
1472 /* | |
1473 +--------------------------------------------------------------------+ | |
1474 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
1475 | STATE : code ROUTINE : tl_mnsms_query_cnf | | |
1476 +--------------------------------------------------------------------+ | |
1477 | |
1478 PURPOSE : Generate a response to the primitive MNSMS_QUERY_REQ. | |
1479 */ | |
1480 | |
1481 GLOBAL void tl_mnsms_query_cnf ( U8 query_type, U8 status ) | |
1482 { | |
1483 | |
1484 switch (query_type) | |
1485 { | |
1486 case SMS_QUERY_DELIVER_STATUS: | |
1487 { | |
1488 PALLOC (query_cnf, MNSMS_QUERY_CNF); | |
1489 | |
1490 query_cnf->query_type = SMS_QUERY_DELIVER_STATUS; | |
1491 query_cnf->v_deliver_status = 1; | |
1492 query_cnf->deliver_status = status; | |
1493 | |
1494 PSENDX (MMI, query_cnf); | |
1495 } | |
1496 break; | |
1497 default: | |
1498 TRACE_ERROR("sms query type unknown!"); | |
1499 } | |
1500 | |
1501 } | |
1502 | |
1503 /* | |
1504 +--------------------------------------------------------------------+ | |
1505 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
1506 | STATE : code ROUTINE : tl_sim_sms_insert_ind | | |
1507 +--------------------------------------------------------------------+ | |
1508 | |
1509 PURPOSE : Process the primitive SIM_SMS_INSERT_IND. | |
1510 | |
1511 */ | |
1512 | |
1513 GLOBAL void tl_sim_sms_insert_ind (T_SIM_SMS_INSERT_IND *insert_ind) | |
1514 { | |
1515 UBYTE i; | |
1516 GET_INSTANCE_DATA; | |
1517 | |
1518 TRACE_FUNCTION ("tl_sim_sms_insert_ind()"); | |
1519 | |
1520 if (sms_data) /*lint !e774 always True*/ | |
1521 { | |
1522 tl_sim_abort_to_mmi (SMS_CAUSE_SIM_BUSY); | |
1523 sms_data->init_done = FALSE; | |
1524 tl_mnsms_report_ind (SMS_ENT_STATE(sms_data) = SMS_STATE_INITIALISING); | |
1525 /* | |
1526 * copy SMS initialisation parameter | |
1527 */ | |
1528 SMS_SIM_PHASE(sms_data) = insert_ind->phase; | |
1529 SMS_INST.tp_mr = insert_ind->tp_mr; | |
1530 /* | |
1531 * memory capacity exceeded notification flag | |
1532 */ | |
1533 switch (insert_ind->mem_cap_avail) | |
1534 { | |
1535 case SIM_SMS_MEM_FULL: | |
1536 /* | |
1537 * Notification Flag = TRUE | |
1538 */ | |
1539 TRACE_EVENT("SIM_SMS_MEM_FULL => Notification Flag = TRUE"); | |
1540 break; | |
1541 case SIM_SMS_MEM_AVAIL: | |
1542 /* | |
1543 * Notification Flag = FALSE | |
1544 */ | |
1545 TRACE_EVENT("SIM_SMS_MEM_AVAIL => Notification Flag = FALSE"); | |
1546 break; | |
1547 case SIM_SMS_NO_MEM: | |
1548 /* | |
1549 * SMS storage on SIM not present | |
1550 */ | |
1551 TRACE_EVENT("SIM_SMS_NO_MEM"); | |
1552 break; | |
1553 default: | |
1554 TRACE_ERROR("invalid mem cap avail information from sim"); | |
1555 } | |
1556 SMS_SIM_MEM_AVAIL(sms_data) = insert_ind->mem_cap_avail & 1; | |
1557 SMS_SAT_DWNLD(sms_data) = insert_ind->download_sms; | |
1558 | |
1559 /* | |
1560 * scan status and protocol identifier for all SMS entries | |
1561 * first one in tl_find_first, the rest with the for loop | |
1562 * in mobile memory | |
1563 */ | |
1564 tl_find_first (MEM_ME); | |
1565 for (i = 2; i <= sms_data->me_backup.max_record; i++) | |
1566 tl_find_next (MEM_ME, i); | |
1567 | |
1568 /* | |
1569 * check for existing but empty memory | |
1570 */ | |
1571 if (SMS_ME_PROP(sms_data).max_record > 0 | |
1572 AND !SMS_ME_PROP(sms_data).any_valid) | |
1573 tl_message_ind_from_sim (MEM_ME, 0, | |
1574 SMS_ME_PROP(sms_data).max_record, | |
1575 NULL); | |
1576 /* | |
1577 * scan status and protocol identifier for all SMS entries | |
1578 * in sim memory | |
1579 */ | |
1580 #ifdef FF_CPHS | |
1581 SET_STATE (STATE_MMI, MMI_FIND_FIRST); | |
1582 tl_sim_read_req (SIM_CPHS_VMW, 1); | |
1583 #elif defined FF_SMS_NW_RCG_SIM | |
1584 SET_STATE (STATE_MMI, MMI_FIND_FIRST); | |
1585 tl_sim_read_req (SIM_IMSI, 9); | |
1586 #else | |
1587 tl_find_first (MEM_SM); | |
1588 #endif | |
1589 } | |
1590 PFREE (insert_ind); | |
1591 } | |
1592 | |
1593 /* | |
1594 +--------------------------------------------------------------------+ | |
1595 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
1596 | STATE : code ROUTINE : tl_sim_read_cnf | | |
1597 +--------------------------------------------------------------------+ | |
1598 | |
1599 PURPOSE : Process the primitive SIM_READ_CNF. | |
1600 */ | |
1601 #if defined(SIM_TOOLKIT) OR defined(FF_CPHS) OR defined(FF_SMS_NW_RCG_SIM) | |
1602 GLOBAL void tl_sim_read_cnf (T_SIM_READ_CNF *read_cnf) | |
1603 { | |
1604 GET_INSTANCE_DATA; | |
1605 USHORT datafield; | |
1606 | |
1607 TRACE_FUNCTION ("tl_sim_file_update_ind()"); | |
1608 | |
1609 datafield = sms_data->sms_sim_access_info[read_cnf->req_id].datafield; | |
1610 sms_data->sms_sim_access_info[read_cnf->req_id].entry_used = FALSE; | |
1611 | |
1612 if (sms_data) | |
1613 { | |
1614 switch (GET_STATE (STATE_MMI)) | |
1615 { | |
1616 case MMI_STATE_UPDATE: | |
1617 /* | |
1618 * EF_SMSS has been updated by SAT. | |
1619 */ | |
1620 if (read_cnf->cause EQ SIM_NO_ERROR) | |
1621 { | |
1622 /* Fetch TP-MR value out of EF_SMSS */ | |
1623 SMS_INST.tp_mr = read_cnf->trans_data[0]; | |
1624 | |
1625 if (sms_data->mem_cap_avail NEQ (read_cnf->trans_data[1] & 1)) | |
1626 { | |
1627 /* | |
1628 * The memory capacity available flag has been changed. | |
1629 * Re-read EF_SMS also even in case this has not been announced | |
1630 * by the SIM application. | |
1631 */ | |
1632 sms_data->mem_cap_avail = read_cnf->trans_data[1] & 1; | |
1633 sms_data->sim_mem_update = TRUE; | |
1634 } | |
1635 else | |
1636 { | |
1637 SET_STATE (STATE_MMI, MMI_IDLE); | |
1638 } | |
1639 } | |
1640 if (sms_data->sim_mem_update) | |
1641 { | |
1642 tl_mnsms_report_ind (SMS_ENT_STATE(sms_data) = SMS_STATE_INITIALISING); | |
1643 tl_find_first (MEM_SM); | |
1644 #ifdef SIM_TOOLKIT | |
1645 if (sms_data->stored_read_cnf NEQ NULL) | |
1646 { | |
1647 /* | |
1648 * Resets the stored MMI state & read_cnf primitive | |
1649 */ | |
1650 sms_data->stored_mmi_state = MMI_IDLE; | |
1651 PFREE (sms_data->stored_read_cnf); | |
1652 sms_data->stored_read_cnf = NULL; | |
1653 } | |
1654 #endif /* SIM_TOOLKIT */ | |
1655 } | |
1656 else | |
1657 { | |
1658 PALLOC (file_update_res, SIM_FILE_UPDATE_RES); | |
1659 file_update_res->fu_rsc = SIM_FU_SUCCESS; | |
1660 file_update_res->source = SRC_SMS; | |
1661 PSENDX (SIM, file_update_res); | |
1662 } | |
1663 #ifdef SIM_TOOLKIT | |
1664 /* | |
1665 * If the SMS has not yet completed reading all the records, start from | |
1666 * the place where it has left earlier. | |
1667 */ | |
1668 if( sms_data->stored_read_cnf NEQ NULL) | |
1669 { | |
1670 SET_STATE(STATE_MMI, sms_data->stored_mmi_state); | |
1671 tl_set_access_fifo (ACCESS_BY_MMI); | |
1672 tl_sim_read_record_cnf(sms_data->stored_read_cnf); | |
1673 sms_data->stored_mmi_state = MMI_IDLE; | |
1674 sms_data->stored_read_cnf = NULL; | |
1675 } | |
1676 #endif /* SIM_TOOLKIT */ | |
1677 | |
1678 break; | |
1679 #ifdef FF_CPHS | |
1680 case MMI_FIND_FIRST: /* CPHS Voice Message Waiting flag existent? */ | |
1681 #ifdef FF_SMS_NW_RCG_SIM | |
1682 if ( datafield EQ SIM_CPHS_VMW) | |
1683 { | |
1684 SMS_CPHS(sms_data) = read_cnf->cause EQ SIM_NO_ERROR; | |
1685 tl_sim_read_req (SIM_IMSI, 9); | |
1686 break; | |
1687 } | |
1688 else if (datafield EQ SIM_IMSI | |
1689 AND read_cnf->cause EQ SIM_NO_ERROR) | |
1690 { | |
1691 tl_check_network_on_sim (read_cnf->trans_data); | |
1692 } | |
1693 tl_find_first (MEM_SM); | |
1694 #else | |
1695 SMS_CPHS(sms_data) = datafield EQ SIM_CPHS_VMW | |
1696 AND read_cnf->cause EQ SIM_NO_ERROR; | |
1697 tl_find_first (MEM_SM); | |
1698 #endif | |
1699 #elif defined FF_SMS_NW_RCG_SIM | |
1700 case MMI_FIND_FIRST: /* SIM operator determination required? */ | |
1701 if (read_cnf->cause EQ SIM_NO_ERROR) | |
1702 tl_check_network_on_sim (read_cnf->trans_data); | |
1703 tl_find_first (MEM_SM); | |
1704 break; | |
1705 #endif | |
1706 default: | |
1707 break; | |
1708 } | |
1709 } | |
1710 PFREE (read_cnf); | |
1711 } | |
1712 #endif /* SIM_TOOLKIT OR FF_CPHS */ | |
1713 | |
1714 /* | |
1715 +--------------------------------------------------------------------+ | |
1716 | PROJECT : GSM-PS (8410) MODULE : SMS_TLF | | |
1717 | STATE : code ROUTINE : tl_sim_update_rec_cnf_mmi | | |
1718 +--------------------------------------------------------------------+ | |
1719 | |
1720 PURPOSE : Processing the function TL_SIM_UPDATE_REC_CNF_MMI. | |
1721 | |
1722 */ | |
1723 | |
1724 LOCAL void tl_sim_update_rec_cnf_mmi ( | |
1725 T_SIM_UPDATE_RECORD_CNF *update_cnf) | |
1726 { | |
1727 GET_INSTANCE_DATA; | |
1728 UBYTE next_rec_num=0,record; | |
1729 TRACE_FUNCTION ("tl_sim_update_rec_cnf_mmi()"); | |
1730 | |
1731 record = sms_data->sms_sim_access_info[update_cnf->req_id].rec_num; | |
1732 sms_data->sms_sim_access_info[update_cnf->req_id].entry_used = FALSE; | |
1733 | |
1734 switch (GET_STATE (STATE_MMI)) | |
1735 { | |
1736 case MMI_READ_STATE_UPDATE: | |
1737 if (update_cnf->cause EQ SIM_NO_ERROR AND | |
1738 record EQ SMS_SEL_REC(sms_data)) | |
1739 { | |
1740 /* | |
1741 * update status byte | |
1742 */ | |
1743 tl_store_status (&SMS_SIM_PROP(sms_data), record-1, | |
1744 SMS_RECORD_REC_READ); | |
1745 } | |
1746 if (SMS_READ_MODE(sms_data) EQ READ_STATUS_CHANGE) | |
1747 { | |
1748 tl_mnsms_read_cnf (MEM_SM, SMS_SEL_REC(sms_data), | |
1749 NULL, SIM_NO_ERROR); | |
1750 } | |
1751 else | |
1752 { | |
1753 tl_mnsms_read_cnf (MEM_SM, SMS_SEL_REC(sms_data), | |
1754 SMS_SIM_READ(sms_data)->linear_data, | |
1755 SIM_NO_ERROR); | |
1756 PFREE (SMS_SIM_READ(sms_data)); | |
1757 SMS_SIM_READ(sms_data) = NULL; | |
1758 } | |
1759 SMS_READ_MODE(sms_data) = READ_NORMAL; | |
1760 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
1761 break; | |
1762 | |
1763 case MMI_WRITE: | |
1764 if (update_cnf->cause EQ SIM_NO_ERROR) | |
1765 { | |
1766 /* | |
1767 * update status byte | |
1768 */ | |
1769 tl_store_status (&SMS_SIM_PROP(sms_data), record-1, | |
1770 SMS_REC_STATUS(sms_data)); | |
1771 tl_store_pid (&SMS_SIM_PROP(sms_data), record-1, | |
1772 SMS_PID(sms_data)); | |
1773 | |
1774 | |
1775 SMS_EM_STORE_MO_SHORT_MESSAGE_2; | |
1776 | |
1777 SMS_EM_CHANGE_SHORT_MESSAGE_2; | |
1778 | |
1779 } | |
1780 else | |
1781 { | |
1782 tl_store_status (&SMS_SIM_PROP(sms_data), record-1, SIM_SMS_FREE); | |
1783 } | |
1784 tl_mnsms_store_cnf (MEM_SM, record, update_cnf->cause); | |
1785 SMS_READ_MODE(sms_data) = READ_NORMAL; | |
1786 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
1787 break; | |
1788 | |
1789 case MMI_DELETE: | |
1790 if (record EQ SMS_SEL_REC(sms_data)) | |
1791 { | |
1792 if (update_cnf->cause EQ SIM_NO_ERROR) | |
1793 { | |
1794 tl_store_status (&SMS_SIM_PROP(sms_data), record-1, SIM_SMS_FREE); | |
1795 | |
1796 TRACE_EVENT_P1 ("mem cap avail %d", sms_data->mem_cap_avail); | |
1797 | |
1798 if (!sms_data->mem_cap_avail) | |
1799 { | |
1800 GET_MO_INSTANCE(sms_data); | |
1801 /* | |
1802 * TL state transition TL_ESTABLISH | |
1803 * EST state transition EST_SMMA | |
1804 */ | |
1805 SET_STATE (STATE_EST, EST_SMMA); | |
1806 SMS_INST_SET_STATE (STATE_TL, TL_ESTABLISH); | |
1807 /* | |
1808 * 1st shot | |
1809 */ | |
1810 SMS_INST.retrans = FALSE; | |
1811 /* | |
1812 * establish connection | |
1813 */ | |
1814 tl_establish_connection(FALSE); | |
1815 /* | |
1816 * wait for processing of RP-SMMA | |
1817 */ | |
1818 return; | |
1819 } | |
1820 if(SMS_REC_STATUS(sms_data) NEQ CMGD_DEL_INDEX) | |
1821 { | |
1822 /* Status value is given. Find the next record satisfying this status value */ | |
1823 next_rec_num = tl_search_record_for_delete (&SMS_SIM_PROP(sms_data), | |
1824 record, | |
1825 SMS_REC_STATUS(sms_data)); | |
1826 | |
1827 | |
1828 TRACE_EVENT_P1 ("tl_sim_update_rec_cnf_mmi :: next_rec_num=%d", next_rec_num); | |
1829 } | |
1830 tl_mnsms_delete_cnf (MEM_SM, record, next_rec_num, SIM_NO_ERROR); | |
1831 } | |
1832 else | |
1833 tl_mnsms_delete_cnf (MEM_SM, record, 0, update_cnf->cause); | |
1834 } | |
1835 else | |
1836 tl_mnsms_delete_cnf (MEM_SM, record, 0, SMS_CAUSE_INV_INDEX); | |
1837 | |
1838 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
1839 break; | |
1840 | |
1841 case MMI_REPLACE: | |
1842 if (record EQ SMS_SEL_REC(sms_data)) | |
1843 { | |
1844 if (update_cnf->cause EQ SIM_NO_ERROR) | |
1845 { | |
1846 #ifdef REL99 | |
1847 if(SMS_INST.failed_msg_retx EQ FALSE) | |
1848 { | |
1849 #endif | |
1850 tl_mnsms_submit_cnf (MEM_SM, record, | |
1851 SMS_TP_REF_RET(sms_data), | |
1852 SMS_NO_ERROR, SMS_SDU(sms_data)); | |
1853 #ifdef REL99 | |
1854 } | |
1855 else | |
1856 { | |
1857 tl_mnsms_retrans_cnf (MEM_SM, record, | |
1858 SMS_TP_REF_RET(sms_data), | |
1859 SMS_NO_ERROR, SMS_SDU(sms_data)); | |
1860 } | |
1861 #endif | |
1862 | |
1863 /* | |
1864 * update status byte | |
1865 */ | |
1866 tl_store_status (&SMS_SIM_PROP(sms_data), record-1, | |
1867 SMS_RECORD_STO_SENT); | |
1868 tl_store_pid (&SMS_SIM_PROP(sms_data), record-1, | |
1869 SMS_PID_DEFAULT); | |
1870 } | |
1871 else | |
1872 { | |
1873 #ifdef REL99 | |
1874 if(SMS_INST.failed_msg_retx EQ FALSE) | |
1875 { | |
1876 #endif | |
1877 tl_mnsms_submit_cnf (MEM_SM, SMS_RECORD_NOT_EXIST, | |
1878 SMS_TP_REF_RET(sms_data), | |
1879 update_cnf->cause, SMS_SDU(sms_data)); | |
1880 #ifdef REL99 | |
1881 } | |
1882 else | |
1883 { | |
1884 tl_mnsms_retrans_cnf (MEM_SM, SMS_RECORD_NOT_EXIST, | |
1885 SMS_TP_REF_RET(sms_data), | |
1886 update_cnf->cause, SMS_SDU(sms_data)); | |
1887 } | |
1888 #endif | |
1889 tl_store_status (&SMS_SIM_PROP(sms_data), record-1, | |
1890 SMS_RECORD_FREE); /* reset reservation */ | |
1891 } | |
1892 } | |
1893 else | |
1894 tl_mnsms_submit_cnf (MEM_SM, record, | |
1895 SMS_TP_REF_RET(sms_data), | |
1896 SMS_CAUSE_INV_INDEX, SMS_SDU(sms_data)); | |
1897 | |
1898 if (SMS_SDU(sms_data) NEQ NULL) | |
1899 { | |
1900 MFREE (SMS_SDU(sms_data)); | |
1901 SMS_SDU(sms_data) = NULL; | |
1902 } | |
1903 SMS_SEL_REC(sms_data) = SMS_RECORD_NOT_EXIST; | |
1904 /* | |
1905 * concat control | |
1906 */ | |
1907 if (sms_data->concat_cntrl.concatenation EQ TRUE) | |
1908 { | |
1909 /* | |
1910 * start timer TLCT for next submit req supervision | |
1911 */ | |
1912 sms_timer_start(TLCT); | |
1913 /* | |
1914 * TL State Transition TL_SEND_CONTD | |
1915 */ | |
1916 SMS_INST_SET_STATE (STATE_TL, TL_SEND_CONTD); | |
1917 /* | |
1918 * remember to release connection | |
1919 */ | |
1920 sms_data->concat_cntrl.release_pending = TRUE; | |
1921 } | |
1922 else | |
1923 { | |
1924 /* | |
1925 * TL State Transition TL_IDLE | |
1926 */ | |
1927 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
1928 } | |
1929 break; | |
1930 | |
1931 default: | |
1932 assert (GET_STATE (STATE_MMI) EQ MMI_IDLE); /* illegal state */ | |
1933 break; | |
1934 } | |
1935 SET_STATE (STATE_MMI, MMI_IDLE); | |
1936 #ifdef SIM_TOOLKIT | |
1937 if (sms_data->file_update_ind NEQ NULL) | |
1938 { | |
1939 T_SIM_FILE_UPDATE_IND *file_update_ind = sms_data->file_update_ind; | |
1940 sms_data->file_update_ind = NULL; | |
1941 tl_sim_file_update_ind (file_update_ind); | |
1942 } | |
1943 #endif | |
1944 } | |
1945 | |
1946 /* | |
1947 +--------------------------------------------------------------------+ | |
1948 | PROJECT : GSM-PS (8410) MODULE : SMS_TLF | | |
1949 | STATE : code ROUTINE : tl_sim_update_rec_cnf_net | | |
1950 +--------------------------------------------------------------------+ | |
1951 | |
1952 PURPOSE : Processing the function TL_SIM_UPDATE_REC_CNF_NET. | |
1953 | |
1954 */ | |
1955 | |
1956 LOCAL void tl_sim_update_rec_cnf_net (T_SIM_UPDATE_RECORD_CNF *update_cnf) | |
1957 { | |
1958 GET_INSTANCE_DATA; | |
1959 UBYTE record; | |
1960 UBYTE data[SIZE_EF_SMS]; | |
1961 | |
1962 TRACE_FUNCTION ("tl_sim_update_rec_cnf_net()"); | |
1963 | |
1964 record = sms_data->sms_sim_access_info[update_cnf->req_id].rec_num; | |
1965 sms_data->sms_sim_access_info[update_cnf->req_id].entry_used = FALSE; | |
1966 | |
1967 | |
1968 CCD_START; | |
1969 | |
1970 switch (GET_STATE (STATE_NET)) | |
1971 { | |
1972 case NET_WRITE: | |
1973 if (update_cnf->cause EQ SIM_NO_ERROR) | |
1974 { | |
1975 /* | |
1976 * update status byte | |
1977 */ | |
1978 tl_store_status (&SMS_SIM_PROP(sms_data), record-1, | |
1979 SMS_RECORD_REC_UNREAD); | |
1980 tl_store_pid (&SMS_SIM_PROP(sms_data), record-1, SMS_PID(sms_data)); | |
1981 /* | |
1982 * send indication to MMI | |
1983 */ | |
1984 tl_message_ind_from_net (MEM_SM, record, | |
1985 SMS_SIM_PROP(sms_data).max_record, | |
1986 SMS_RP_RCVD(sms_data)); | |
1987 | |
1988 rl_report_req_ack (NULL); | |
1989 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
1990 } | |
1991 else switch (sms_data->use_mem_b) // check alternative B | |
1992 { | |
1993 case DISPLAY: | |
1994 /* | |
1995 * Only display of the message | |
1996 */ | |
1997 tl_message_ind_from_net (NOT_PRESENT_8BIT, 0, 0, | |
1998 SMS_RP_RCVD(sms_data)); | |
1999 { | |
2000 if (sms_data->mhc NEQ SMS_MHC_PH2PLUS) | |
2001 { | |
2002 rl_report_req_ack (NULL); | |
2003 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
2004 } | |
2005 } | |
2006 break; | |
2007 | |
2008 case MEM_ME: | |
2009 /* | |
2010 * memory type is mobile memory | |
2011 */ | |
2012 record = tl_get_free_space (MEM_ME); | |
2013 if (record) | |
2014 { | |
2015 /* | |
2016 * store in mobile memory | |
2017 */ | |
2018 /* Implements Measure#32: Row 104 */ | |
2019 if (pcm_WriteRecord ((UBYTE *)ef_sms_id, record, | |
2020 SIZE_EF_SMS, data) EQ PCM_OK) | |
2021 { | |
2022 /* | |
2023 * update status byte | |
2024 */ | |
2025 tl_store_status (&SMS_ME_PROP(sms_data), record-1, SMS_RECORD_REC_UNREAD); | |
2026 tl_store_pid (&SMS_ME_PROP(sms_data), record-1, SMS_PID(sms_data)); | |
2027 /* | |
2028 * send indication to MMI | |
2029 */ | |
2030 tl_message_ind_from_net (MEM_ME, record, | |
2031 SMS_ME_PROP(sms_data).max_record, | |
2032 SMS_RP_RCVD(sms_data)); | |
2033 /* | |
2034 * acknowledge to the infrastructure | |
2035 */ | |
2036 rl_report_req_ack (NULL); | |
2037 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
2038 break; | |
2039 } | |
2040 } | |
2041 /*FALLTHROUGH*/ /*lint -fallthrough*/ | |
2042 default: | |
2043 if (tl_get_free_space (MEM_ME) OR tl_get_free_space (MEM_SM)) | |
2044 { | |
2045 /* | |
2046 * error to the infrastructure | |
2047 */ | |
2048 rl_report_req_error (SMS_RP_CS_PROTOCOL_ERROR, NULL); | |
2049 /* | |
2050 * RL_RELEASE_REQ ==> | |
2051 */ | |
2052 rl_release_req(SMS_INST.ti); | |
2053 | |
2054 } | |
2055 else | |
2056 { | |
2057 if (update_cnf->cause NEQ SIM_CAUSE_DRV_TEMPFAIL) | |
2058 { | |
2059 /* change mem_cap_avail flag on SIM and return error */ | |
2060 tl_sms_memo_exceeded (FALSE); | |
2061 } | |
2062 else | |
2063 { | |
2064 /* | |
2065 * RP_ERROR => | |
2066 */ | |
2067 rl_report_req_error ( | |
2068 SMS_RP_CS_PROTOCOL_ERROR, NULL); | |
2069 /* | |
2070 * RL_RELEASE_REQ ==> | |
2071 */ | |
2072 rl_release_req(SMS_INST.ti); | |
2073 } | |
2074 } | |
2075 tl_store_status (&SMS_SIM_PROP(sms_data), record-1, SIM_SMS_FREE); | |
2076 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
2077 break; | |
2078 | |
2079 case IGNORE: | |
2080 rl_report_req_ack (NULL); | |
2081 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
2082 | |
2083 MFREE (SMS_RP_RCVD(sms_data)); | |
2084 SMS_RP_RCVD(sms_data) = NULL; | |
2085 break; | |
2086 } | |
2087 sms_data->use_mem_b = NOTHING; | |
2088 | |
2089 MFREE (SMS_RP_RCVD(sms_data)); | |
2090 SMS_RP_RCVD(sms_data) = NULL; | |
2091 break; | |
2092 | |
2093 case NET_23430_WRITE: | |
2094 if (update_cnf->cause EQ SIM_NO_ERROR) | |
2095 { | |
2096 CCD_END; | |
2097 | |
2098 tl_sim_update_req (record, | |
2099 SMS_RECORD_FREE, NULL); | |
2100 | |
2101 tl_set_access_fifo (ACCESS_BY_NET); | |
2102 SET_STATE (STATE_NET, NET_23430_DELETE); | |
2103 return; | |
2104 } | |
2105 tl_store_status (&SMS_SIM_PROP(sms_data), record-1, SIM_SMS_FREE); | |
2106 | |
2107 tl_sms_memo_exceeded (FALSE); | |
2108 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
2109 break; | |
2110 | |
2111 case NET_23430_DELETE: | |
2112 tl_store_status (&SMS_SIM_PROP(sms_data), record-1, SIM_SMS_FREE); | |
2113 rl_report_req_ack (NULL); | |
2114 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
2115 break; | |
2116 | |
2117 default: | |
2118 assert (GET_STATE (STATE_NET) EQ NET_IDLE); /* illegal state */ | |
2119 // SET_STATE (STATE_NET, NET_IDLE); | |
2120 break; | |
2121 } | |
2122 CCD_END; | |
2123 | |
2124 SET_STATE (STATE_NET, NET_IDLE); | |
2125 } | |
2126 | |
2127 /* | |
2128 +--------------------------------------------------------------------+ | |
2129 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
2130 | STATE : code ROUTINE : tl_sim_update_cnf | | |
2131 +--------------------------------------------------------------------+ | |
2132 | |
2133 PURPOSE : After updating of EF(SMSS) the Entity state is checked | |
2134 and a MNSMS_REPORT_IND is sent to indicate the Ready | |
2135 State | |
2136 */ | |
2137 | |
2138 GLOBAL void tl_sim_update_cnf (T_SIM_UPDATE_CNF *update_cnf) | |
2139 { | |
2140 GET_INSTANCE_DATA; | |
2141 UBYTE next_rec_num = 0; | |
2142 | |
2143 TRACE_FUNCTION ("tl_sim_update_cnf()"); | |
2144 sms_data->sms_sim_access_info[update_cnf->req_id].entry_used = FALSE; | |
2145 | |
2146 switch (tl_read_access_fifo ()) | |
2147 { | |
2148 case ACCESS_BY_MMI: | |
2149 if (sms_data->sms_sim_access_info[update_cnf->req_id].datafield EQ SIM_SMSS AND | |
2150 SMS_ENT_STATE(sms_data) EQ SMS_STATE_INITIALISING) | |
2151 { | |
2152 tl_mnsms_report_ind (SMS_ENT_STATE(sms_data) = SMS_STATE_READY); | |
2153 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
2154 PFREE (update_cnf); | |
2155 return; | |
2156 } | |
2157 if (GET_STATE (STATE_MMI) EQ MMI_DELETE) | |
2158 { | |
2159 GET_MO_INSTANCE(sms_data); | |
2160 /* | |
2161 * confirm deletion to user | |
2162 */ | |
2163 if(SMS_REC_STATUS(sms_data) NEQ CMGD_DEL_INDEX) | |
2164 { | |
2165 /* Status value is given. Find the next record satisfying this status value */ | |
2166 next_rec_num = tl_search_record_for_delete (((SMS_SEL_MEM(sms_data) EQ MEM_ME)? | |
2167 &SMS_ME_PROP(sms_data):&SMS_SIM_PROP(sms_data)), | |
2168 SMS_SEL_REC(sms_data), | |
2169 SMS_REC_STATUS(sms_data)); | |
2170 } | |
2171 tl_mnsms_delete_cnf (SMS_SEL_MEM(sms_data), SMS_SEL_REC(sms_data), next_rec_num, SIM_NO_ERROR); | |
2172 SET_STATE (STATE_MMI, MMI_IDLE); | |
2173 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
2174 } | |
2175 else if (GET_STATE (STATE_MMI) EQ MMI_RESUME) | |
2176 { | |
2177 /* | |
2178 * confirm resumption to user | |
2179 */ | |
2180 if (sms_data->pr_cntrl.save_cause EQ SMS_NO_ERROR) | |
2181 { | |
2182 if (update_cnf->cause == SIM_NO_ERROR) | |
2183 { | |
2184 tl_mnsms_resume_cnf(SMS_NO_ERROR); | |
2185 } | |
2186 else | |
2187 { | |
2188 tl_mnsms_resume_cnf(update_cnf->cause); | |
2189 } | |
2190 } | |
2191 else | |
2192 { | |
2193 tl_mnsms_resume_cnf(sms_data->pr_cntrl.save_cause); | |
2194 } | |
2195 SET_STATE (STATE_MMI, MMI_IDLE); | |
2196 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
2197 } | |
2198 break; | |
2199 | |
2200 case ACCESS_BY_NET: | |
2201 TRACE_EVENT ("SIM_UPDATE_CNF ignored"); | |
2202 break; | |
2203 | |
2204 default: | |
2205 TRACE_ERROR ("Unexpected Error Value"); | |
2206 break; | |
2207 } | |
2208 #ifdef SIM_TOOLKIT | |
2209 if (sms_data->file_update_ind NEQ NULL) | |
2210 { | |
2211 T_SIM_FILE_UPDATE_IND *file_update_ind = sms_data->file_update_ind; | |
2212 sms_data->file_update_ind = NULL; | |
2213 tl_sim_file_update_ind (file_update_ind); | |
2214 } | |
2215 #endif | |
2216 PFREE (update_cnf); | |
2217 } | |
2218 | |
2219 /* | |
2220 +--------------------------------------------------------------------+ | |
2221 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
2222 | STATE : code ROUTINE : tl_sim_update_record_cnf | | |
2223 +--------------------------------------------------------------------+ | |
2224 | |
2225 PURPOSE : Process the primitive SIM_UPDATE_RECORD_CNF. | |
2226 | |
2227 */ | |
2228 | |
2229 GLOBAL void tl_sim_update_record_cnf (T_SIM_UPDATE_RECORD_CNF *update_cnf) | |
2230 { | |
2231 GET_INSTANCE_DATA; | |
2232 | |
2233 TRACE_FUNCTION ("tl_sim_update_record_cnf()"); | |
2234 | |
2235 switch (tl_read_access_fifo ()) | |
2236 { | |
2237 case ACCESS_BY_NET: | |
2238 GET_MT_INSTANCE(sms_data); /* MT */ | |
2239 tl_sim_update_rec_cnf_net (update_cnf); | |
2240 break; | |
2241 | |
2242 case ACCESS_BY_MMI: | |
2243 GET_MO_INSTANCE(sms_data); /* MO */ | |
2244 tl_sim_update_rec_cnf_mmi (update_cnf); | |
2245 break; | |
2246 | |
2247 default: | |
2248 assert (0); /* impossible case */ | |
2249 break; | |
2250 } | |
2251 PFREE (update_cnf); | |
2252 } | |
2253 | |
2254 /* | |
2255 +--------------------------------------------------------------------+ | |
2256 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
2257 | STATE : code ROUTINE : tl_sim_read_record_cnf | | |
2258 +--------------------------------------------------------------------+ | |
2259 | |
2260 PURPOSE : Process the primitive SIM_READ_RECORD_CNF. | |
2261 | |
2262 */ | |
2263 | |
2264 GLOBAL void tl_sim_read_record_cnf (T_SIM_READ_RECORD_CNF *read_cnf) | |
2265 { | |
2266 T_SIM_PDU *sim_pdu; | |
2267 GET_INSTANCE_DATA; | |
2268 UBYTE record; | |
2269 TRACE_FUNCTION ("tl_sim_read_record_cnf()"); | |
2270 | |
2271 record = sms_data->sms_sim_access_info[read_cnf->req_id].rec_num; | |
2272 sms_data->sms_sim_access_info[read_cnf->req_id].entry_used = FALSE; | |
2273 | |
2274 if (sms_data) /*lint !e774 always True*/ | |
2275 { | |
2276 switch (tl_read_access_fifo ()) | |
2277 { | |
2278 case ACCESS_BY_MMI: | |
2279 GET_MO_INSTANCE(sms_data); /* MO */ | |
2280 switch (GET_STATE (STATE_MMI)) | |
2281 { | |
2282 case MMI_READ: | |
2283 /* | |
2284 * read attempt from MMI | |
2285 */ | |
2286 if (read_cnf->cause EQ SIM_NO_ERROR AND | |
2287 record EQ SMS_SEL_REC(sms_data)) | |
2288 { | |
2289 tl_store_status (&SMS_SIM_PROP(sms_data), record-1, | |
2290 read_cnf->linear_data[0]); | |
2291 if (SMS_INST_GET_STATE (STATE_TL) EQ TL_SEND) | |
2292 { | |
2293 MCAST (cp_data, U_CP_DATA); | |
2294 | |
2295 MALLOC (sim_pdu, sizeof(T_SIM_PDU)); | |
2296 CCD_START; | |
2297 if (tl_modify_submit (sim_pdu, SMS_MODIFY(sms_data), | |
2298 SMS_SDU(sms_data), | |
2299 read_cnf->linear_data) AND | |
2300 tl_prepare_submit (sim_pdu, cp_data)) | |
2301 { | |
2302 /* | |
2303 * RL_DATA_REQ | |
2304 */ | |
2305 if (!rl_data_req (SMS_INST.tp_mr, cp_data)) | |
2306 { | |
2307 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
2308 /* | |
2309 * release connection | |
2310 */ | |
2311 rl_release_req(SMS_INST.ti); | |
2312 /* | |
2313 * send not successful but we confirm with no error ???!! | |
2314 */ | |
2315 tl_mnsms_submit_cnf (MEM_SM, record, | |
2316 NOT_PRESENT_8BIT, SMS_NO_ERROR, NULL); | |
2317 } | |
2318 } | |
2319 else | |
2320 { | |
2321 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
2322 tl_mnsms_submit_cnf (MEM_SM, record, | |
2323 NOT_PRESENT_8BIT, SMS_CAUSE_PARAM_WRONG, NULL); | |
2324 } | |
2325 CCD_END; | |
2326 MFREE (sim_pdu); | |
2327 MFREE (SMS_SDU(sms_data)); | |
2328 SMS_SDU(sms_data) = NULL; | |
2329 | |
2330 SET_STATE (STATE_MMI, MMI_IDLE); | |
2331 break; | |
2332 } | |
2333 if ((read_cnf->linear_data[0] & 1) EQ SMS_RECORD_FREE) | |
2334 { | |
2335 tl_mnsms_read_cnf (MEM_SM, 0, | |
2336 NULL, SMS_CAUSE_INV_INDEX); | |
2337 } | |
2338 else if (((read_cnf->linear_data[0] & 7) EQ SMS_RECORD_REC_UNREAD) | |
2339 AND SMS_READ_MODE(sms_data) NEQ READ_PREVIEW) | |
2340 { | |
2341 tl_set_access_fifo (ACCESS_BY_MMI); | |
2342 SET_STATE (STATE_MMI, MMI_READ_STATE_UPDATE); | |
2343 SMS_INST_SET_STATE (STATE_TL, TL_OTHER); | |
2344 tl_sim_update_req (record, SMS_RECORD_REC_READ, | |
2345 &read_cnf->linear_data[1]); | |
2346 | |
2347 if (SMS_READ_MODE(sms_data) NEQ READ_STATUS_CHANGE) | |
2348 { | |
2349 // read_cnf->linear_data[0] = SMS_RECORD_REC_READ; | |
2350 /* | |
2351 * keep read data until reception of UPDATE CONFIRM | |
2352 */ | |
2353 if (SMS_SIM_READ(sms_data) NEQ 0) | |
2354 PFREE(SMS_SIM_READ(sms_data)); | |
2355 SMS_SIM_READ(sms_data) = read_cnf; | |
2356 return; /* read_cnf not to be deallocated */ | |
2357 } | |
2358 PFREE (read_cnf); | |
2359 return; /* keep states */ | |
2360 } | |
2361 else | |
2362 { | |
2363 | |
2364 SMS_EM_READ_SHORT_MESSAGE_2; | |
2365 | |
2366 tl_mnsms_read_cnf (MEM_SM, record, | |
2367 ((SMS_READ_MODE(sms_data) EQ READ_STATUS_CHANGE)? | |
2368 NULL: read_cnf->linear_data), | |
2369 SIM_NO_ERROR); | |
2370 } | |
2371 } | |
2372 else | |
2373 { | |
2374 if (SMS_INST_GET_STATE (STATE_TL) EQ TL_SEND) | |
2375 { | |
2376 if (read_cnf->cause EQ SIM_NO_ERROR) | |
2377 tl_mnsms_submit_cnf (MEM_SM, record, | |
2378 NOT_PRESENT_8BIT, SMS_CAUSE_INV_INDEX, NULL); | |
2379 else | |
2380 tl_mnsms_submit_cnf (MEM_SM, record, | |
2381 NOT_PRESENT_8BIT, read_cnf->cause, NULL); | |
2382 } | |
2383 else | |
2384 tl_mnsms_read_cnf (MEM_SM, 0, | |
2385 NULL, SMS_CAUSE_INV_INDEX); | |
2386 } | |
2387 SET_STATE (STATE_MMI, MMI_IDLE); | |
2388 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
2389 break; | |
2390 | |
2391 case MMI_FIND_FIRST: | |
2392 #ifdef SIM_TOOLKIT | |
2393 if (sms_data->file_update_ind NEQ NULL) | |
2394 { | |
2395 T_SIM_FILE_UPDATE_IND *file_update_ind = sms_data->file_update_ind; | |
2396 /* | |
2397 * Take a backup of the current status of the MMI_STATE | |
2398 */ | |
2399 sms_data->stored_mmi_state = GET_STATE(STATE_MMI); | |
2400 SET_STATE (STATE_MMI, MMI_IDLE); | |
2401 sms_data->file_update_ind = NULL; | |
2402 tl_sim_file_update_ind (file_update_ind); | |
2403 | |
2404 /* Implements Measure# 7 */ | |
2405 if( tl_sim_rd_record_update_state(read_cnf) ) | |
2406 return; | |
2407 } | |
2408 #endif | |
2409 /* | |
2410 * first record is scanned | |
2411 */ | |
2412 if (read_cnf->cause EQ SIM_NO_ERROR) | |
2413 { | |
2414 /* Store max. supported records of the SIM */ | |
2415 SMS_SIM_PROP(sms_data).max_record = read_cnf->max_record; | |
2416 | |
2417 if (SMS_SIM_PROP(sms_data).max_record > MAX_RECORD_SIM) | |
2418 { | |
2419 /* The number of supported records is limited by SMS */ | |
2420 SMS_SIM_PROP(sms_data).max_record = MAX_RECORD_SIM; | |
2421 } | |
2422 else if (SMS_SIM_PROP(sms_data).max_record EQ 0) | |
2423 { | |
2424 /* We have at least one record as we successfully read it | |
2425 * regardless of the returned value from the SIM */ | |
2426 SMS_SIM_PROP(sms_data).max_record = 1; | |
2427 } | |
2428 /* | |
2429 * continue with MMI_FIND_NEXT | |
2430 */ | |
2431 } | |
2432 else | |
2433 { | |
2434 /* | |
2435 * No EF_SMS field on the SIM. | |
2436 */ | |
2437 SMS_SIM_PROP(sms_data).max_record = 0; | |
2438 SET_STATE (STATE_MMI, MMI_IDLE); | |
2439 /* | |
2440 * init done | |
2441 */ | |
2442 tl_init_complete(); | |
2443 break; | |
2444 } | |
2445 /*FALLTHROUGH*/ /*lint -fallthrough*/ | |
2446 case MMI_FIND_NEXT: | |
2447 | |
2448 #ifdef SIM_TOOLKIT | |
2449 /* | |
2450 * Take a backup of the current status of the MMI_STATE | |
2451 */ | |
2452 sms_data->stored_mmi_state = GET_STATE(STATE_MMI); | |
2453 #endif /* SIM_TOOLKIT */ | |
2454 | |
2455 SET_STATE (STATE_MMI, MMI_IDLE); | |
2456 | |
2457 #ifdef SIM_TOOLKIT | |
2458 | |
2459 if (sms_data->file_update_ind NEQ NULL) | |
2460 { | |
2461 T_SIM_FILE_UPDATE_IND *file_update_ind = sms_data->file_update_ind; | |
2462 sms_data->file_update_ind = NULL; | |
2463 tl_sim_file_update_ind (file_update_ind); | |
2464 | |
2465 /* Implements Measure# 7 */ | |
2466 if( tl_sim_rd_record_update_state(read_cnf) ) | |
2467 return; | |
2468 } | |
2469 #endif | |
2470 /* | |
2471 * next record is scanned | |
2472 */ | |
2473 if (read_cnf->cause EQ SIM_NO_ERROR) | |
2474 { | |
2475 if (tl_find_status_pid (MEM_SM, | |
2476 record, | |
2477 read_cnf->linear_data, | |
2478 &SMS_SIM_PROP(sms_data))) | |
2479 tl_message_ind_from_sim (MEM_SM, record, | |
2480 read_cnf->max_record, | |
2481 read_cnf->linear_data); | |
2482 if (record < SMS_SIM_PROP(sms_data).max_record) | |
2483 tl_find_next (MEM_SM, (UBYTE)(record + 1)); | |
2484 else | |
2485 { | |
2486 #ifdef SIM_TOOLKIT | |
2487 if (sms_data->sim_mem_update) | |
2488 { | |
2489 PALLOC (file_update_res, SIM_FILE_UPDATE_RES); | |
2490 file_update_res->source = SRC_SMS; | |
2491 file_update_res->fu_rsc = SIM_FU_SUCCESS; | |
2492 PSENDX (SIM, file_update_res); | |
2493 sms_data->sim_mem_update = FALSE; | |
2494 } | |
2495 #endif | |
2496 /* | |
2497 * check for existing but empty memory | |
2498 */ | |
2499 if (SMS_SIM_PROP(sms_data).max_record > 0 | |
2500 AND !SMS_SIM_PROP(sms_data).any_valid) | |
2501 tl_message_ind_from_sim (MEM_SM, 0, | |
2502 SMS_SIM_PROP(sms_data).max_record, | |
2503 NULL); | |
2504 | |
2505 /* | |
2506 * init done | |
2507 */ | |
2508 tl_init_complete(); | |
2509 } | |
2510 } | |
2511 else | |
2512 { | |
2513 /* | |
2514 * declare only successful read | |
2515 * entries as available | |
2516 */ | |
2517 SMS_SIM_PROP(sms_data).max_record = record - 1; | |
2518 // must be doubled | |
2519 /* | |
2520 * init done | |
2521 */ | |
2522 tl_init_complete(); | |
2523 } | |
2524 break; | |
2525 | |
2526 default: | |
2527 assert (GET_STATE (STATE_MMI) EQ MMI_IDLE); /* illegal state */ | |
2528 break; | |
2529 } | |
2530 #ifdef SIM_TOOLKIT | |
2531 if (sms_data->file_update_ind NEQ NULL) | |
2532 { | |
2533 T_SIM_FILE_UPDATE_IND *file_update_ind = sms_data->file_update_ind; | |
2534 sms_data->file_update_ind = NULL; | |
2535 tl_sim_file_update_ind (file_update_ind); | |
2536 } | |
2537 #endif | |
2538 break; | |
2539 | |
2540 case ACCESS_BY_NET: | |
2541 GET_MT_INSTANCE(sms_data); /* MT */ | |
2542 switch (GET_STATE (STATE_NET)) | |
2543 { | |
2544 case NET_READ: | |
2545 if (tl_check_replace_entry (&SMS_RP_RCVD(sms_data)->rp_user_data.tpdu.b_tpdu[1], | |
2546 &read_cnf->linear_data[1])) | |
2547 { | |
2548 /* | |
2549 *record shall be replaced | |
2550 */ | |
2551 tl_sim_conv_update_req (record, SMS_RP_RCVD(sms_data)); | |
2552 | |
2553 SMS_EM_REPLACE_SMS_IN_SIM; | |
2554 | |
2555 tl_set_access_fifo (ACCESS_BY_NET); | |
2556 SET_STATE (STATE_NET, NET_WRITE); | |
2557 } | |
2558 else | |
2559 { | |
2560 int i; | |
2561 | |
2562 i = tl_check_mt_pid (&SMS_SIM_PROP(sms_data), | |
2563 record + 1, | |
2564 SMS_PID(sms_data)); | |
2565 if (i > 0) | |
2566 { | |
2567 tl_set_access_fifo (ACCESS_BY_NET); | |
2568 tl_sim_read_record_req((UBYTE)i); | |
2569 } | |
2570 else | |
2571 { | |
2572 MCAST (sms_deliver, TP_DELIVER); | |
2573 | |
2574 SET_STATE (STATE_NET, NET_IDLE); | |
2575 | |
2576 CCD_START; | |
2577 ccd_decodeMsg (CCDENT_SMS, | |
2578 DOWNLINK, | |
2579 (T_MSGBUF *)&SMS_RP_RCVD(sms_data)->rp_user_data.tpdu, | |
2580 (UBYTE *)sms_deliver, | |
2581 TP_DELIVER); | |
2582 tl_handle_message (sms_deliver); | |
2583 CCD_END; | |
2584 } | |
2585 } | |
2586 break; | |
2587 | |
2588 default: | |
2589 assert (GET_STATE (STATE_NET) EQ NET_IDLE); /* illegal state */ | |
2590 break; | |
2591 } | |
2592 break; | |
2593 | |
2594 default: | |
2595 assert (0); /* impossible case */ | |
2596 break; | |
2597 } | |
2598 } | |
2599 PFREE (read_cnf); | |
2600 } | |
2601 | |
2602 /* | |
2603 +--------------------------------------------------------------------+ | |
2604 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
2605 | STATE : code ROUTINE : tl_sim_remove_ind | | |
2606 +--------------------------------------------------------------------+ | |
2607 | |
2608 PURPOSE : Process the primitive SIM_REMOVE_IND. | |
2609 | |
2610 */ | |
2611 | |
2612 GLOBAL void tl_sim_remove_ind (T_SIM_REMOVE_IND *remove_ind) | |
2613 { | |
2614 USHORT error; | |
2615 register T_SMS_DATA *sms_data = GET_SMS_INSTANCE (0); | |
2616 | |
2617 TRACE_FUNCTION ("tl_sim_remove_ind()"); | |
2618 if (sms_data) | |
2619 { | |
2620 error = (remove_ind->cause EQ SIM_NO_ERROR)? | |
2621 SMS_CAUSE_SIM_BUSY: remove_ind->cause; | |
2622 | |
2623 tl_sim_abort_to_mmi (error); | |
2624 | |
2625 sms_data->init_done = FALSE; | |
2626 SMS_SIM_PROP(sms_data).max_record = 0; | |
2627 sms_data->me_backup.max_record = 0; | |
2628 sms_data->sim_mem_update = FALSE; | |
2629 } | |
2630 PFREE (remove_ind); | |
2631 } | |
2632 | |
2633 #if defined(SIM_TOOLKIT) | |
2634 /* | |
2635 +--------------------------------------------------------------------+ | |
2636 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
2637 | STATE : code ROUTINE : tl_sim_toolkit_cnf | | |
2638 +--------------------------------------------------------------------+ | |
2639 | |
2640 PURPOSE : Process the primitive SIM_TOOLKIT_CNF. | |
2641 | |
2642 */ | |
2643 | |
2644 GLOBAL void tl_sim_toolkit_cnf (T_SIM_TOOLKIT_CNF *toolkit_cnf) | |
2645 { | |
2646 GET_INSTANCE_DATA; | |
2647 | |
2648 TRACE_FUNCTION ("tl_sim_toolkit_cnf()"); | |
2649 | |
2650 switch (tl_read_access_fifo ()) | |
2651 { | |
2652 case ACCESS_BY_NET: | |
2653 GET_MT_INSTANCE(sms_data); /* MT */ | |
2654 tl_sim_toolkit_confirm (toolkit_cnf); | |
2655 break; | |
2656 | |
2657 default: | |
2658 assert(0); | |
2659 break; | |
2660 } | |
2661 PFREE (toolkit_cnf); | |
2662 } | |
2663 | |
2664 /* | |
2665 +--------------------------------------------------------------------+ | |
2666 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
2667 | STATE : code ROUTINE : tl_sim_file_update_ind | | |
2668 +--------------------------------------------------------------------+ | |
2669 | |
2670 PURPOSE : Process the primitive SIM_FILE_UPDATE_IND. | |
2671 | |
2672 */ | |
2673 | |
2674 GLOBAL void tl_sim_file_update_ind (T_SIM_FILE_UPDATE_IND *file_update_ind) | |
2675 { | |
2676 USHORT i; | |
2677 BOOL found_sms = FALSE; /* short messages changed by SAT */ | |
2678 BOOL found_smss = FALSE; /* short message status changed by SAT */ | |
2679 register T_SMS_DATA *sms_data = GET_SMS_INSTANCE (0); | |
2680 | |
2681 TRACE_FUNCTION ("tl_sim_file_update_ind()"); | |
2682 | |
2683 if (sms_data) | |
2684 { | |
2685 /* | |
2686 * avoid interference with active MMI procedure | |
2687 */ | |
2688 switch (GET_STATE (STATE_MMI)) | |
2689 { | |
2690 case MMI_IDLE: | |
2691 break; | |
2692 | |
2693 default: | |
2694 if (sms_data->file_update_ind NEQ NULL) | |
2695 PFREE (sms_data->file_update_ind); | |
2696 /* store primitive for delayed reaction */ | |
2697 sms_data->file_update_ind = file_update_ind; | |
2698 return; | |
2699 } | |
2700 | |
2701 for (i = 0; i < file_update_ind->val_nr; i++) | |
2702 { | |
2703 if((file_update_ind->file_info[i].v_path_info EQ TRUE) AND | |
2704 (file_update_ind->file_info[i].path_info.df_level1 EQ SIM_DF_TELECOM) AND | |
2705 (file_update_ind->file_info[i].path_info.v_df_level2 EQ FALSE)) | |
2706 { | |
2707 if (file_update_ind->file_info[i].datafield EQ SIM_SMS) | |
2708 { | |
2709 /* short messages changed by SAT */ | |
2710 found_sms = TRUE; | |
2711 sms_data->sim_mem_update = TRUE; | |
2712 } | |
2713 else if (file_update_ind->file_info[i].datafield EQ SIM_SMSS) | |
2714 { | |
2715 /* short message status changed by SAT */ | |
2716 found_smss = TRUE; | |
2717 } | |
2718 } | |
2719 | |
2720 if (found_sms AND found_smss) | |
2721 break; | |
2722 } | |
2723 | |
2724 if (found_smss) | |
2725 { | |
2726 /* short message status changed by SAT */ | |
2727 tl_sim_read_req (SIM_SMSS, 2); | |
2728 sms_data->sim_mem_update = found_sms NEQ FALSE; | |
2729 | |
2730 SET_STATE (STATE_MMI, MMI_STATE_UPDATE); | |
2731 } | |
2732 else if (found_sms) | |
2733 { | |
2734 /* short messages changed by SAT */ | |
2735 sms_data->init_done = FALSE; | |
2736 SMS_SIM_PROP(sms_data).max_record = 0; | |
2737 tl_mnsms_report_ind (SMS_ENT_STATE(sms_data) = SMS_STATE_INITIALISING); | |
2738 sms_data->sim_mem_update = TRUE; | |
2739 tl_find_first (MEM_SM); | |
2740 } | |
2741 else | |
2742 { | |
2743 /* Nothing to do, indicate success to SAT */ | |
2744 PALLOC (file_update_res, SIM_FILE_UPDATE_RES); /* T_SIM_FILE_UPDATE_RES */ | |
2745 file_update_res->source = SRC_SMS; | |
2746 file_update_res->fu_rsc = SIM_FU_SUCCESS; | |
2747 PSENDX (SIM, file_update_res); | |
2748 } | |
2749 } | |
2750 PFREE (file_update_ind); | |
2751 } | |
2752 | |
2753 #endif // SIM_TOOLKIT | |
2754 | |
2755 /* | |
2756 +--------------------------------------------------------------------+ | |
2757 | PROJECT : GSM-PS (8410) MODULE : SMS_TLF | | |
2758 | STATE : code ROUTINE : tl_mnsms_cmms_end_ind | | |
2759 +--------------------------------------------------------------------+ | |
2760 | |
2761 PURPOSE : Function used for sending MNSMS_REPORT_IND.Primitive to ACI | |
2762 when cmms_mode is eqaul to 1. | |
2763 | |
2764 */ | |
2765 | |
2766 GLOBAL void tl_mnsms_cmms_end_ind(void) | |
2767 { | |
2768 GET_INSTANCE_DATA; | |
2769 PALLOC (report_ind, MNSMS_REPORT_IND); | |
2770 | |
2771 TRACE_FUNCTION ("tl_mnsms_cmms_end_ind()"); | |
2772 | |
2773 if(sms_data->cmms_mode EQ CMMS_MODE_ONE) | |
2774 { | |
2775 sms_data->cmms_mode = CMMS_MODE_DEF; | |
2776 report_ind->state = SMS_STATE_READY; | |
2777 report_ind->v_cmms_mode = TRUE; | |
2778 report_ind->cmms_mode = sms_data->cmms_mode; | |
2779 PSENDX (MMI, report_ind); | |
2780 } | |
2781 } | |
2782 | |
2783 #ifdef SIM_PERS_OTA | |
2784 /* | |
2785 +--------------------------------------------------------------------+ | |
2786 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
2787 | STATE : code ROUTINE : tl_mnsms_OTA_message_res | | |
2788 +--------------------------------------------------------------------+ | |
2789 | |
2790 PURPOSE : Process the primitive MNSMS_OTA_MESSAGE_RES. | |
2791 | |
2792 */ | |
2793 | |
2794 GLOBAL void tl_mnsms_OTA_message_res ( T_MNSMS_OTA_MESSAGE_RES *mnsms_OTA_message_res ) | |
2795 { | |
2796 | |
2797 T_SMS_DATA *sms_data = GET_INSTANCE(0); | |
2798 | |
2799 TRACE_FUNCTION ("tl_mnsms_OTA_message_res()"); | |
2800 | |
2801 if (sms_data) /*lint !e774 always True*/ | |
2802 { | |
2803 GET_MT_INSTANCE(sms_data); /* MT operation */ | |
2804 | |
2805 switch (SMS_INST_GET_STATE (STATE_TL)) | |
2806 { | |
2807 case TL_RECEIVE: | |
2808 if (sms_timer_check(TR2M)) | |
2809 { | |
2810 T_TP_DLVR_REP_ACK *rep_ack ; | |
2811 T_rp_user_data *rp_ud; | |
2812 MALLOC(rep_ack, sizeof(T_TP_DLVR_REP_ACK)); | |
2813 MALLOC(rp_ud, sizeof(T_rp_user_data)); | |
2814 | |
2815 rep_ack->tp_vt_mti = SMS_VT_DLVR_REP_ACK; | |
2816 rep_ack->tp_udhi = SMS_UDHI_NOT_INCLUDED; | |
2817 rep_ack->tp_mti = SMS_DELIVER_REPORT; | |
2818 rep_ack->v_tp_udh_inc = FALSE; | |
2819 | |
2820 memcpy(rep_ack->tp_ud.data, mnsms_OTA_message_res->data,mnsms_OTA_message_res->len); | |
2821 | |
2822 rep_ack->tp_ud.c_data =mnsms_OTA_message_res->len; //No of octets | |
2823 rep_ack->tp_ud.length = mnsms_OTA_message_res->packedlen; /*Since default alphabet is used as per 23.040 sec. 9.2.3.16 | |
2824 the length contains no of septets of data returned */ | |
2825 | |
2826 rep_ack->tp_ext = SMS_EXT_NOT_INCLUDED; | |
2827 rep_ack->v_tp_ud = TRUE; | |
2828 rep_ack->tp_udl_p = SMS_UD_INCLUDED; | |
2829 rep_ack->tp_dcs = mnsms_OTA_message_res->tp_dcs; | |
2830 rep_ack->v_tp_dcs = TRUE; | |
2831 rep_ack->tp_dcs_p = SMS_DCS_INCLUDED; | |
2832 rep_ack->tp_pid = mnsms_OTA_message_res->tp_pid; | |
2833 rep_ack->v_tp_pid = TRUE; | |
2834 rep_ack->tp_pid_p = SMS_PID_INCLUDED; | |
2835 rp_ud->tpdu.o_tpdu = 0; | |
2836 rp_ud->tpdu.l_tpdu = TPDU_BIT_LEN; | |
2837 rp_ud->v_tpdu = (ccd_codeMsg (CCDENT_SMS, UPLINK, | |
2838 (T_MSGBUF *)&rp_ud->tpdu, | |
2839 (UBYTE *)rep_ack, | |
2840 SMS_VT_DLVR_REP_ACK) EQ ccdOK); | |
2841 rp_ud->tp_mti = SMS_DELIVER_REPORT; | |
2842 | |
2843 MFREE (rep_ack); | |
2844 rl_report_req_ack (rp_ud); | |
2845 MFREE (rp_ud); | |
2846 SMS_INST_SET_STATE (STATE_TL, TL_IDLE); | |
2847 } | |
2848 else | |
2849 { | |
2850 /*TR2M TIM EXPIRE -ACI NOT RESPONDED WITHIN TR2M */ | |
2851 } | |
2852 break; | |
2853 | |
2854 default: | |
2855 /* INVALID SMS TL STATE IN MNSMS_OTA_MESSAGE_RES */ | |
2856 break; | |
2857 | |
2858 } | |
2859 } | |
2860 PFREE (mnsms_OTA_message_res); | |
2861 | |
2862 } | |
2863 #endif /* End OTA */ | |
2864 /* | |
2865 +--------------------------------------------------------------------+ | |
2866 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
2867 | STATE : code ROUTINE : tl_mnsms_retrans_req | | |
2868 +--------------------------------------------------------------------+ | |
2869 | |
2870 PURPOSE : Handles the primitive MNSMS_RETRANS_REQ. This will support user | |
2871 requested retransmission of the last failed message as per | |
2872 23.040 R99 Section 9.2.3.6. | |
2873 */ | |
2874 #ifdef REL99 | |
2875 GLOBAL void tl_mnsms_retrans_req (T_MNSMS_RETRANS_REQ *mnsms_retrans_req) | |
2876 { | |
2877 GET_INSTANCE_DATA; | |
2878 | |
2879 TRACE_FUNCTION ("tl_mnsms_retrans_req()"); | |
2880 | |
2881 switch (SMS_INST_GET_STATE (STATE_TL)) | |
2882 { | |
2883 case TL_SEND_CONTD: | |
2884 /* | |
2885 * stop timer TLCT | |
2886 */ | |
2887 sms_timer_stop(TLCT); | |
2888 /*FALLTHROUGH*/ /*lint -fallthrough*/ | |
2889 case TL_IDLE: | |
2890 if (sms_timer_check(TRAM)) | |
2891 { | |
2892 /* | |
2893 * MNSMS_SUBMIT_CNF | |
2894 */ | |
2895 tl_mnsms_retrans_cnf (SMS_SEL_MEM(sms_data), SMS_SEL_REC(sms_data), | |
2896 NOT_PRESENT_8BIT, SMS_CAUSE_ENTITY_BUSY, NULL); | |
2897 break; | |
2898 } | |
2899 | |
2900 /* Check if MO message is present(stored CPDU data available?) */ | |
2901 if (SMS_DATA_REQ(sms_data) NEQ NULL) | |
2902 { | |
2903 if(mnsms_retrans_req->auto_rep_flag EQ AUTO_REP_FLAG_ENABLED) | |
2904 { | |
2905 SMS_INST.tl_retx = 0; | |
2906 } | |
2907 else | |
2908 { | |
2909 /* Set to the max value so that retransmission will not be done */ | |
2910 SMS_INST.tl_retx = TL_MAX_RETANS; | |
2911 } | |
2912 | |
2913 SMS_INST_SET_STATE (STATE_TL, TL_SEND); | |
2914 | |
2915 /* Restore the record number and storage type */ | |
2916 SMS_SEL_REC(sms_data) = SMS_INST.failed_msg_rec_num; | |
2917 SMS_SEL_MEM(sms_data) = SMS_INST.failed_msg_mem; | |
2918 SMS_INST.failed_msg_retx = TRUE; | |
2919 | |
2920 /* | |
2921 * TL state transition TL_ESTABLISH | |
2922 * EST state transition EST_SEND | |
2923 */ | |
2924 SMS_INST_SET_STATE (STATE_TL, TL_ESTABLISH); | |
2925 SET_STATE (STATE_EST, EST_RTX); | |
2926 /* | |
2927 * establish connection | |
2928 */ | |
2929 tl_establish_connection(FALSE); | |
2930 } | |
2931 else | |
2932 { | |
2933 tl_mnsms_retrans_cnf (SMS_SEL_MEM(sms_data),SMS_SEL_REC(sms_data), | |
2934 SMS_TP_REF_RET(sms_data), | |
2935 SMS_CAUSE_FAILED_MSG_NOT_FOUND, NULL); | |
2936 } | |
2937 break; | |
2938 | |
2939 default: | |
2940 tl_mnsms_retrans_cnf (SMS_SEL_MEM(sms_data),SMS_SEL_REC(sms_data), | |
2941 SMS_TP_REF_RET(sms_data), | |
2942 SMS_CAUSE_ENTITY_BUSY, NULL); | |
2943 break; | |
2944 } | |
2945 | |
2946 PFREE(mnsms_retrans_req); | |
2947 | |
2948 return; | |
2949 } | |
2950 /* | |
2951 +--------------------------------------------------------------------+ | |
2952 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
2953 | STATE : code ROUTINE : tl_mnsms_retrans_cnf | | |
2954 +--------------------------------------------------------------------+ | |
2955 | |
2956 PURPOSE : Generate a response to the primitive MNSMS_RETRANS_REQ. | |
2957 */ | |
2958 | |
2959 GLOBAL void tl_mnsms_retrans_cnf ( UBYTE mem_type, | |
2960 UBYTE record, | |
2961 UBYTE tp_mr, | |
2962 USHORT cause, | |
2963 T_sms_sdu *sms_sdu ) | |
2964 { | |
2965 TRACE_FUNCTION ("tl_mnsms_retrans_cnf()"); | |
2966 { | |
2967 PALLOC (retrans_cnf, MNSMS_RETRANS_CNF); | |
2968 retrans_cnf->mem_type = mem_type; | |
2969 retrans_cnf->rec_num = record; | |
2970 retrans_cnf->tp_mr = tp_mr; | |
2971 retrans_cnf->cause = cause; | |
2972 | |
2973 if (sms_sdu NEQ NULL) | |
2974 { | |
2975 memcpy (&retrans_cnf->sms_sdu, sms_sdu, sizeof (T_sms_sdu)); | |
2976 } | |
2977 else | |
2978 { | |
2979 memset (&retrans_cnf->sms_sdu, 0, sizeof (T_sms_sdu)); | |
2980 } | |
2981 | |
2982 PSENDX (MMI, retrans_cnf); | |
2983 } | |
2984 } | |
2985 | |
2986 /* | |
2987 +--------------------------------------------------------------------+ | |
2988 | PROJECT : GSM-PS (8410) MODULE : SMS_TLP | | |
2989 | STATE : code ROUTINE : tl_mnsms_send_prog_ind | | |
2990 +--------------------------------------------------------------------+ | |
2991 | |
2992 PURPOSE : Send the primitive MNSMS_SEND_PROG_IND. | |
2993 */ | |
2994 GLOBAL void tl_mnsms_send_prog_ind (void) | |
2995 { | |
2996 GET_INSTANCE_DATA; | |
2997 TRACE_FUNCTION ("tl_mnsms_send_prog_ind ()"); | |
2998 { | |
2999 PALLOC (send_prog_ind, MNSMS_SEND_PROG_IND); | |
3000 send_prog_ind->resend_count = sms_data->data[INST_MO].tl_retx; | |
3001 send_prog_ind->max_retrans = TL_MAX_RETANS; | |
3002 PSENDX (MMI, send_prog_ind); | |
3003 } | |
3004 } | |
3005 #endif /* REL99 */ | |
3006 | |
3007 #endif |