FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/g23m-gsm/sms/sms_cp.c @ 673:2f7df7a314f8
gsm-fw/g23m-gsm subtree: initial import from LoCosto source
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 28 Sep 2014 23:20:04 +0000 |
parents | |
children | 833f2fee131b |
comparison
equal
deleted
inserted
replaced
672:0dc6f9e8e980 | 673:2f7df7a314f8 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-F&D (8411) | |
4 | Modul : SMS_CP | |
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 control protocol | |
18 | of the component SMS. | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #ifndef SMS_CP_C | |
23 #define SMS_CP_C | |
24 | |
25 #define ENTITY_SMS | |
26 | |
27 /*==== INCLUDES ===================================================*/ | |
28 | |
29 #include <string.h> | |
30 #include <stdlib.h> | |
31 #include <stddef.h> | |
32 #include "typedefs.h" | |
33 #include "pcm.h" | |
34 #include "vsi.h" | |
35 #include "custom.h" | |
36 #include "gsm.h" | |
37 #include "message.h" | |
38 #include "ccdapi.h" | |
39 #include "prim.h" | |
40 #include "cus_sms.h" | |
41 #include "cnf_sms.h" | |
42 #include "mon_sms.h" | |
43 #include "pei.h" | |
44 #include "tok.h" | |
45 #include "sms.h" | |
46 #include "sms_em.h" | |
47 | |
48 /*==== EXPORT ======================================================*/ | |
49 | |
50 /*==== PRIVAT ======================================================*/ | |
51 | |
52 /*==== VARIABLES ===================================================*/ | |
53 | |
54 /*==== FUNCTIONS ===================================================*/ | |
55 | |
56 /* Implements Measure# 4 */ | |
57 /* | |
58 +------------------------------------------------------------------------+ | |
59 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
60 | STATE : code ROUTINE : cp_send_err_ind_errcs | | |
61 +------------------------------------------------------------------------+ | |
62 | |
63 PURPOSE : This routine process the signal CP_DATA_IND_CP_ERROR for the | |
64 cases CP_MM_CONNECTION_ESTABLISHED and CP_WAIT_FOR_ACK | |
65 | |
66 */ | |
67 | |
68 LOCAL void cp_send_err_ind_errcs(UBYTE errcs) | |
69 { | |
70 GET_INSTANCE_DATA; | |
71 TRACE_FUNCTION("cp_send_err_ind_errcs()"); | |
72 /* | |
73 * Check if the cmms_mode is enabled or not | |
74 * If enabled dont release the MM connection | |
75 */ | |
76 if(!CMMS_ACTIVE) | |
77 { | |
78 cp_send_release_req (SMS_INST.ti); | |
79 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
80 SMS_INST.r_flag = FALSE; | |
81 } | |
82 else | |
83 { | |
84 sms_data->cmms_release_pending = TRUE; | |
85 } | |
86 | |
87 rl_error_ind (CAUSE_MAKE(DEFBY_STD, ORIGSIDE_NET, | |
88 SMSCP_ORIGINATING_ENTITY, errcs)); | |
89 | |
90 } | |
91 | |
92 /* Implements Measure# 3 */ | |
93 /* | |
94 +------------------------------------------------------------------------- -+ | |
95 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
96 | STATE : code ROUTINE : cp_send_err_ind_msg_type_unknown | | |
97 +---------------------------------------------------------------------------+ | |
98 | |
99 PURPOSE : Processing the signal CP_DATA_IND_CP_UNKNOWN for the | |
100 cases CP_MM_CONNECTION_ESTABLISHED and CP_WAIT_FOR_ACK | |
101 | |
102 */ | |
103 | |
104 LOCAL void cp_send_err_ind_msg_type_unknown(void) | |
105 { | |
106 GET_INSTANCE_DATA; | |
107 TRACE_FUNCTION("cp_send_err_ind_msg_type_unknown()"); | |
108 | |
109 cp_build_cp_error (SMS_CP_CS_MSG_TYPE_NON_EXIST); | |
110 | |
111 /* | |
112 * Check if the cmms_mode is enabled or not | |
113 * If enabled dont release the MM connection | |
114 */ | |
115 if(!CMMS_ACTIVE) | |
116 { | |
117 cp_send_release_req (SMS_INST.ti); | |
118 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
119 SMS_INST.r_flag = FALSE; | |
120 } | |
121 else | |
122 { | |
123 sms_data->cmms_release_pending = TRUE; | |
124 } | |
125 | |
126 rl_error_ind (CAUSE_MAKE(DEFBY_STD, ORIGSIDE_MS, | |
127 SMSCP_ORIGINATING_ENTITY, SMS_CP_CS_MSG_TYPE_NON_EXIST)); | |
128 | |
129 } | |
130 | |
131 /* Implements Measure# 8 */ | |
132 /* | |
133 +------------------------------------------------------------------------+ | |
134 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
135 | STATE : code ROUTINE : cp_send_err_ind_msg_not_comp | | |
136 +------------------------------------------------------------------------+ | |
137 | |
138 PURPOSE : This routine process the signals CP_DATA_IND_CP_ACK and CP_DATA_IND_CP_DATA | |
139 for the cases CP_MM_CONNECTION_ESTABLISHED and CP_WAIT_FOR_ACK | |
140 | |
141 */ | |
142 | |
143 LOCAL void cp_send_err_ind_msg_not_comp (void) | |
144 { | |
145 GET_INSTANCE_DATA; | |
146 TRACE_FUNCTION("cp_send_err_ind_msg_not_comp()"); | |
147 | |
148 cp_build_cp_error (SMS_CP_CS_MSG_NOT_COMP); | |
149 | |
150 cp_send_release_req (SMS_INST.ti); | |
151 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
152 SMS_INST.r_flag = FALSE; | |
153 | |
154 rl_error_ind (CAUSE_MAKE(DEFBY_STD, ORIGSIDE_MS, | |
155 SMSCP_ORIGINATING_ENTITY, SMS_CP_CS_MSG_NOT_COMP)); | |
156 | |
157 } | |
158 | |
159 | |
160 /* | |
161 +--------------------------------------------------------------------+ | |
162 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
163 | STATE : code ROUTINE : cp_init | | |
164 +--------------------------------------------------------------------+ | |
165 | |
166 PURPOSE : Initialize the control protocol. | |
167 | |
168 */ | |
169 | |
170 GLOBAL void cp_init (void) | |
171 { | |
172 GET_INSTANCE_DATA; | |
173 | |
174 TRACE_FUNCTION ("cp_init()"); | |
175 | |
176 memset (sms_data, 0, sizeof (T_SMS_DATA)); | |
177 | |
178 sms_data->data[0].state[STATE_CP] = CP_IDLE; | |
179 sms_data->data[1].state[STATE_CP] = CP_IDLE; | |
180 | |
181 /* | |
182 * Initialize the timer_values with default values | |
183 */ | |
184 sms_data->timer_values[TC1M] = TC1M_VALUE; | |
185 sms_data->timer_values[TR1M] = TR1M_VALUE; | |
186 sms_data->timer_values[TR2M] = TR2M_VALUE; | |
187 sms_data->timer_values[TRAM] = TRAM_VALUE; | |
188 sms_data->timer_values[TLCT] = TLCT_VALUE; | |
189 sms_data->timer_values[TMMS] = TMMS_VALUE; | |
190 | |
191 #if defined (GPRS) | |
192 { | |
193 int i; | |
194 /* | |
195 * default for MO SM: CCT preferred, | |
196 * no LLC flow information known yet | |
197 */ | |
198 SMS_ROUTE_PREF(sms_data) = GPRS_SMS_CCT_PREF; | |
199 SMS_LLC_FLOW(sms_data) = SMS_LLC_UNKNOWN; | |
200 SMS_SMS_FLOW(sms_data) = SMS_FLOW_UNKNOWN; | |
201 | |
202 /* | |
203 * initialize downlink info of each instance | |
204 */ | |
205 for (i = 0; i < MAX_SMS_CALLS; i++) | |
206 { | |
207 sms_data->data[i].downlink = SMS_DOWNLINK_NONE; | |
208 sms_data->data[i].ack_type = SMS_CP_NONE; | |
209 sms_data->data[i].cp_cause = NOT_PRESENT_8BIT; | |
210 sms_data->data[i].cp_user_data_dl = NULL; | |
211 } | |
212 } | |
213 #endif | |
214 } | |
215 | |
216 /* | |
217 +--------------------------------------------------------------------+ | |
218 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
219 | STATE : code ROUTINE : cp_add_pd_ti | | |
220 +--------------------------------------------------------------------+ | |
221 | |
222 PURPOSE : Add Protocol Discriminator and Transaction Identifier to | |
223 the SDU and modify its parameters accordingly. | |
224 */ | |
225 void cp_add_pd_ti (UBYTE ti, | |
226 T_sdu *sdu) | |
227 { | |
228 if (sdu NEQ NULL) | |
229 { | |
230 sdu->o_buf -= BSIZE_TI_PD; | |
231 sdu->l_buf += BSIZE_TI_PD; | |
232 sdu->buf[BYTELEN_POS(sdu->o_buf)] = PD_SMS | (ti << 4); | |
233 | |
234 memset (sdu->buf, 0, BYTELEN(sdu->o_buf)); | |
235 } | |
236 } | |
237 | |
238 #if defined (GPRS) | |
239 /* | |
240 +--------------------------------------------------------------------+ | |
241 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
242 | STATE : code ROUTINE : cp_init_ll_unitdata_req | | |
243 +--------------------------------------------------------------------+ | |
244 | |
245 PURPOSE : Initialize a ll_unitdata_req. | |
246 | |
247 */ | |
248 void cp_init_ll_unitdata_req (T_LL_UNITDATA_REQ * unitdata_req) | |
249 { | |
250 unitdata_req->sapi = LL_SAPI_7; | |
251 unitdata_req->tlli = LL_TLLI_INVALID; | |
252 unitdata_req->ll_qos.delay = LL_DELAY_SUB; | |
253 unitdata_req->ll_qos.relclass = LL_RLC_PROT; | |
254 unitdata_req->ll_qos.peak = LL_PEAK_SUB; | |
255 unitdata_req->ll_qos.preced = LL_PRECED_SUB; | |
256 unitdata_req->ll_qos.mean = LL_MEAN_SUB; | |
257 unitdata_req->radio_prio = LL_RADIO_PRIO_1; | |
258 unitdata_req->cipher = LL_CIPHER_OFF; | |
259 } | |
260 | |
261 /* | |
262 +--------------------------------------------------------------------+ | |
263 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
264 | STATE : code ROUTINE : cp_send_getunitdata_req | | |
265 +--------------------------------------------------------------------+ | |
266 | |
267 PURPOSE : Initialize ready to receive protocol. | |
268 | |
269 */ | |
270 | |
271 GLOBAL void cp_send_getunitdata_req (void) | |
272 { | |
273 GET_INSTANCE_DATA; | |
274 TRACE_FUNCTION ("cp_send_getunitdata_req()"); | |
275 | |
276 if (SMS_SMS_FLOW(sms_data) NEQ SMS_FLOW_AVAILABLE) | |
277 { | |
278 PALLOC (get_unitdata_req, LL_GETUNITDATA_REQ); | |
279 | |
280 memset (get_unitdata_req, 0, sizeof (T_LL_GETUNITDATA_REQ)); | |
281 get_unitdata_req->sapi = LL_SAPI_7; | |
282 get_unitdata_req->tlli = LL_TLLI_INVALID; | |
283 SMS_SMS_FLOW(sms_data) = SMS_FLOW_AVAILABLE; | |
284 | |
285 PSENDX (LLC, get_unitdata_req); | |
286 } | |
287 } | |
288 #endif /* GPRS */ | |
289 | |
290 /*---- PRIMITIVES --------------------------------------------------*/ | |
291 | |
292 /* | |
293 +--------------------------------------------------------------------+ | |
294 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
295 | STATE : code ROUTINE : cp_mmsms_error_ind | | |
296 +--------------------------------------------------------------------+ | |
297 | |
298 PURPOSE : Processing the primitive MMSMS_ERROR_IND. | |
299 | |
300 */ | |
301 | |
302 GLOBAL void cp_mmsms_error_ind (T_MMSMS_ERROR_IND *error_ind) | |
303 { | |
304 register T_SMS_DATA *sms_data = GET_SMS_INSTANCE (error_ind->ti); | |
305 | |
306 TRACE_FUNCTION_P1 ("cp_mmsms_error_ind(TI=%u)", error_ind->ti); | |
307 | |
308 if (sms_data) | |
309 { | |
310 TRACE_EVENT_P1 ("MMSMS_ERROR_IND.CAUSE: 0x%4.4hX", error_ind->cause); | |
311 | |
312 SMS_EM_LOSS_OF_MM_CONNECTION; | |
313 | |
314 cp_send_release_req (error_ind->ti); | |
315 | |
316 switch (SMS_INST_GET_STATE (STATE_CP)) | |
317 { | |
318 case CP_MM_CONNECTION_PENDING: | |
319 { | |
320 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
321 SMS_INST.ti = error_ind->ti; | |
322 | |
323 /* This is meant for SMS over GSM as preference and GPRS as fallback. | |
324 */ | |
325 | |
326 #ifdef GPRS | |
327 if(sms_data->mo_dst_pref EQ GPRS_SMS_CCT_PREF) | |
328 { | |
329 TRACE_FUNCTION ("GSM Failed trying with GPRS "); | |
330 rl_establish_cnf(FALSE); | |
331 } | |
332 else | |
333 #endif | |
334 { | |
335 SMS_INST.r_flag = FALSE; | |
336 /* | |
337 * RL_ERROR_IND => | |
338 */ | |
339 rl_error_ind (error_ind->cause); | |
340 } | |
341 break; | |
342 } | |
343 | |
344 case CP_WAIT_FOR_ACK: | |
345 /* | |
346 * stop timer TC1M | |
347 */ | |
348 sms_timer_stop(TC1M); | |
349 | |
350 SMS_RETX(sms_data) = 0; | |
351 SMS_INST.r_flag = FALSE; | |
352 SMS_INST.ti = error_ind->ti; | |
353 | |
354 /*FALLTHROUGH*/ /*lint -fallthrough*/ | |
355 | |
356 case CP_MM_CONNECTION_ESTABLISHED: | |
357 | |
358 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
359 rl_error_ind (error_ind->cause); | |
360 break; | |
361 | |
362 default: | |
363 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
364 FREE_SMS_INSTANCE (error_ind->ti); | |
365 break; | |
366 } | |
367 } | |
368 PFREE (error_ind); | |
369 } | |
370 | |
371 /* | |
372 +--------------------------------------------------------------------+ | |
373 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
374 | STATE : code ROUTINE : cp_mmsms_establish_cnf | | |
375 +--------------------------------------------------------------------+ | |
376 | |
377 PURPOSE : Processing the primitive MMSMS_ESTABLISH_CNF. | |
378 | |
379 */ | |
380 | |
381 GLOBAL void cp_mmsms_establish_cnf (T_MMSMS_ESTABLISH_CNF *establish_cnf) | |
382 { | |
383 register T_SMS_DATA *sms_data = GET_SMS_INSTANCE (establish_cnf->ti); | |
384 | |
385 TRACE_FUNCTION_P1 ("cp_mmsms_establish_cnf(TI=%u)", establish_cnf->ti); | |
386 | |
387 SMS_EM_MM_CONNECTION_ESTABLISHED; | |
388 | |
389 if (sms_data) | |
390 { | |
391 /* | |
392 * set TI | |
393 */ | |
394 sms_data->data[INST_MO].ti = establish_cnf->ti; | |
395 /* | |
396 * reset ack pending | |
397 */ | |
398 SMS_INST.cp_ack_pending = FALSE; | |
399 switch (SMS_INST_GET_STATE (STATE_CP)) | |
400 { | |
401 case CP_MM_CONNECTION_PENDING: | |
402 { | |
403 /* | |
404 * CP state transition | |
405 */ | |
406 SMS_INST_SET_STATE (STATE_CP, CP_MM_CONNECTION_ESTABLISHED); | |
407 /* | |
408 * RL_ESTABLISH_CNF => | |
409 */ | |
410 rl_establish_cnf(TRUE); | |
411 break; | |
412 } | |
413 default: | |
414 TRACE_ERROR("MMSMS_ESTABLISH_CNF in wrong state received!"); | |
415 break; | |
416 } | |
417 } | |
418 PFREE (establish_cnf); | |
419 } | |
420 | |
421 /* | |
422 +--------------------------------------------------------------------+ | |
423 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
424 | STATE : code ROUTINE : cp_mmsms_release_ind | | |
425 +--------------------------------------------------------------------+ | |
426 | |
427 PURPOSE : Processing the primitive MMSMS_RELEASE_IND. | |
428 | |
429 */ | |
430 | |
431 GLOBAL void cp_mmsms_release_ind (T_MMSMS_RELEASE_IND *release_ind) | |
432 { | |
433 register T_SMS_DATA *sms_data = GET_SMS_INSTANCE (release_ind->ti); | |
434 | |
435 TRACE_FUNCTION_P1 ("cp_mmsms_release_ind(TI=%u)", release_ind->ti); | |
436 | |
437 if (sms_data) | |
438 { | |
439 TRACE_EVENT_P1 ("MMSMS_RELEASE_IND: cause=0x%4.4hX", | |
440 release_ind->cause); | |
441 | |
442 SMS_EM_MM_CONNECTION_FAILED; | |
443 | |
444 switch (SMS_INST_GET_STATE (STATE_CP)) | |
445 { | |
446 /* ------------------------------------ */ | |
447 case CP_MM_CONNECTION_PENDING: | |
448 /* ------------------------------------ */ | |
449 { | |
450 /* | |
451 * safe TI | |
452 */ | |
453 SMS_INST.ti = release_ind->ti; | |
454 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
455 | |
456 /* This is meant for SMS over GSM as preference and GPRS as fallback. | |
457 */ | |
458 | |
459 #ifdef GPRS | |
460 if(sms_data->mo_dst_pref EQ GPRS_SMS_CCT_PREF) | |
461 { | |
462 TRACE_FUNCTION ("GSM Failed trying with GPRS "); | |
463 rl_establish_cnf(FALSE); | |
464 } | |
465 else | |
466 #endif | |
467 { | |
468 SMS_INST.r_flag = FALSE; | |
469 /* RL_ERROR_IND */ | |
470 rl_error_ind (release_ind->cause); | |
471 } | |
472 break; | |
473 } | |
474 | |
475 /* ------------------------------------ */ | |
476 case CP_MM_CONNECTION_ESTABLISHED: | |
477 /* ------------------------------------ */ | |
478 { | |
479 /* | |
480 * CP state transition CP_IDLE | |
481 */ | |
482 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
483 SMS_INST.r_flag = FALSE; | |
484 /* | |
485 * RL_ERROR_IND => | |
486 */ | |
487 rl_error_ind (release_ind->cause); | |
488 break; | |
489 } | |
490 /* ------------------------------------ */ | |
491 case CP_WAIT_FOR_ACK: | |
492 /* ------------------------------------ */ | |
493 { | |
494 /* | |
495 * stop timer TC1M | |
496 */ | |
497 sms_timer_stop(TC1M); | |
498 /* | |
499 * CP state transition CP_IDLE | |
500 */ | |
501 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
502 SMS_RETX(sms_data) = 0; | |
503 SMS_INST.r_flag = FALSE; | |
504 /* | |
505 * RL_ERROR_IND => | |
506 */ | |
507 rl_error_ind (release_ind->cause); | |
508 break; | |
509 } | |
510 /* ------------------------------------ */ | |
511 default: | |
512 /* ------------------------------------ */ | |
513 /* | |
514 * CP state transition CP_IDLE | |
515 */ | |
516 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
517 FREE_SMS_INSTANCE (release_ind->ti); | |
518 break; | |
519 } | |
520 } | |
521 PFREE (release_ind); | |
522 } | |
523 | |
524 /*---- SIGNALS -----------------------------------------------------*/ | |
525 | |
526 /* | |
527 +--------------------------------------------------------------------+ | |
528 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
529 | STATE : code ROUTINE : cp_abort_req | | |
530 +--------------------------------------------------------------------+ | |
531 | |
532 PURPOSE : Processing the signal CP_ABORT_REQ. | |
533 | |
534 */ | |
535 | |
536 GLOBAL void cp_abort_req (void) | |
537 { | |
538 GET_INSTANCE_DATA; | |
539 TRACE_FUNCTION_P1 ("cp_abort_req(TI=%u)",SMS_INST.ti); | |
540 | |
541 | |
542 SMS_EM_ABORT_OF_MM_CONNECTION; | |
543 | |
544 if (sms_data) | |
545 { | |
546 switch (SMS_INST_GET_STATE (STATE_CP)) | |
547 { | |
548 /* ------------------------------------ */ | |
549 case CP_MM_CONNECTION_ESTABLISHED: | |
550 /* ------------------------------------ */ | |
551 { | |
552 CCD_START; | |
553 /* | |
554 * check whether CP ACK needs to be send | |
555 */ | |
556 if (SMS_INST.cp_ack_pending EQ TRUE) | |
557 { | |
558 cp_build_cp_ack (); | |
559 } | |
560 /* | |
561 * generate CP_ERROR | |
562 */ | |
563 cp_build_cp_error (SMS_CP_CS_PROTOCOL_ERROR); | |
564 /* | |
565 * release connection | |
566 */ | |
567 SMS_INST.r_flag = FALSE; | |
568 cp_send_release_req (SMS_INST.ti); | |
569 CCD_END; | |
570 break; | |
571 } | |
572 | |
573 /* ------------------------------------ */ | |
574 case CP_MM_CONNECTION_PENDING: | |
575 /* ------------------------------------ */ | |
576 { | |
577 /* | |
578 * release connection | |
579 */ | |
580 SMS_INST.r_flag = FALSE; | |
581 cp_send_release_req (SMS_INST.ti); | |
582 break; | |
583 } | |
584 | |
585 /* ------------------------------------ */ | |
586 case CP_WAIT_FOR_ACK: | |
587 /* ------------------------------------ */ | |
588 { | |
589 /* | |
590 * stop timer TC1M | |
591 */ | |
592 sms_timer_stop(TC1M); | |
593 CCD_START; | |
594 /* | |
595 * check whether CP ACK needs to be send | |
596 */ | |
597 if (SMS_INST.cp_ack_pending EQ TRUE) | |
598 { | |
599 cp_build_cp_ack (); | |
600 } | |
601 /* | |
602 * generate CP_ERROR | |
603 */ | |
604 cp_build_cp_error (SMS_CP_CS_PROTOCOL_ERROR); | |
605 /* | |
606 * release connection | |
607 */ | |
608 SMS_INST.r_flag = FALSE; | |
609 cp_send_release_req (SMS_INST.ti); | |
610 | |
611 CCD_END; | |
612 break; | |
613 } | |
614 | |
615 #if defined (GPRS) | |
616 /* ------------------------------------ */ | |
617 case CP_GSMS_MO_WAIT_FOR_CP_DATA: | |
618 /* ------------------------------------ */ | |
619 case CP_GSMS_MT_WAIT_FOR_RP_ACK: | |
620 /* ------------------------------------ */ | |
621 { | |
622 /* | |
623 * stop timer TC1M | |
624 */ | |
625 sms_timer_stop(TC1M); | |
626 cp_error_req_gsms (SMS_CP_CS_PROTOCOL_ERROR, FALSE); | |
627 break; | |
628 } | |
629 #endif /* GPRS */ | |
630 } | |
631 #if defined (GPRS) | |
632 if (SMS_CP_ACK_TYPE(sms_data) EQ SMS_CP_NONE) | |
633 #endif /* GPRS */ | |
634 { | |
635 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
636 } | |
637 } | |
638 } | |
639 | |
640 /* | |
641 +--------------------------------------------------------------------+ | |
642 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
643 | STATE : code ROUTINE : cp_data_ind_cp_ack | | |
644 +--------------------------------------------------------------------+ | |
645 | |
646 PURPOSE : Processing the signal CP_DATA_IND_CP_ACK. | |
647 | |
648 */ | |
649 | |
650 GLOBAL void cp_data_ind_cp_ack (void) | |
651 { | |
652 GET_INSTANCE_DATA; | |
653 TRACE_FUNCTION_P1 ("cp_data_ind_cp_ack(TI=%u)", SMS_INST.ti); | |
654 | |
655 if (sms_data) | |
656 { | |
657 switch (SMS_INST_GET_STATE (STATE_CP)) | |
658 { | |
659 /* ------------------------------------ */ | |
660 case CP_MM_CONNECTION_ESTABLISHED: | |
661 /* ------------------------------------ */ | |
662 { | |
663 /* Implements Measure# 8 */ | |
664 cp_send_err_ind_msg_not_comp (); | |
665 break; | |
666 } | |
667 | |
668 /* ------------------------------------ */ | |
669 case CP_WAIT_FOR_ACK: | |
670 /* ------------------------------------ */ | |
671 { | |
672 /* | |
673 * stop timer TC1M | |
674 */ | |
675 sms_timer_stop(TC1M); | |
676 | |
677 | |
678 if (SMS_INST.r_flag) | |
679 { | |
680 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
681 SMS_INST.r_flag = FALSE; | |
682 | |
683 cp_send_release_req (SMS_INST.ti); | |
684 FREE_SMS_INSTANCE (SMS_INST.ti); | |
685 } | |
686 else | |
687 { | |
688 SMS_INST_SET_STATE (STATE_CP, CP_MM_CONNECTION_ESTABLISHED); | |
689 } | |
690 break; | |
691 } | |
692 | |
693 #if defined (GPRS) | |
694 /* ------------------------------------ */ | |
695 case CP_GSMS_IDLE: | |
696 /* ------------------------------------ */ | |
697 { | |
698 if (SMS_INST.r_flag) | |
699 { | |
700 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
701 SMS_INST.r_flag = FALSE; | |
702 FREE_SMS_INSTANCE (SMS_INST.ti); | |
703 } | |
704 else | |
705 { | |
706 cp_error_req_gsms (SMS_CP_CS_MSG_NOT_COMP, TRUE); | |
707 } | |
708 break; | |
709 } | |
710 | |
711 /* ------------------------------------ */ | |
712 case CP_GSMS_MO_WAIT_FOR_CP_ACK: | |
713 /* ------------------------------------ */ | |
714 { | |
715 /* | |
716 * stop timer TC1M | |
717 */ | |
718 sms_timer_stop(TC1M); | |
719 if (SMS_INST.r_flag) | |
720 { | |
721 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
722 SMS_INST.r_flag = FALSE; | |
723 FREE_SMS_INSTANCE (SMS_INST.ti); | |
724 } | |
725 else | |
726 { | |
727 SMS_INST_SET_STATE (STATE_CP, CP_GSMS_MO_WAIT_FOR_CP_DATA); | |
728 } | |
729 break; | |
730 } | |
731 | |
732 /* ------------------------------------ */ | |
733 case CP_GSMS_MT_WAIT_FOR_CP_ACK: | |
734 /* ------------------------------------ */ | |
735 { | |
736 /* | |
737 * stop timer TC1M | |
738 */ | |
739 sms_timer_stop(TC1M); | |
740 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
741 if (SMS_INST.r_flag) | |
742 { | |
743 SMS_INST.r_flag = FALSE; | |
744 } | |
745 FREE_SMS_INSTANCE (SMS_INST.ti); | |
746 break; | |
747 } | |
748 | |
749 /* ------------------------------------ */ | |
750 case CP_GSMS_MO_WAIT_FOR_CP_DATA: | |
751 /* ------------------------------------ */ | |
752 case CP_GSMS_MT_WAIT_FOR_RP_ACK: | |
753 /* ------------------------------------ */ | |
754 { | |
755 cp_error_req_gsms (SMS_CP_CS_MSG_NOT_COMP, FALSE); | |
756 rl_error_ind (CAUSE_MAKE(DEFBY_STD, ORIGSIDE_MS, | |
757 SMSCP_ORIGINATING_ENTITY, SMS_CP_CS_MSG_NOT_COMP)); | |
758 | |
759 break; | |
760 } | |
761 #endif /* GPRS */ | |
762 } | |
763 } | |
764 } | |
765 | |
766 /* | |
767 +--------------------------------------------------------------------+ | |
768 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
769 | STATE : code ROUTINE : cp_data_ind_cp_data | | |
770 +--------------------------------------------------------------------+ | |
771 | |
772 PURPOSE : Processing the signal CP_DATA_IND_CP_DATA. | |
773 | |
774 */ | |
775 GLOBAL void cp_data_ind_cp_data (T_D_CP_DATA *cp_data) | |
776 { | |
777 GET_INSTANCE_DATA; | |
778 TRACE_FUNCTION_P1 ("cp_data_ind_cp_data(TI=%u)", SMS_INST.ti); | |
779 | |
780 if (sms_data) | |
781 { | |
782 switch (SMS_INST_GET_STATE (STATE_CP)) | |
783 { | |
784 /* ------------------------------------ */ | |
785 case CP_WAIT_FOR_ACK: | |
786 /* ------------------------------------ */ | |
787 { | |
788 if (SMS_INST.r_flag) | |
789 { | |
790 /* Nothing expected anymore */ | |
791 | |
792 /* | |
793 * stop timer TC1M | |
794 */ | |
795 sms_timer_stop(TC1M); | |
796 /* Implements Measure# 8 */ | |
797 cp_send_err_ind_msg_not_comp (); | |
798 break; | |
799 } | |
800 else | |
801 { | |
802 TRACE_EVENT ("CP ACK lost"); | |
803 cp_data_ind_cp_ack (); | |
804 } | |
805 } | |
806 /*FALLTHROUGH*/ /*lint -fallthrough*/ | |
807 | |
808 /* ------------------------------------ */ | |
809 case CP_MM_CONNECTION_ESTABLISHED: | |
810 /* ------------------------------------ */ | |
811 { | |
812 /* | |
813 * remember to cp ack | |
814 */ | |
815 SMS_INST.cp_ack_pending = TRUE; | |
816 /* | |
817 * RL_DATA_IND => | |
818 */ | |
819 rl_data_ind (&cp_data->cp_user_data_dl); | |
820 break; | |
821 } | |
822 | |
823 #if defined (GPRS) | |
824 /* ------------------------------------ */ | |
825 case CP_GSMS_IDLE: | |
826 /* ------------------------------------ */ | |
827 { | |
828 if (SMS_LLC_FLOW(sms_data) EQ SMS_LLC_AVAILABLE) | |
829 { | |
830 cp_build_cp_ack (); | |
831 } | |
832 else | |
833 { | |
834 SMS_CP_ACK_TYPE(sms_data) = SMS_CP_ACK; | |
835 SMS_LLC_FLOW(sms_data) = SMS_LLC_BUSY_WAITING; | |
836 } | |
837 SMS_INST_SET_STATE (STATE_CP, CP_GSMS_MT_WAIT_FOR_RP_ACK); | |
838 rl_data_ind (&cp_data->cp_user_data_dl); | |
839 break; | |
840 } | |
841 | |
842 /* ------------------------------------ */ | |
843 case CP_GSMS_MO_WAIT_FOR_CP_DATA: | |
844 /* ------------------------------------ */ | |
845 { | |
846 if (SMS_LLC_FLOW(sms_data) EQ SMS_LLC_AVAILABLE) | |
847 { | |
848 /* | |
849 * generate CP_ACK | |
850 */ | |
851 cp_build_cp_ack (); | |
852 /* | |
853 * RL_DATA_IND => | |
854 */ | |
855 rl_data_ind (&cp_data->cp_user_data_dl); | |
856 } | |
857 else | |
858 { | |
859 if (SMS_CP_UDL(sms_data) EQ NULL) | |
860 { | |
861 MALLOC(SMS_CP_UDL(sms_data), sizeof(T_cp_user_data_dl)); | |
862 } | |
863 memcpy (SMS_CP_UDL(sms_data), &cp_data->cp_user_data_dl, | |
864 sizeof(T_cp_user_data_dl)); | |
865 SMS_CP_ACK_TYPE(sms_data) = SMS_CP_ACK; | |
866 SMS_LLC_FLOW(sms_data) = SMS_LLC_BUSY_WAITING; | |
867 SMS_INST_SET_STATE (STATE_CP, CP_GSMS_IDLE); | |
868 SMS_INST.r_flag = TRUE; | |
869 } | |
870 break; | |
871 } | |
872 /* ------------------------------------ */ | |
873 case CP_GSMS_MO_WAIT_FOR_CP_ACK: | |
874 /* ------------------------------------ */ | |
875 case CP_GSMS_MT_WAIT_FOR_CP_ACK: | |
876 /* ------------------------------------ */ | |
877 case CP_GSMS_MT_WAIT_FOR_RP_ACK: | |
878 /* ------------------------------------ */ | |
879 { | |
880 /* | |
881 * stop timer TC1M | |
882 */ | |
883 sms_timer_stop(TC1M); | |
884 cp_error_req_gsms (SMS_CP_CS_MSG_NOT_COMP, FALSE); | |
885 | |
886 rl_error_ind (CAUSE_MAKE(DEFBY_STD, ORIGSIDE_MS, | |
887 SMSCP_ORIGINATING_ENTITY, SMS_CP_CS_MSG_NOT_COMP)); | |
888 break; | |
889 } | |
890 #endif /* GPRS */ | |
891 } | |
892 } | |
893 } | |
894 | |
895 /* | |
896 +--------------------------------------------------------------------+ | |
897 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
898 | STATE : code ROUTINE : cp_data_ind_cp_error | | |
899 +--------------------------------------------------------------------+ | |
900 | |
901 PURPOSE : Processing the signal CP_DATA_IND_CP_ERROR. | |
902 The cause value is marked as CP-ERROR | |
903 */ | |
904 GLOBAL void cp_data_ind_cp_error (UBYTE errcs) | |
905 { | |
906 GET_INSTANCE_DATA; | |
907 TRACE_FUNCTION_P1 ("cp_data_ind_cp_error(TI=%u)", SMS_INST.ti); | |
908 TRACE_EVENT_P1 ("CP Error Cause = %d", (int)errcs); | |
909 | |
910 if (sms_data) | |
911 { | |
912 TRACE_EVENT_P1 ("CP_ERROR.CAUSE rcvd: 0x%2.2X", (int)errcs); | |
913 | |
914 switch (SMS_INST_GET_STATE (STATE_CP)) | |
915 { | |
916 /* ------------------------------------ */ | |
917 case CP_MM_CONNECTION_ESTABLISHED: | |
918 /* ------------------------------------ */ | |
919 { | |
920 /* Implements Measure# 4 */ | |
921 cp_send_err_ind_errcs(errcs); | |
922 break; | |
923 } | |
924 | |
925 /* ------------------------------------ */ | |
926 case CP_WAIT_FOR_ACK: | |
927 /* ------------------------------------ */ | |
928 { | |
929 /* | |
930 * stop timer TC1M | |
931 */ | |
932 sms_timer_stop(TC1M); | |
933 /* Implements Measure# 4 */ | |
934 cp_send_err_ind_errcs(errcs); | |
935 break; | |
936 } | |
937 | |
938 #if defined (GPRS) | |
939 /* ------------------------------------ */ | |
940 case CP_GSMS_IDLE: | |
941 /* ------------------------------------ */ | |
942 { | |
943 SMS_INST.r_flag = FALSE; | |
944 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
945 | |
946 /* FREE_SMS_INSTANCE (SMS_INST.ti); */ | |
947 break; | |
948 } | |
949 | |
950 /* ------------------------------------ */ | |
951 case CP_GSMS_MO_WAIT_FOR_CP_DATA: | |
952 /* ------------------------------------ */ | |
953 case CP_GSMS_MT_WAIT_FOR_RP_ACK: | |
954 /* ------------------------------------ */ | |
955 { | |
956 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
957 SMS_INST.r_flag = FALSE; | |
958 | |
959 rl_error_ind (CAUSE_MAKE(DEFBY_STD, ORIGSIDE_NET, | |
960 SMSCP_ORIGINATING_ENTITY, errcs)); | |
961 /* FREE_SMS_INSTANCE (SMS_INST.ti); */ | |
962 break; | |
963 } | |
964 | |
965 /* ------------------------------------ */ | |
966 case CP_GSMS_MO_WAIT_FOR_CP_ACK: | |
967 /* ------------------------------------ */ | |
968 case CP_GSMS_MT_WAIT_FOR_CP_ACK: | |
969 /* ------------------------------------ */ | |
970 { | |
971 /* | |
972 * stop timer TC1M | |
973 */ | |
974 sms_timer_stop(TC1M); | |
975 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
976 | |
977 SMS_INST.r_flag = FALSE; | |
978 rl_error_ind (CAUSE_MAKE(DEFBY_STD, ORIGSIDE_NET, | |
979 SMSCP_ORIGINATING_ENTITY, errcs)); | |
980 | |
981 /*FREE_SMS_INSTANCE (SMS_INST.ti);*/ | |
982 break; | |
983 } | |
984 #endif /* GPRS */ | |
985 | |
986 } | |
987 } | |
988 } | |
989 | |
990 /* | |
991 +--------------------------------------------------------------------+ | |
992 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
993 | STATE : code ROUTINE : cp_data_ind_cp_unknown | | |
994 +--------------------------------------------------------------------+ | |
995 | |
996 PURPOSE : Processing the signal CP_DATA_IND_CP_UNKNOWN. | |
997 | |
998 */ | |
999 GLOBAL void cp_data_ind_cp_unknown (void) | |
1000 { | |
1001 GET_INSTANCE_DATA; | |
1002 TRACE_FUNCTION_P1 ("cp_data_ind_cp_unknown(TI=%u)", SMS_INST.ti); | |
1003 | |
1004 if (sms_data) | |
1005 { | |
1006 switch (SMS_INST_GET_STATE (STATE_CP)) | |
1007 { | |
1008 /* ------------------------------------ */ | |
1009 case CP_MM_CONNECTION_ESTABLISHED: | |
1010 /* ------------------------------------ */ | |
1011 { | |
1012 /* Implements Measure# 3 */ | |
1013 cp_send_err_ind_msg_type_unknown(); | |
1014 break; | |
1015 } | |
1016 | |
1017 /* ------------------------------------ */ | |
1018 case CP_WAIT_FOR_ACK: | |
1019 /* ------------------------------------ */ | |
1020 { | |
1021 /* | |
1022 * stop timer TC1M | |
1023 */ | |
1024 sms_timer_stop(TC1M); | |
1025 /* Implements Measure# 3 */ | |
1026 cp_send_err_ind_msg_type_unknown(); | |
1027 break; | |
1028 } | |
1029 | |
1030 #if defined (GPRS) | |
1031 /* ------------------------------------ */ | |
1032 case CP_GSMS_IDLE: | |
1033 /* ------------------------------------ */ | |
1034 { | |
1035 cp_error_req_gsms (SMS_CP_CS_MSG_TYPE_NON_EXIST, TRUE); | |
1036 break; | |
1037 } | |
1038 | |
1039 /* ------------------------------------ */ | |
1040 case CP_GSMS_MO_WAIT_FOR_CP_ACK: | |
1041 /* ------------------------------------ */ | |
1042 case CP_GSMS_MT_WAIT_FOR_CP_ACK: | |
1043 /* ------------------------------------ */ | |
1044 { | |
1045 /* | |
1046 * stop timer TC1M | |
1047 */ | |
1048 sms_timer_stop(TC1M); | |
1049 } | |
1050 /*FALLTHROUGH*/ /*lint -fallthrough*/ | |
1051 /* ------------------------------------ */ | |
1052 case CP_GSMS_MO_WAIT_FOR_CP_DATA: | |
1053 /* ------------------------------------ */ | |
1054 case CP_GSMS_MT_WAIT_FOR_RP_ACK: | |
1055 /* ------------------------------------ */ | |
1056 { | |
1057 cp_error_req_gsms (SMS_CP_CS_MSG_TYPE_NON_EXIST, FALSE); | |
1058 rl_error_ind (CAUSE_MAKE(DEFBY_STD, ORIGSIDE_MS, | |
1059 SMSCP_ORIGINATING_ENTITY, SMS_CP_CS_MSG_TYPE_NON_EXIST)); | |
1060 | |
1061 break; | |
1062 } | |
1063 #endif /* GPRS */ | |
1064 } | |
1065 } | |
1066 } | |
1067 | |
1068 /* | |
1069 +--------------------------------------------------------------------+ | |
1070 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
1071 | STATE : code ROUTINE : cp_establish_req | | |
1072 +--------------------------------------------------------------------+ | |
1073 | |
1074 PURPOSE : Processing the signal CP_ESTABLISH_REQ. | |
1075 | |
1076 */ | |
1077 | |
1078 GLOBAL void cp_establish_req (UBYTE ti) | |
1079 { | |
1080 GET_INSTANCE_DATA; | |
1081 TRACE_FUNCTION_P1 ("cp_establish_req(TI=%u)",ti); | |
1082 | |
1083 #if defined (GPRS) | |
1084 /* | |
1085 * send data on selected downlink | |
1086 */ | |
1087 if (SMS_INST.downlink EQ SMS_DOWNLINK_MMSMS) | |
1088 { | |
1089 #endif /* GPRS */ | |
1090 | |
1091 /* | |
1092 * GSM - establish connection | |
1093 */ | |
1094 switch (SMS_INST_GET_STATE (STATE_CP)) | |
1095 { | |
1096 /* ------------------------------------ */ | |
1097 case CP_IDLE: | |
1098 /* ------------------------------------ */ | |
1099 default: | |
1100 /* ------------------------------------ */ | |
1101 { | |
1102 PALLOC (establish_req, MMSMS_ESTABLISH_REQ); | |
1103 | |
1104 SMS_EM_MM_CONNECTION_ESTABLISHMENT; | |
1105 | |
1106 establish_req->ti = ti; | |
1107 | |
1108 SMS_INST_SET_STATE (STATE_CP, CP_MM_CONNECTION_PENDING); | |
1109 | |
1110 PSENDX (MM, establish_req); | |
1111 break; | |
1112 } | |
1113 /* ------------------------------------ */ | |
1114 //default: | |
1115 /* ------------------------------------ */ | |
1116 // TRACE_ERROR("CP_ESTABLISH_REQ in wrong state received!"); | |
1117 } | |
1118 #if defined (GPRS) | |
1119 } | |
1120 else if (SMS_INST.downlink EQ SMS_DOWNLINK_LL_CHECK) | |
1121 { | |
1122 /* | |
1123 * GMMSMS_REG_STATE_REQ ==> | |
1124 */ | |
1125 PALLOC (reg_state_req, GMMSMS_REG_STATE_REQ); | |
1126 PSENDX (GMM, reg_state_req); | |
1127 /* | |
1128 * CP state transition | |
1129 */ | |
1130 SMS_INST_SET_STATE (STATE_CP, CP_MM_CONNECTION_PENDING); | |
1131 /* | |
1132 * set TI | |
1133 */ | |
1134 sms_data->data[INST_MO].ti = ti; | |
1135 } | |
1136 else | |
1137 { | |
1138 /* | |
1139 * set TI | |
1140 */ | |
1141 sms_data->data[INST_MO].ti = ti; | |
1142 /* | |
1143 * GPRS - do nothing | |
1144 */ | |
1145 rl_establish_cnf(TRUE); /* synchronous call back */ | |
1146 } | |
1147 #endif /* GPRS */ | |
1148 | |
1149 } | |
1150 | |
1151 /* | |
1152 +--------------------------------------------------------------------+ | |
1153 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
1154 | STATE : code ROUTINE : cp_data_req | | |
1155 +--------------------------------------------------------------------+ | |
1156 | |
1157 PURPOSE : Processing the signal CP_DATA_REQ. | |
1158 | |
1159 */ | |
1160 | |
1161 GLOBAL void cp_data_req (T_U_CP_DATA *cp_data) | |
1162 { | |
1163 GET_INSTANCE_DATA; | |
1164 TRACE_FUNCTION_P1 ("cp_data_req(TI=%u)",SMS_INST.ti); | |
1165 | |
1166 if (sms_data) | |
1167 { | |
1168 /* | |
1169 * U_CP_DATA contains a maximum of 252 Bytes | |
1170 */ | |
1171 PALLOC_SDU (data_req, MMSMS_DATA_REQ, LEN_U_CP_DATA); | |
1172 | |
1173 data_req->sdu.o_buf = ENCODE_OFFSET; | |
1174 | |
1175 cp_data->msg_type = U_CP_DATA; | |
1176 | |
1177 ccd_codeMsg (CCDENT_SMS, | |
1178 UPLINK, | |
1179 (T_MSGBUF *)&data_req->sdu, | |
1180 (UBYTE *)cp_data, | |
1181 NOT_PRESENT_8BIT); | |
1182 | |
1183 cp_add_pd_ti (SMS_CP_REF(sms_data), &data_req->sdu); | |
1184 #if defined (GPRS) | |
1185 /* | |
1186 * send data on selected downlink | |
1187 */ | |
1188 if (SMS_INST.downlink EQ SMS_DOWNLINK_MMSMS) | |
1189 { | |
1190 #endif /* GPRS */ | |
1191 | |
1192 switch (SMS_INST_GET_STATE (STATE_CP)) | |
1193 { | |
1194 /* ------------------------------------ */ | |
1195 case CP_MM_CONNECTION_ESTABLISHED: | |
1196 /* ------------------------------------ */ | |
1197 { | |
1198 USHORT bsize_message = D_SDU_OFF (data_req)+ | |
1199 D_SDU_LEN (data_req); | |
1200 PALLOC_SDU (tx_data_req, MMSMS_DATA_REQ, bsize_message); | |
1201 /* | |
1202 * check whether CP ACK needs to be send | |
1203 */ | |
1204 if (SMS_INST.cp_ack_pending EQ TRUE) | |
1205 { | |
1206 cp_build_cp_ack (); | |
1207 } | |
1208 /* | |
1209 * reset retry counter | |
1210 */ | |
1211 SMS_RETX(sms_data) = 0; | |
1212 /* | |
1213 * save data req | |
1214 */ | |
1215 if (SMS_DATA_REQ(sms_data) NEQ NULL) | |
1216 PFREE (SMS_DATA_REQ(sms_data)); | |
1217 SMS_DATA_REQ(sms_data) = data_req; | |
1218 /* | |
1219 * CP state transition CP_WAIT_FOR_ACK | |
1220 */ | |
1221 SMS_INST_SET_STATE (STATE_CP, CP_WAIT_FOR_ACK); | |
1222 | |
1223 SMS_EM_SEND_CP_DATA; | |
1224 | |
1225 #if FALSE | |
1226 PCOPY (tx_data_req, data_req); | |
1227 #else | |
1228 SMS_SDU_COPY (tx_data_req, data_req, MMSMS_DATA_REQ); | |
1229 #endif | |
1230 TRACE_BINDUMP(sms_handle, | |
1231 TC_USER4, | |
1232 "U_CP_DATA", | |
1233 (&(tx_data_req->sdu.buf[0]) + ((tx_data_req->sdu.o_buf >> 3) -1)), | |
1234 ((tx_data_req->sdu.l_buf >> 3) + 1)); | |
1235 PSENDX (MM, tx_data_req); | |
1236 /* | |
1237 * start timer TC1M | |
1238 */ | |
1239 sms_timer_start(TC1M); | |
1240 break; | |
1241 } | |
1242 | |
1243 /* ------------------------------------ */ | |
1244 default: | |
1245 /* ------------------------------------ */ | |
1246 { | |
1247 TRACE_ERROR("CP_DATA_REQ in wrong state received!"); | |
1248 PFREE (data_req); | |
1249 break; | |
1250 } | |
1251 } | |
1252 | |
1253 #if defined (GPRS) | |
1254 } | |
1255 else | |
1256 cp_data_req_gsms (data_req); | |
1257 #endif /* GPRS */ | |
1258 | |
1259 } | |
1260 } | |
1261 | |
1262 #if defined (GPRS) | |
1263 /* | |
1264 +--------------------------------------------------------------------+ | |
1265 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
1266 | STATE : code ROUTINE : cp_send_data_gsms | | |
1267 +--------------------------------------------------------------------+ | |
1268 | |
1269 PURPOSE : Send CP_DATA_REQ on LL downlink. LLC availability to be | |
1270 checked by the caller | |
1271 */ | |
1272 | |
1273 GLOBAL void cp_send_data_gsms (void) | |
1274 { | |
1275 GET_INSTANCE_DATA; | |
1276 TRACE_FUNCTION ("cp_send_data_gsms()"); | |
1277 | |
1278 if (sms_data) | |
1279 { | |
1280 USHORT bsize_message = ENCODE_OFFSET + | |
1281 D_SDU_LEN (SMS_DATA_REQ(sms_data)); | |
1282 PALLOC_SDU (unitdata_req, LL_UNITDATA_REQ, bsize_message); | |
1283 | |
1284 /* | |
1285 * copy stored mo message sdu to unitdata sdu buffer | |
1286 */ | |
1287 SMS_SDU_COPY (unitdata_req, SMS_DATA_REQ(sms_data), LL_UNITDATA_REQ); | |
1288 | |
1289 cp_init_ll_unitdata_req (unitdata_req); | |
1290 TRACE_BINDUMP(sms_handle, | |
1291 TC_USER4, | |
1292 "U_CP_DATA", | |
1293 (&(unitdata_req->sdu.buf[0]) + ((unitdata_req->sdu.o_buf >> 3) -1)), | |
1294 ((unitdata_req->sdu.l_buf >> 3) + 1)); | |
1295 PSENDX (LLC, unitdata_req); | |
1296 } | |
1297 } | |
1298 | |
1299 /* | |
1300 +--------------------------------------------------------------------+ | |
1301 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
1302 | STATE : code ROUTINE : cp_data_req_gsms | | |
1303 +--------------------------------------------------------------------+ | |
1304 | |
1305 PURPOSE : Processing the signal CP_DATA_REQ on LL downlink. | |
1306 | |
1307 */ | |
1308 | |
1309 GLOBAL void cp_data_req_gsms (T_MMSMS_DATA_REQ *data_req) | |
1310 { | |
1311 GET_INSTANCE_DATA; | |
1312 TRACE_FUNCTION ("cp_data_req_gsms()"); | |
1313 | |
1314 if (sms_data) | |
1315 { | |
1316 /* | |
1317 * check if LL is still registered | |
1318 */ | |
1319 if (SMS_INST.downlink EQ SMS_DOWNLINK_LL_CHECK) | |
1320 { | |
1321 PALLOC (reg_state_req, GMMSMS_REG_STATE_REQ); | |
1322 memset (reg_state_req, 0, sizeof (T_GMMSMS_REG_STATE_REQ)); | |
1323 PSENDX (GMM, reg_state_req); | |
1324 | |
1325 SMS_INST_SET_STATE (STATE_CP, CP_GSMS_IDLE); | |
1326 } | |
1327 | |
1328 switch (SMS_INST_GET_STATE (STATE_CP)) | |
1329 { | |
1330 case CP_IDLE: | |
1331 case CP_GSMS_IDLE: | |
1332 case CP_GSMS_MO_WAIT_FOR_CP_DATA: | |
1333 case CP_GSMS_MT_WAIT_FOR_RP_ACK: | |
1334 { | |
1335 /* | |
1336 * save message for later usage | |
1337 */ | |
1338 if (SMS_DATA_REQ(sms_data) NEQ NULL) | |
1339 { | |
1340 PFREE (SMS_DATA_REQ(sms_data)); | |
1341 } | |
1342 SMS_DATA_REQ(sms_data) = data_req; | |
1343 | |
1344 /* | |
1345 * send message if flow control allows | |
1346 */ | |
1347 if (SMS_INST.downlink EQ SMS_DOWNLINK_LL) | |
1348 { | |
1349 if (SMS_LLC_FLOW(sms_data) EQ SMS_LLC_AVAILABLE) | |
1350 { | |
1351 cp_send_data_gsms (); | |
1352 SMS_LLC_FLOW(sms_data) = SMS_LLC_BUSY; | |
1353 } | |
1354 else | |
1355 { | |
1356 SMS_LLC_FLOW(sms_data) = SMS_LLC_BUSY_WAITING; | |
1357 } | |
1358 if ((SMS_INST_GET_STATE (STATE_CP)) EQ CP_GSMS_MT_WAIT_FOR_RP_ACK) | |
1359 { | |
1360 SMS_INST_SET_STATE (STATE_CP, CP_GSMS_MT_WAIT_FOR_CP_ACK); | |
1361 } | |
1362 else if ((SMS_INST_GET_STATE (STATE_CP)) EQ CP_GSMS_MO_WAIT_FOR_CP_DATA) | |
1363 { | |
1364 SMS_INST_SET_STATE (STATE_CP, CP_GSMS_IDLE); | |
1365 } | |
1366 else | |
1367 { | |
1368 SMS_INST_SET_STATE (STATE_CP, CP_GSMS_MO_WAIT_FOR_CP_ACK); | |
1369 } | |
1370 SMS_RETX(sms_data) = 0; | |
1371 /* | |
1372 * start timer TC1M | |
1373 */ | |
1374 sms_timer_start(TC1M); | |
1375 } | |
1376 break; | |
1377 } | |
1378 | |
1379 default: | |
1380 { | |
1381 PFREE (data_req); | |
1382 break; | |
1383 } | |
1384 } | |
1385 } | |
1386 } | |
1387 | |
1388 /* | |
1389 +--------------------------------------------------------------------+ | |
1390 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
1391 | STATE : code ROUTINE : cp_error_req_gsms | | |
1392 +--------------------------------------------------------------------+ | |
1393 | |
1394 PURPOSE : Sending CP-ERROR over GPRS with consideration of LLC | |
1395 flow control. | |
1396 */ | |
1397 | |
1398 GLOBAL void cp_error_req_gsms (UBYTE cause, | |
1399 BOOL free_ti) | |
1400 { | |
1401 GET_INSTANCE_DATA; | |
1402 TRACE_FUNCTION ("cp_error_req_gsms()"); | |
1403 | |
1404 if (sms_data) | |
1405 { | |
1406 if (SMS_LLC_FLOW(sms_data) EQ SMS_LLC_AVAILABLE) | |
1407 { | |
1408 CCD_START; | |
1409 cp_build_cp_error (cause); | |
1410 CCD_END; | |
1411 | |
1412 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
1413 SMS_INST.r_flag = FALSE; | |
1414 if(free_ti) | |
1415 { | |
1416 FREE_SMS_INSTANCE (SMS_INST.ti); | |
1417 } | |
1418 sms_data->llc_flow = SMS_LLC_BUSY; | |
1419 } | |
1420 else | |
1421 { | |
1422 SMS_CP_ACK_TYPE(sms_data) = SMS_CP_ERROR; | |
1423 SMS_CP_CAUSE(sms_data) = cause; | |
1424 | |
1425 SMS_INST_SET_STATE (STATE_CP, CP_GSMS_IDLE); | |
1426 SMS_LLC_FLOW(sms_data) = SMS_LLC_BUSY_WAITING; | |
1427 } | |
1428 } | |
1429 } | |
1430 #endif /* GPRS */ | |
1431 | |
1432 /* | |
1433 +--------------------------------------------------------------------+ | |
1434 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
1435 | STATE : code ROUTINE : cp_est_ind_cp_ack | | |
1436 +--------------------------------------------------------------------+ | |
1437 | |
1438 PURPOSE : Processing the signal CP_EST_IND_CP_ACK. | |
1439 | |
1440 */ | |
1441 | |
1442 GLOBAL void cp_est_ind_cp_ack (void) | |
1443 { | |
1444 GET_INSTANCE_DATA; | |
1445 TRACE_FUNCTION_P1 ("cp_est_ind_cp_ack(TI=%u)",SMS_INST.ti); | |
1446 | |
1447 if (sms_data) | |
1448 { | |
1449 switch (SMS_INST_GET_STATE (STATE_CP)) | |
1450 { | |
1451 case CP_IDLE: | |
1452 { | |
1453 cp_build_cp_error (SMS_CP_CS_MSG_NOT_COMP); | |
1454 | |
1455 SMS_INST.r_flag = FALSE; | |
1456 /*FALLTHROUGH*/ /*lint -fallthrough*/ | |
1457 default: | |
1458 cp_send_release_req (SMS_INST.ti); | |
1459 | |
1460 FREE_SMS_INSTANCE (SMS_INST.ti); | |
1461 break; | |
1462 } | |
1463 } | |
1464 } | |
1465 } | |
1466 | |
1467 /* | |
1468 +--------------------------------------------------------------------+ | |
1469 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
1470 | STATE : code ROUTINE : cp_est_ind_cp_data | | |
1471 +--------------------------------------------------------------------+ | |
1472 | |
1473 PURPOSE : Processing the signal CP_EST_IND_CP_DATA. | |
1474 | |
1475 */ | |
1476 | |
1477 GLOBAL void cp_est_ind_cp_data (T_D_CP_DATA *cp_data) | |
1478 { | |
1479 GET_INSTANCE_DATA; | |
1480 TRACE_FUNCTION_P1 ("cp_est_ind_cp_data(TI=%u)",SMS_INST.ti); | |
1481 | |
1482 switch (SMS_INST_GET_STATE (STATE_CP)) | |
1483 { | |
1484 case CP_IDLE: | |
1485 { | |
1486 /* | |
1487 * generate CP_ACK | |
1488 */ | |
1489 cp_build_cp_ack (); | |
1490 /* | |
1491 * CP state transition CP_MM_CONNECTION_ESTABLISHED | |
1492 */ | |
1493 SMS_INST_SET_STATE (STATE_CP, CP_MM_CONNECTION_ESTABLISHED); | |
1494 /* | |
1495 * r flag | |
1496 */ | |
1497 SMS_INST.r_flag = FALSE; | |
1498 /* | |
1499 * RL_DATA_IND => | |
1500 */ | |
1501 rl_data_ind (&cp_data->cp_user_data_dl); | |
1502 break; | |
1503 } | |
1504 } | |
1505 } | |
1506 | |
1507 /* | |
1508 +--------------------------------------------------------------------+ | |
1509 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
1510 | STATE : code ROUTINE : cp_est_ind_cp_error | | |
1511 +--------------------------------------------------------------------+ | |
1512 | |
1513 PURPOSE : Processing the signal CP_EST_IND_CP_ERROR. | |
1514 | |
1515 */ | |
1516 | |
1517 GLOBAL void cp_est_ind_cp_error (UBYTE cp_error) | |
1518 { | |
1519 GET_INSTANCE_DATA; | |
1520 TRACE_FUNCTION_P1 ("cp_est_ind_cp_error(TI=%u)", SMS_INST.ti); | |
1521 TRACE_EVENT_P1 ("CP Error Cause = %d", (int)cp_error); | |
1522 | |
1523 if (sms_data) | |
1524 { | |
1525 TRACE_EVENT_P1 ("CP_ERROR.CAUSE rcvd: 0x%2.2X", (int)cp_error); | |
1526 | |
1527 switch (SMS_INST_GET_STATE (STATE_CP)) | |
1528 { | |
1529 case CP_IDLE: | |
1530 { | |
1531 SMS_INST.r_flag = FALSE; | |
1532 | |
1533 cp_send_release_req (SMS_INST.ti); | |
1534 FREE_SMS_INSTANCE (SMS_INST.ti); | |
1535 break; | |
1536 } | |
1537 } | |
1538 } | |
1539 } | |
1540 | |
1541 /* | |
1542 +--------------------------------------------------------------------+ | |
1543 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
1544 | STATE : code ROUTINE : cp_est_ind_cp_unknown | | |
1545 +--------------------------------------------------------------------+ | |
1546 | |
1547 PURPOSE : Processing the signal CP_EST_IND_CP_UNKNOWN. | |
1548 | |
1549 */ | |
1550 | |
1551 GLOBAL void cp_est_ind_cp_unknown (void) | |
1552 { | |
1553 GET_INSTANCE_DATA; | |
1554 TRACE_FUNCTION_P1 ("cp_est_ind_cp_unknown(TI=%u)", SMS_INST.ti); | |
1555 | |
1556 if (sms_data) | |
1557 { | |
1558 switch (SMS_INST_GET_STATE (STATE_CP)) | |
1559 { | |
1560 case CP_IDLE: | |
1561 { | |
1562 cp_build_cp_error (SMS_CP_CS_INFO_NON_EXIST); | |
1563 | |
1564 SMS_INST.r_flag = FALSE; | |
1565 | |
1566 cp_send_release_req (SMS_INST.ti); | |
1567 | |
1568 FREE_SMS_INSTANCE (SMS_INST.ti); | |
1569 break; | |
1570 } | |
1571 } | |
1572 } | |
1573 } | |
1574 | |
1575 /* | |
1576 +--------------------------------------------------------------------+ | |
1577 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
1578 | STATE : code ROUTINE : cp_release_req | | |
1579 +--------------------------------------------------------------------+ | |
1580 | |
1581 PURPOSE : Processing the signal CP_RELEASE_REQ. | |
1582 | |
1583 */ | |
1584 | |
1585 GLOBAL void cp_release_req (UBYTE ti) | |
1586 { | |
1587 GET_INSTANCE_DATA; | |
1588 TRACE_FUNCTION_P1 ("cp_release_req(TI=%u)", ti); | |
1589 | |
1590 if (sms_data) | |
1591 { | |
1592 switch (SMS_INST_GET_STATE (STATE_CP)) | |
1593 { | |
1594 case CP_IDLE: | |
1595 SMS_INST.r_flag = FALSE; | |
1596 FREE_SMS_INSTANCE (ti); | |
1597 break; | |
1598 | |
1599 case CP_WAIT_FOR_ACK: | |
1600 SMS_INST.r_flag = TRUE; | |
1601 break; | |
1602 | |
1603 case CP_MM_CONNECTION_PENDING: | |
1604 /* | |
1605 * new connection establishment pending | |
1606 * while releasing old connection | |
1607 * (-> concat sms) | |
1608 */ | |
1609 /* | |
1610 * check whether CP ACK needs to be send | |
1611 */ | |
1612 if (SMS_INST.cp_ack_pending EQ TRUE) | |
1613 { | |
1614 cp_build_cp_ack (); | |
1615 } | |
1616 /* | |
1617 * release connection | |
1618 */ | |
1619 SMS_INST.r_flag = FALSE; | |
1620 cp_send_release_req (ti); | |
1621 break; | |
1622 | |
1623 case CP_MM_CONNECTION_ESTABLISHED: | |
1624 /* | |
1625 * check whether CP ACK needs to be send | |
1626 */ | |
1627 if (SMS_INST.cp_ack_pending EQ TRUE) | |
1628 { | |
1629 cp_build_cp_ack (); | |
1630 } | |
1631 /* | |
1632 * CP state transition CP_IDLE | |
1633 */ | |
1634 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
1635 /* | |
1636 * release connection | |
1637 */ | |
1638 SMS_INST.r_flag = FALSE; | |
1639 cp_send_release_req (ti); | |
1640 break; | |
1641 | |
1642 #ifdef GPRS | |
1643 case CP_GSMS_IDLE: | |
1644 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
1645 SMS_INST.r_flag = FALSE; | |
1646 FREE_SMS_INSTANCE (SMS_INST.ti); | |
1647 break; | |
1648 | |
1649 case CP_GSMS_MO_WAIT_FOR_CP_ACK: | |
1650 case CP_GSMS_MT_WAIT_FOR_CP_ACK: | |
1651 SMS_INST.r_flag = TRUE; | |
1652 break; | |
1653 | |
1654 case CP_GSMS_MO_WAIT_FOR_CP_DATA: | |
1655 case CP_GSMS_MT_WAIT_FOR_RP_ACK: | |
1656 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
1657 SMS_INST.r_flag = FALSE; | |
1658 FREE_SMS_INSTANCE (SMS_INST.ti); | |
1659 break; | |
1660 #endif /* #ifdef GPRS */ | |
1661 | |
1662 default: | |
1663 break; | |
1664 } | |
1665 } | |
1666 } | |
1667 | |
1668 #if defined (GPRS) | |
1669 /* | |
1670 +--------------------------------------------------------------------+ | |
1671 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
1672 | STATE : code ROUTINE : cp_gmmsms_reg_state_cnf | | |
1673 +--------------------------------------------------------------------+ | |
1674 | |
1675 PURPOSE : Processing the signal GMMSMS_REG_STATE_CNF (GSMS only). | |
1676 | |
1677 */ | |
1678 GLOBAL void cp_gmmsms_reg_state_cnf (T_GMMSMS_REG_STATE_CNF *reg_state_cnf) | |
1679 { | |
1680 GET_INSTANCE_DATA; | |
1681 | |
1682 TRACE_FUNCTION ("cp_gmmsms_reg_state_cnf()"); | |
1683 | |
1684 if (sms_data EQ NULL) | |
1685 { | |
1686 TRACE_ERROR("Horror: sms_data=NULL"); | |
1687 return; | |
1688 } | |
1689 | |
1690 if (SMS_INST_GET_STATE (STATE_CP) EQ CP_MM_CONNECTION_PENDING) | |
1691 { | |
1692 /* | |
1693 * CP state transition | |
1694 */ | |
1695 SMS_INST_SET_STATE (STATE_CP, CP_GSMS_IDLE); | |
1696 if (reg_state_cnf->reg_state EQ SMS_RS_REGISTERED) | |
1697 { | |
1698 TRACE_EVENT("downlink = SMS_DOWNLINK_LL"); | |
1699 SMS_INST.downlink = SMS_DOWNLINK_LL; | |
1700 cp_send_getunitdata_req (); | |
1701 /* | |
1702 * RL_ESTABLISH_CNF => | |
1703 */ | |
1704 rl_establish_cnf(TRUE); | |
1705 } | |
1706 else | |
1707 { | |
1708 /* | |
1709 * RL_ESTABLISH_CNF => | |
1710 */ | |
1711 rl_establish_cnf(FALSE); | |
1712 } | |
1713 } | |
1714 else if (SMS_INST_GET_STATE (STATE_CP) EQ CP_GSMS_IDLE) | |
1715 { | |
1716 if (reg_state_cnf->reg_state EQ SMS_RS_REGISTERED) | |
1717 { | |
1718 SMS_INST.downlink = SMS_DOWNLINK_LL; | |
1719 cp_send_getunitdata_req (); | |
1720 | |
1721 if (SMS_LLC_FLOW(sms_data) EQ SMS_LLC_AVAILABLE) | |
1722 { | |
1723 /* | |
1724 * using LL is possible, send message | |
1725 */ | |
1726 cp_send_data_gsms (); | |
1727 SMS_LLC_FLOW(sms_data) = SMS_LLC_BUSY; | |
1728 } | |
1729 else | |
1730 { | |
1731 SMS_LLC_FLOW(sms_data) = SMS_LLC_BUSY_WAITING; | |
1732 } | |
1733 SMS_INST_SET_STATE (STATE_CP, CP_GSMS_MO_WAIT_FOR_CP_ACK); | |
1734 SMS_RETX(sms_data) = 0; | |
1735 /* | |
1736 * start timer TC1M | |
1737 */ | |
1738 sms_timer_start(TC1M); | |
1739 } | |
1740 else | |
1741 { | |
1742 SMS_LLC_FLOW(sms_data) = SMS_LLC_UNKNOWN; | |
1743 | |
1744 if (sms_data->mo_dst_pref EQ GPRS_SMS_GPRS_PREF) | |
1745 { | |
1746 /* | |
1747 * unsing the preferred downlink LL failed, use CSD | |
1748 */ | |
1749 | |
1750 PALLOC (establish_req, MMSMS_ESTABLISH_REQ); | |
1751 TRACE_EVENT("GPRS not registered, fallback to CSD"); | |
1752 | |
1753 establish_req->ti = SMS_INST.ti; | |
1754 | |
1755 SMS_INST.downlink = SMS_DOWNLINK_MMSMS; | |
1756 SMS_INST_SET_STATE (STATE_CP, CP_MM_CONNECTION_PENDING); | |
1757 | |
1758 PSENDX (MM, establish_req); | |
1759 } | |
1760 else | |
1761 { | |
1762 /* | |
1763 * only GPRS is configured to be used, abort | |
1764 */ | |
1765 cp_send_release_req (SMS_INST.ti); | |
1766 | |
1767 SMS_INST_SET_STATE (STATE_CP, CP_IDLE); | |
1768 SMS_INST.r_flag = FALSE; | |
1769 | |
1770 SMS_INST.downlink = SMS_DOWNLINK_NONE; | |
1771 | |
1772 rl_error_ind (SMS_CAUSE_NO_SERVICE); | |
1773 | |
1774 /* FREE_SMS_INSTANCE (SMS_INST.ti); */ | |
1775 } | |
1776 } | |
1777 } | |
1778 PFREE (reg_state_cnf); | |
1779 } | |
1780 #endif /* GPRS */ | |
1781 | |
1782 /*---- FUNCTIONS ---------------------------------------------------*/ | |
1783 | |
1784 /* | |
1785 +--------------------------------------------------------------------+ | |
1786 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
1787 | STATE : code ROUTINE : cp_build_cp_ack | | |
1788 +--------------------------------------------------------------------+ | |
1789 | |
1790 PURPOSE : Processing the function CP_BUILD_CP_ACK. | |
1791 (GPRS: the appropriate downlink is determined first) | |
1792 */ | |
1793 GLOBAL void cp_build_cp_ack (void) | |
1794 { | |
1795 GET_INSTANCE_DATA; | |
1796 TRACE_FUNCTION ("cp_build_cp_ack()"); | |
1797 | |
1798 /* | |
1799 * reset cp ack pending | |
1800 */ | |
1801 SMS_INST.cp_ack_pending = FALSE; | |
1802 | |
1803 #if defined (GPRS) | |
1804 if (SMS_INST.downlink EQ SMS_DOWNLINK_MMSMS) | |
1805 #endif /* GPRS */ | |
1806 { | |
1807 PALLOC_SDU (data_req, MMSMS_DATA_REQ, ENCODE_OFFSET+BSIZE_B_CP_ACK); | |
1808 | |
1809 data_req->sdu.o_buf = ENCODE_OFFSET; | |
1810 data_req->sdu.l_buf = BSIZE_B_CP_ACK; | |
1811 | |
1812 data_req->sdu.buf[BYTELEN_POS(data_req->sdu.o_buf)] = B_CP_ACK; | |
1813 cp_add_pd_ti (SMS_CP_REF(sms_data), &data_req->sdu); | |
1814 | |
1815 SMS_EM_SEND_CP_ACKNOWLEDGE; | |
1816 TRACE_BINDUMP(sms_handle, | |
1817 TC_USER4, | |
1818 "B_CP_ACK", | |
1819 (&(data_req->sdu.buf[0]) + ((data_req->sdu.o_buf >> 3) -1)), | |
1820 ((data_req->sdu.l_buf >> 3) + 1)); | |
1821 PSENDX (MM, data_req); | |
1822 return; | |
1823 } | |
1824 | |
1825 #if defined (GPRS) | |
1826 if ((SMS_INST.downlink EQ SMS_DOWNLINK_LL) /*AND | |
1827 (sms_data->llc_flow EQ SMS_LLC_AVAILABLE)*/) | |
1828 { | |
1829 /* | |
1830 * build cp_ack for LL downlink | |
1831 */ | |
1832 PALLOC_SDU (unitdata_req, LL_UNITDATA_REQ, ENCODE_OFFSET+BSIZE_B_CP_ACK); | |
1833 | |
1834 unitdata_req->sdu.o_buf = ENCODE_OFFSET; | |
1835 unitdata_req->sdu.l_buf = BSIZE_B_CP_ACK; | |
1836 | |
1837 unitdata_req->sdu.buf[BYTELEN_POS(unitdata_req->sdu.o_buf)] = B_CP_ACK; | |
1838 cp_add_pd_ti (SMS_CP_REF(sms_data), &unitdata_req->sdu); | |
1839 | |
1840 cp_init_ll_unitdata_req (unitdata_req); | |
1841 | |
1842 SMS_LLC_FLOW(sms_data) = SMS_LLC_BUSY; | |
1843 TRACE_BINDUMP(sms_handle, | |
1844 TC_USER4, | |
1845 "B_CP_ACK", | |
1846 (&(unitdata_req->sdu.buf[0]) + ((unitdata_req->sdu.o_buf >> 3) -1)), | |
1847 ((unitdata_req->sdu.l_buf >> 3) + 1)); | |
1848 PSENDX (LLC, unitdata_req); | |
1849 } | |
1850 #endif /* GPRS */ | |
1851 } | |
1852 | |
1853 | |
1854 /* | |
1855 +--------------------------------------------------------------------+ | |
1856 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
1857 | STATE : code ROUTINE : cp_build_cp_error | | |
1858 +--------------------------------------------------------------------+ | |
1859 | |
1860 PURPOSE : Processing the function CP_BUILD_CP_ERROR. | |
1861 | |
1862 */ | |
1863 GLOBAL void cp_build_cp_error (UBYTE error) | |
1864 { | |
1865 GET_INSTANCE_DATA; | |
1866 if (sms_data) | |
1867 { | |
1868 TRACE_EVENT_P1 ("CP_ERROR.CAUSE sent: 0x%2.2X", (int)error); | |
1869 | |
1870 #if defined (GPRS) | |
1871 if (SMS_INST.downlink EQ SMS_DOWNLINK_MMSMS) | |
1872 #endif /* GPRS */ | |
1873 | |
1874 { | |
1875 MCAST (cp_error, B_CP_ERROR); | |
1876 PALLOC_MSG (data_req, MMSMS_DATA_REQ, B_CP_ERROR); | |
1877 | |
1878 TRACE_FUNCTION ("cp_build_cp_error()"); | |
1879 | |
1880 SMS_EM_SEND_CP_ERROR; | |
1881 | |
1882 /* | |
1883 * check whether CP ACK needs to be send | |
1884 */ | |
1885 if (SMS_INST.cp_ack_pending EQ TRUE) | |
1886 { | |
1887 cp_build_cp_ack (); | |
1888 } | |
1889 | |
1890 data_req->sdu.o_buf = ENCODE_OFFSET; | |
1891 | |
1892 cp_error->msg_type = B_CP_ERROR; | |
1893 cp_error->cp_cause = error; | |
1894 | |
1895 ccd_codeMsg (CCDENT_SMS, | |
1896 UPLINK, | |
1897 (T_MSGBUF *) &data_req->sdu, | |
1898 (UBYTE *) _decodedMsg, | |
1899 NOT_PRESENT_8BIT); | |
1900 | |
1901 cp_add_pd_ti (SMS_CP_REF(sms_data), &data_req->sdu); | |
1902 TRACE_BINDUMP(sms_handle, | |
1903 TC_USER4, | |
1904 "B_CP_ERROR", | |
1905 (&(data_req->sdu.buf[0]) + ((data_req->sdu.o_buf >> 3) -1)), | |
1906 ((data_req->sdu.l_buf >> 3) + 1)); | |
1907 PSENDX (MM, data_req); | |
1908 return; | |
1909 } | |
1910 | |
1911 #if defined (GPRS) | |
1912 if ((SMS_INST.downlink EQ SMS_DOWNLINK_LL) /*&& | |
1913 (sms_data->llc_flow EQ SMS_LLC_AVAILABLE)*/) | |
1914 { | |
1915 /* | |
1916 * build cp_error for LL downlink | |
1917 */ | |
1918 MCAST (cp_error, B_CP_ERROR); | |
1919 | |
1920 PALLOC_MSG (unitdata_req, LL_UNITDATA_REQ, B_CP_ERROR); | |
1921 | |
1922 TRACE_FUNCTION ("cp_build_cp_error() - LL downlink"); | |
1923 | |
1924 unitdata_req->sdu.o_buf = ENCODE_OFFSET; | |
1925 | |
1926 cp_error->msg_type = B_CP_ERROR; | |
1927 cp_error->cp_cause = error; | |
1928 | |
1929 ccd_codeMsg (CCDENT_SMS, | |
1930 UPLINK, | |
1931 (T_MSGBUF *) &unitdata_req->sdu, | |
1932 (UBYTE *) _decodedMsg, | |
1933 NOT_PRESENT_8BIT); | |
1934 | |
1935 cp_add_pd_ti (SMS_CP_REF(sms_data), &unitdata_req->sdu); | |
1936 cp_init_ll_unitdata_req (unitdata_req); | |
1937 TRACE_BINDUMP(sms_handle, | |
1938 TC_USER4, | |
1939 "B_CP_ERROR", | |
1940 (&(unitdata_req->sdu.buf[0]) + ((unitdata_req->sdu.o_buf >> 3) -1)), | |
1941 ((unitdata_req->sdu.l_buf >> 3) + 1)); | |
1942 PSENDX (LLC, unitdata_req); | |
1943 } | |
1944 #endif /* GPRS */ | |
1945 } | |
1946 } | |
1947 | |
1948 /* | |
1949 +--------------------------------------------------------------------+ | |
1950 | PROJECT : GSM-PS (8410) MODULE : SMS_CP | | |
1951 | STATE : code ROUTINE : cp_send_release_req | | |
1952 +--------------------------------------------------------------------+ | |
1953 | |
1954 PURPOSE : Send a MMSMS_RELEASE_REQ. | |
1955 (GPRS: only if this is not an LL downlink) | |
1956 | |
1957 */ | |
1958 GLOBAL void cp_send_release_req ( UBYTE ti) | |
1959 { | |
1960 GET_INSTANCE_DATA; | |
1961 TRACE_FUNCTION ("cp_send_release_req()"); | |
1962 | |
1963 if (sms_data) | |
1964 { | |
1965 #if defined (GPRS) | |
1966 if (SMS_INST.downlink EQ SMS_DOWNLINK_MMSMS) | |
1967 { | |
1968 #endif | |
1969 PALLOC (release_req, MMSMS_RELEASE_REQ); | |
1970 | |
1971 release_req->ti = ti; | |
1972 | |
1973 PSENDX (MM, release_req); | |
1974 | |
1975 #if defined (GPRS) | |
1976 } | |
1977 #endif | |
1978 } | |
1979 } | |
1980 | |
1981 #endif |