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