comparison src/g23m-gprs/llc/llc_llmef.c @ 183:219afcfc6250

src/g23m-gprs: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 13 Oct 2016 04:24:13 +0000
parents
children
comparison
equal deleted inserted replaced
182:f02d0a0e1849 183:219afcfc6250
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul :
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 is part of the entity LLC and implements all
18 | procedures and functions as described in the
19 | SDL-documentation (LLME-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef LLC_LLMEF_C
24 #define LLC_LLMEF_C
25 #endif
26
27 #define ENTITY_LLC
28
29 /*==== INCLUDES =============================================================*/
30
31 #include <string.h> /* to get memcpy() */
32
33 #include "typedefs.h" /* to get Condat data types */
34 #include "vsi.h" /* to get a lot of macros */
35 #include "macdef.h"
36 #include "gprs.h"
37 #include "gsm.h" /* to get a lot of macros */
38 #include "cnf_llc.h" /* to get cnf-definitions */
39 #include "mon_llc.h" /* to get mon-definitions */
40 #include "prim.h" /* to get the definitions of used SAP and directions */
41 #include "llc.h" /* to get the global entity definitions */
42
43 #include "llc_par.h" /* to get the default values of the LLC paramters */
44
45 /*==== CONST ================================================================*/
46
47 /*==== LOCAL VARS ===========================================================*/
48
49 /*==== PRIVATE FUNCTIONS ====================================================*/
50
51 /*==== PUBLIC FUNCTIONS =====================================================*/
52
53
54
55 /*
56 +------------------------------------------------------------------------------
57 | Function : llme_init
58 +------------------------------------------------------------------------------
59 | Description : This procedure initialises all necessary variables of llme for
60 | all SAPIs.
61 | Also global variables are initialised that relate not to a
62 | specific service (e.g. tlli_new/tlli_old).
63 |
64 | Parameters :
65 |
66 +------------------------------------------------------------------------------
67 */
68 GLOBAL void llme_init (void)
69 {
70 int n;
71
72 TRACE_FUNCTION( "llme_init" );
73
74 /*
75 * Initialise service LLME with state TLLI_UNASSIGNED.
76 */
77 INIT_STATE (LLME, LLME_TLLI_UNASSIGNED);
78
79 /*
80 * Initialise global variables.
81 */
82 llc_data->suspended = FALSE;
83 llc_data->grlc_suspended = FALSE;
84
85 #ifdef LL_2to1
86 llc_data->tlli_new = PS_TLLI_INVALID;
87 llc_data->tlli_old = PS_TLLI_INVALID;
88 #else
89 llc_data->tlli_new = LL_TLLI_INVALID;
90 llc_data->tlli_old = LL_TLLI_INVALID;
91 #endif
92
93 llc_data->ciphering_algorithm = LLGMM_CIPHER_NO_ALGORITHM;
94 #ifdef LL_2to1
95 memset (&(llc_data->kc), 0, sizeof(T_LLGMM_llgmm_kc));
96 #else
97 memset (&(llc_data->kc), 0, sizeof(T_llgmm_kc));
98 #endif
99
100 /* init current values */
101 #ifdef REL99
102 llc_data->cur_pfi = LL_PFI_SIGNALING;
103 #endif
104 llc_data->cur_qos.delay = LL_DELAY_SUB;
105 llc_data->cur_qos.relclass = LL_NO_REL;
106 llc_data->cur_qos.peak = LL_PEAK_SUB;
107 llc_data->cur_qos.preced = LL_PRECED_SUB;
108 llc_data->cur_qos.mean = LL_MEAN_SUB;
109 llc_data->cur_radio_prio = LL_RADIO_PRIO_1;
110
111 /*
112 * Initialise all the global SAPI data, which is
113 * not related to only one service
114 */
115 for (n=0; n < MAX_SAPI_INC; n++)
116 {
117 SWITCH_SERVICE (llc, sapi, n);
118
119 llc_data->sapi->vur = 0;
120
121 llc_data->sapi->va = 0;
122 llc_data->sapi->vs = 0;
123 llc_data->sapi->vr = 0;
124
125 llc_data->sapi->oc_ui_tx = 0L;
126 llc_data->sapi->oc_ui_rx = 0L;
127 llc_data->sapi->oc_i_tx = 0L;
128 llc_data->sapi->oc_i_rx = 0L;
129
130 llc_data->sapi->pbit_outstanding = FALSE;
131 }
132
133 return;
134 } /* llme_init() */
135
136
137
138 /*
139 +------------------------------------------------------------------------------
140 | Function : llme_init_cipher
141 +------------------------------------------------------------------------------
142 | Description : This procedure initialises the global LLC variables llc_kc
143 | (ciphering key Kc) and llc_ciphering_algorithm (ciphering
144 | algorithm). If ciphering_algorithm is LLGMM_CIPH_NA, the
145 | parameters are ignored and the procedure doesn't change
146 | anything. The procedures cipher_ll_pdu (service send_pdu)
147 | and decipher_ll_pdu (service receive_pdu) use the global
148 | variables for ciphering and deciphering.
149 |
150 | Parameters : kc - ciphering key
151 | ciphering_algorithm - ciphering algorithm
152 |
153 +------------------------------------------------------------------------------
154 */
155 #ifdef LL_2to1
156 GLOBAL void llme_init_cipher (T_LLGMM_llgmm_kc kc, UBYTE ciphering_algorithm)
157 #else
158 GLOBAL void llme_init_cipher (T_llgmm_kc kc, UBYTE ciphering_algorithm)
159 #endif
160 {
161 TRACE_FUNCTION( "llme_init_cipher" );
162
163 if (ciphering_algorithm != LLGMM_CIPHER_NA)
164 {
165 switch (ciphering_algorithm)
166 {
167 case LLGMM_CIPHER_NO_ALGORITHM:
168 TRACE_0_INFO("No cipher algorithm used!");
169 break;
170
171 case LLGMM_CIPHER_GPRS_A5_1:
172 TRACE_0_INFO("Cipher algorithm GEA/1 used!");
173 break;
174
175 case LLGMM_CIPHER_GPRS_A5_2:
176 TRACE_0_INFO("Cipher algorithm GEA/2 used!");
177 break;
178
179 default:
180 TRACE_ERROR("Unknown Cipher algorithm used!");
181 break;
182 }
183
184 /*
185 * Set IOV default values, if kc is changed to a different value
186 */
187 #ifdef LL_2to1
188 if ( memcmp (&(llc_data->kc), &kc, sizeof(T_LLGMM_llgmm_kc)) )
189 #else
190 if ( memcmp (&(llc_data->kc), &kc, sizeof(T_llgmm_kc)) )
191 #endif
192 {
193 TRACE_0_INFO( "kc changed" );
194 #ifdef LL_2to1
195 memcpy (&(llc_data->kc), &kc, sizeof(T_LLGMM_llgmm_kc));
196 #else
197 memcpy (&(llc_data->kc), &kc, sizeof(T_llgmm_kc));
198 #endif
199
200 /*
201 * Apply the default value of IOV-UI in case no negotiation
202 * is started by the SGSN.
203 * <R.LLC.LLC_PAR.A.016>
204 */
205 llc_data->iov_ui = LLC_IOV_UI_ALL_SAPIS;
206
207 /*
208 * Apply the default value of IOV-I in case no negotiation
209 * is started by the SGSN.
210 * <R.LLC.LLC_PAR.A.018>
211 */
212 #ifdef LL_2to1
213 llc_data->iov_i_base[IMAP(PS_SAPI_3)] = LLC_IOV_I_SAPI_3;
214 llc_data->iov_i_base[IMAP(PS_SAPI_5)] = LLC_IOV_I_SAPI_5;
215 llc_data->iov_i_base[IMAP(PS_SAPI_9)] = LLC_IOV_I_SAPI_9;
216 llc_data->iov_i_base[IMAP(PS_SAPI_11)] = LLC_IOV_I_SAPI_11;
217 #else
218 llc_data->iov_i_base[IMAP(LL_SAPI_3)] = LLC_IOV_I_SAPI_3;
219 llc_data->iov_i_base[IMAP(LL_SAPI_5)] = LLC_IOV_I_SAPI_5;
220 llc_data->iov_i_base[IMAP(LL_SAPI_9)] = LLC_IOV_I_SAPI_9;
221 llc_data->iov_i_base[IMAP(LL_SAPI_11)] = LLC_IOV_I_SAPI_11;
222 #endif
223 }
224
225 /*
226 * Set new ciphering algorithm
227 */
228 llc_data->ciphering_algorithm = ciphering_algorithm;
229 }
230 else
231 {
232 TRACE_0_INFO("Cipher algorithm not changed");
233 }
234
235 return;
236 } /* llme_init_cipher() */