comparison gsm-fw/g23m-gsm/cc/cc_cfk.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 8b1121359341
comparison
equal deleted inserted replaced
672:0dc6f9e8e980 673:2f7df7a314f8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CC_CFK
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 called by the primitive
18 | processing functions of the SDL process CC.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef CC_CFK_C
23 #define CC_CFK_C
24
25 #define ENTITY_CC
26 /*==== INCLUDES ===================================================*/
27
28 #include <string.h>
29 #include "typedefs.h"
30 #include "pcm.h"
31 #include "vsi.h"
32 #include "custom.h"
33 #include "gsm.h"
34 #include "message.h"
35 #include "ccdapi.h"
36 #include "prim.h"
37 #include "cnf_cc.h"
38 #include "mon_cc.h"
39 #include "pei.h"
40 #include "tok.h"
41 #include "cc.h"
42
43 /*==== EXPORT =====================================================*/
44
45 /*==== PROTOTYPE ==================================================*/
46 /* Implements Measure# 21 */
47 LOCAL void cc_set_neg_bearer_cap (const T_M_CC_bearer_cap * bearer_cap,
48 T_MNCC_bcpara * bcpara,
49 T_M_CC_bearer_cap * neg_bearer_cap,
50 EF_MSCAP mscap);
51 /* Implements Measure# 15 */
52 LOCAL void cc_fill_struct (UBYTE is_num_pres,
53 T_MNCC_calling_party *calling_party,
54 const T_M_CC_calling_num *calling_num);
55 /* Implements Measure# 24, 25 and 26 */
56 LOCAL void cc_fill_sub_struct (UBYTE is_num_pres,
57 T_MNCC_connected_number_sub *connected_number_sub,
58 const T_M_CC_connect_subaddr *connect_subaddr);
59 /*==== PRIVAT =====================================================*/
60
61 /*==== VARIABLES ==================================================*/
62
63 /*==== FUNCTIONS ==================================================*/
64
65 /*
66 +--------------------------------------------------------------------+
67 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
68 | STATE : code ROUTINE : cc_voice_capability |
69 +--------------------------------------------------------------------+
70
71 PURPOSE : This function returns TRUE if the mobile has voice
72 cababilities (support for any speech codec).
73
74 */
75
76 GLOBAL BOOL cc_voice_capability (void)
77 {
78 GET_INSTANCE_DATA;
79 TRACE_FUNCTION ("cc_voice_capability()");
80
81 return (FldGet (cc_data->mscap.chnMode, spchSupV1) OR
82 FldGet (cc_data->mscap.chnMode, AHS) OR
83 FldGet (cc_data->mscap.chnMode, AFS));
84 }
85
86
87 /*
88 +--------------------------------------------------------------------+
89 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
90 | STATE : code ROUTINE : cc_bcs_compatible |
91 +--------------------------------------------------------------------+
92
93 PURPOSE : Compare of two bearer capabilities.
94
95 */
96
97 GLOBAL BOOL cc_bcs_compatible (const T_M_CC_bearer_cap * bc1,
98 const T_M_CC_bearer_cap * bc2,
99 BOOL full)
100 {
101 BOOL itc_chg = FALSE;
102
103 TRACE_FUNCTION ("cc_bcs_compatible()");
104
105 /*
106 * Compare Octett 3, Coding Standard
107 */
108 if (bc1->code NEQ bc2->code)
109 return FALSE;
110
111 /*
112 * Compare Transfer Mode
113 */
114 if (bc1->trans_mode NEQ bc2->trans_mode)
115 return FALSE;
116
117 /*
118 * Compare Information Transfer Capability
119 * Note: The combination UDI <-> AUDIO is allowed
120 */
121 if (bc1->trans_cap NEQ bc2->trans_cap)
122 {
123 itc_chg = TRUE;
124
125 if (((bc1->trans_cap NEQ M_CC_ITC_DIGITAL_UNRESTRICTED)
126 AND
127 (bc1->trans_cap NEQ M_CC_ITC_AUDIO))
128 OR
129 ((bc2->trans_cap NEQ M_CC_ITC_DIGITAL_UNRESTRICTED)
130 AND
131 (bc2->trans_cap NEQ M_CC_ITC_AUDIO)))
132 return FALSE;
133 }
134
135 /*
136 * if speech is used the compare is successfull
137 */
138 if (bc1->trans_cap EQ M_CC_ITC_SPEECH OR
139 bc1->trans_cap EQ M_CC_ITC_AUXILIARY_SPEECH)
140 return TRUE;
141
142 /*
143 * Octett 4, Check Existence
144 */
145 if (bc1->v_compress NEQ bc2->v_compress)
146 return FALSE;
147
148 /*
149 * Compare Compression
150 */
151 if (bc1->compress NEQ bc2->compress)
152 return FALSE;
153
154 /*
155 * Compare Duplex Mode
156 */
157 if (bc1->duplex NEQ bc2->duplex)
158 return FALSE;
159
160 /*
161 * Compare Configuration
162 */
163 if (bc1->config NEQ bc2->config)
164 return FALSE;
165
166 #ifdef REL99
167 if (bc1->v_nirr != bc2->v_nirr)
168 return FALSE;
169 if (bc1->v_nirr AND (bc1->nirr != bc2->nirr))
170 return FALSE;
171 #endif
172
173
174
175 /*
176 * Compare Establishment
177 */
178 if (bc1->establish NEQ bc2->establish)
179 return FALSE;
180
181 /*
182 * Octett 5, Check Existence
183 */
184 if (bc1->v_access_ident NEQ bc2->v_access_ident)
185 return FALSE;
186
187 /*
188 * Compare Rate Adaption
189 * Note: Error if same ITC but different rate adaption
190 */
191 if (bc1->rate_adapt NEQ bc2->rate_adapt)
192 {
193 if (itc_chg EQ FALSE)
194 return FALSE;
195 }
196
197 /*
198 * Compare Signalling Access Protocol
199 */
200 if (bc1->sig_access_prot NEQ bc2->sig_access_prot)
201 return FALSE;
202
203 #ifdef REL99
204 /*
205 * Octet 5a, Check Existence and contents
206 */
207 if (bc1->v_other_itc != bc2->v_other_itc)
208 return FALSE;
209 if (bc1->v_other_itc AND (bc1->other_itc != bc2->other_itc))
210 return FALSE;
211 if (bc1->v_other_ra != bc2->v_other_ra)
212 return FALSE;
213 if (bc1->v_other_ra AND (bc1->other_ra != bc2->other_ra))
214 return FALSE;
215 #endif
216
217 /*
218 * Octett 6, Check Existence
219 */
220 if (bc1->v_l1_ident NEQ bc2->v_l1_ident)
221 return FALSE;
222
223 /*
224 * Compare User Information Layer 1 Protocol
225 */
226 if (bc1->v_user_inf_l1_prot NEQ bc2->v_user_inf_l1_prot)
227 return FALSE;
228
229 /*
230 * Compare Synchronous / Asynchronous
231 */
232 if (bc1->sync_async NEQ bc2->sync_async)
233 return FALSE;
234
235 /*
236 * Octett 6a, Check Existence
237 */
238 if (bc1->v_num_stop NEQ bc2->v_num_stop)
239 return FALSE;
240
241 /*
242 * Compare negotiation
243 */
244 if (bc1->negotiate NEQ bc2->negotiate)
245 return FALSE;
246
247 /*
248 * Compare User Rate
249 * Note: For Fax the user rate is unimportant
250 */
251 if (bc1->user_rate NEQ bc2->user_rate)
252 {
253 if (bc1->trans_cap NEQ M_CC_ITC_FAX_GROUP_3)
254 return FALSE;
255 }
256
257 /*
258 * Octett 6b, Check Existence
259 */
260 if (bc1->v_intermed_rate NEQ bc2->v_intermed_rate)
261 return FALSE;
262
263 /*
264 * Compare Network Independent Clock TX
265 */
266 if (bc1->nic_tx NEQ bc2->nic_tx)
267 return FALSE;
268
269 /*
270 * Compare Network Independent Clock RX
271 */
272 if (bc1->nic_rx NEQ bc2->nic_rx)
273 return FALSE;
274
275 /*
276 * Octett 6c, Check Existence
277 */
278 if (bc1->v_conn_elem NEQ bc2->v_conn_elem)
279 return FALSE;
280
281 /*
282 * Compare Connection Element
283 * Note: The combination transparent and non-transparent
284 * is not allowed.
285 * For transparent the structure must be UNSTRUCTED.
286 * For non-transparent the structure must be DATA UNIT INTEGRITY.
287 */
288 if (((bc1->conn_elem EQ M_CC_CE_TRANSPA) AND
289 (bc2->conn_elem EQ M_CC_CE_RLP)) OR
290 ((bc1->conn_elem EQ M_CC_CE_RLP) AND
291 (bc2->conn_elem EQ M_CC_CE_TRANSPA)))
292 return FALSE;
293
294 if (bc1->v_structure AND bc1->v_conn_elem)
295 {
296 if (bc1->conn_elem EQ M_CC_CE_TRANSPA)
297 {
298 if (bc1->structure NEQ M_CC_STRC_UNSTRUCTURED)
299 return FALSE;
300 }
301 else
302 {
303 if (bc1->structure NEQ M_CC_STRC_SERV_DATA_INTEG)
304 return FALSE;
305 }
306 }
307
308 /*
309 * Compare Modem Type
310 * Note: Error if no change in information
311 * Transfer Capability.
312 */
313 if (bc1->modem_type NEQ bc2->modem_type)
314 if (itc_chg EQ FALSE)
315 return FALSE;
316
317 /*
318 * Compare of all parameters ?
319 */
320 if (full EQ FALSE)
321 return TRUE;
322
323 /*
324 * Compare Number of Stop Bits
325 */
326 if (bc1->num_stop NEQ bc2->num_stop)
327 return FALSE;
328
329 /*
330 * Compare Number of Data Bits
331 */
332 if (bc1->num_data NEQ bc2->num_data)
333 return FALSE;
334
335 /*
336 * Compare Intermediate Rate
337 */
338 if (bc1->intermed_rate NEQ bc2->intermed_rate)
339 return FALSE;
340
341 /*
342 * Compare Parity
343 */
344 if (bc1->parity NEQ bc2->parity)
345 return FALSE;
346
347 #ifdef REL99
348 /*
349 * Octet 6d, Compare Existence only
350 */
351 /*(subject to negotiation)*/
352 if (bc1->v_modem_type_2 != bc2->v_modem_type_2)
353 return FALSE;
354 /*(subject to negotiation)*/
355 if (bc1->v_fnur != bc2->v_fnur)
356 return FALSE;
357
358
359 if(bc1->v_fnur)
360 {
361 /*
362 * Octet 6e, Compare Existence and contents
363 */
364 if (bc1->v_acc != bc2->v_acc)
365 return FALSE;
366 if (bc1->v_acc AND (bc1->acc != bc2->acc))
367 return FALSE;
368 if (bc1->v_mTch != bc2->v_mTch)
369 return FALSE;
370 if (bc1->v_mTch AND (bc1->mTch != bc2->mTch))
371 return FALSE;
372
373 /*
374 * Theres a extra condition here with MO NT pref negotiated to T because
375 * according to 24.008 Octet 6e (UIMI+WAIUR) is not sent in T Bearer Cap
376 */
377 if(bc1->conn_elem != M_CC_CE_TRANSPA && bc2->conn_elem != M_CC_CE_TRANSPA)
378 {
379 /*
380 * Octet 6f, Compare Existence and contents
381 */
382 if (bc1->v_uimi != bc2->v_uimi)
383 return FALSE;
384 if (bc1->v_uimi AND (bc1->uimi != bc2->uimi))
385 return FALSE;
386 if (bc1->v_waiur != bc2->v_waiur)
387 return FALSE;
388 if (bc1->v_waiur AND (bc1->waiur != bc2->waiur))
389 return FALSE;
390 }
391
392
393
394 /*
395 * Octet 6g, Compare Existence and contents
396 */
397 if (bc1->v_acc_ext_288 != bc2->v_acc_ext_288)
398 return FALSE;
399 if (bc1->v_acc_ext_288 AND (bc1->acc_ext_288 != bc2->acc_ext_288))
400 return FALSE;
401 if (bc1->v_acc_ext_320 != bc2->v_acc_ext_320)
402 return FALSE;
403 if (bc1->v_acc_ext_320 AND (bc1->acc_ext_320 != bc2->acc_ext_320))
404 return FALSE;
405 if (bc1->v_acc_ext_432 != bc2->v_acc_ext_432)
406 return FALSE;
407 if (bc1->v_acc_ext_432 AND (bc1->acc_ext_432 != bc2->acc_ext_432))
408 return FALSE;
409
410 if (bc1->v_ch_cod_asym != bc2->v_ch_cod_asym)
411 return FALSE;
412 if (bc1->v_ch_cod_asym AND (bc1->ch_cod_asym != bc2->ch_cod_asym))
413 return FALSE;
414 }
415
416 #endif
417
418 /*
419 * Octett 7, Compare Existence
420 */
421 if (bc1->v_l2_ident NEQ bc2->v_l2_ident)
422 return FALSE;
423
424 /*
425 * Compare User Information Layer 2 Protocol
426 */
427 if (bc1->v_l2_ident AND
428 (bc1->user_inf_l2_prot NEQ bc2->user_inf_l2_prot))
429 return FALSE;
430
431 return TRUE;
432 }
433
434
435
436 /*
437 +--------------------------------------------------------------------+
438 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
439 | STATE : code ROUTINE : cc_build_bc |
440 +--------------------------------------------------------------------+
441
442 PURPOSE : Define bearer capability depending on the bearer capability
443 parameters.
444
445 */
446 GLOBAL void cc_build_bc (T_M_CC_bearer_cap * bearer_cap, /* out */
447 UBYTE * serv, /* out */
448 const T_MNCC_bcpara * bc_params) /* in*/
449 {
450
451 TRACE_FUNCTION ("cc_build_bc()");
452
453 cc_csf_ms_cap ();
454
455 switch (bc_params->bearer_serv)
456 {
457 case MNCC_BEARER_SERV_SPEECH:
458 case MNCC_BEARER_SERV_AUX_SPEECH:
459 case MNCC_BEARER_SERV_SPEECH_CTM:
460 case MNCC_BEARER_SERV_AUX_SPEECH_CTM:
461 * serv = MNCC_SERV_SPEECH;
462 memset (bearer_cap, 0, sizeof (T_M_CC_bearer_cap));
463 cc_set_trans_cap (bearer_cap, bc_params);
464
465 cc_set_radio_channel_requirement (bearer_cap, bc_params);
466 break;
467
468 case MNCC_BEARER_SERV_FAX:
469 /*
470 * Only transparent is supported
471 */
472 * serv = MNCC_SERV_DATA;
473 memset (bearer_cap, 0, sizeof (T_M_CC_bearer_cap));
474 cc_set_trans_cap (bearer_cap, bc_params);
475 cc_set_radio_channel_requirement (bearer_cap, bc_params);
476 cc_set_data_default_parameter (bearer_cap);
477 cc_set_conn_elem (bearer_cap, MNCC_CONN_ELEM_TRANS, bc_params->flow_control);
478 cc_set_user_rate (bearer_cap, bc_params->rate, M_CC_MT_NONE);
479 cc_set_sync_async (bearer_cap, bc_params);
480 break;
481
482 case MNCC_BEARER_SERV_PACKET_ACCESS:
483 case MNCC_BEARER_SERV_SYNC:
484 * serv = MNCC_SERV_DATA;
485 memset (bearer_cap, 0, sizeof (T_M_CC_bearer_cap));
486 cc_set_trans_cap (bearer_cap, bc_params);
487 cc_set_radio_channel_requirement (bearer_cap, bc_params);
488 cc_set_data_default_parameter (bearer_cap);
489 cc_set_conn_elem (bearer_cap, bc_params->conn_elem, bc_params->flow_control);
490 cc_set_user_rate (bearer_cap, bc_params->rate, bc_params->modem_type);
491 cc_set_sync_async (bearer_cap, bc_params);
492 break;
493
494 case MNCC_BEARER_SERV_PAD_ACCESS:
495 case MNCC_BEARER_SERV_ASYNC:
496 * serv = MNCC_SERV_DATA;
497 memset (bearer_cap, 0, sizeof (T_M_CC_bearer_cap));
498 cc_set_trans_cap (bearer_cap, bc_params);
499 cc_set_radio_channel_requirement (bearer_cap, bc_params);
500 cc_set_data_default_parameter (bearer_cap);
501 cc_set_conn_elem (bearer_cap, bc_params->conn_elem, bc_params->flow_control);
502 cc_set_user_rate (bearer_cap, bc_params->rate, bc_params->modem_type);
503 cc_set_sync_async (bearer_cap, bc_params);
504 break;
505
506 default:
507 TRACE_ERROR ("Unexpected bearer_serv");
508 break;
509 }
510 }
511
512
513
514 /*
515 +--------------------------------------------------------------------+
516 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
517 | STATE : code ROUTINE : cc_set_data_default_parameter |
518 +--------------------------------------------------------------------+
519
520 PURPOSE : Set bearer capability parameters for data.
521
522 */
523
524 GLOBAL void cc_set_data_default_parameter (T_M_CC_bearer_cap * bearer_cap)
525 {
526 TRACE_FUNCTION ("cc_set_data_default_parameter()");
527
528 /*
529 * Octet 3
530 */
531 #ifdef REL99
532 bearer_cap->v_code = TRUE;
533 bearer_cap->code = M_CC_CSTD_GSM;
534 bearer_cap->v_trans_mode = TRUE;
535 bearer_cap->trans_mode = M_CC_TM_CIRCUIT;
536 #endif
537
538 /*
539 * Octet 4
540 */
541 bearer_cap->v_compress = TRUE; /* now spare, used in previous releases */
542 bearer_cap->compress = M_CC_COMP_NO;
543 /* structure -> by other function */
544 bearer_cap->v_duplex = TRUE;
545 bearer_cap->duplex = M_CC_DUPLEX_FULL;
546
547 bearer_cap->v_config = TRUE;
548 bearer_cap->config = M_CC_CONF_POINT_TO_POINT;
549 /* nirr -> by other function */
550 bearer_cap->v_establish= TRUE;
551 bearer_cap->establish = M_CC_ESTAB_DEMAND;
552
553 /*
554 * Octet 5
555 */
556 bearer_cap->v_access_ident = TRUE;
557 bearer_cap->access_ident = M_CC_AI_OCT_ID;
558
559 bearer_cap->v_sig_access_prot = TRUE;
560 bearer_cap->sig_access_prot = M_CC_SIAP_I440;
561
562 /*
563 * Octet 6
564 */
565 bearer_cap->v_l1_ident = TRUE;
566 bearer_cap->l1_ident = M_CC_L1_OCT_ID;
567
568 bearer_cap->v_user_inf_l1_prot = TRUE;
569 bearer_cap->user_inf_l1_prot = M_CC_L1_DEFAULT;
570 /* sync_async -> by other function */
571 /*
572 * Octet 6a
573 */
574 /* num_stop -> by other function */
575 bearer_cap->v_negotiate = TRUE;
576 bearer_cap->negotiate = M_CC_NEGOTIATE_NO;
577 /* num_data -> by other function */
578 /* user_rate -> by other function */
579 /*
580 * Octet 6b
581 */
582 /* intermed_rate -> by other function */
583 bearer_cap->v_nic_tx = TRUE;
584 bearer_cap->nic_tx = M_CC_NIC_TX_NO;
585 bearer_cap->v_nic_rx = TRUE;
586 bearer_cap->nic_rx = M_CC_NIC_RX_NO;
587 /* parity -> by other function */
588 /* conn_elem -> by other function */
589 /* modem_type -> by other function */
590 /*
591 * Octet 7
592 */
593 /* l2_ident -> by other function */
594 /* user_inf_l2_prot -> by other function */
595 }
596
597 /*
598 +--------------------------------------------------------------------+
599 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
600 | STATE : code ROUTINE : cc_set_radio_channel_requirement |
601 +--------------------------------------------------------------------+
602
603 PURPOSE : Set bearer capability parameters for data.
604
605 */
606 GLOBAL void cc_set_radio_channel_requirement (T_M_CC_bearer_cap * bearer_cap,
607 const T_MNCC_bcpara * bcpara)
608 {
609 GET_INSTANCE_DATA;
610 UBYTE index, prio;
611 const UBYTE codec_prio[5] = {M_CC_SPEECH_VERS_AMR_FR, M_CC_SPEECH_VERS_AMR_HR, M_CC_SPEECH_VERS_EFR,
612 M_CC_SPEECH_VERS_FR, M_CC_SPEECH_VERS_HR};
613 UBYTE codec_val[5] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
614
615 TRACE_FUNCTION ("cc_set_radio_channel_requirement()");
616
617 switch (bcpara->bearer_serv)
618 {
619 case MNCC_BEARER_SERV_SPEECH:
620 case MNCC_BEARER_SERV_AUX_SPEECH:
621 case MNCC_BEARER_SERV_SPEECH_CTM:
622 case MNCC_BEARER_SERV_AUX_SPEECH_CTM:
623 bearer_cap->v_rad_chan_req = TRUE;
624 bearer_cap->v_code = TRUE;
625 bearer_cap->code = M_CC_CSTD_GSM;
626 bearer_cap->v_trans_mode = TRUE;
627 bearer_cap->trans_mode = M_CC_TM_CIRCUIT;
628 index = (UBYTE)FldGet(cc_data->mscap.chnMode, HR_EFRSup);
629
630 TRACE_EVENT_P1 ("index = %d", index);
631 if(bcpara->rad_chan_req NEQ 0)
632 {
633 TRACE_EVENT_P1 ("bearer_cap->rad_chan_req = %d", bearer_cap->rad_chan_req);
634 bearer_cap->rad_chan_req = bcpara->rad_chan_req ;
635 }
636 else
637 bearer_cap->rad_chan_req = bc_prio_0 [index];
638 index = 0;
639 for (prio = 0; prio < MAX_SPEECH_CODECS; prio++)
640 {
641 switch (codec_prio[prio])
642 {
643 case M_CC_SPEECH_VERS_FR: /* Full rate speech version 1 */
644 /* Always */
645 codec_val[index] = M_CC_SPEECH_VERS_FR;
646 index++;
647 break;
648 case M_CC_SPEECH_VERS_HR: /* Half rate speech version 1 */
649 if (FldGet (cc_data->mscap.chnMode, hrSup) NEQ 0)
650 {
651 codec_val[index] = M_CC_SPEECH_VERS_HR;
652 index++;
653 }
654 break;
655 case M_CC_SPEECH_VERS_EFR: /* Full rate speech version 2 - EFR */
656 if (FldGet (cc_data->mscap.chnMode, EFRSupV2) NEQ 0)
657 {
658 codec_val[index] = M_CC_SPEECH_VERS_EFR;
659 index++;
660 }
661 break;
662 case M_CC_SPEECH_VERS_AMR_HR: /* Half rate speech version 3 - AMR */
663 if ((FldGet (cc_data->mscap.chnMode, AHS) NEQ 0)
664 #if (CHIPSET != 15)
665 AND !(bcpara->bearer_serv EQ MNCC_BEARER_SERV_SPEECH_CTM OR
666 bcpara->bearer_serv EQ MNCC_BEARER_SERV_AUX_SPEECH_CTM)
667 #endif
668 ) /* TTY over AMR is currently not supported by DSP, except Locosto Chipset 15*/
669 {
670 codec_val[index] = M_CC_SPEECH_VERS_AMR_HR;
671 index++;
672 }
673
674 break;
675 case M_CC_SPEECH_VERS_AMR_FR: /* Full rate speech version 3 - AMR */
676 if ((FldGet (cc_data->mscap.chnMode, AFS) NEQ 0)
677 #if (CHIPSET != 15)
678 AND !(bcpara->bearer_serv EQ MNCC_BEARER_SERV_SPEECH_CTM OR
679 bcpara->bearer_serv EQ MNCC_BEARER_SERV_AUX_SPEECH_CTM)
680 #endif
681 ) /* TTY over AMR is currently not supported by the DSP, except Locosto Chipset 15*/
682 {
683 codec_val[index] = M_CC_SPEECH_VERS_AMR_FR;
684 index++;
685 }
686 break;
687 } /* switch (codec_prio[prio])*/
688 } /* for */
689
690 if (bcpara->bearer_serv EQ MNCC_BEARER_SERV_SPEECH_CTM OR
691 bcpara->bearer_serv EQ MNCC_BEARER_SERV_AUX_SPEECH_CTM)
692 {
693 bearer_cap->v_ctm = TRUE;
694 bearer_cap->ctm = M_CC_CTM_YES;
695 bearer_cap->v_coding_bc3x1 = TRUE;
696 bearer_cap->coding_bc3x1 = M_CC_CODING_BC3X_SPEECH;
697 bearer_cap->v_speech_vers1 = TRUE;
698
699 if (codec_val[0] NEQ NOT_PRESENT_8BIT)
700 {
701 bearer_cap->speech_vers1 = codec_val[0];
702 }
703 else switch (bearer_cap->rad_chan_req)
704 {
705 case M_CC_RCR_HALF_PREF:
706 bearer_cap->speech_vers1 = M_CC_SPEECH_VERS_HR;
707 break;
708 case M_CC_RCR_FULL_PREF:
709 default:
710 bearer_cap->speech_vers1 = M_CC_SPEECH_VERS_FR;
711 break;
712 }
713 }
714 else if (codec_val[0] NEQ NOT_PRESENT_8BIT)
715 {
716 bearer_cap->v_ctm = TRUE;
717 bearer_cap->ctm = M_CC_CTM_NO;
718 bearer_cap->v_coding_bc3x1 = TRUE;
719 bearer_cap->coding_bc3x1 = M_CC_CODING_BC3X_SPEECH;
720 bearer_cap->v_speech_vers1 = TRUE;
721 bearer_cap->speech_vers1 = codec_val[0];
722 }
723 if (codec_val[1] NEQ NOT_PRESENT_8BIT)
724 {
725 bearer_cap->v_speech_vers2 = TRUE;
726 bearer_cap->speech_vers2 = codec_val[1];
727 bearer_cap->v_coding_bc3x2 = TRUE;
728 bearer_cap->coding_bc3x2 = M_CC_CODING_BC3X_SPEECH;
729 }
730 if (codec_val[2] NEQ NOT_PRESENT_8BIT)
731 {
732 bearer_cap->v_speech_vers3 = TRUE;
733 bearer_cap->speech_vers3 = codec_val[2];
734 bearer_cap->v_coding_bc3x3 = TRUE;
735 bearer_cap->coding_bc3x3 = M_CC_CODING_BC3X_SPEECH;
736 }
737 if (codec_val[3] NEQ NOT_PRESENT_8BIT)
738 {
739 bearer_cap->v_speech_vers4 = TRUE;
740 bearer_cap->speech_vers4 = codec_val[3];
741 bearer_cap->v_coding_bc3x4 = TRUE;
742 bearer_cap->coding_bc3x4 = M_CC_CODING_BC3X_SPEECH;
743 }
744 if (codec_val[4] NEQ NOT_PRESENT_8BIT)
745 {
746 bearer_cap->v_speech_vers5 = TRUE;
747 bearer_cap->speech_vers5 = codec_val[4];
748 bearer_cap->v_coding_bc3x5 = TRUE;
749 bearer_cap->coding_bc3x5 = M_CC_CODING_BC3X_SPEECH;
750 }
751 break;
752 default:
753 bearer_cap->v_rad_chan_req = TRUE;
754 bearer_cap->v_code = TRUE;
755 bearer_cap->code = M_CC_CSTD_GSM;
756 bearer_cap->v_trans_mode = TRUE;
757 bearer_cap->trans_mode = M_CC_TM_CIRCUIT;
758
759 if (FldGet (cc_data->mscap.datCap2, DHRSup) AND
760 bcpara->bearer_serv NEQ MNCC_BEARER_SERV_FAX) /* TA 29.2.3.7 */
761 /* Halfrate support */
762 bearer_cap->rad_chan_req = M_CC_RCR_FULL_PREF;
763 else
764 bearer_cap->rad_chan_req = M_CC_RCR_FULL_ONLY;
765 break;
766 }
767 }
768
769
770 /*
771 +--------------------------------------------------------------------+
772 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
773 | STATE : code ROUTINE : cc_set_trans_cap |
774 +--------------------------------------------------------------------+
775
776 PURPOSE : Set bearer capability parameters for data.
777
778 */
779
780 GLOBAL void cc_set_trans_cap (T_M_CC_bearer_cap * bearer_cap,
781 const T_MNCC_bcpara * bcpara)
782 {
783 TRACE_FUNCTION ("cc_set_trans_cap()");
784
785 bearer_cap->v_trans_cap = TRUE;
786
787 switch (bcpara->bearer_serv)
788 {
789 case MNCC_BEARER_SERV_SPEECH:
790 case MNCC_BEARER_SERV_SPEECH_CTM:
791 bearer_cap->trans_cap = M_CC_ITC_SPEECH;
792 break;
793
794 case MNCC_BEARER_SERV_AUX_SPEECH:
795 case MNCC_BEARER_SERV_AUX_SPEECH_CTM:
796 /*
797 * Alternate Line Service
798 */
799 bearer_cap->trans_cap = M_CC_ITC_AUXILIARY_SPEECH;
800 break;
801
802 case MNCC_BEARER_SERV_FAX:
803 bearer_cap->trans_cap = M_CC_ITC_FAX_GROUP_3;
804 bearer_cap->rate_adapt = M_CC_RA_NONE;
805 bearer_cap->v_rate_adapt = TRUE;
806 break;
807
808 case MNCC_BEARER_SERV_ASYNC:
809 case MNCC_BEARER_SERV_SYNC:
810 case MNCC_BEARER_SERV_PAD_ACCESS:
811 case MNCC_BEARER_SERV_PACKET_ACCESS:
812 #ifdef REL99
813 /* MT - Modem type digital */
814 if (bcpara->modem_type EQ M_CC_MT_NONE)
815 {
816 /* ITC - Information Transfer Capability */
817 if (bcpara->transfer_cap == MNCC_ITC_UDI)
818 {
819 bearer_cap->trans_cap = M_CC_ITC_DIGITAL_UNRESTRICTED;
820 }
821 else if (bcpara->transfer_cap == MNCC_ITC_RDI)
822 {
823 bearer_cap->trans_cap = M_CC_ITC_OTHER;
824 bearer_cap->other_itc = M_CC_ITC_DIGITAL_RESTRICTED;
825 bearer_cap->v_other_itc = TRUE;
826 }
827 /* RA - Rate adaption */
828 if (bcpara->rate_adaption == MNCC_RATE_ADAPT_V110)
829 {
830 bearer_cap->rate_adapt = M_CC_RA_V110;
831 }
832 else if (bcpara->rate_adaption == MNCC_RATE_ADAPT_V120)
833 {
834 bearer_cap->rate_adapt = M_CC_RA_OTHER;
835 bearer_cap->other_ra = M_CC_RA_V120;
836 bearer_cap->v_other_itc = TRUE; /* set for CCD encoding of Octet 5a */
837 bearer_cap->v_other_ra = TRUE;
838 }
839 }
840 /* MT - Modem type audio */
841 else
842 {
843 bearer_cap->trans_cap = M_CC_ITC_AUDIO;
844 if (bcpara->rate_adaption == MNCC_RATE_ADAPT_H223_H245)
845 {
846 bearer_cap->rate_adapt = M_CC_RA_OTHER;
847 bearer_cap->v_other_itc = TRUE; /* set for CCD encoding of Octet 5a */
848 bearer_cap->v_other_ra = TRUE;
849 bearer_cap->other_ra = M_CC_RA_H223_H245;
850 }
851 else
852 {
853 bearer_cap->rate_adapt = M_CC_RA_NONE;
854 }
855 }
856 bearer_cap->v_rate_adapt = TRUE;
857 break;
858 #else
859 if (bcpara->modem_type EQ M_CC_MT_NONE)
860 {
861 bearer_cap->trans_cap = M_CC_ITC_DIGITAL_UNRESTRICTED;
862 bearer_cap->rate_adapt = M_CC_RA_V110;
863 }
864 else
865 {
866 bearer_cap->trans_cap = M_CC_ITC_AUDIO;
867 bearer_cap->rate_adapt = M_CC_RA_NONE;
868 }
869 bearer_cap->v_rate_adapt = TRUE;
870 break;
871 #endif
872
873 }
874 }
875
876
877 /*
878 +--------------------------------------------------------------------+
879 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
880 | STATE : code ROUTINE : cc_set_conn_elem |
881 +--------------------------------------------------------------------+
882
883 PURPOSE : Set bearer capability parameters according to connection
884 element.
885
886 */
887
888 GLOBAL void cc_set_conn_elem (T_M_CC_bearer_cap * bearer_cap,
889 UBYTE conn_elem,
890 UBYTE flow_control)
891 {
892 TRACE_FUNCTION ("cc_set_conn_elem()");
893
894 bearer_cap->v_structure = TRUE;
895 bearer_cap->v_conn_elem = TRUE;
896 switch (conn_elem)
897 {
898 case MNCC_CONN_ELEM_TRANS:
899 bearer_cap->conn_elem = M_CC_CE_TRANSPA;
900 bearer_cap->structure = M_CC_STRC_UNSTRUCTURED;
901 flow_control = MNCC_OUTBAND_FLOW_CONTROL;
902 break;
903 case MNCC_CONN_ELEM_NON_TRANS:
904 bearer_cap->conn_elem = M_CC_CE_RLP;
905 bearer_cap->structure = M_CC_STRC_SERV_DATA_INTEG;
906 flow_control = MNCC_OUTBAND_FLOW_CONTROL;
907 break;
908 case MNCC_CONN_ELEM_TRANS_PREF:
909 bearer_cap->conn_elem = M_CC_CE_TRANSPA_PREF;
910 bearer_cap->structure = M_CC_STRC_SERV_DATA_INTEG;
911 flow_control = MNCC_OUTBAND_FLOW_CONTROL;
912 break;
913 case MNCC_CONN_ELEM_NON_TRANS_PREF:
914 bearer_cap->conn_elem = M_CC_CE_RLP_PREF;
915 bearer_cap->structure = M_CC_STRC_SERV_DATA_INTEG;
916 flow_control = MNCC_OUTBAND_FLOW_CONTROL;
917 break;
918 default:
919 break;
920 }
921 switch (flow_control)
922 {
923 case MNCC_INBAND_FLOW_CONTROL:
924 case MNCC_NO_FLOW_CONTROL:
925 bearer_cap->v_l2_ident = TRUE;
926 bearer_cap->l2_ident = M_CC_L2_OCT_ID;
927 bearer_cap->v_user_inf_l2_prot = TRUE;
928 bearer_cap->user_inf_l2_prot = flow_control;
929 break;
930 default:
931 break;
932 }
933 }
934
935 /*
936 +--------------------------------------------------------------------+
937 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
938 | STATE : code ROUTINE : cc_set_sync_async |
939 +--------------------------------------------------------------------+
940
941 PURPOSE : Set bearer capability parameters according to synchronous
942 flag.
943
944 */
945
946 GLOBAL void cc_set_sync_async (T_M_CC_bearer_cap * bearer_cap,
947 const T_MNCC_bcpara * bc_para)
948 {
949 TRACE_FUNCTION ("cc_set_sync_async()");
950
951 bearer_cap->v_sync_async = TRUE;
952 bearer_cap->v_num_stop = TRUE;
953 bearer_cap->v_num_data = TRUE;
954 bearer_cap->v_parity = TRUE;
955
956 switch (bc_para->bearer_serv)
957 {
958 case MNCC_BEARER_SERV_SYNC:
959 case MNCC_BEARER_SERV_PACKET_ACCESS:
960 case MNCC_BEARER_SERV_FAX:
961 bearer_cap->sync_async = 0;
962 bearer_cap->num_stop = M_CC_NSTOP_1;
963 bearer_cap->num_data = M_CC_NDATA_8;
964 bearer_cap->parity = bc_para->parity;
965 break;
966 default:
967 bearer_cap->sync_async = 1;
968 bearer_cap->num_stop = bc_para->stop_bits;
969 bearer_cap->num_data = bc_para->data_bits;
970 bearer_cap->parity = bc_para->parity;
971 break;
972 }
973 }
974
975 /*
976 +--------------------------------------------------------------------+
977 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
978 | STATE : code ROUTINE : cc_set_user_rate |
979 +--------------------------------------------------------------------+
980
981 PURPOSE : Set bearer capability parameters according to user rate.
982
983 */
984
985
986 GLOBAL void cc_set_user_rate (T_M_CC_bearer_cap * bearer_cap,
987 UBYTE rate,
988 UBYTE modem_type)
989 {
990 GET_INSTANCE_DATA;
991 TRACE_FUNCTION ("cc_set_user_rate()");
992
993 bearer_cap->v_user_rate = TRUE;
994 bearer_cap->v_nirr = TRUE;
995 bearer_cap->nirr = M_CC_NIRR_NO_MEANING;
996
997 bearer_cap->v_intermed_rate = TRUE;
998 bearer_cap->v_modem_type = TRUE;
999
1000 switch( modem_type )
1001 {
1002 case MNCC_MT_V32_BIS:
1003 bearer_cap->modem_type = M_CC_MT_V32;
1004 bearer_cap->v_modem_type_2 = TRUE;
1005 bearer_cap->modem_type_2 = M_CC_OTHER_MODEM_TYPE_V32BIS;
1006 break;
1007
1008 case MNCC_MT_V34:
1009 bearer_cap->modem_type = M_CC_MT_V32;
1010 bearer_cap->v_modem_type_2 = TRUE;
1011 bearer_cap->modem_type_2 = M_CC_OTHER_MODEM_TYPE_V34;
1012 break;
1013
1014 default:
1015 bearer_cap->modem_type = modem_type;
1016 if( rate EQ MNCC_UR_14_4_KBIT )
1017 {
1018 bearer_cap->v_modem_type_2 = TRUE;
1019 bearer_cap->modem_type_2 = M_CC_OTHER_MODEM_TYPE_NONE;
1020 }
1021 }
1022
1023 switch (rate)
1024 {
1025 case MNCC_UR_0_3_KBIT:
1026 case MNCC_UR_1_2_KBIT:
1027 case MNCC_UR_2_4_KBIT:
1028 case MNCC_UR_4_8_KBIT:
1029 case MNCC_UR_1_2_KBIT_V23:
1030 bearer_cap->user_rate = rate;
1031 if (bearer_cap->conn_elem EQ M_CC_CE_RLP)
1032 bearer_cap->intermed_rate = M_CC_IR_16_KBIT;
1033 else
1034 bearer_cap->intermed_rate = M_CC_IR_8_KBIT;
1035
1036 /*
1037 * PZ removed because R&S does not support 6 kbit channels
1038 if (bearer_cap->conn_elem EQ M_CC_CE_RLP AND
1039 bearer_cap->rad_chan_req EQ RCR_FULL_ONLY)
1040 bearer_cap->nirr = M_CC_NIRR_DATA;
1041 */
1042 break;
1043 case MNCC_UR_14_4_KBIT:
1044 bearer_cap->user_rate = MNCC_UR_9_6_KBIT;
1045 bearer_cap->intermed_rate = M_CC_IR_16_KBIT;
1046 bearer_cap->v_fnur = TRUE;
1047 bearer_cap->fnur = M_CC_FNUR_14400;
1048 bearer_cap->v_mTch = TRUE;
1049 bearer_cap->mTch = M_CC_MAX_TCH_1;
1050
1051 /*
1052 * These parameters are only used for NT data.
1053 * Otherwise they are optional (i.e. omitted).
1054 */
1055 if (bearer_cap->conn_elem == M_CC_CE_RLP)
1056 {
1057 bearer_cap->v_uimi = TRUE;
1058 bearer_cap->uimi = M_CC_UIMI_NOT_ALLOWED;
1059 bearer_cap->v_waiur = TRUE;
1060 bearer_cap->waiur = M_CC_WAIUR_14400;
1061 }
1062
1063 bearer_cap->v_acc = TRUE;
1064 bearer_cap->acc = M_CC_ACC_96;
1065
1066 if (FldGet (cc_data->mscap.datCap2, DHRSup))
1067 bearer_cap->acc += M_CC_ACC_48;
1068 if (FldGet (cc_data->mscap.datCap1, Dr14_4Sup))
1069 bearer_cap->acc += M_CC_ACC_144;
1070 break;
1071 default:
1072 bearer_cap->user_rate = rate;
1073 bearer_cap->intermed_rate = M_CC_IR_16_KBIT;
1074 break;
1075 }
1076 }
1077
1078 /*
1079 +--------------------------------------------------------------------+
1080 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1081 | STATE : code ROUTINE : cc_build_call_confirm |
1082 +--------------------------------------------------------------------+
1083
1084 PURPOSE : Filling of the C-Structure for call confirm message.
1085
1086 */
1087
1088 GLOBAL void cc_build_call_confirm ( T_U_CALL_CONF * call_cnf,
1089 USHORT cause)
1090 {
1091 GET_INSTANCE_DATA;
1092 TRACE_FUNCTION ("cc_build_call_confirm()");
1093
1094 call_cnf->msg_type = U_CALL_CONF;
1095
1096 if (cc_data->negotiation)
1097 {
1098 if (cc_data->neg_ri EQ NOT_PRESENT_8BIT)
1099 call_cnf->v_repeat = FALSE;
1100 else
1101 {
1102 call_cnf->v_repeat = TRUE;
1103 call_cnf->repeat = cc_data->neg_ri;
1104 }
1105
1106 if (cc_data->neg_serv1 EQ NOT_PRESENT_8BIT)
1107 call_cnf->v_bearer_cap = FALSE;
1108 else
1109 {
1110 call_cnf->v_bearer_cap = TRUE;
1111 call_cnf->bearer_cap = cc_data->neg_bc1;
1112 }
1113
1114 if (cc_data->neg_serv2 EQ NOT_PRESENT_8BIT)
1115 call_cnf->v_bearer_cap_2 = FALSE;
1116 else
1117 {
1118 call_cnf->v_bearer_cap_2 = TRUE;
1119 memcpy (&call_cnf->bearer_cap_2, &cc_data->neg_bc2,
1120 sizeof (T_M_CC_bearer_cap));
1121 }
1122 }
1123 else
1124 {
1125 call_cnf->v_repeat = FALSE;
1126 call_cnf->v_bearer_cap = FALSE;
1127 call_cnf->v_bearer_cap_2 = FALSE;
1128 }
1129 if (IS_CAUSE_INVALID(cause))
1130 call_cnf->v_cc_cause = FALSE;
1131 else
1132 {
1133 call_cnf->v_cc_cause = TRUE;
1134 cc_encode_cause (&call_cnf->cc_cause, cause);
1135 }
1136
1137 /*
1138 * GSM 24.008 has no clear advice when to include the CC capabilities,
1139 * neither in clause 5.2.2.3 nor in clause 9.3.2, but it is assumed that
1140 * it has to be included if at least one capability is present.
1141 * This means, with R99 and above always.
1142 */
1143 call_cnf->v_call_ctrl_cap = (cc_data->call_ctrl_cap.dtmf NEQ 0) OR
1144 (cc_data->call_ctrl_cap.pcp NEQ 0);
1145 if (call_cnf->v_call_ctrl_cap)
1146 {
1147 call_cnf->call_ctrl_cap = cc_data->call_ctrl_cap; /* Struct copy */
1148 }
1149 }
1150
1151
1152 /*
1153 +--------------------------------------------------------------------+
1154 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1155 | STATE : code ROUTINE : cc_build_cc_est_confirm |
1156 +--------------------------------------------------------------------+
1157
1158 PURPOSE : Filling of the C-Structure for CC EST. CONFIRMED message.
1159
1160 */
1161
1162 GLOBAL void cc_build_cc_est_confirm (T_U_CC_EST_CONF * cc_est_conf,
1163 USHORT cause)
1164 {
1165 GET_INSTANCE_DATA;
1166 TRACE_FUNCTION ("cc_build_cc_est_confirm()");
1167
1168 cc_est_conf->msg_type = U_CC_EST_CONF;
1169 if (cc_data->neg_ri EQ NOT_PRESENT_8BIT)
1170 cc_est_conf->v_repeat = FALSE;
1171 else
1172 {
1173 cc_est_conf->v_repeat = TRUE;
1174 cc_est_conf->repeat = cc_data->neg_ri;
1175 }
1176
1177 cc_est_conf->v_bearer_cap = TRUE;
1178 cc_est_conf->bearer_cap = cc_data->neg_bc1;
1179
1180 if (cc_data->neg_serv2 EQ NOT_PRESENT_8BIT)
1181 cc_est_conf->v_bearer_cap_2 = FALSE;
1182 else
1183 {
1184 cc_est_conf->v_bearer_cap_2 = TRUE;
1185 memcpy (&cc_est_conf->bearer_cap_2, &cc_data->neg_bc2,
1186 sizeof (T_M_CC_bearer_cap));
1187 }
1188
1189 if (IS_CAUSE_INVALID(cause))
1190 cc_est_conf->v_cc_cause = FALSE;
1191 else
1192 {
1193 cc_est_conf->v_cc_cause = TRUE;
1194 cc_encode_cause (&cc_est_conf->cc_cause, cause);
1195 }
1196 }
1197
1198
1199 /*
1200 +--------------------------------------------------------------------+
1201 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1202 | STATE : code ROUTINE : cc_build_congestion_control|
1203 +--------------------------------------------------------------------+
1204
1205 PURPOSE : Filling of the C-Structure for congestion control message.
1206
1207 */
1208
1209 GLOBAL void cc_build_congestion_control (const T_MNCC_USER_REQ * user,
1210 T_B_CONGEST_CTRL * cong_ctrl)
1211 {
1212 TRACE_FUNCTION ("cc_build_congestion_control()");
1213
1214 cong_ctrl->msg_type = B_CONGEST_CTRL;
1215 cong_ctrl->congest_lev = user->congest_lev;
1216 cong_ctrl->v_cc_cause = FALSE;
1217 }
1218
1219 /*
1220 +--------------------------------------------------------------------+
1221 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1222 | STATE : code ROUTINE : cc_build_disconnect |
1223 +--------------------------------------------------------------------+
1224
1225 PURPOSE : Filling of the C-Structure for disconnect message.
1226
1227 */
1228 GLOBAL void cc_build_disconnect (T_U_DISCONNECT * disconnect,
1229 USHORT cause,
1230 const T_NAS_fac_inf * fac_inf,
1231 UBYTE ss_ver)
1232 {
1233
1234 TRACE_FUNCTION ("cc_build_disconnect()");
1235
1236 disconnect->msg_type = U_DISCONNECT;
1237 cc_encode_cause (&disconnect->cc_cause, cause);
1238
1239 disconnect->v_facility = FALSE;
1240 disconnect->v_user_user = FALSE;
1241 disconnect->v_ss_version = FALSE;
1242
1243 if ((fac_inf NEQ NULL) AND (fac_inf->l_fac NEQ 0))
1244 {
1245 /* Send facility IE */
1246 disconnect->v_facility = TRUE;
1247 disconnect->facility.c_fac = fac_inf->l_fac >> 3;
1248 memcpy (disconnect->facility.fac,
1249 &fac_inf->fac[fac_inf->o_fac >> 3],
1250 disconnect->facility.c_fac);
1251
1252 if (ss_ver NEQ MNCC_SS_VER_NOT_PRES)
1253 {
1254 disconnect->v_ss_version = TRUE;
1255 disconnect->ss_version.c_ver = 1;
1256 disconnect->ss_version.ver[0] = ss_ver;
1257 }
1258 }
1259
1260 /* no security check for validity of cause; cause is mandatory in DISCONNECT */
1261 cc_encode_cause (&disconnect->cc_cause, cause);
1262 }
1263
1264 /*
1265 +--------------------------------------------------------------------+
1266 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1267 | STATE : code ROUTINE : cc_build_emergency_setup |
1268 +--------------------------------------------------------------------+
1269
1270 PURPOSE : Filling of the C-Structure for emergency setup message.
1271
1272 */
1273
1274 GLOBAL void cc_build_emergency_setup (T_U_EMERGE_SETUP * emergency_setup)
1275 {
1276 GET_INSTANCE_DATA;
1277 TRACE_FUNCTION ("cc_build_emergency_setup()");
1278
1279 emergency_setup->msg_type = U_EMERGE_SETUP;
1280 /*emergency_setup->v_bearer_cap = FALSE;*/
1281 emergency_setup->v_bearer_cap = TRUE;
1282 emergency_setup->bearer_cap = cc_data->bc1;
1283 }
1284
1285 /*
1286 +--------------------------------------------------------------------+
1287 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1288 | STATE : code ROUTINE : cc_build_facility |
1289 +--------------------------------------------------------------------+
1290
1291 PURPOSE : Filling of the C-Structure for facility message.
1292
1293 */
1294
1295 GLOBAL void cc_build_facility (const T_MNCC_FACILITY_REQ * facility,
1296 T_U_FACILITY * facility_msg)
1297 {
1298 UBYTE length;
1299
1300 TRACE_FUNCTION ("cc_build_facility()");
1301
1302 length = facility->fac_inf.l_fac>>3;
1303
1304 if (length > 251)
1305 return;
1306
1307 facility_msg->msg_type = U_FACILITY;
1308 facility_msg->facility.c_fac = length;
1309 memcpy (facility_msg->facility.fac,
1310 &facility->fac_inf.fac[facility->fac_inf.o_fac>>3], length);
1311
1312 if (facility->ss_version EQ NOT_PRESENT_8BIT)
1313 facility_msg->v_ss_version = FALSE;
1314 else
1315 {
1316 facility_msg->v_ss_version = TRUE;
1317 facility_msg->ss_version.c_ver = 1;
1318 facility_msg->ss_version.ver[0] = facility->ss_version;
1319 }
1320 }
1321
1322
1323 /*
1324 +--------------------------------------------------------------------+
1325 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1326 | STATE : code ROUTINE : cc_build_mncc_alert_ind |
1327 +--------------------------------------------------------------------+
1328
1329 PURPOSE : Filling of the C-Structure for MNCC_ALERT_IND.
1330
1331 */
1332
1333 GLOBAL void cc_build_mncc_alert_ind ( const T_D_ALERT * alert,
1334 T_MNCC_ALERT_IND * alert_ind)
1335 {
1336 GET_INSTANCE_DATA;
1337 TRACE_FUNCTION ("cc_build_mncc_alert_ind()");
1338
1339 alert_ind->ti = cc_data->ti;
1340
1341 if (alert->v_progress)
1342 {
1343 alert_ind->progress_desc = alert->progress.progress_desc;
1344 }
1345 else
1346 {
1347 alert_ind->progress_desc = NOT_PRESENT_8BIT;
1348 }
1349 }
1350
1351 /*
1352 +--------------------------------------------------------------------+
1353 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1354 | STATE : code ROUTINE : cc_build_mncc_proceed_ind |
1355 +--------------------------------------------------------------------+
1356
1357 PURPOSE : Filling of the C-Structure for MNCC_CALL_PROCEED_IND.
1358
1359 */
1360
1361 GLOBAL void cc_build_mncc_proceed_ind (const T_D_CALL_PROCEED * proceed,
1362 T_MNCC_CALL_PROCEED_IND * proceed_ind)
1363 {
1364 GET_INSTANCE_DATA;
1365 TRACE_FUNCTION ("cc_build_mncc_proceed_ind()");
1366
1367 proceed_ind->ti = cc_data->ti;
1368 proceed_ind->ri = cc_data->neg_ri;
1369 memcpy (&proceed_ind->bcpara, &cc_data->neg_bcpara1, sizeof (T_MNCC_bcpara));
1370 memcpy (&proceed_ind->bcpara2, &cc_data->neg_bcpara2, sizeof (T_MNCC_bcpara));
1371
1372 #if defined (WIN32)
1373 TRACE_EVENT_P1 ("Rate = %d", cc_data->neg_bcpara1.rate);
1374 TRACE_EVENT_P1 ("Bearer Serv = %d", cc_data->neg_bcpara1.bearer_serv);
1375 TRACE_EVENT_P1 ("Conn Elem = %d", cc_data->neg_bcpara1.conn_elem);
1376 TRACE_EVENT_P1 ("Stop Bits = %d", cc_data->neg_bcpara1.stop_bits);
1377 TRACE_EVENT_P1 ("Data Bits = %d", cc_data->neg_bcpara1.data_bits);
1378 TRACE_EVENT_P1 ("Parity = %d", cc_data->neg_bcpara1.parity);
1379 TRACE_EVENT_P1 ("Flow Control = %d", cc_data->neg_bcpara1.flow_control);
1380 #endif
1381
1382 if (proceed->v_progress)
1383 {
1384 proceed_ind->progress_desc = proceed->progress.progress_desc;
1385 }
1386 else
1387 {
1388 proceed_ind->progress_desc = NOT_PRESENT_8BIT;
1389 }
1390 }
1391
1392
1393 /*
1394 +--------------------------------------------------------------------+
1395 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1396 | STATE : code ROUTINE : cc_build_mncc_progress_ind |
1397 +--------------------------------------------------------------------+
1398
1399 PURPOSE : Filling of the C-Structure for MNCC_PROGRESS_IND.
1400
1401 */
1402
1403 GLOBAL void cc_build_mncc_progress_ind (const T_D_PROGRESS * progress,
1404 T_MNCC_PROGRESS_IND * progress_ind)
1405 {
1406 GET_INSTANCE_DATA;
1407 TRACE_FUNCTION ("cc_build_mncc_progress_ind()");
1408
1409 progress_ind->ti = cc_data->ti;
1410 progress_ind->progress_desc = progress->progress.progress_desc;
1411 }
1412
1413 /*
1414 +--------------------------------------------------------------------+
1415 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1416 | STATE : code ROUTINE : cc_build_mncc_setup_cnf |
1417 +--------------------------------------------------------------------+
1418
1419 PURPOSE : Filling of the C-Structure for MNCC_SETUP_CNF.
1420
1421 */
1422
1423 GLOBAL void cc_build_mncc_setup_cnf (const T_D_CONNECT * connect,
1424 T_MNCC_SETUP_CNF * setup_cnf)
1425 {
1426 GET_INSTANCE_DATA;
1427 TRACE_FUNCTION ("cc_build_mncc_setup_cnf()");
1428
1429 setup_cnf->ti = cc_data->ti;
1430 setup_cnf->cause = MNCC_CAUSE_SUCCESS;
1431
1432 if (connect->v_progress)
1433 {
1434 setup_cnf->progress_desc = connect->progress.progress_desc;
1435 }
1436 else
1437 {
1438 setup_cnf->progress_desc = NOT_PRESENT_8BIT;
1439 }
1440 /* Implements Measure# 15 */
1441 cc_fill_struct (connect->v_connect_num,
1442 &setup_cnf->connected_number,
1443 (T_M_CC_calling_num*)&connect->connect_num);
1444 /* Implements Measure# 24 */
1445 cc_fill_sub_struct (connect->v_connect_subaddr,
1446 &setup_cnf->connected_number_sub,
1447 &connect->connect_subaddr);
1448 }
1449
1450 /*
1451 +--------------------------------------------------------------------+
1452 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1453 | STATE : code ROUTINE : cc_build_mncc_setup_ind |
1454 +--------------------------------------------------------------------+
1455
1456 PURPOSE : Filling of the C-Structure for MNCC_SETUP_IND.
1457
1458 */
1459
1460 GLOBAL void cc_build_mncc_setup_ind (const T_D_SETUP * setup,
1461 T_MNCC_SETUP_IND * setup_ind)
1462 {
1463 GET_INSTANCE_DATA;
1464 TRACE_FUNCTION ("cc_build_mncc_setup_ind()");
1465
1466 setup_ind->ti = cc_data->ti;
1467
1468 setup_ind->ri = cc_data->neg_ri;
1469 memcpy (&setup_ind->bcpara, &cc_data->neg_bcpara1, sizeof (T_MNCC_bcpara));
1470 memcpy (&setup_ind->bcpara2, &cc_data->neg_bcpara2, sizeof (T_MNCC_bcpara));
1471
1472 if (setup->v_progress)
1473 {
1474 setup_ind->progress_desc = setup->progress.progress_desc;
1475 }
1476 else
1477 {
1478 setup_ind->progress_desc = MNCC_PROG_NOT_PRES;
1479 }
1480
1481 if (setup->v_signal)
1482 setup_ind->sig = setup->signal;
1483 else
1484 setup_ind->sig = MNCC_SIG_NOT_PRES;
1485 /* Implements Measure# 15 */
1486 cc_fill_struct (setup->v_calling_num,
1487 &setup_ind->calling_party,
1488 &setup->calling_num);
1489 /* Implements Measure# 24 */
1490 cc_fill_sub_struct (setup->v_calling_subaddr,
1491 &setup_ind->calling_party_sub,
1492 (T_M_CC_connect_subaddr*)&setup->calling_subaddr);
1493 if (setup->v_dl_called_num)
1494 {
1495 setup_ind->called_party.ton = setup->dl_called_num.ton;
1496 setup_ind->called_party.npi = setup->dl_called_num.npi;
1497 setup_ind->called_party.c_called_num = setup->dl_called_num.c_num;
1498 memcpy (setup_ind->called_party.called_num,
1499 setup->dl_called_num.num, setup->dl_called_num.c_num);
1500 }
1501 else
1502 {
1503 setup_ind->called_party.ton = MNCC_TON_NOT_PRES;
1504 setup_ind->called_party.npi = MNCC_NPI_NOT_PRES;
1505 setup_ind->called_party.c_called_num = 0;
1506 }
1507 /* Implements Measure# 25 */
1508 cc_fill_sub_struct (setup->v_called_subaddr,
1509 &setup_ind->called_party_sub,
1510 (T_M_CC_connect_subaddr *)&setup->called_subaddr);
1511 if (setup->v_redirecting_num)
1512 {
1513 setup_ind->redirecting_party.ton = setup->redirecting_num.ton;
1514 setup_ind->redirecting_party.npi = setup->redirecting_num.npi;
1515 setup_ind->redirecting_party.c_redir_num = setup->redirecting_num.c_num;
1516 memcpy (setup_ind->redirecting_party.redir_num,
1517 setup->redirecting_num.num,
1518 setup->redirecting_num.c_num);
1519 if (setup->redirecting_num.v_screen)
1520 setup_ind->redirecting_party.screen = setup->redirecting_num.screen;
1521 else
1522 setup_ind->redirecting_party.screen = MNCC_SCREEN_IND_NOT_PRES;
1523 if (setup->redirecting_num.v_present)
1524 setup_ind->redirecting_party.present = setup->redirecting_num.present;
1525 else
1526 setup_ind->redirecting_party.present = MNCC_PRES_NOT_PRES;
1527 }
1528 else
1529 {
1530 setup_ind->redirecting_party.ton = MNCC_TON_NOT_PRES;
1531 setup_ind->redirecting_party.npi = MNCC_NPI_NOT_PRES;
1532 setup_ind->redirecting_party.present = MNCC_PRES_NOT_PRES;
1533 setup_ind->redirecting_party.screen = MNCC_SCREEN_IND_NOT_PRES;
1534 setup_ind->redirecting_party.c_redir_num = 0;
1535 }
1536 /* Implements Measure# 26 */
1537 cc_fill_sub_struct (setup->v_redirecting_subaddr,
1538 &setup_ind->redirecting_party_sub,
1539 (T_M_CC_connect_subaddr *)&setup->redirecting_subaddr);
1540 }
1541
1542 /*
1543 +--------------------------------------------------------------------+
1544 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1545 | STATE : code ROUTINE : cc_build_modify |
1546 +--------------------------------------------------------------------+
1547
1548 PURPOSE : Filling of the C-Structure for modify message.
1549
1550 */
1551
1552 GLOBAL void cc_build_modify (const T_MNCC_MODIFY_REQ * modify,
1553 T_B_MODIFY * modify_msg)
1554 {
1555 GET_INSTANCE_DATA;
1556 TRACE_FUNCTION ("cc_build_modify()");
1557
1558 modify_msg->msg_type = B_MODIFY;
1559 if (modify->serv EQ cc_data->neg_serv1)
1560 {
1561 modify_msg->bearer_cap = cc_data->neg_bc1;
1562 cc_data->new_itc = cc_data->neg_bc1.trans_cap;
1563 cc_data->old_itc = cc_data->neg_bc2.trans_cap;
1564 }
1565 else
1566 {
1567 modify_msg->bearer_cap = cc_data->neg_bc2;
1568 cc_data->new_itc = cc_data->neg_bc2.trans_cap;
1569 cc_data->old_itc = cc_data->neg_bc1.trans_cap;
1570 }
1571
1572 if (modify_msg->bearer_cap.trans_cap EQ M_CC_ITC_DIGITAL_UNRESTRICTED)
1573 {
1574 cc_build_llc (&modify_msg->v_low_layer_comp,
1575 &modify_msg->low_layer_comp,
1576 &modify_msg->bearer_cap);
1577 }
1578 else
1579 modify_msg->v_low_layer_comp = FALSE;
1580 modify_msg->v_high_layer_comp = FALSE;
1581
1582 if (cc_data->call_type [cc_data->index_ti] EQ CALL_TYPE_MTC)
1583 modify_msg->v_reverse_call = TRUE;
1584 else
1585 modify_msg->v_reverse_call = FALSE;
1586 }
1587
1588 /*
1589 +--------------------------------------------------------------------+
1590 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1591 | STATE : code ROUTINE : cc_build_modify_complete |
1592 +--------------------------------------------------------------------+
1593
1594 PURPOSE : Filling of the C-Structure for modify complete message.
1595
1596 */
1597
1598 GLOBAL void cc_build_modify_complete (T_B_MODIFY_COMP * modify_com)
1599 {
1600 GET_INSTANCE_DATA;
1601 TRACE_FUNCTION ("cc_build_modify_complete()");
1602
1603 modify_com->msg_type = B_MODIFY_COMP;
1604 if (cc_data->active_service EQ cc_data->neg_serv1)
1605 modify_com->bearer_cap = cc_data->neg_bc1;
1606 else
1607 modify_com->bearer_cap = cc_data->neg_bc2;
1608
1609
1610 if (cc_data->call_type [cc_data->index_ti] EQ CALL_TYPE_MTC)
1611 {
1612 modify_com->v_reverse_call = TRUE;
1613 modify_com->v_low_layer_comp = FALSE;
1614 }
1615 else
1616 {
1617 modify_com->v_reverse_call = FALSE;
1618 if (modify_com->bearer_cap.trans_cap EQ M_CC_ITC_DIGITAL_UNRESTRICTED)
1619 {
1620 cc_build_llc (&modify_com->v_low_layer_comp,
1621 &modify_com->low_layer_comp,
1622 &modify_com->bearer_cap);
1623 }
1624 else
1625 modify_com->v_low_layer_comp = FALSE;
1626 }
1627
1628 modify_com->v_high_layer_comp = FALSE;
1629 }
1630
1631 /*
1632 +--------------------------------------------------------------------+
1633 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1634 | STATE : code ROUTINE : cc_build_modify_reject |
1635 +--------------------------------------------------------------------+
1636
1637 PURPOSE : Filling of the C-Structure for modify reject message.
1638
1639 */
1640
1641 GLOBAL void cc_build_modify_reject (T_B_MODIFY_REJ * modify_rej,
1642 USHORT cause)
1643 {
1644 GET_INSTANCE_DATA;
1645 TRACE_FUNCTION ("cc_build_modify_reject()");
1646
1647 modify_rej->msg_type = B_MODIFY_REJ;
1648 if (cc_data->active_service EQ cc_data->neg_serv1)
1649 modify_rej->bearer_cap = cc_data->neg_bc1;
1650 else
1651 modify_rej->bearer_cap = cc_data->neg_bc2;
1652
1653 if (cc_data->call_type [cc_data->index_ti] EQ CALL_TYPE_MTC)
1654 {
1655 modify_rej->v_low_layer_comp = FALSE;
1656 }
1657 else
1658 {
1659 if (modify_rej->bearer_cap.trans_cap EQ M_CC_ITC_DIGITAL_UNRESTRICTED)
1660 {
1661 cc_build_llc (&modify_rej->v_low_layer_comp,
1662 &modify_rej->low_layer_comp,
1663 &modify_rej->bearer_cap);
1664 }
1665 else
1666 modify_rej->v_low_layer_comp = FALSE;
1667 }
1668
1669 modify_rej->v_high_layer_comp = FALSE;
1670
1671 /* no security check for validity of cause; cause is mandatory in MODIFY REJECT */
1672 cc_encode_cause (&modify_rej->cc_cause, cause);
1673 }
1674
1675
1676 /*
1677 +--------------------------------------------------------------------+
1678 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1679 | STATE : code ROUTINE : cc_build_release |
1680 +--------------------------------------------------------------------+
1681
1682 PURPOSE : Filling of the C-Structure for release message.
1683
1684 */
1685 GLOBAL void cc_build_release (T_U_RELEASE * release,
1686 USHORT cause,
1687 const T_NAS_fac_inf * fac_inf,
1688 UBYTE ss_ver)
1689 {
1690
1691 TRACE_FUNCTION ("cc_build_release()");
1692
1693 release->msg_type = U_RELEASE;
1694 if (IS_CAUSE_INVALID(cause))
1695 {
1696 release->v_cc_cause = FALSE;
1697 }
1698 else
1699 {
1700 release->v_cc_cause = TRUE;
1701 cc_encode_cause (&release->cc_cause, cause);
1702 }
1703
1704 release->v_cc_cause_2 = FALSE;
1705 release->v_facility = FALSE;
1706 release->v_user_user = FALSE;
1707 release->v_ss_version = FALSE;
1708
1709 if ((fac_inf NEQ NULL) AND (fac_inf->l_fac NEQ 0))
1710 {
1711 /* Send facility IE */
1712 release->v_facility = TRUE;
1713 release->facility.c_fac = fac_inf->l_fac >> 3;
1714 memcpy (release->facility.fac,
1715 &fac_inf->fac[fac_inf->o_fac >> 3],
1716 release->facility.c_fac);
1717
1718 if (ss_ver NEQ MNCC_SS_VER_NOT_PRES)
1719 {
1720 release->v_ss_version = TRUE;
1721 release->ss_version.c_ver = 1;
1722 release->ss_version.ver[0] = ss_ver;
1723 }
1724 }
1725 }
1726
1727
1728 /*
1729 +--------------------------------------------------------------------+
1730 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1731 | STATE : code ROUTINE : cc_build_release_complete |
1732 +--------------------------------------------------------------------+
1733
1734 PURPOSE : Filling of the C-Structure for release complete message.
1735
1736 */
1737
1738 GLOBAL void cc_build_release_complete (T_U_RELEASE_COMP * rel_com,
1739 USHORT cause)
1740 {
1741
1742 TRACE_FUNCTION ("cc_build_release_complete()");
1743
1744 rel_com->msg_type = U_RELEASE_COMP;
1745 if (IS_CAUSE_INVALID(cause))
1746 {
1747 rel_com->v_cc_cause = FALSE;
1748 }
1749 else
1750 {
1751 rel_com->v_cc_cause = TRUE;
1752 cc_encode_cause (&rel_com->cc_cause, cause);
1753 }
1754
1755 rel_com->v_facility = FALSE;
1756 rel_com->v_user_user = FALSE;
1757 rel_com->v_ss_version = FALSE;
1758 }
1759
1760 /*
1761 +--------------------------------------------------------------------+
1762 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1763 | STATE : code ROUTINE : cc_build_start_cc |
1764 +--------------------------------------------------------------------+
1765
1766 PURPOSE : Filling of the C-Structure for a START CC message.
1767
1768 */
1769
1770 GLOBAL void cc_build_start_cc (T_U_START_CC * start_cc)
1771 {
1772 GET_INSTANCE_DATA;
1773 TRACE_FUNCTION ("cc_build_start_cc()");
1774
1775 start_cc->msg_type = U_START_CC;
1776 start_cc->v_call_ctrl_cap = (cc_data->call_ctrl_cap.dtmf NEQ 0) OR
1777 (cc_data->call_ctrl_cap.pcp NEQ 0);
1778 if (start_cc->v_call_ctrl_cap)
1779 {
1780 start_cc->call_ctrl_cap = cc_data->call_ctrl_cap; /* Struct copy */
1781 }
1782 }
1783
1784
1785 /*
1786 +--------------------------------------------------------------------+
1787 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1788 | STATE : code ROUTINE : cc_fill_llc_hlc |
1789 +--------------------------------------------------------------------+
1790
1791 PURPOSE : Filling of the C-Structure for LLC and HLC in the
1792 setup message.
1793
1794 */
1795
1796 GLOBAL void cc_fill_llc_hlc (T_U_SETUP * setup)
1797 {
1798
1799 TRACE_FUNCTION ("cc_fill_llc_hlc()");
1800
1801 /*
1802 * add lower layer capability if
1803 * at least one bearer cap indicates
1804 * information transfer capability = UDI
1805 */
1806 if ((setup->v_bearer_cap AND
1807 setup->bearer_cap.trans_cap EQ M_CC_ITC_DIGITAL_UNRESTRICTED) OR
1808 (setup->v_bearer_cap_2 AND
1809 setup->bearer_cap_2.trans_cap EQ M_CC_ITC_DIGITAL_UNRESTRICTED))
1810 {
1811 /*
1812 * copy repeat indicator if available
1813 */
1814 setup->v_repeat_2 = setup->v_repeat;
1815 setup->repeat_2 = setup->repeat;
1816 /*
1817 * Fill LLC if bearer cap is available
1818 */
1819 if (setup->v_bearer_cap)
1820 cc_build_llc (&setup->v_low_layer_comp, &setup->low_layer_comp,
1821 &setup->bearer_cap);
1822 if (setup->v_bearer_cap_2)
1823 cc_build_llc (&setup->v_low_layer_comp_2, (T_M_CC_low_layer_comp *)&setup->low_layer_comp_2,
1824 (T_M_CC_bearer_cap *)&setup->bearer_cap_2);
1825 }
1826 else
1827 {
1828 /*
1829 * default dont include LLC
1830 */
1831 setup->v_repeat_2 = FALSE;
1832 setup->v_low_layer_comp = FALSE;
1833 setup->v_low_layer_comp_2 = FALSE;
1834 }
1835 setup->v_repeat_3 = FALSE;
1836 setup->v_high_layer_comp = FALSE;
1837 setup->v_high_layer_comp_2 = FALSE;
1838 }
1839
1840
1841 /*
1842 +--------------------------------------------------------------------+
1843 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1844 | STATE : code ROUTINE : cc_build_setup |
1845 +--------------------------------------------------------------------+
1846
1847 PURPOSE : Filling of the C-Structure for setup message.
1848
1849 */
1850
1851 GLOBAL void cc_build_setup ( T_U_SETUP * setup_msg,
1852 const T_MNCC_SETUP_REQ *setup_prm)
1853 {
1854 GET_INSTANCE_DATA;
1855 TRACE_FUNCTION ("cc_build_setup()");
1856
1857 TRACE_EVENT_P2 ("SERV2=%x RI=%x", cc_data->serv2, cc_data->ri);
1858
1859 setup_msg->msg_type = U_SETUP;
1860 setup_msg->v_bearer_cap = TRUE;
1861 setup_msg->bearer_cap = cc_data->bc1;
1862 if (cc_data->serv2 NEQ NOT_PRESENT_8BIT)
1863 {
1864 setup_msg->v_bearer_cap_2 = TRUE;
1865 memcpy (&setup_msg->bearer_cap_2,
1866 &cc_data->bc2,
1867 sizeof (T_M_CC_bearer_cap));
1868 setup_msg->v_repeat = TRUE;
1869 setup_msg->repeat = cc_data->ri;
1870 }
1871 else
1872 {
1873 setup_msg->v_repeat = FALSE;
1874 setup_msg->v_bearer_cap_2 = FALSE;
1875 }
1876
1877 cc_fill_llc_hlc (setup_msg);
1878
1879 setup_msg->v_user_user = FALSE;
1880 setup_msg->v_ss_version = FALSE;
1881 setup_msg->v_fac_adv = FALSE;
1882
1883 if (cc_data->my_party_subaddr.c_subaddr NEQ 0)
1884 {
1885 setup_msg->v_calling_subaddr = TRUE;
1886 setup_msg->calling_subaddr = cc_data->my_party_subaddr; /* Struct copy */
1887 }
1888 else
1889 {
1890 setup_msg->v_calling_subaddr = FALSE;
1891 }
1892
1893 if (setup_prm->called_party.c_called_num NEQ 0)
1894 {
1895 setup_msg->v_ul_called_num = TRUE;
1896 setup_msg->ul_called_num.v_ton = TRUE;
1897 setup_msg->ul_called_num.ton = setup_prm->called_party.ton;
1898 setup_msg->ul_called_num.v_npi = TRUE;
1899 setup_msg->ul_called_num.npi = setup_prm->called_party.npi;
1900 setup_msg->ul_called_num.c_num = setup_prm->called_party.c_called_num;
1901 memcpy (&setup_msg->ul_called_num.num[0],
1902 &setup_prm->called_party.called_num[0],
1903 setup_prm->called_party.c_called_num);
1904 }
1905 else
1906 {
1907 setup_msg->v_ul_called_num = FALSE;
1908 }
1909
1910 if (setup_prm->called_party_sub.c_subaddr NEQ 0)
1911 {
1912 setup_msg->v_called_subaddr = TRUE;
1913 setup_msg->called_subaddr.v_tos = TRUE;
1914 setup_msg->called_subaddr.tos = setup_prm->called_party_sub.tos;
1915 setup_msg->called_subaddr.v_odd_even = TRUE;
1916 setup_msg->called_subaddr.odd_even = setup_prm->called_party_sub.odd_even;
1917 setup_msg->called_subaddr.c_subaddr = setup_prm->called_party_sub.c_subaddr;
1918 memcpy (&setup_msg->called_subaddr.subaddr[0],
1919 &setup_prm->called_party_sub.subaddr[0],
1920 setup_prm->called_party_sub.c_subaddr);
1921 }
1922 else
1923 {
1924 setup_msg->v_called_subaddr = FALSE;
1925 }
1926
1927 switch (setup_prm->clir_sup)
1928 {
1929 case MNCC_CLR_SUP:
1930 setup_msg->v_clir_suppr = TRUE;
1931 setup_msg->v_clir_invoc = FALSE;
1932 break;
1933
1934 case MNCC_CLR_SUP_NOT:
1935 setup_msg->v_clir_suppr = FALSE;
1936 setup_msg->v_clir_invoc = TRUE;
1937 break;
1938
1939 default: /* CLR_NOT_PRES */
1940 setup_msg->v_clir_suppr = FALSE;
1941 setup_msg->v_clir_invoc = FALSE;
1942 break;
1943 }
1944
1945 setup_msg->v_call_ctrl_cap = (cc_data->call_ctrl_cap.dtmf NEQ 0) OR
1946 (cc_data->call_ctrl_cap.pcp NEQ 0);
1947 if (setup_msg->v_call_ctrl_cap)
1948 {
1949 setup_msg->call_ctrl_cap = cc_data->call_ctrl_cap; /* Struct copy */
1950 }
1951
1952 if (setup_msg->bearer_cap.conn_elem EQ MNCC_CONN_ELEM_TRANS)
1953 {
1954 /*
1955 * set parameters invalid according to GSM 07.01 V7.1.1 Rel 1998 -
1956 * CC-ENH-2378
1957 */
1958 setup_msg->bearer_cap.v_uimi = FALSE;
1959 setup_msg->bearer_cap.v_waiur = FALSE;
1960 }
1961
1962 if (setup_prm->fac_inf.l_fac EQ 0)
1963 {
1964 setup_msg->v_facility = FALSE;
1965 }
1966 else
1967 {
1968 setup_msg->v_facility = TRUE;
1969 setup_msg->facility.c_fac = setup_prm->fac_inf.l_fac >> 3;
1970 memcpy (setup_msg->facility.fac,
1971 &setup_prm->fac_inf.fac[setup_prm->fac_inf.o_fac>>3],
1972 setup_msg->facility.c_fac);
1973 }
1974 }
1975
1976 /*
1977 +--------------------------------------------------------------------+
1978 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1979 | STATE : code ROUTINE : cc_build_start_dtmf |
1980 +--------------------------------------------------------------------+
1981
1982 PURPOSE : Filling of the C-Structure for start dtmf message.
1983
1984 */
1985
1986 GLOBAL void cc_build_start_dtmf (UBYTE key,
1987 T_U_START_DTMF * start_dtmf)
1988 {
1989 TRACE_FUNCTION ("cc_build_start_dtmf()");
1990
1991 start_dtmf->msg_type = U_START_DTMF;
1992 start_dtmf->v_key_facility = TRUE;
1993 start_dtmf->key_facility.key = key;
1994 }
1995
1996 /*
1997 +--------------------------------------------------------------------+
1998 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
1999 | STATE : code ROUTINE : cc_build_alert |
2000 +--------------------------------------------------------------------+
2001
2002 PURPOSE : Filling of the C-Structure for alert message.
2003
2004 */
2005
2006 GLOBAL void cc_build_alert (T_U_ALERT * alert_msg)
2007 {
2008 TRACE_FUNCTION ("cc_build_alert()");
2009
2010 alert_msg->msg_type = U_ALERT;
2011 alert_msg->v_facility = FALSE;
2012 alert_msg->v_user_user = FALSE;
2013 alert_msg->v_ss_version = FALSE;
2014 }
2015
2016 /*
2017 +--------------------------------------------------------------------+
2018 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
2019 | STATE : code ROUTINE : cc_build_connect |
2020 +--------------------------------------------------------------------+
2021
2022 PURPOSE : Filling of the C-Structure for connect message.
2023
2024 */
2025
2026 GLOBAL void cc_build_connect (T_U_CONNECT * connect_msg)
2027 {
2028 TRACE_FUNCTION ("cc_build_connect()");
2029
2030 connect_msg->msg_type = U_CONNECT;
2031 connect_msg->v_facility = FALSE;
2032 connect_msg->v_connect_subaddr = FALSE;
2033 connect_msg->v_user_user = FALSE;
2034 connect_msg->v_ss_version = FALSE;
2035 }
2036
2037 /*
2038 +--------------------------------------------------------------------+
2039 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
2040 | STATE : code ROUTINE : cc_build_status |
2041 +--------------------------------------------------------------------+
2042
2043 PURPOSE : Filling of the C-Structure for status message.
2044
2045 */
2046
2047 GLOBAL void cc_build_status (T_B_STATUS * status,
2048 USHORT cause)
2049 {
2050 GET_INSTANCE_DATA;
2051 TRACE_FUNCTION ("cc_build_status()");
2052
2053 status->msg_type = B_STATUS;
2054
2055 /* no security check for validity of cause; cause is mandatory in STATUS */
2056 cc_encode_cause (&status->cc_cause, cause);
2057
2058 status->call_state.cs = M_CC_CS_GSM_PLMN; /* vk 04-jul-97 */
2059 status->call_state.state = cc_data->state[cc_data->index_ti];
2060
2061 switch (status->call_state.state)
2062 {
2063 case M_CC_CS_10:
2064 case M_CC_CS_26:
2065 if (cc_data->hold_state[cc_data->index_ti] NEQ M_CC_HLD_IDLE OR
2066 cc_data->mpty_state[cc_data->index_ti] NEQ M_CC_MPTY_IDLE)
2067 {
2068
2069 TRACE_EVENT_P3 (" ti=%d, hold=%d, mpty=%d",
2070 cc_data->ti,
2071 cc_data->hold_state[cc_data->index_ti],
2072 cc_data->mpty_state[cc_data->index_ti]);
2073
2074 status->v_aux_states = TRUE;
2075 status->aux_states.v_hold = TRUE;
2076 status->aux_states.hold = cc_data->hold_state[cc_data->index_ti];
2077 status->aux_states.v_mpty = TRUE;
2078 status->aux_states.mpty = cc_data->mpty_state[cc_data->index_ti];
2079 }
2080 else
2081 {
2082 status->v_aux_states = FALSE;
2083 }
2084 break;
2085
2086 default:
2087 status->v_aux_states = FALSE;
2088 break;
2089 }
2090 }
2091
2092 /*
2093 +--------------------------------------------------------------------+
2094 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
2095 | STATE : code ROUTINE : cc_build_user_ind_from_cong|
2096 +--------------------------------------------------------------------+
2097
2098 PURPOSE : Build primitive MNCC_USER_IND from congestion control
2099 message.
2100
2101 */
2102
2103 GLOBAL void cc_build_user_ind_from_cong (T_MNCC_USER_IND * user,
2104 const T_B_CONGEST_CTRL * cong)
2105 {
2106 GET_INSTANCE_DATA;
2107 TRACE_FUNCTION ("cc_build_user_ind_from_cong()");
2108
2109 user->ti = cc_data->ti;
2110 user->more_data = NOT_PRESENT_8BIT;
2111 user->congest_lev = cong->congest_lev;
2112 memset (&user->user, 0, sizeof (T_MNCC_user));
2113 }
2114
2115 /*
2116 +--------------------------------------------------------------------+
2117 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
2118 | STATE : code ROUTINE : cc_build_user_ind_from_user|
2119 +--------------------------------------------------------------------+
2120
2121 PURPOSE : Build primitive MNCC_USER_IND from user information
2122 message.
2123
2124 */
2125
2126 GLOBAL void cc_build_user_ind_from_user (T_MNCC_USER_IND * user_ind,
2127 const T_B_USER_INFO * user)
2128 {
2129 GET_INSTANCE_DATA;
2130 TRACE_FUNCTION ("cc_build_user_ind_from_user()");
2131
2132 user_ind->ti = cc_data->ti;
2133 user_ind->user.info_context = MNCC_USER_IN_USER;
2134 user_ind->user.pd = user->user_user.pd;
2135 user_ind->user.c_info = user->user_user.c_info;
2136 memcpy (user_ind->user.info, user->user_user.info, MNCC_USER_LEN);
2137 user_ind->congest_lev = NOT_PRESENT_8BIT;
2138 user_ind->more_data = user->v_more_data;
2139 }
2140
2141 /*
2142 +--------------------------------------------------------------------+
2143 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
2144 | STATE : code ROUTINE : cc_build_user_information |
2145 +--------------------------------------------------------------------+
2146
2147 PURPOSE : Filling the C-structure for user information message.
2148
2149 */
2150
2151 GLOBAL void cc_build_user_information (T_MNCC_USER_REQ * user,
2152 T_B_USER_INFO * user_msg)
2153 {
2154 TRACE_FUNCTION ("cc_build_user_information()");
2155
2156 user_msg->msg_type = B_USER_INFO;
2157 user_msg->user_user.pd = user->user.pd;
2158 user_msg->user_user.c_info = user->user.c_info;
2159 memcpy (user_msg->user_user.info, user->user.info, MNCC_USER_LEN);
2160 user_msg->v_more_data = user->more_data;
2161 }
2162
2163 /*
2164 +--------------------------------------------------------------------+
2165 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
2166 | STATE : code ROUTINE : cc_check_error_flag |
2167 +--------------------------------------------------------------------+
2168
2169 PURPOSE : Checks the error variable of CC data and sends status
2170 message if necessary.
2171
2172 */
2173
2174 GLOBAL BOOL cc_check_error_flag (void)
2175 {
2176 GET_INSTANCE_DATA;
2177
2178 TRACE_FUNCTION ("cc_check_error_flag()");
2179
2180 switch (cc_data->error)
2181 {
2182 case M_CC_CAUSE_INVALID_MAND_INFO:
2183 case M_CC_CAUSE_COND_INFO_ELEM:
2184 CCD_END;
2185 /* Implements Measure# 7 and streamline encoding*/
2186 cc_send_status (cc_data->error);
2187 return FALSE;
2188
2189 default:
2190 return TRUE;
2191 }
2192 }
2193
2194 /*
2195 +--------------------------------------------------------------------+
2196 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
2197 | STATE : code ROUTINE : cc_check_ms_cap_repeat_indicator_support |
2198 +--------------------------------------------------------------------+
2199
2200 PURPOSE : The mobile station repeat indicator capabilities are checked
2201 against the request.
2202
2203 RETURN: OKAY if capabilities supported.
2204 ERROR if capabilitis not supported.
2205
2206 */
2207 U8 cc_check_ms_cap_repeat_indicator_support(const U8 repeat)
2208 {
2209 GET_INSTANCE_DATA;
2210 TRACE_FUNCTION ("cc_check_ms_cap_repeat_indicator_support()");
2211
2212 cc_csf_ms_cap ();
2213
2214 switch (repeat)
2215 {
2216 case M_CC_REPEAT_CIRCULAR:
2217 if (FldGet (cc_data->mscap.datCap2, NAltSrvSup) EQ TRUE) /* still needed for TS61 - not for BS61 */
2218 {
2219 TRACE_EVENT("ERROR - alternate services not allowed by manufacturer");
2220 return ERROR; /* No alternate services allowed by manufacturer */
2221 }
2222
2223 if(
2224 ((cc_data->neg_bcpara1.bearer_serv EQ MNCC_BEARER_SERV_FAX) AND
2225 (cc_data->neg_bcpara2.bearer_serv EQ MNCC_BEARER_SERV_SPEECH) )
2226 OR
2227 ((cc_data->neg_bcpara2.bearer_serv EQ MNCC_BEARER_SERV_FAX) AND
2228 (cc_data->neg_bcpara1.bearer_serv EQ MNCC_BEARER_SERV_SPEECH) )
2229 )
2230 return OKAY;
2231
2232 TRACE_EVENT("ERROR - no TS61 found - wrong repeat indicator - BS61 not supported at all");
2233 return ERROR;
2234
2235 case M_CC_REPEAT_FALLBACK:
2236 return OKAY; /* MS cap checked earlier */
2237
2238 default:
2239 return ERROR;
2240 } /* switch (repeat) */
2241
2242 }/* cc_check_ms_cap_repeat_indicator_support */
2243
2244
2245
2246 /*
2247 +--------------------------------------------------------------------+
2248 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
2249 | STATE : code ROUTINE : cc_compatibility_check |
2250 +--------------------------------------------------------------------+
2251
2252 PURPOSE : Checks the compatibility of incoming setup message to
2253 its own configuration.
2254
2255 */
2256
2257 GLOBAL UBYTE cc_compatibility_check (const T_D_SETUP * setup)
2258 {
2259 GET_INSTANCE_DATA;
2260 TRACE_FUNCTION ("cc_compatibility_check()");
2261
2262 cc_csf_ms_cap ();
2263
2264 cc_data->negotiation = FALSE;
2265
2266 cc_data->neg_serv1 = NOT_PRESENT_8BIT;
2267 memset (&cc_data->neg_bcpara1, 0, sizeof (T_MNCC_bcpara));
2268 cc_data->neg_bcpara1.bearer_serv = NOT_PRESENT_8BIT;
2269
2270 cc_data->neg_serv2 = NOT_PRESENT_8BIT;
2271 memset (&cc_data->neg_bcpara2, 0, sizeof (T_MNCC_bcpara));
2272 cc_data->neg_bcpara2.bearer_serv = NOT_PRESENT_8BIT;
2273 cc_data->neg_ri = NOT_PRESENT_8BIT;
2274
2275
2276
2277 if (setup->v_bearer_cap)
2278 {
2279 if (cc_check_bc (&setup->bearer_cap,
2280 &cc_data->neg_bc1,
2281 &cc_data->neg_bcpara1,
2282 &cc_data->neg_serv1,
2283 &cc_data->negotiation) EQ ERROR)
2284 {
2285 #if 0 /* HM 03-09-2002, code to merge is superflous, I don't take it
2286 The part of the code between #if 0 to #endif is never executed.*/
2287 /*
2288 * set parameters invalid according to GSM 07.01 V7.1.1 Rel 1998 -
2289 * CC-ENH-2378
2290 */
2291 if ((setup->bearer_cap.v_modem_type_2 EQ FALSE) OR
2292 (setup->bearer_cap.v_fnur EQ FALSE))
2293 {
2294 cc_data->neg_bc1.v_modem_type_2 = FALSE;
2295 cc_data->neg_bc1.v_fnur = FALSE;
2296 cc_data->neg_bc1.v_acc = FALSE;
2297 cc_data->neg_bc1.v_mTch = FALSE;
2298 cc_data->neg_bc1.v_uimi = FALSE;
2299 cc_data->neg_bc1.v_waiur = FALSE;
2300 }
2301 #endif
2302 return ERROR;
2303 }
2304 }
2305 else
2306 {
2307 /*
2308 * The incoming setup message contains no bearer capabilities
2309 *
2310 * This indicates single numbering scheme
2311 *
2312 * use the parameter of sns_mode to set the negotiated answer
2313 */
2314 cc_data->negotiation = TRUE;
2315 memset (&cc_data->neg_bcpara1, 0, sizeof (T_MNCC_bcpara));
2316 memset (&cc_data->neg_bcpara2, 0, sizeof (T_MNCC_bcpara));
2317
2318 switch (cc_data->sns_mode)
2319 {
2320 case MNCC_SNS_MODE_VOICE: /* VOICE calls */
2321 if (!cc_voice_capability ())
2322 return ERROR;
2323 memcpy (&cc_data->neg_bcpara1, &cc_data->sns_bcpara,
2324 sizeof (T_MNCC_bcpara));
2325 cc_data->neg_bcpara2.bearer_serv = NOT_PRESENT_8BIT;
2326 cc_data->neg_ri = NOT_PRESENT_8BIT;
2327 cc_data->neg_serv1 = MNCC_SERV_SPEECH;
2328 cc_data->neg_serv2 = NOT_PRESENT_8BIT;
2329 cc_build_bc (&cc_data->neg_bc1, &cc_data->neg_serv1,
2330 &cc_data->neg_bcpara1);
2331 break;
2332 case MNCC_SNS_MODE_VAF_VOICE: /* Voice Alternating Fax, VOICE first */
2333 case MNCC_SNS_MODE_VAD_VOICE: /* Voice Alternating Data, VOICE first */
2334 if (!cc_voice_capability ())
2335 return ERROR;
2336 memset (&cc_data->neg_bcpara1, 0, sizeof (T_MNCC_bcpara));
2337 cc_data->neg_bcpara1.bearer_serv = (cc_data->ctm_ena EQ MNCC_CTM_ENABLED)?
2338 MNCC_BEARER_SERV_SPEECH_CTM: MNCC_BEARER_SERV_SPEECH;
2339 memcpy (&cc_data->neg_bcpara2, &cc_data->sns_bcpara,
2340 sizeof (T_MNCC_bcpara));
2341 cc_data->neg_ri = MNCC_RI_CIRCULAR;
2342 cc_data->neg_serv1 = MNCC_SERV_SPEECH;
2343 cc_data->neg_serv2 = MNCC_SERV_DATA;
2344 cc_build_bc (&cc_data->neg_bc1, &cc_data->neg_serv1,
2345 &cc_data->neg_bcpara1);
2346 cc_build_bc (&cc_data->neg_bc2, &cc_data->neg_serv2,
2347 &cc_data->neg_bcpara2);
2348 break;
2349 case MNCC_SNS_MODE_FAX: /* FAX calls */
2350 case MNCC_SNS_MODE_DATA: /* DATA calls */
2351 memcpy (&cc_data->neg_bcpara1, &cc_data->sns_bcpara,
2352 sizeof (T_MNCC_bcpara));
2353 cc_data->neg_bcpara2.bearer_serv = NOT_PRESENT_8BIT;
2354 cc_data->neg_ri = NOT_PRESENT_8BIT;
2355 cc_data->neg_serv1 = MNCC_SERV_DATA;
2356 cc_data->neg_serv2 = NOT_PRESENT_8BIT;
2357 cc_build_bc (&cc_data->neg_bc1, &cc_data->neg_serv1,
2358 &cc_data->neg_bcpara1);
2359 break;
2360 case MNCC_SNS_MODE_VAF_FAX: /* Voice Alternating Fax, FAX first */
2361 case MNCC_SNS_MODE_VAD_DATA: /* Voice Alternating Data, DATA first */
2362 if (!cc_voice_capability ())
2363 return ERROR;
2364 memset (&cc_data->neg_bcpara2, 0, sizeof (T_MNCC_bcpara));
2365 cc_data->neg_bcpara2.bearer_serv = (cc_data->ctm_ena EQ MNCC_CTM_ENABLED)?
2366 MNCC_BEARER_SERV_SPEECH_CTM: MNCC_BEARER_SERV_SPEECH;
2367 memcpy (&cc_data->neg_bcpara1, &cc_data->sns_bcpara,
2368 sizeof (T_MNCC_bcpara));
2369 cc_data->neg_ri = MNCC_RI_CIRCULAR;
2370 cc_data->neg_serv1 = MNCC_SERV_DATA;
2371 cc_data->neg_serv2 = MNCC_SERV_SPEECH;
2372 cc_build_bc (&cc_data->neg_bc1, &cc_data->neg_serv1,
2373 &cc_data->neg_bcpara1);
2374 break;
2375 case MNCC_SNS_MODE_VFD: /* Voice Followed by Data */
2376 if (!cc_voice_capability ())
2377 return ERROR;
2378 memset (&cc_data->neg_bcpara1, 0, sizeof (T_MNCC_bcpara));
2379 cc_data->neg_bcpara1.bearer_serv = (cc_data->ctm_ena EQ MNCC_CTM_ENABLED)?
2380 MNCC_BEARER_SERV_SPEECH_CTM: MNCC_BEARER_SERV_SPEECH;
2381 memcpy (&cc_data->neg_bcpara2, &cc_data->sns_bcpara,
2382 sizeof (T_MNCC_bcpara));
2383 cc_data->neg_ri = MNCC_RI_SEQUENTIAL;
2384 cc_data->neg_serv1 = MNCC_SERV_SPEECH;
2385 cc_data->neg_serv2 = MNCC_SERV_DATA;
2386 cc_build_bc (&cc_data->neg_bc1, &cc_data->neg_serv1,
2387 &cc_data->neg_bcpara1);
2388 cc_build_bc (&cc_data->neg_bc2, &cc_data->neg_serv2,
2389 &cc_data->neg_bcpara2);
2390 break;
2391 default:
2392 TRACE_ERROR ("Unexpected default"); /* All cases caught */
2393 break;
2394 }
2395 }
2396 if (setup->v_bearer_cap_2)
2397 {
2398 if (cc_check_bc ((T_M_CC_bearer_cap *)&setup->bearer_cap_2,
2399 &cc_data->neg_bc2,
2400 &cc_data->neg_bcpara2,
2401 &cc_data->neg_serv2,
2402 &cc_data->negotiation) EQ ERROR)
2403 return ERROR;
2404 }
2405
2406 /*Check for repeat Indicator*/
2407 if (setup->v_repeat)
2408 {
2409 if (cc_check_ms_cap_repeat_indicator_support(setup->repeat) EQ ERROR)
2410 return ERROR;
2411
2412 cc_data->neg_ri = setup->repeat;
2413 }
2414
2415
2416 /*
2417 * Two bearer capabilities are available. The
2418 * single numbering scheme command on ACI level can
2419 * be used to swap bearer capabilities. For example
2420 * SNS Mode is set to voice alternating fax, voice first
2421 * and the network indicates voice alternating fax, fax first.
2422 * Then the BCs are swapped.
2423 */
2424 if (setup->v_bearer_cap_2)
2425 {
2426 UBYTE swap = FALSE;
2427 switch (cc_data->sns_mode)
2428 {
2429 case MNCC_SNS_MODE_VAF_VOICE:
2430 if (cc_data->neg_bcpara1.bearer_serv EQ MNCC_BEARER_SERV_FAX AND
2431 (cc_data->neg_serv2 EQ MNCC_SERV_SPEECH) AND
2432 cc_data->neg_ri EQ MNCC_RI_CIRCULAR)
2433 swap = TRUE;
2434 break;
2435 case MNCC_SNS_MODE_VAD_VOICE:
2436 if (cc_data->neg_bcpara1.bearer_serv NEQ MNCC_BEARER_SERV_FAX AND
2437 (cc_data->neg_serv1 NEQ MNCC_SERV_SPEECH) AND
2438 (cc_data->neg_serv2 EQ MNCC_SERV_SPEECH) AND
2439 cc_data->neg_ri EQ MNCC_RI_CIRCULAR)
2440 swap = TRUE;
2441 break;
2442 case MNCC_SNS_MODE_VAF_FAX:
2443 if (cc_data->neg_bcpara2.bearer_serv EQ MNCC_BEARER_SERV_FAX AND
2444 (cc_data->neg_serv1 EQ MNCC_SERV_SPEECH) AND
2445 cc_data->neg_ri EQ MNCC_RI_CIRCULAR)
2446 swap = TRUE;
2447 break;
2448 case MNCC_SNS_MODE_VAD_DATA:
2449 if (cc_data->neg_bcpara2.bearer_serv NEQ MNCC_BEARER_SERV_FAX AND
2450 (cc_data->neg_serv2 NEQ MNCC_SERV_SPEECH) AND
2451 (cc_data->neg_serv1 EQ MNCC_SERV_SPEECH) AND
2452 cc_data->neg_ri EQ MNCC_RI_CIRCULAR)
2453 swap = TRUE;
2454 break;
2455 }
2456 if (swap)
2457 {
2458 /*
2459 * Both bearer capabilities shall be swapped
2460 */
2461 T_MNCC_bcpara temp_bcpara;
2462 UBYTE temp_serv;
2463 T_M_CC_bearer_cap temp_bc; /*lint !e813 length info of struct*/
2464
2465 memcpy (&temp_bcpara, &cc_data->neg_bcpara1, sizeof (T_MNCC_bcpara));
2466 memcpy (&cc_data->neg_bcpara1, &cc_data->neg_bcpara2, sizeof (T_MNCC_bcpara));
2467 memcpy (&cc_data->neg_bcpara2, &temp_bcpara, sizeof (T_MNCC_bcpara));
2468
2469 temp_serv = cc_data->neg_serv1;
2470 cc_data->neg_serv1 = cc_data->neg_serv2;
2471 cc_data->neg_serv2 = temp_serv;
2472
2473 memcpy (&temp_bc, &cc_data->neg_bc1, sizeof (T_M_CC_bearer_cap));
2474 memcpy (&cc_data->neg_bc1, &cc_data->neg_bc2, sizeof (T_M_CC_bearer_cap));
2475 memcpy (&cc_data->neg_bc2, &temp_bc, sizeof (T_M_CC_bearer_cap));
2476
2477 cc_data->negotiation = TRUE;
2478 }
2479 }
2480
2481 /*
2482 * set parameters invalid according to GSM 07.01 V7.1.1 Rel 1998 -
2483 * CC-ENH-2378
2484 */
2485 if ((setup->bearer_cap.v_modem_type_2 EQ FALSE) OR
2486 (setup->bearer_cap.v_fnur EQ FALSE))
2487 {
2488 cc_data->neg_bc1.v_modem_type_2 = FALSE;
2489 cc_data->neg_bc1.v_fnur = FALSE;
2490 cc_data->neg_bc1.v_acc = FALSE;
2491 cc_data->neg_bc1.v_mTch = FALSE;
2492 cc_data->neg_bc1.v_uimi = FALSE;
2493 cc_data->neg_bc1.v_waiur = FALSE;
2494 }
2495
2496 cc_data->active_service = cc_data->neg_serv1;
2497
2498 if (cc_mtc_check_subaddr (setup) EQ BAD_SUBADDRESS)
2499 return BAD_SUBADDRESS;
2500
2501 if (cc_data->negotiation)
2502 return NEGOTIATION;
2503 else
2504 return OKAY;
2505 }
2506
2507
2508 /*
2509 +--------------------------------------------------------------------+
2510 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
2511 | STATE : code ROUTINE : cc_basic_service_align() |
2512 +--------------------------------------------------------------------+
2513
2514 PURPOSE: Checks the compatibility of incoming uplink setup message
2515 to its own configuration and performs basic service group
2516 alignment. This is used for Network Initiated MO Call (CCBS).
2517 See GSM 04.08 subclause 5.2.3.2.1 "Basic service group
2518 alignment".
2519
2520 The following fields in cc_data are changed by a call
2521 of this function:
2522
2523 cc_data->serv1;
2524 cc_data->serv2;
2525 cc_data->ri;
2526 cc_data->bc1;
2527 cc_data->bc2;
2528 cc_data->bcpara1;
2529 cc_data->bcpara2;
2530 cc_data->neg_serv1;
2531 cc_data->neg_serv2;
2532 cc_data->neg_ri;
2533 cc_data->neg_bc1;
2534 cc_data->neg_bc2;
2535 cc_data->neg_bcpara1;
2536 cc_data->neg_bcpara2;
2537 cc_data->negotiation;
2538
2539 PARAMETERS: cc_data: IN/OUT
2540 setup: IN/OUT
2541
2542 RETURN: OKAY if setup (bearer caps) is compatible with mobile,
2543 ERROR otherwise.
2544
2545 */
2546
2547 GLOBAL UBYTE cc_basic_service_align (T_U_SETUP * setup)
2548 {
2549 GET_INSTANCE_DATA;
2550 TRACE_FUNCTION ("cc_basic_service_align()");
2551
2552 cc_csf_ms_cap ();
2553
2554 if (FldGet (cc_data->mscap.datCap2, NAltSrvSup) AND setup->v_repeat)
2555 return ERROR; /* No alternate services allowed by manufacturer */
2556
2557 cc_data->ri = (setup->v_repeat) ? setup->repeat : NOT_PRESENT_8BIT;
2558 cc_data->neg_ri = cc_data->ri;
2559
2560 /* BC is mandatory IE in uplink setup message */
2561 if (!setup->v_bearer_cap)
2562 return ERROR;
2563 if (cc_check_bc (&setup->bearer_cap,
2564 &cc_data->bc1, /* Not used */
2565 &cc_data->bcpara1,
2566 &cc_data->serv1, /* Not used */
2567 &cc_data->negotiation) /* Not used */
2568 EQ ERROR)
2569 return ERROR; /* Not expected to catch */
2570
2571 if (!cc_check_capabilities (&cc_data->bcpara1))
2572 return ERROR; /* Not expected to catch */
2573
2574 cc_build_bc (&cc_data->bc1, &cc_data->serv1, &cc_data->bcpara1);
2575 setup->bearer_cap = cc_data->bc1; /* Struct copy */
2576 cc_data->neg_serv1 = cc_data->serv1;
2577 cc_data->neg_bc1 = cc_data->bc1; /* Struct copy */
2578 cc_data->neg_bcpara1 = cc_data->bcpara1; /* Struct copy */
2579
2580 /* BC2 is optional IE in uplink setup message */
2581 if (setup->v_bearer_cap_2)
2582 {
2583 if (cc_check_bc ((T_M_CC_bearer_cap *)&setup->bearer_cap_2,
2584 &cc_data->bc2, /* Not used */
2585 &cc_data->bcpara2,
2586 &cc_data->serv2, /* Not used */
2587 &cc_data->negotiation)
2588 EQ ERROR)
2589 return ERROR; /* Bearer caps 2 incompatible */
2590 if (!cc_check_capabilities (&cc_data->bcpara2))
2591 return ERROR; /* Not expected to catch */
2592
2593 cc_build_bc (&cc_data->bc2, &cc_data->serv2, &cc_data->bcpara2);
2594 setup->bearer_cap_2 = *(T_M_CC_bearer_cap_2*)&cc_data->bc2; /* Struct copy */
2595 cc_data->neg_bc2 = cc_data->bc2; /* Struct copy */
2596 }
2597 else
2598 {
2599 cc_data->serv2 = NOT_PRESENT_8BIT;
2600 cc_data->bcpara2.bearer_serv = NOT_PRESENT_8BIT;
2601 }
2602 cc_data->neg_serv2 = cc_data->serv2;
2603 cc_data->neg_bcpara2 = cc_data->bcpara2; /* Struct copy */
2604
2605 /* check repeat indicator */
2606 if (setup->v_repeat EQ TRUE)
2607 {
2608 if (cc_check_ms_cap_repeat_indicator_support(setup->repeat) EQ ERROR)
2609 return ERROR;
2610
2611 cc_data->ri = setup->repeat;
2612 }
2613 else
2614 cc_data->ri = NOT_PRESENT_8BIT;
2615
2616 cc_data->neg_ri = cc_data->ri;
2617
2618 cc_fill_llc_hlc (setup);
2619
2620 return OKAY;
2621 }
2622
2623
2624 /*
2625 +--------------------------------------------------------------------+
2626 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
2627 | STATE : code ROUTINE : cc_count_active_connections|
2628 +--------------------------------------------------------------------+
2629
2630 PURPOSE : Counts the number of active connections.
2631
2632 */
2633
2634 GLOBAL UBYTE cc_count_active_connections (void)
2635 {
2636 GET_INSTANCE_DATA;
2637 UBYTE i;
2638 UBYTE x;
2639
2640 TRACE_FUNCTION ("cc_count_active_connections()");
2641
2642 for (i=0,x=0 ; i< MAX_CC_CALLS; i++)
2643 if (cc_data->state[i] NEQ M_CC_CS_0)
2644 x++;
2645
2646 return x;
2647 }
2648
2649
2650 /*
2651 +--------------------------------------------------------------------+
2652 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
2653 | STATE : code ROUTINE : cc_disconnect_after_timeout|
2654 +--------------------------------------------------------------------+
2655
2656 PURPOSE : Start disconnection after timeout. A disconnect message
2657 is send to the infrastructure. MMI is informed and timer
2658 T305 is started.
2659
2660 */
2661
2662 GLOBAL void cc_disconnect_after_timeout (void)
2663 {
2664 GET_INSTANCE_DATA;
2665 PALLOC (setup_cnf, MNCC_SETUP_CNF);
2666
2667 TRACE_FUNCTION ("cc_disconnect_after_timeout()");
2668
2669 CCD_START;
2670 {
2671 MCAST (disconnect, U_DISCONNECT);
2672 cc_build_disconnect (disconnect, CAUSE_MAKE(DEFBY_STD,
2673 ORIGSIDE_MS,
2674 MNCC_CC_ORIGINATING_ENTITY,
2675 M_CC_CAUSE_TIMER),
2676 NULL, MNCC_SS_VER_NOT_PRES);
2677 for_disconnect (disconnect);
2678 }
2679 CCD_END;
2680
2681 memset (setup_cnf, 0, sizeof (T_MNCC_SETUP_CNF));
2682 setup_cnf->ti = cc_data->ti;
2683 setup_cnf->cause = CAUSE_MAKE(DEFBY_STD,
2684 ORIGSIDE_MS,
2685 MNCC_CC_ORIGINATING_ENTITY,
2686 M_CC_CAUSE_TIMER);
2687 PSENDX (MMI, setup_cnf);
2688
2689 TIMERSTART (T305, T305_VALUE);
2690 }
2691
2692
2693 /*
2694 +--------------------------------------------------------------------+
2695 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
2696 | STATE : code ROUTINE : cc_encode_cause |
2697 +--------------------------------------------------------------------+
2698
2699 PURPOSE : Coding of the cc_cause element and storing of the cause
2700 value in cc data. Dependent on the cause the diagnostic
2701 field is filled. It is expected that checking of validity
2702 is done outside this function.
2703
2704 */
2705
2706 static const UBYTE timername[] = { '3', '0', '3', 0,
2707 '3', '0', '5', 0,
2708 '3', '0', '8', 0,
2709 '3', '1', '0', 0,
2710 '3', '1', '3', 0,
2711 '3', '2', '3', 0,
2712 '3', '3', '2', 0,
2713 '3', '3', '5', 0,
2714 '3', '3', '6', 0,
2715 '3', '3', '7', 0 };
2716
2717 GLOBAL void cc_encode_cause (T_M_CC_cc_cause * cc_cause,
2718 USHORT cause)
2719 {
2720 GET_INSTANCE_DATA;
2721 TRACE_FUNCTION ("cc_encode_cause()");
2722
2723 /* perform "security" checks of application of cause concept */
2724 switch (GET_CAUSE_DEFBY(cause))
2725 {
2726 case DEFBY_STD:
2727 {
2728 switch (GET_CAUSE_ORIGIN_ENTITY(cause))
2729 {
2730 case MNCC_CC_ORIGINATING_ENTITY:
2731 case MNCC_ACI_ORIGINATING_ENTITY:
2732 {
2733 switch (GET_CAUSE_ORIGSIDE(cause))
2734 {
2735 case ORIGSIDE_NET:
2736 TRACE_EVENT("Warning: NET originated cause");
2737 /* no error correction */
2738 break;
2739 default: /* ORIGSIDE_MS */
2740 break; /* this is the expected case */
2741 }
2742 break; /* MNCC_ACI_ORIGINATING_ENTITY, ACI_ORIGINATING_ENTITY */
2743 }
2744 default:
2745 TRACE_ERROR("Non ACI or CC cause originator");
2746 /* no error correction */
2747 break;
2748 }
2749 }
2750 break;
2751 default: /* DEFBY_CONDAT */
2752 TRACE_ERROR("Illegal use of cause: DEFBY_CONDAT");
2753 /* overwrite the cause with a standard cause */
2754 cause = CAUSE_MAKE(DEFBY_STD, ORIGSIDE_MS, MNCC_ACI_ORIGINATING_ENTITY, M_CC_CAUSE_UNSPECIFIED);
2755 break;
2756 }
2757
2758 cc_cause->v_cs = TRUE;
2759 cc_cause->cs = M_CC_CS_GSM_PLMN;
2760 cc_cause->v_loc = TRUE;
2761 cc_cause->loc = M_CC_LOC_USER;
2762 cc_cause->v_rec = FALSE;
2763 cc_cause->v_cause = TRUE;
2764 cc_cause->cause = GET_CAUSE_VALUE(cause);
2765
2766 /*
2767 * store the cause for later usage (e.g. timeout)
2768 * store the entire 16 bits
2769 */
2770 if (cc_cause->cause NEQ M_CC_CAUSE_STATUS_ENQUIRY)
2771 cc_data->cc_cause [cc_data->index_ti] = cause;
2772
2773 /* feed diagnostic information if necessary */
2774 switch (cc_cause->cause)
2775 {
2776 case M_CC_CAUSE_MESSAGE_TYPE_INCOMPAT:
2777 case M_CC_CAUSE_MESSAGE_TYPE_NOT_IMPLEM:
2778 case M_CC_CAUSE_MESSAGE_INCOMPAT:
2779 cc_cause->c_diag = 1;
2780 cc_cause->diag[0] = cc_data->mt;
2781 break;
2782
2783 case M_CC_CAUSE_INVALID_MAND_INFO:
2784 case M_CC_CAUSE_COND_INFO_ELEM:
2785 cc_cause->c_diag = cc_data->error_count;
2786 memcpy (cc_cause->diag, cc_data->error_inf, cc_cause->c_diag);
2787 break;
2788
2789 case M_CC_CAUSE_TIMER:
2790 cc_cause->c_diag = 3;
2791 memcpy (cc_cause->diag,
2792 &timername[cc_data->timer[cc_data->index_ti]<<2], 3);
2793 break;
2794
2795 default:
2796 cc_cause->c_diag = 0;
2797 break;
2798 }
2799 }
2800
2801 /*
2802 +--------------------------------------------------------------------+
2803 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
2804 | STATE : code ROUTINE : cc_mtc_check_subaddr |
2805 +--------------------------------------------------------------------+
2806
2807 PURPOSE : Check the subaddress if available for the
2808 mobile terminated call.
2809
2810 */
2811
2812 GLOBAL UBYTE cc_mtc_check_subaddr (const T_D_SETUP * setup)
2813 {
2814 GET_INSTANCE_DATA;
2815 UBYTE i;
2816
2817 TRACE_FUNCTION ("cc_mtc_check_subaddr()");
2818
2819 if (cc_data->my_party_subaddr.c_subaddr AND setup->v_called_subaddr)
2820 {
2821 if (cc_data->my_party_subaddr.tos NEQ setup->called_subaddr.tos)
2822 return BAD_SUBADDRESS;
2823
2824 if (cc_data->my_party_subaddr.c_subaddr NEQ
2825 setup->called_subaddr.c_subaddr)
2826 return BAD_SUBADDRESS;
2827
2828 for (i=0; i<cc_data->my_party_subaddr.c_subaddr; i++)
2829 if (cc_data->my_party_subaddr.subaddr[i] NEQ
2830 setup->called_subaddr.subaddr[i])
2831 return BAD_SUBADDRESS;
2832 }
2833
2834 return OKAY;
2835 }
2836
2837
2838 /*
2839 +--------------------------------------------------------------------+
2840 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
2841 | STATE : code ROUTINE : cc_build_bcpara |
2842 +--------------------------------------------------------------------+
2843
2844 PURPOSE : Build the local transmission parameters (for MMI)(bcpara)
2845 of the incoming bearer caps to the mobile station configuration
2846 for the Mobile Originated Call (after reception of a call
2847 proceeding message).
2848
2849 */
2850
2851 LOCAL void cc_build_bcpara( T_MNCC_bcpara *bcpara,
2852 const T_M_CC_bearer_cap *bearer_cap)
2853 {
2854 TRACE_FUNCTION ("cc_build_bcpara()");
2855
2856 memset (bcpara, 0, sizeof (T_MNCC_bcpara));
2857
2858 switch (bearer_cap->trans_cap)
2859 {
2860 case M_CC_ITC_SPEECH:
2861 /*
2862 * Speech bearer capability
2863 */
2864 {
2865 bcpara->bearer_serv = MNCC_BEARER_SERV_SPEECH;
2866
2867 break;
2868 }
2869 case M_CC_ITC_AUXILIARY_SPEECH:
2870 /*
2871 * Speech bearer capability for alternate line service
2872 */
2873 {
2874 bcpara->bearer_serv = MNCC_BEARER_SERV_AUX_SPEECH;
2875
2876 break;
2877 }
2878 case M_CC_ITC_AUDIO:
2879 case M_CC_ITC_DIGITAL_UNRESTRICTED:
2880 {
2881 bcpara->bearer_serv = MNCC_BEARER_SERV_ASYNC;
2882 bcpara->stop_bits = bearer_cap->num_stop;
2883 bcpara->data_bits = bearer_cap->num_data;
2884 bcpara->parity = bearer_cap->parity;
2885 bcpara->modem_type = bearer_cap->modem_type;
2886 if (bearer_cap->v_fnur AND (bearer_cap->fnur EQ M_CC_FNUR_14400))
2887 {
2888 bcpara->rate = MNCC_UR_14_4_KBIT;
2889 }
2890 else
2891 {
2892 bcpara->rate = bearer_cap->user_rate;
2893 }
2894 switch (bearer_cap->conn_elem)
2895 {
2896 case MNCC_CONN_ELEM_TRANS:
2897 {
2898 bcpara->conn_elem = MNCC_CONN_ELEM_TRANS;
2899 bcpara->flow_control = NOT_PRESENT_8BIT;
2900
2901 break;
2902 }
2903 case MNCC_CONN_ELEM_NON_TRANS:
2904 {
2905 bcpara->conn_elem = MNCC_CONN_ELEM_NON_TRANS;
2906 if (bearer_cap->v_user_inf_l2_prot)
2907 {
2908 switch (bearer_cap->user_inf_l2_prot)
2909 {
2910 case M_CC_L2_ISO6429:
2911 {
2912 bcpara->flow_control = MNCC_INBAND_FLOW_CONTROL;
2913
2914 break;
2915 }
2916 case M_CC_L2_COPFC:
2917 {
2918 bcpara->flow_control = MNCC_NO_FLOW_CONTROL;
2919
2920 break;
2921 }
2922 default:
2923 {
2924 bcpara->flow_control = MNCC_OUTBAND_FLOW_CONTROL;
2925
2926 break;
2927 }
2928 }
2929 }
2930 else
2931 {
2932 bcpara->flow_control = MNCC_OUTBAND_FLOW_CONTROL;
2933 }
2934 break;
2935 }
2936 case MNCC_CONN_ELEM_TRANS_PREF:
2937 case MNCC_CONN_ELEM_NON_TRANS_PREF:
2938 case MNCC_CONN_ELEM_NOT_PRES:
2939 {
2940 TRACE_EVENT ("Call setup failed due to wrong conn_elem in bearer caps");
2941
2942 break;
2943 }
2944 }
2945 break;
2946 }
2947 case M_CC_ITC_FAX_GROUP_3:
2948 {
2949 if (bearer_cap->v_fnur AND (bearer_cap->fnur EQ M_CC_FNUR_14400))
2950 {
2951 bcpara->rate = MNCC_UR_14_4_KBIT;
2952 }
2953 else
2954 {
2955 bcpara->rate = bearer_cap->user_rate;
2956 }
2957 bcpara->bearer_serv = MNCC_BEARER_SERV_FAX;
2958 bcpara->conn_elem = MNCC_CONN_ELEM_TRANS;
2959 bcpara->stop_bits = bearer_cap->num_stop;
2960 bcpara->data_bits = bearer_cap->num_data;
2961 bcpara->parity = bearer_cap->parity;
2962 bcpara->modem_type = bearer_cap->modem_type;
2963 bcpara->flow_control = NOT_PRESENT_8BIT;
2964 break;
2965 }
2966 default:
2967 {
2968 TRACE_EVENT ("Call setup failed due to wrong ITC in bearer caps");
2969
2970 break;
2971 }
2972 }
2973 }
2974
2975
2976 /*
2977 +--------------------------------------------------------------------+
2978 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
2979 | STATE : code ROUTINE : cc_moc_compatibility |
2980 +--------------------------------------------------------------------+
2981
2982 PURPOSE : Check the compatibility of the incoming bearer caps
2983 to the mobile station configuration for the
2984 mobile originated call (after reception of a call
2985 proceeding message).
2986
2987 */
2988
2989 GLOBAL UBYTE cc_moc_compatibility (const T_D_CALL_PROCEED * proceed)
2990 {
2991 GET_INSTANCE_DATA;
2992 UBYTE proceed_ri;
2993
2994 TRACE_FUNCTION ("cc_moc_compatibility()");
2995
2996 if (proceed->v_bearer_cap)
2997 {
2998 if (proceed->v_repeat)
2999 proceed_ri = proceed->repeat;
3000 else
3001 proceed_ri = NOT_PRESENT_8BIT;
3002 if ((proceed_ri EQ NOT_PRESENT_8BIT) && (cc_data->ri NEQ NOT_PRESENT_8BIT))
3003 {
3004 /*
3005 * No repeat indicator from the network
3006 * that means only one bearer capability.
3007 * Mobile station has send two bearer
3008 * capabilities. Check whether bearer
3009 * capability is compatible to one of the
3010 * mobile station bearer capabilities.
3011 */
3012 if (cc_bcs_compatible (&proceed->bearer_cap,
3013 &cc_data->bc1, TRUE))
3014 {
3015 cc_data->neg_ri = NOT_PRESENT_8BIT;
3016 cc_data->neg_bc1 = proceed->bearer_cap;
3017 cc_data->neg_serv1 = cc_data->serv1;
3018 cc_data->neg_serv2 = NOT_PRESENT_8BIT;
3019 cc_build_bcpara(&cc_data->neg_bcpara1,&proceed->bearer_cap);
3020 cc_data->neg_bcpara2.bearer_serv = NOT_PRESENT_8BIT; /* jk: wg. cc705 */
3021 cc_data->active_service = cc_data->serv1;
3022 return OKAY;
3023 }
3024 else
3025 {
3026 if (cc_bcs_compatible (&proceed->bearer_cap,
3027 &cc_data->bc2, TRUE))
3028 {
3029 cc_data->neg_ri = NOT_PRESENT_8BIT;
3030 memcpy (&cc_data->neg_bc1, &proceed->bearer_cap,sizeof (T_M_CC_bearer_cap));
3031 cc_data->neg_serv1 = cc_data->serv2;
3032 cc_data->neg_serv2 = NOT_PRESENT_8BIT;
3033 cc_build_bcpara(&cc_data->neg_bcpara1,&proceed->bearer_cap);
3034 cc_data->active_service = cc_data->serv2;
3035 return OKAY;
3036 }
3037 else
3038 {
3039 return ERROR;
3040 }
3041 }
3042 }
3043 else
3044 {
3045 if (proceed_ri EQ cc_data->ri)
3046 {
3047 /*
3048 * both Repeat Indicators are the same
3049 * e.g. both not present OR both valid
3050 * but not the Bearer Capabilities.
3051 */
3052 if (cc_bcs_compatible (&proceed->bearer_cap,
3053 &cc_data->bc1, TRUE) EQ FALSE)
3054 {
3055 return ERROR;
3056 }
3057 else
3058 {
3059 if (proceed_ri NEQ NOT_PRESENT_8BIT)
3060 {
3061 if (cc_bcs_compatible ((T_M_CC_bearer_cap*)&proceed->bearer_cap_2,
3062 &cc_data->bc2, TRUE) EQ FALSE)
3063 return ERROR;
3064 /* 2 Bearer Capabilities from the Network sent */
3065 cc_data->neg_ri = proceed_ri;
3066 cc_data->neg_bc1 = proceed->bearer_cap;
3067 memcpy (&cc_data->neg_bc2, &proceed->bearer_cap_2,sizeof (T_M_CC_bearer_cap));
3068 cc_data->neg_serv1 = cc_data->serv1;
3069 cc_data->neg_serv2 = cc_data->serv2;
3070 cc_build_bcpara(&cc_data->neg_bcpara1,&cc_data->neg_bc1);
3071 cc_build_bcpara(&cc_data->neg_bcpara2,&cc_data->neg_bc2);
3072 cc_data->active_service = cc_data->serv1;
3073 return OKAY;
3074 }
3075 else
3076 {
3077 /* only 1 BC from the Network sent*/
3078 cc_data->neg_ri = proceed_ri;
3079 cc_data->neg_bc1 = proceed->bearer_cap;
3080 cc_data->neg_serv1 = cc_data->serv1;
3081 cc_data->neg_serv2 = NOT_PRESENT_8BIT;
3082 cc_build_bcpara(&cc_data->neg_bcpara1,&cc_data->neg_bc1);
3083 cc_data->neg_bcpara2 = cc_data->bcpara2;
3084 cc_data->active_service = cc_data->serv1;
3085 return OKAY;
3086 }
3087 }/*else*/
3088 }/*if*/
3089 else
3090 {
3091 /*
3092 * network has changed repeat indicator in an illegal way
3093 */
3094 return ERROR;
3095 }
3096 } /*else*/
3097 }
3098 cc_data->neg_ri = cc_data->ri;
3099 cc_data->neg_bc1 = cc_data->bc1;
3100 cc_data->neg_bc2 = cc_data->bc2;
3101 cc_data->neg_serv1 = cc_data->serv1;
3102 cc_data->neg_serv2 = cc_data->serv2;
3103 cc_data->neg_bcpara1 = cc_data->bcpara1;
3104 cc_data->neg_bcpara2 = cc_data->bcpara2;
3105 cc_data->active_service = cc_data->serv1;
3106 return OKAY;
3107 }
3108
3109
3110
3111 #ifndef NTRACE
3112 /*
3113 +--------------------------------------------------------------------+
3114 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
3115 | STATE : code ROUTINE : cc_trace_state |
3116 +--------------------------------------------------------------------+
3117
3118 PURPOSE : Maps CC state numbers to string constants.
3119
3120 */
3121 LOCAL T_S2I_STRING cc_sname (UBYTE state)
3122 {
3123 switch (state)
3124 {
3125 case M_CC_CS_0 : return S2I_STRING("U0 ");
3126 case M_CC_CS_01 : return S2I_STRING("U0.1");
3127 case M_CC_CS_03 : return S2I_STRING("U0.3");
3128 case M_CC_CS_05 : return S2I_STRING("U0.5");
3129 case M_CC_CS_06 : return S2I_STRING("U0.6");
3130 case M_CC_CS_1 : return S2I_STRING("U1 ");
3131 case M_CC_CS_3 : return S2I_STRING("U3 ");
3132 case M_CC_CS_4 : return S2I_STRING("U4 ");
3133 case M_CC_CS_6 : return S2I_STRING("U6 ");
3134 case M_CC_CS_7 : return S2I_STRING("U7 ");
3135 case M_CC_CS_8 : return S2I_STRING("U8 ");
3136 case M_CC_CS_9 : return S2I_STRING("U9 ");
3137 case M_CC_CS_10 : return S2I_STRING("U10");
3138 case M_CC_CS_11 : return S2I_STRING("U11");
3139 case M_CC_CS_12 : return S2I_STRING("U12");
3140 case M_CC_CS_19 : return S2I_STRING("U19");
3141 case M_CC_CS_26 : return S2I_STRING("U26");
3142 case M_CC_CS_27 : return S2I_STRING("U27");
3143 case M_CC_CS_28 : return S2I_STRING("U28");
3144 case CS_101 : return S2I_STRING("U10.1");
3145 case CS_261 : return S2I_STRING("U26.1");
3146 default : return S2I_STRING("???");
3147 }
3148 }
3149 #endif
3150
3151 /*
3152 +--------------------------------------------------------------------+
3153 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
3154 | STATE : code ROUTINE : cc_set_state |
3155 +--------------------------------------------------------------------+
3156
3157 PURPOSE : Sets the new state for call control. If necessary the
3158 instance administration is updated.
3159
3160 */
3161
3162 GLOBAL void cc_set_state (UBYTE new_state)
3163 {
3164 GET_INSTANCE_DATA;
3165 #ifndef NTRACE
3166 vsi_o_state_ttrace ("CC[%d]: %s -> %s",
3167 cc_data->index_ti,
3168 S2I_STRING(cc_sname(cc_data->state[cc_data->index_ti])),
3169 S2I_STRING(cc_sname(new_state)));
3170 #endif
3171
3172 cc_data->state[cc_data->index_ti] = new_state;
3173 if ((new_state EQ M_CC_CS_0) AND (cc_data->ti NEQ cc_data->setup_reattempt_ti))
3174 srv_free_ti ();
3175 if (new_state EQ M_CC_CS_10) /* // Questionable after RLF/REEST */
3176 cc_data->hold_state[cc_data->index_ti] = M_CC_HLD_IDLE;
3177 }
3178
3179 /*
3180 +--------------------------------------------------------------------+
3181 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
3182 | STATE : code ROUTINE : cc_check_bc |
3183 +--------------------------------------------------------------------+
3184
3185 PURPOSE : Checks an incoming bearer capability.
3186 But not only checks are done, also
3187 neg_bearer_cap, bcpara and service are
3188 computed. If negotiation is required,
3189 negotiation will be set to TRUE
3190 (but never to FALSE by this function).
3191
3192 RETURN: OKAY if bearer_cap could be processed,
3193 otherwise ERROR.
3194
3195 */
3196
3197
3198 GLOBAL UBYTE cc_check_bc (const T_M_CC_bearer_cap * bearer_cap, /* in */
3199 T_M_CC_bearer_cap * neg_bearer_cap, /* out */
3200 T_MNCC_bcpara * bcpara, /* out */
3201 UBYTE * service, /* out */
3202 BOOL * negotiation ) /* in/out */
3203 {
3204 GET_INSTANCE_DATA;
3205 UBYTE found, temp;
3206
3207 TRACE_FUNCTION ("cc_check_bc()");
3208
3209 memcpy (neg_bearer_cap, bearer_cap, sizeof (T_M_CC_bearer_cap));
3210
3211 cc_csf_ms_cap ();
3212
3213 switch (bearer_cap->trans_cap)
3214 {
3215 case M_CC_ITC_SPEECH:
3216 case M_CC_ITC_AUXILIARY_SPEECH:
3217 if (!cc_voice_capability ())
3218 return ERROR;
3219 temp = bcpara->rad_chan_req;
3220 memset (bcpara, 0, sizeof (T_MNCC_bcpara));
3221 bcpara->rad_chan_req = temp;
3222 *service = MNCC_SERV_SPEECH;
3223 if (bearer_cap->trans_cap EQ M_CC_ITC_SPEECH)
3224 {
3225 /* Speech bearer capability */
3226 if (cc_data->ctm_ena EQ MNCC_CTM_ENABLED)
3227 {
3228 bcpara->bearer_serv = MNCC_BEARER_SERV_SPEECH_CTM;
3229 cc_build_bc (neg_bearer_cap, service, bcpara);
3230 *negotiation = TRUE;
3231 return OKAY;
3232 }
3233 else
3234 bcpara->bearer_serv = MNCC_BEARER_SERV_SPEECH;
3235 }
3236 else
3237 {
3238 /* Speech bearer capability for alternate line service */
3239 if (cc_data->ctm_ena EQ MNCC_CTM_ENABLED)
3240 {
3241 bcpara->bearer_serv = MNCC_BEARER_SERV_AUX_SPEECH_CTM;
3242 cc_build_bc (neg_bearer_cap, service, bcpara);
3243 *negotiation = TRUE;
3244 return OKAY;
3245 }
3246 else
3247 bcpara->bearer_serv = MNCC_BEARER_SERV_AUX_SPEECH;
3248 }
3249
3250 /*
3251 * For negotiation, the rules of GSM 04.08 clause 9.3.2.2 shall apply
3252 */
3253 if ((FldGet(cc_data->mscap.chnMode, EFRSupV2) OR
3254 FldGet(cc_data->mscap.chnMode, AHS) OR
3255 FldGet(cc_data->mscap.chnMode, AFS)) AND
3256 (bearer_cap->v_speech_vers1 EQ FALSE))
3257 {
3258 /*
3259 * if the incoming message indicates only full rate channel,
3260 * all supported bearer caps shall be returned.
3261 */
3262 cc_build_bc (neg_bearer_cap, service, bcpara);
3263 *negotiation = TRUE;
3264 }
3265 return OKAY;
3266
3267 case M_CC_ITC_AUDIO:
3268 case M_CC_ITC_DIGITAL_UNRESTRICTED:
3269 *service = MNCC_SERV_DATA;
3270 found = FALSE;
3271 switch (cc_data->conn_elem)
3272 {
3273 case MNCC_CONN_ELEM_TRANS:
3274 cc_check_transparent_async (&found, bearer_cap, neg_bearer_cap,
3275 bcpara, negotiation );
3276 break;
3277 case MNCC_CONN_ELEM_NON_TRANS:
3278 cc_check_non_transparent_async (&found, bearer_cap, neg_bearer_cap,
3279 bcpara, negotiation);
3280 break;
3281 case MNCC_CONN_ELEM_TRANS_PREF:
3282 cc_check_transparent_async (&found, bearer_cap, neg_bearer_cap,
3283 bcpara, negotiation);
3284 cc_check_non_transparent_async (&found, bearer_cap, neg_bearer_cap,
3285 bcpara, negotiation);
3286 break;
3287 case MNCC_CONN_ELEM_NON_TRANS_PREF:
3288 cc_check_non_transparent_async (&found, bearer_cap, neg_bearer_cap,
3289 bcpara, negotiation);
3290 cc_check_transparent_async (&found, bearer_cap, neg_bearer_cap,
3291 bcpara, negotiation);
3292 break;
3293 case MNCC_CONN_ELEM_NOT_PRES:
3294 TRACE_EVENT ("Call setup failed due to uninitialised conn_elem in cc_data");
3295 break;
3296 }
3297 /*
3298 * not yet supported (this stuff must be included in the switch (cc_data->conn_elem) above )
3299 *
3300 * cc_check_transparent_sync (&found, bearer_cap, neg_bearer_cap,
3301 * bcpara, cc_data);
3302 * cc_check_non_transparent_sync (&found, bearer_cap, neg_bearer_cap,
3303 * bcpara, cc_data);
3304 *
3305 * cc_check_transparent_packet_sync
3306 * cc_check_non_transparent_packet_sync
3307 * cc_check_transparent_pad_async
3308 * cc_check_non_transparent_pad_async
3309 *
3310 */
3311 if (found)
3312 {
3313 return OKAY;
3314 }
3315 return ERROR;
3316
3317 case M_CC_ITC_FAX_GROUP_3:
3318 *service = MNCC_SERV_DATA;
3319 if (cc_check_transparent_fax (bearer_cap, neg_bearer_cap,
3320 bcpara, negotiation))
3321 {
3322 return OKAY;
3323 }
3324 return ERROR;
3325
3326 default:
3327 /* reserved ITC value e.g. */
3328 return ERROR;
3329 }
3330 }
3331
3332 /*
3333 +--------------------------------------------------------------------+
3334 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
3335 | STATE : code ROUTINE : cc_check_transparent_async |
3336 +--------------------------------------------------------------------+
3337
3338 PURPOSE : Checks an incoming bearer capability for the transparent
3339 asynchronous data service.
3340
3341 */
3342 GLOBAL void cc_check_transparent_async (UBYTE * found,
3343 const T_M_CC_bearer_cap * bearer_cap,
3344 T_M_CC_bearer_cap * neg_bearer_cap,
3345 T_MNCC_bcpara * bcpara,
3346 BOOL * negotiation )
3347 {
3348 GET_INSTANCE_DATA;
3349 TRACE_FUNCTION ("cc_check_transparent_async()");
3350
3351 if (*found EQ FALSE)
3352 {
3353 memcpy (neg_bearer_cap, bearer_cap, sizeof (T_M_CC_bearer_cap));
3354
3355 if (FldGet(cc_data->mscap.datCap1, AsySup))
3356 {
3357 /*
3358 * check only if transparent M_CC_ASYNCHRONOUS data services are supported
3359 */
3360 if (bearer_cap->sync_async NEQ M_CC_ASYNCHRONOUS OR
3361 bearer_cap->sig_access_prot NEQ M_CC_SIAP_I440) /* no async service */
3362 return;
3363 switch (bearer_cap->conn_elem)
3364 {
3365 case M_CC_CE_TRANSPA:
3366 neg_bearer_cap->compress = M_CC_COMP_NO;
3367 break;
3368 case M_CC_CE_TRANSPA_PREF: /* set to trans async */
3369 case M_CC_CE_RLP_PREF:
3370 *negotiation = TRUE;
3371 neg_bearer_cap->conn_elem = M_CC_CE_TRANSPA;
3372 neg_bearer_cap->structure = M_CC_STRC_UNSTRUCTURED;
3373 neg_bearer_cap->compress = M_CC_COMP_NO;
3374 if (bearer_cap->modem_type EQ M_CC_MT_AUTO)
3375 {
3376 switch (bearer_cap->user_rate) /* set the modem type matching a data rate */
3377 {
3378 case MNCC_UR_0_3_KBIT:
3379 neg_bearer_cap->modem_type = M_CC_MT_V21;
3380 break;
3381 case MNCC_UR_1_2_KBIT:
3382 neg_bearer_cap->modem_type = M_CC_MT_V22;
3383 break;
3384 case MNCC_UR_2_4_KBIT:
3385 neg_bearer_cap->modem_type = M_CC_MT_V22BIS;
3386 break;
3387 case MNCC_UR_4_8_KBIT:
3388 neg_bearer_cap->modem_type = M_CC_MT_V32;
3389 break;
3390 case MNCC_UR_9_6_KBIT:
3391 case MNCC_UR_12_0_KBIT_TRANS:
3392 case MNCC_UR_14_4_KBIT:
3393 neg_bearer_cap->modem_type = M_CC_MT_V32;
3394 break;
3395 case MNCC_UR_1_2_KBIT_V23:
3396 neg_bearer_cap->modem_type = M_CC_MT_V23;
3397 break;
3398 default:
3399 neg_bearer_cap->modem_type = M_CC_MT_UNDEF;
3400 break;
3401 } /* END OF set the modem type matching the data rate */
3402 } /* END OF if (bearer_cap->modem_type EQ M_CC_MT_AUTO) */
3403 if ((bearer_cap->user_rate EQ M_CC_UR_9_6_KBIT) OR
3404 (bearer_cap->user_rate EQ M_CC_UR_12_0_KBIT_TRANS))
3405 neg_bearer_cap->intermed_rate = M_CC_IR_16_KBIT;
3406 else
3407 neg_bearer_cap->intermed_rate = M_CC_IR_8_KBIT;
3408 neg_bearer_cap->v_l2_ident = FALSE;
3409 neg_bearer_cap->v_user_inf_l2_prot = FALSE;
3410 break;
3411
3412 case M_CC_CE_RLP: /* non-transparent service */
3413 return;
3414
3415 default:
3416 return;
3417 } /* end SWITCH (bearer_cap->conn_elem)*/
3418 /*
3419 * copy important parameters
3420 */
3421 *found = TRUE;
3422
3423 /*
3424 * this is a first step to 14.4
3425 * if FNUR is available, use this as user rate
3426 */
3427 /* Implements Measure# 21 */
3428 cc_set_neg_bearer_cap(bearer_cap, bcpara, neg_bearer_cap, cc_data->mscap);
3429 bcpara->flow_control = NOT_PRESENT_8BIT;
3430 bcpara->conn_elem = MNCC_CONN_ELEM_TRANS;
3431
3432 }
3433 }
3434 }
3435
3436 /*
3437 +--------------------------------------------------------------------+
3438 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
3439 | STATE : code ROUTINE : cc_check_non_transparent_async |
3440 +--------------------------------------------------------------------+
3441
3442 PURPOSE : Checks an incoming bearer capability for the
3443 non-transparent asynchronous data service.
3444
3445 */
3446
3447 GLOBAL void cc_check_non_transparent_async (UBYTE * found,
3448 const T_M_CC_bearer_cap * bearer_cap,
3449 T_M_CC_bearer_cap * neg_bearer_cap,
3450 T_MNCC_bcpara * bcpara,
3451 BOOL * negotiation )
3452 {
3453 GET_INSTANCE_DATA;
3454 TRACE_FUNCTION ("cc_check_non_transparent_async()");
3455
3456 if (*found EQ FALSE)
3457 {
3458 memcpy (neg_bearer_cap, bearer_cap, sizeof (T_M_CC_bearer_cap));
3459
3460 if (FldGet (cc_data->mscap.datCap1, RLPSup))
3461 {
3462 /*
3463 * check only if non-transparent M_CC_ASYNCHRONOUS data services are supported
3464 */
3465 if (bearer_cap->sync_async NEQ M_CC_ASYNCHRONOUS OR
3466 bearer_cap->sig_access_prot NEQ M_CC_SIAP_I440) /* no async service */
3467 return;
3468 switch (bearer_cap->conn_elem)
3469 {
3470 case M_CC_CE_RLP:
3471 break;
3472
3473 case M_CC_CE_RLP_PREF: /* set to non-trans async */
3474 case M_CC_CE_TRANSPA_PREF:
3475 *negotiation = TRUE;
3476 neg_bearer_cap->conn_elem = M_CC_CE_RLP;
3477 neg_bearer_cap->structure = M_CC_STRC_SERV_DATA_INTEG;
3478 /*
3479 * TA 29.2.3.5 Negotiation of intermediate rate
3480 */
3481 if ((bearer_cap->nirr EQ M_CC_NIRR_DATA) AND
3482 (bearer_cap->user_rate <= M_CC_UR_4_8_KBIT))
3483 neg_bearer_cap->intermed_rate = M_CC_IR_8_KBIT;
3484 else
3485 neg_bearer_cap->intermed_rate = M_CC_IR_16_KBIT;
3486 break;
3487
3488 case M_CC_CE_TRANSPA: /* transparent service */
3489 return;
3490
3491 default:
3492 return;
3493 }
3494
3495 /*
3496 * copy important parameters
3497 */
3498 *found = TRUE;
3499 /*
3500 * this is a first step to 14.4
3501 * if FNUR is available, use this as user rate
3502 */
3503 /* Implements Measure# 21 */
3504 cc_set_neg_bearer_cap(bearer_cap, bcpara, neg_bearer_cap, cc_data->mscap);
3505 bcpara->conn_elem = MNCC_CONN_ELEM_NON_TRANS;
3506
3507 if (bearer_cap->v_user_inf_l2_prot)
3508 {
3509 switch (bearer_cap->user_inf_l2_prot)
3510 {
3511 case M_CC_L2_ISO6429:
3512 bcpara->flow_control = MNCC_INBAND_FLOW_CONTROL;
3513 break;
3514 case M_CC_L2_COPFC:
3515 bcpara->flow_control = MNCC_NO_FLOW_CONTROL;
3516 break;
3517 default:
3518 bcpara->flow_control = MNCC_OUTBAND_FLOW_CONTROL;
3519 break;
3520 }
3521 }
3522 else
3523 bcpara->flow_control = MNCC_OUTBAND_FLOW_CONTROL;
3524 }
3525 }
3526 }
3527
3528 /*
3529 +--------------------------------------------------------------------+
3530 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
3531 | STATE : code ROUTINE : cc_check_transparent_fax |
3532 +--------------------------------------------------------------------+
3533
3534 PURPOSE : Checks an incoming bearer capability for the transparent
3535 fax service.
3536
3537 */
3538
3539 GLOBAL UBYTE cc_check_transparent_fax (const T_M_CC_bearer_cap * bearer_cap,
3540 T_M_CC_bearer_cap * neg_bearer_cap,
3541 T_MNCC_bcpara * bcpara,
3542 BOOL * negotiation )
3543 {
3544 GET_INSTANCE_DATA;
3545 TRACE_FUNCTION ("cc_check_transparent_fax()");
3546
3547 memcpy (neg_bearer_cap, bearer_cap, sizeof (T_M_CC_bearer_cap));
3548
3549 if (FldGet (cc_data->mscap.datCap1, TFaxSup))
3550 {
3551 /*
3552 * check only if transparent fax services are supported
3553 */
3554
3555 if (bearer_cap->sync_async NEQ M_CC_SYNCHRONOUS OR
3556 bearer_cap->sig_access_prot NEQ M_CC_SIAP_I440) /* no async service */
3557 return FALSE;
3558
3559 switch (bearer_cap->conn_elem)
3560 {
3561 case M_CC_CE_TRANSPA:
3562 break;
3563
3564 case M_CC_CE_TRANSPA_PREF: /* set to trans async */
3565 case M_CC_CE_RLP_PREF:
3566 *negotiation = TRUE;
3567 neg_bearer_cap->conn_elem = M_CC_CE_TRANSPA;
3568 neg_bearer_cap->structure = M_CC_STRC_UNSTRUCTURED;
3569 if ((bearer_cap->user_rate EQ M_CC_UR_9_6_KBIT) OR
3570 (bearer_cap->user_rate EQ M_CC_UR_12_0_KBIT_TRANS))
3571 neg_bearer_cap->intermed_rate = M_CC_IR_16_KBIT;
3572 else
3573 neg_bearer_cap->intermed_rate = M_CC_IR_8_KBIT;
3574 neg_bearer_cap->v_l2_ident = FALSE;
3575 neg_bearer_cap->v_user_inf_l2_prot = FALSE;
3576 break;
3577
3578
3579 case M_CC_CE_RLP: /* non-transparent service */
3580 default:
3581 return FALSE;
3582 }
3583
3584 /*
3585 * copy important parameters
3586 */
3587 /*
3588 * this is a first step to 14.4
3589 * if FNUR is available, use this as user rate
3590 */
3591 if (bearer_cap->v_fnur AND (bearer_cap->fnur EQ M_CC_FNUR_14400))
3592 {
3593 bcpara->rate = 8;
3594 /*
3595 * define acceptable channel codings
3596 */
3597 neg_bearer_cap->acc = M_CC_ACC_96;
3598 if (FldGet (cc_data->mscap.datCap2, DHRSup))
3599 neg_bearer_cap->acc += M_CC_ACC_48;
3600 if (FldGet (cc_data->mscap.datCap1, Dr14_4Sup))
3601 neg_bearer_cap->acc += M_CC_ACC_144;
3602 neg_bearer_cap->v_acc = TRUE;
3603
3604 neg_bearer_cap->intermed_rate = M_CC_IR_16_KBIT;
3605
3606 neg_bearer_cap->v_mTch = TRUE;
3607 neg_bearer_cap->mTch = M_CC_MAX_TCH_1;
3608 neg_bearer_cap->v_uimi = TRUE;
3609 neg_bearer_cap->uimi = M_CC_UIMI_NOT_ALLOWED;
3610 neg_bearer_cap->modem_type_2 = M_CC_OTHER_MODEM_TYPE_V34;
3611 }
3612 else
3613 bcpara->rate = bearer_cap->user_rate;
3614 bcpara->bearer_serv = MNCC_BEARER_SERV_FAX;
3615 bcpara->conn_elem = MNCC_CONN_ELEM_TRANS;
3616 bcpara->stop_bits = bearer_cap->num_stop;
3617 bcpara->data_bits = bearer_cap->num_data;
3618 bcpara->parity = bearer_cap->parity;
3619 bcpara->modem_type = bearer_cap->modem_type;
3620 bcpara->flow_control = NOT_PRESENT_8BIT;
3621 return TRUE;
3622 }
3623 return FALSE;
3624 }
3625
3626
3627 /*
3628 +--------------------------------------------------------------------+
3629 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
3630 | STATE : code ROUTINE : cc_build_facility_ind |
3631 +--------------------------------------------------------------------+
3632
3633 PURPOSE : Forwards a facility information element to the upper layer
3634 if available.
3635
3636 */
3637
3638
3639
3640 GLOBAL void cc_build_facility_ind (UBYTE context,
3641 UBYTE valid,
3642 const T_M_CC_facility * facility )
3643 {
3644 GET_INSTANCE_DATA;
3645 TRACE_FUNCTION ("cc_build_facility_ind()");
3646
3647 if (valid)
3648 {
3649 PALLOC (facility_ind, MNCC_FACILITY_IND);
3650
3651 facility_ind->ti = cc_data->ti;
3652 facility_ind->fac_context = context;
3653 facility_ind->fac_inf.l_fac = facility->c_fac<<3;
3654 facility_ind->fac_inf.o_fac = 0;
3655
3656 memcpy (facility_ind->fac_inf.fac, facility->fac, facility->c_fac);
3657
3658 PSENDX (MMI, facility_ind);
3659 }
3660 }
3661
3662
3663 /*
3664 +--------------------------------------------------------------------+
3665 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
3666 | STATE : code ROUTINE : cc_build_user_user_ind |
3667 +--------------------------------------------------------------------+
3668
3669 PURPOSE : Forwards a user user information element to the upper layer
3670 if available.
3671
3672 */
3673
3674
3675 GLOBAL void cc_build_user_user_ind (UBYTE context,
3676 UBYTE valid,
3677 T_M_CC_user_user * user_user )
3678 {
3679 GET_INSTANCE_DATA;
3680 TRACE_FUNCTION ("cc_build_user_user_ind()");
3681
3682 if (valid)
3683 {
3684 PALLOC (user_ind, MNCC_USER_IND);
3685
3686 user_ind->ti = cc_data->ti;
3687 user_ind->user.info_context = context;
3688 user_ind->user.c_info = user_user->c_info;
3689 user_ind->user.pd = user_user->pd;
3690 memcpy (user_ind->user.info, user_user->info,
3691 MNCC_USER_LEN);
3692
3693 PSENDX (MMI, user_ind);
3694 }
3695 }
3696
3697 /*
3698 +--------------------------------------------------------------------+
3699 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
3700 | STATE : code ROUTINE : cc_check_capabilities |
3701 +--------------------------------------------------------------------+
3702
3703 PURPOSE : The mobile station capabilities are checked against the
3704 upper layer request.
3705
3706 RETURN: TRUE if bearer capabilities supported.
3707 FALSE if bearer capabilitis not supported.
3708
3709 */
3710
3711 GLOBAL UBYTE cc_check_capabilities (const T_MNCC_bcpara * bcpara)
3712 {
3713 GET_INSTANCE_DATA;
3714 TRACE_FUNCTION ("cc_check_capabilities()");
3715
3716 cc_csf_ms_cap ();
3717 switch (bcpara->bearer_serv)
3718 {
3719 case MNCC_BEARER_SERV_SYNC:
3720 if (bcpara->conn_elem EQ MNCC_CONN_ELEM_TRANS)
3721 {
3722 return (FldGet (cc_data->mscap.datCap1, TSynSup) NEQ 0);
3723 }
3724 return (FldGet (cc_data->mscap.datCap1, NTSynSup) NEQ 0);
3725
3726 case MNCC_BEARER_SERV_ASYNC:
3727 if (bcpara->conn_elem EQ MNCC_CONN_ELEM_TRANS)
3728 {
3729 return (FldGet (cc_data->mscap.datCap1, AsySup) NEQ 0);
3730 }
3731 return (FldGet (cc_data->mscap.datCap1, RLPSup) NEQ 0);
3732
3733 case MNCC_BEARER_SERV_PAD_ACCESS:
3734 if (bcpara->conn_elem EQ MNCC_CONN_ELEM_TRANS)
3735 {
3736 return (FldGet (cc_data->mscap.datCap2,TPadSup) NEQ 0);
3737 }
3738 return (FldGet (cc_data->mscap.datCap2,NTPadSup) NEQ 0);
3739
3740 case MNCC_BEARER_SERV_PACKET_ACCESS:
3741 if (bcpara->conn_elem EQ MNCC_CONN_ELEM_TRANS)
3742 {
3743 return (FldGet (cc_data->mscap.datCap2, TPackSup) NEQ 0);
3744 }
3745 return (FldGet (cc_data->mscap.datCap2, NTPackSup) NEQ 0);
3746
3747 case MNCC_BEARER_SERV_FAX:
3748 if (bcpara->conn_elem EQ MNCC_CONN_ELEM_TRANS)
3749 {
3750 return (FldGet (cc_data->mscap.datCap1, TFaxSup) NEQ 0);
3751 }
3752 return FALSE;
3753
3754 case MNCC_BEARER_SERV_SPEECH:
3755 case MNCC_BEARER_SERV_AUX_SPEECH:
3756 case MNCC_BEARER_SERV_SPEECH_CTM:
3757 case MNCC_BEARER_SERV_AUX_SPEECH_CTM:
3758 return cc_voice_capability ();
3759
3760 case MNCC_BEARER_SERV_NOT_PRES:
3761 return TRUE;
3762
3763 default:
3764 return FALSE;
3765 }
3766 }
3767
3768 #ifdef SIM_TOOLKIT
3769 /*
3770 +--------------------------------------------------------------------+
3771 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
3772 | STATE : code ROUTINE : cc_bearer_cap_code |
3773 +--------------------------------------------------------------------+
3774
3775 PURPOSE: Checks the compatibility of bearer capabilities.
3776 Bearer capabilities in paramter form are tranformed to
3777 coded form.
3778
3779 RETURN VALUE: ERROR if bearer caps not supported, otherwise OKAY
3780 Special case of no bearer caps given is OKAY.
3781
3782 */
3783
3784 GLOBAL UBYTE cc_bearer_cap_code (const T_MNCC_bcpara *bcpara, T_MNCC_bcconf *bcconf )
3785 {
3786 T_M_CC_bearer_cap bearer_cap; /* A lot of stuff on stack */ /*lint !e813 length info of struct*/
3787 UBYTE dummy_service;
3788 UBYTE *ptr;
3789 UBYTE result;
3790
3791 TRACE_FUNCTION ("cc_bearer_cap_code()");
3792
3793 /* Clear output */
3794 bcconf->bc_len = 0;
3795 memset (bcconf->bc, 0x00, sizeof (bcconf->bc));
3796
3797 if (bcpara->bearer_serv EQ MNCC_BEARER_SERV_NOT_PRES)
3798 return OKAY; /* No BC in -> no BC out */
3799
3800 /*
3801 * Check requested upper layer capabilities
3802 * against mobile station capabilities
3803 */
3804 if (cc_check_capabilities (bcpara) EQ FALSE)
3805 {
3806 /* MS doesn´t support the requested services */
3807 return ERROR;
3808 }
3809
3810 cc_build_bc (&bearer_cap,
3811 &dummy_service, /* Not used */
3812 bcpara);
3813
3814 /*
3815 * Build a U_EMERGE_SETUP message which contains the coded bearer caps.
3816 * The U_EMERGE_SETUP message was chosen because it is the most
3817 * simple message containing bearer capabilities. In the next step,
3818 * read the coded bearer capabilities directly from this message.
3819 */
3820 CCD_START;
3821 {
3822 MCAST (emerge_setup, U_EMERGE_SETUP);
3823 PALLOC_MSG (data, MMCM_DATA_REQ, U_EMERGE_SETUP);
3824
3825 emerge_setup->msg_type = U_EMERGE_SETUP;
3826 emerge_setup->v_bearer_cap = TRUE;
3827 emerge_setup->bearer_cap = bearer_cap;
3828 data->sdu.o_buf = CC_ENCODE_OFFSET;
3829 ccd_codeMsg (CCDENT_CC,
3830 UPLINK,
3831 (T_MSGBUF *) &data->sdu,
3832 (UBYTE *) emerge_setup,
3833 NOT_PRESENT_8BIT);
3834
3835 ptr = &data->sdu.buf[CC_ENCODE_OFFSET >> 3];
3836
3837 /*
3838 * The following is an internal check and not expected to fail.
3839 * Short circuit evaluation, ANSI C guarantees execution order LR here.
3840 */
3841 if ((*ptr++ EQ U_EMERGE_SETUP) AND /* Message type */
3842 (*ptr++ EQ 0x04) AND /* BC tag (0x04) */
3843 (*ptr <= sizeof (bcconf->bc))) /* Field length not exceeded */
3844 {
3845 result = OKAY;
3846 bcconf->bc_len = *ptr++;
3847 memcpy (bcconf->bc, ptr, bcconf->bc_len);
3848 }
3849 else
3850 result = ERROR;
3851 PFREE (data);
3852 }
3853 CCD_END;
3854
3855 return result;
3856 }
3857
3858 /*
3859 +--------------------------------------------------------------------+
3860 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
3861 | STATE : code ROUTINE : cc_bearer_cap_decode |
3862 +--------------------------------------------------------------------+
3863
3864 PURPOSE: Checks the compatibility of bearer capabilities.
3865 Bearer capabilities in coded form are tranformed to
3866 parameter form.
3867
3868 RETURN VALUE: ERROR if bearer caps not supported
3869 Special case of empty bearer caps given is OKAY
3870
3871 */
3872
3873 GLOBAL UBYTE cc_bearer_cap_decode (const T_MNCC_bcconf *bcconf, T_MNCC_bcpara *bcpara )
3874
3875 {
3876 T_M_CC_bearer_cap dummy_neg_bearer_cap; /* A lot of stuff on stack */ /*lint !e813 length info of struct*/
3877 UBYTE dummy_service;
3878 BOOL dummy_negotiation;
3879 UBYTE * start_ptr;
3880 UBYTE * ptr;
3881 BYTE result;
3882
3883 TRACE_FUNCTION ("cc_bearer_cap_decode()");
3884
3885 bcpara->bearer_serv = MNCC_BEARER_SERV_NOT_PRES;
3886
3887 if (bcconf->bc_len EQ 0)
3888 return OKAY; /* No BC in -> no BC out */
3889
3890 CCD_START
3891 {
3892 /*
3893 * Build a U_EMERGE_SETUP message which contains the coded bearer caps.
3894 * The U_EMERGE_SETUP message was chosen because it is the most
3895 * simple message containing bearer capabilities.
3896 */
3897 MCAST (emerge_setup, U_EMERGE_SETUP);
3898 PALLOC_MSG (data, MMCM_DATA_REQ, U_EMERGE_SETUP);
3899 data->sdu.o_buf = CC_ENCODE_OFFSET;
3900 ptr = start_ptr = &data->sdu.buf[CC_ENCODE_OFFSET >> 3];
3901 *ptr++ = U_EMERGE_SETUP; /* Message type field */
3902 *ptr++ = 0x04; /* BC tag */
3903 *ptr++ = bcconf->bc_len; /* BC length */
3904 memcpy(ptr, bcconf->bc, bcconf->bc_len);
3905 ptr += bcconf->bc_len;
3906 data->sdu.l_buf = (ptr - start_ptr) << 3;
3907
3908 result = ERROR;
3909 if ((ccd_decodeMsg (CCDENT_CC,
3910 UPLINK,
3911 (T_MSGBUF *) &data->sdu,
3912 (UBYTE *)_decodedMsg,
3913 NOT_PRESENT_8BIT) EQ ccdOK))
3914 {
3915 if (emerge_setup->v_bearer_cap)
3916 {
3917 /*
3918 * CCD was able to decode emergency setup message
3919 * and contained BC. Check them.
3920 * This also transforms coded form into parameter form as desired
3921 */
3922 if(emerge_setup->bearer_cap.v_rad_chan_req)
3923 {
3924 bcpara->rad_chan_req = emerge_setup->bearer_cap.rad_chan_req ;
3925 TRACE_EVENT_P1 ("bcpara->rad_chan_req = %d", bcpara->rad_chan_req );
3926 }
3927 result = cc_check_bc (&emerge_setup->bearer_cap, /* Input BC */
3928 &dummy_neg_bearer_cap, /* Not used */
3929 bcpara, /* BC parameter */
3930 &dummy_service, /* Not used */
3931 &dummy_negotiation ); /* Not used */
3932 }
3933 }
3934 PFREE (data);
3935 }
3936 CCD_END;
3937
3938 return result;
3939 }
3940
3941 #endif /*SIM_TOOLKIT */
3942
3943 /*
3944 +--------------------------------------------------------------------+
3945 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
3946 | STATE : code ROUTINE : cc_build_llc |
3947 +--------------------------------------------------------------------+
3948
3949 PURPOSE : Define low layer compat depending on the bearer capability
3950 parameters.
3951
3952 */
3953
3954 static const UBYTE BC_LLC_USERRATE[8] =
3955 {
3956 /* reserved 0000 */ 0,
3957 /* 0.3 0001 */ 0x1E,
3958 /* 1.2 0010 */ 2,
3959 /* 2.4 0011 */ 3,
3960 /* 4.8 0100 */ 5,
3961 /* 9.6 0101 */ 8,
3962 /* 12.0 transp 0110 */ 0x1F,
3963 /* 12.0/75 0111 */ 0x18
3964 };
3965
3966 static const UBYTE BC_LLC_INTERMED_RATE [4] =
3967 {
3968 /* not used 00 */ 0x00,
3969 /* not used 01 */ 0x00,
3970 /* 8 kbit/s 10 */ 0x20,
3971 /* 16 kbit/s 11 */ 0x40
3972 };
3973
3974 GLOBAL void cc_build_llc (UBYTE * v_low_layer_compat,
3975 T_M_CC_low_layer_comp * low_layer_compat,
3976 const T_M_CC_bearer_cap * bc)
3977 {
3978 TRACE_FUNCTION ("cc_build_llc()");
3979
3980 /*
3981 * infoelement shall be included
3982 */
3983 *v_low_layer_compat = TRUE;
3984
3985 if (bc->trans_cap EQ M_CC_ITC_DIGITAL_UNRESTRICTED)
3986 {
3987 /*
3988 * length is fixed with 6 bytes
3989 */
3990 low_layer_compat->c_llc = 6;
3991
3992 /*
3993 * octet 3
3994 *
3995 * bit 8 : extension = 1 (fixed)
3996 * bit 76 : coding standard = GSM (fixed)
3997 * bit 54321 : information transfer capability = UDI (fixed)
3998 */
3999 low_layer_compat->llc[0] = 0x88;
4000
4001 /*
4002 * octet 4
4003 *
4004 * bit 8 : extension = 1 (fixed)
4005 * bit 76 : transfer mode = circuit (fixed)
4006 * bit 54321 : information transfer rate = 64 kbit/s (fixed)
4007 */
4008 low_layer_compat->llc[1] = 0x90;
4009
4010 /*
4011 * octet 5
4012 *
4013 * bit 8 : extension = 0 (fixed)
4014 * bit 76 : layer 1 identifier = 1 (fixed)
4015 * bit 54321 : user information layer 1 protocol = V.110 (fixed)
4016 */
4017 low_layer_compat->llc[2] = 0x21;
4018
4019 /*
4020 * octet 5a
4021 *
4022 * bit 8 : extension = 0 (fixed)
4023 * bit 7 : sync/async -> from BC
4024 * BC LLC
4025 * M_CC_ASYNCHRONOUS 1 1
4026 * M_CC_SYNCHRONOUS 0 0
4027 * bit 6 : negotiation = 0 (fixed)
4028 * bit 54321 : user rate -> from BC
4029 BC LLC
4030 0.3 0001 11110
4031 1.2 0010 00010
4032 2.4 0011 00011
4033 4.8 0100 00101
4034 9.6 0101 01000
4035 12.0 transp 0110 11111
4036 12.0/75 0111 11000
4037 */
4038
4039 if (bc->sync_async)
4040 low_layer_compat->llc[3] = 0x40;
4041 else
4042 low_layer_compat->llc[3] = 0x00;
4043
4044 low_layer_compat->llc[3] += BC_LLC_USERRATE[bc->user_rate & 7];
4045
4046 /*
4047 * octet 5b
4048 *
4049 * bit 8 : extension = 0 (fixed)
4050 * bit 76 : intermediate rate -> from BC
4051 * BC LLC
4052 * not used 00/01 00
4053 * 8 kbit/s 10 01
4054 * 16 kbit/s 11 10
4055 * 32 kbit/s -- 11
4056 * bit 5 : NIC/TX = 0 (fixed)
4057 * bit 4 : NIC/RX = 0 (fixed)
4058 * bit 3 : Flow Control on Tx = 0 (fixed)
4059 * bit 2 : Flow Control on Rx = 0 (fixed)
4060 * bit 1 : Spare = 0 (fixed)
4061 */
4062 low_layer_compat->llc[4] = BC_LLC_INTERMED_RATE[bc->intermed_rate];
4063
4064 /*
4065 * octet 5c
4066 *
4067 * bit 8 : extension = 1 (fixed)
4068 * bit 76 : number of stop bits -> BC
4069 * BC LLC
4070 * not used -- 00
4071 * 1 bit 0 01
4072 * 1.5 bits -- 10
4073 * 2 bits 1 11
4074 * bit 54 : number of data bits -> BC
4075 * BC LLC
4076 * not used 00
4077 * 5 bits 01
4078 * 7 bits 0 10
4079 * 8 bits 1 11
4080 * bit 321 : parity -> BC
4081 * BC LLC
4082 * odd 000 000
4083 * even 010 010
4084 * none 011 011
4085 * forced to 0 100 100
4086 * forced to 1 101 101
4087 */
4088 low_layer_compat->llc[5] = 0x80 + bc->parity;
4089
4090 if (bc->num_stop)
4091 low_layer_compat->llc[5] += 0x60;
4092 else
4093 low_layer_compat->llc[5] += 0x20;
4094
4095 if (bc->num_data)
4096 low_layer_compat->llc[5] += 0x18;
4097 else
4098 low_layer_compat->llc[5] += 0x10;
4099 }
4100 else
4101 {
4102 /*
4103 * set length to zero -> not applicable
4104 */
4105 memset (low_layer_compat, 0, sizeof (T_M_CC_low_layer_comp));
4106 }
4107 }
4108
4109 /*
4110 +--------------------------------------------------------------------+
4111 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
4112 | STATE : code ROUTINE : cc_get_ss_diag |
4113 +--------------------------------------------------------------------+
4114
4115 PURPOSE : Added for CQ23619: Extracts the supplementary diagnostic
4116 from the disconnect indication if there a respective cause given.
4117 For further details see: TS 24.008 section 10.5.4.11 "NOTE 1"
4118 (This implementation follows version V3.19.0 (2004-06))
4119
4120 IN: - curr_cause: current cause
4121 - disconnect indication received by CC
4122 OUT:- ss_diag: ss diagnostic
4123 */
4124
4125 GLOBAL UBYTE cc_get_ss_diag ( USHORT curr_cause,
4126 T_D_DISCONNECT * disc)
4127 {
4128
4129 UBYTE ss_diag = MNCC_SS_DIAG_NOT_PROVIDED; /* holds the ss diagnostic */
4130
4131 TRACE_FUNCTION ("cc_get_ss_diag()");
4132
4133 /*
4134 * Only the following causes may also provide a supplementary diagnostic value
4135 * - cause 17: User busy - MNCC_CAUSE_USER_BUSY
4136 * - cause 29: Facility rejected - MNCC_CAUSE_FACILITY_REJECT
4137 * - cause 34: No circuit/channel available - MNCC_CAUSE_NO_CHAN_AVAIL
4138 * - cause 50: Requested facility not subscribed - MNCC_CAUSE_FACILITY_UNSUBSCRIB
4139 * - cause 55: Incoming call barred within the CUG - MNCC_CAUSE_BARRED_IN_CUG
4140 * - cause 69: Requested facility not implemented - MNCC_CAUSE_FACILITY_NOT_IMPLEM
4141 * - cause 87: User not member of CUG - MNCC_CAUSE_USER_NOT_IN_CUG
4142 */
4143 switch (curr_cause)
4144 {
4145 case MNCC_CAUSE_USER_BUSY:
4146 case MNCC_CAUSE_FACILITY_REJECT:
4147 case MNCC_CAUSE_NO_CHAN_AVAIL:
4148 case MNCC_CAUSE_FACILITY_UNSUBSCRIB:
4149 case MNCC_CAUSE_BARRED_IN_CUG:
4150 case MNCC_CAUSE_FACILITY_NOT_IMPLEM:
4151 case MNCC_CAUSE_USER_NOT_IN_CUG:
4152 /*
4153 * parse ss diagnostic, find details of encoding in TS 24.008
4154 * section 10.5.4.11 "NOTE 1"
4155 */
4156 if(disc->cc_cause.c_diag > 0) /* check count of diag elements */
4157 {
4158 /* take the first byte, ignore the rest */
4159 ss_diag = disc->cc_cause.diag[0] & 0x7F;
4160 if (ss_diag EQ 0x7F)
4161 {
4162 ss_diag = MNCC_SS_DIAG_NOT_PROVIDED;
4163 }
4164 }
4165 break;
4166 default:
4167 /* force MNCC_SS_DIAG_NOT_PROVIDED return */
4168 break;
4169 } /* end of switch (curr_cause) */
4170
4171 return ss_diag;
4172
4173 }
4174 /*
4175 +--------------------------------------------------------------------+
4176 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
4177 | STATE : code ROUTINE : cc_build_cause |
4178 +--------------------------------------------------------------------+
4179
4180 PURPOSE : Added for CQ62853: We have to pass the cause byte stream as
4181 sent by the network to ACI. This has been done to satisfy the SAT test
4182 case 27.22.4.16-2 for event download(CALL DISCONNECTED).
4183
4184 IN: - decoded_cause_val: decoded cause value
4185 OUT:- raw_cause_length: Number of bytes in raw_cause_bytes
4186 raw_cause_bytes: Encoded bytes as in 24.008 v3.15.0 sec 10.5.4.11
4187 */
4188
4189 GLOBAL UBYTE cc_build_cause (T_M_CC_cc_cause * decoded_cause_val,
4190 UBYTE * raw_cause_bytes)
4191 {
4192
4193 UBYTE cause_ix = 0;
4194
4195 TRACE_FUNCTION ("cc_build_cause()");
4196
4197 memset(raw_cause_bytes, 0, MNCC_MAX_CC_CAUSE_LENGTH);
4198
4199 /* Fill the coding standard and the location fields */
4200 raw_cause_bytes[cause_ix] = (decoded_cause_val->cs << 5) | decoded_cause_val->loc;
4201
4202 if(decoded_cause_val->v_rec)
4203 {
4204 /* ext bit is not set in the first byte. Move to the next byte */
4205 cause_ix++;
4206 /* recommendation value is copied and ext bit is set */
4207 raw_cause_bytes[cause_ix++] = decoded_cause_val->rec | 0x80;
4208 }
4209 else
4210 {
4211 /* If the recommendation field is not present, set the ext bit in the first byte*/
4212 raw_cause_bytes[cause_ix] = raw_cause_bytes[cause_ix] | 0x80;
4213 cause_ix++;
4214 }
4215
4216 /* Fill the cause value and set the ext bit */
4217 raw_cause_bytes[cause_ix++] = decoded_cause_val->cause | 0x80;
4218
4219 /* Fill the diagnostics value */
4220 if(decoded_cause_val->c_diag NEQ 0)
4221 {
4222 memcpy (raw_cause_bytes + cause_ix,
4223 decoded_cause_val->diag,
4224 decoded_cause_val->c_diag);
4225 }
4226
4227 /* Return the number of bytes that have been filled */
4228 return (cause_ix + decoded_cause_val->c_diag);
4229 }
4230
4231
4232 /* Implements Measure# 21 */
4233 /*
4234 +--------------------------------------------------------------------+
4235 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
4236 | STATE : code ROUTINE : cc_set_neg_bearer_cap |
4237 +--------------------------------------------------------------------+
4238
4239 PURPOSE : Copy some bearer capabilities values
4240 */
4241
4242 LOCAL void cc_set_neg_bearer_cap (const T_M_CC_bearer_cap * bearer_cap,
4243 T_MNCC_bcpara * bcpara,
4244 T_M_CC_bearer_cap * neg_bearer_cap,
4245 EF_MSCAP mscap)
4246 {
4247
4248 TRACE_FUNCTION ("cc_set_neg_bearer_cap()");
4249
4250 if (bearer_cap->v_fnur AND (bearer_cap->fnur EQ M_CC_FNUR_14400))
4251 {
4252 bcpara->rate = MNCC_UR_14_4_KBIT;
4253 /*
4254 * define acceptable channel codings
4255 */
4256 neg_bearer_cap->acc = M_CC_ACC_96;
4257 if (FldGet (mscap.datCap2, DHRSup))
4258 {
4259 neg_bearer_cap->acc += M_CC_ACC_48;
4260 }
4261 if (FldGet (mscap.datCap1, Dr14_4Sup))
4262 {
4263 neg_bearer_cap->acc += M_CC_ACC_144;
4264 }
4265 neg_bearer_cap->v_acc = TRUE;
4266
4267 neg_bearer_cap->v_intermed_rate = TRUE;
4268 neg_bearer_cap->intermed_rate = M_CC_IR_16_KBIT;
4269 neg_bearer_cap->v_mTch = TRUE;
4270 neg_bearer_cap->mTch = M_CC_MAX_TCH_1;
4271 neg_bearer_cap->v_uimi = TRUE;
4272 neg_bearer_cap->uimi = M_CC_UIMI_NOT_ALLOWED;
4273 neg_bearer_cap->v_waiur = TRUE;
4274 neg_bearer_cap->waiur = M_CC_WAIUR_14400;
4275 neg_bearer_cap->v_modem_type_2 = TRUE;
4276 neg_bearer_cap->modem_type_2 = M_CC_OTHER_MODEM_TYPE_V34;
4277 }
4278 else
4279 {
4280 bcpara->rate = bearer_cap->user_rate;
4281 }
4282
4283 /* ITC - Information Transfer Capability */
4284 if (bearer_cap->trans_cap == M_CC_ITC_DIGITAL_UNRESTRICTED)
4285 {
4286 bcpara->transfer_cap = MNCC_ITC_UDI;
4287 }
4288 else if (bearer_cap->trans_cap == M_CC_ITC_AUDIO)
4289 {
4290 bcpara->transfer_cap = MNCC_ITC_NONE;
4291 }
4292 bcpara->bearer_serv = MNCC_BEARER_SERV_ASYNC;
4293 bcpara->stop_bits = bearer_cap->num_stop;
4294 bcpara->data_bits = bearer_cap->num_data;
4295 bcpara->parity = bearer_cap->parity;
4296
4297 if (bearer_cap->modem_type_2 == M_CC_OTHER_MODEM_TYPE_V34)
4298 {
4299 bcpara->modem_type = MNCC_MT_V34;
4300 }
4301 else
4302 {
4303 bcpara->modem_type = bearer_cap->modem_type;
4304 }
4305
4306 }
4307
4308 /* Implements Measure# 15 */
4309 /*
4310 +--------------------------------------------------------------------+
4311 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
4312 | STATE : code ROUTINE : cc_fill_struct |
4313 +--------------------------------------------------------------------+
4314
4315 PURPOSE : Copy values from setup_ind to setup_cnf
4316 */
4317
4318 LOCAL void cc_fill_struct (UBYTE is_num_pres,
4319 T_MNCC_calling_party *calling_party,
4320 const T_M_CC_calling_num *calling_num)
4321 {
4322
4323 if (is_num_pres)
4324 {
4325 calling_party->ton = calling_num->ton;
4326 calling_party->npi = calling_num->npi;
4327 calling_party->c_num = calling_num->c_num;
4328 memcpy (calling_party->num, calling_num->num,
4329 calling_num->c_num);
4330 if (calling_num->v_screen)
4331 {
4332 calling_party->screen = calling_num->screen;
4333 }
4334 else
4335 {
4336 calling_party->screen = NOT_PRESENT_8BIT;
4337 }
4338 if (calling_num->v_present)
4339 {
4340 calling_party->present = calling_num->present;
4341 }
4342 else
4343 {
4344 calling_party->present = NOT_PRESENT_8BIT;
4345 }
4346 }
4347 else
4348 {
4349 calling_party->ton = MNCC_TON_NOT_PRES;
4350 calling_party->npi = MNCC_NPI_NOT_PRES;
4351 calling_party->present = MNCC_PRES_NOT_PRES;
4352 calling_party->screen = MNCC_SCREEN_IND_NOT_PRES;
4353 calling_party->c_num = 0;
4354 }
4355 }
4356
4357
4358 /* Implements Measure# 24, 25 and 26 */
4359 /*
4360 +--------------------------------------------------------------------+
4361 | PROJECT : GSM-PS (6147) MODULE : CC_CFK |
4362 | STATE : code ROUTINE : cc_fill_sub_struct |
4363 +--------------------------------------------------------------------+
4364
4365 PURPOSE : Copy values from setup_cnf to setup_ind
4366 */
4367
4368 LOCAL void cc_fill_sub_struct (UBYTE is_num_pres,
4369 T_MNCC_connected_number_sub *connected_number_sub,
4370 const T_M_CC_connect_subaddr *connect_subaddr)
4371 {
4372 if (is_num_pres)
4373 {
4374 connected_number_sub->tos = connect_subaddr->tos;
4375 connected_number_sub->odd_even =
4376 connect_subaddr->odd_even;
4377 connected_number_sub->c_subaddr =
4378 connect_subaddr->c_subaddr;
4379 memcpy (connected_number_sub->subaddr,
4380 connect_subaddr->subaddr, MNCC_SUB_LENGTH);
4381 }
4382 else
4383 {
4384 connected_number_sub->tos = NOT_PRESENT_8BIT;
4385 connected_number_sub->c_subaddr = 0;
4386 }
4387 }
4388 #endif