comparison src/g23m-gprs/gmm/gmm_txf.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 : GPRS (8441)
4 | Modul : gmm_txf.c
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 GMM and implements all
18 | procedures and functions as described in the
19 | SDL-documentation (TX-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23
24 #ifndef GMM_TXF_C
25 #define GMM_TXF_C
26 #endif
27
28 #define ENTITY_GMM
29
30 /*==== INCLUDES =============================================================*/
31
32 #include "typedefs.h" /* to get Condat data types */
33 #include "vsi.h" /* to get a lot of macros */
34 #include "macdef.h"
35 #include "gprs.h"
36 #include "gsm.h" /* to get a lot of macros */
37 #include "ccdapi.h" /* to get CCD API */
38 #include "cnf_gmm.h" /* to get cnf-definitions */
39 #include "mon_gmm.h" /* to get mon-definitions */
40 #include "prim.h" /* to get the definitions of used SAP and directions */
41 #include "gmm.h" /* to get the global entity definitions */
42 #include "gmm_f.h" /* to get the gmm_get_tlli procedure */
43 #include <string.h> /* to get memset */
44
45 /*==== CONST ================================================================*/
46
47 /*==== LOCAL VARS ===========================================================*/
48
49 /*==== PRIVATE FUNCTIONS ====================================================*/
50
51 /*==== PUBLIC FUNCTIONS =====================================================*/
52
53
54
55 /*
56 +------------------------------------------------------------------------------
57 | Function : txgmm_init
58 +------------------------------------------------------------------------------
59 | Description : The function txgmm_init() ....
60 |
61 | Parameters : void
62 |
63 +------------------------------------------------------------------------------
64 */
65 GLOBAL void txgmm_init ( void )
66 {
67 TRACE_FUNCTION( "txgmm_init" );
68
69 /*
70 * Initialise service TX with state TX_READY.
71 */
72 INIT_STATE ( TX, TX_READY );
73
74 } /* txgmm_init() */
75 /*
76 +------------------------------------------------------------------------------
77 | Function : tx_fill_unitdata_req
78 +------------------------------------------------------------------------------
79 | Description : This procedure tx_fill_unitdata_req() fills the primitive
80 | ll_unitdata_req with all necessary dafault parameters.except
81 | the SDU
82 |
83 |
84 | Parameters : ll_unitdata_req - the primitive, which has to be filled
85 |
86 |
87 +------------------------------------------------------------------------------
88 */
89 GLOBAL void tx_fill_unitdata_req ( T_LL_UNITDATA_REQ *ll_unitdata_req_p, T_TLLI_TYPE tlli_type, BOOL cipher )
90 {
91 GMM_TRACE_FUNCTION ("tx_fill_unitdata_req");
92 ll_unitdata_req_p-> sapi = LL_SAPI_1;
93 ll_unitdata_req_p-> tlli = gmm_get_tlli ( tlli_type );
94 ll_unitdata_req_p-> ll_qos.delay = LL_DELAY_SUB;
95 ll_unitdata_req_p-> ll_qos.peak = LL_PEAK_SUB;
96 ll_unitdata_req_p-> ll_qos.preced = LL_PRECED_SUB;
97 ll_unitdata_req_p-> ll_qos.mean = LL_MEAN_SUB;
98 ll_unitdata_req_p-> cipher =
99 (gmm_data->config.cipher_on?cipher:FALSE);
100 /*
101 * all GMM (and SM) messages are transmitted in RLC/MAC acknowledged mode
102 */
103 ll_unitdata_req_p-> ll_qos.relclass = LL_RLC_PROT;
104 /*
105 * all GMM messages have highest priority (!!!!! what about SM?)
106 */
107 ll_unitdata_req_p-> radio_prio = LL_RADIO_PRIO_1;
108 ll_unitdata_req_p->ll_qos.reserved_1 = 0xff;
109 ll_unitdata_req_p->ll_qos.reserved_2 = 0xff;
110 ll_unitdata_req_p->ll_qos.reserved_3 = 0xff;
111 ll_unitdata_req_p->reserved_unitdata_req1.ref_npdu_num = 0xffff;
112 ll_unitdata_req_p->reserved_unitdata_req1.ref_nsapi = 0xff;
113 ll_unitdata_req_p->reserved_unitdata_req1.ref_seg_num = 0xff;
114 ll_unitdata_req_p->reserved_unitdata_req4 = 0xffffffff;
115
116 #ifdef REL99
117 /*
118 * This change is related to R99.
119 */
120 ll_unitdata_req_p->pkt_flow_id = 0xffff; /* TCS 4.0 */
121 #else
122 ll_unitdata_req_p->reserved_unitdata_req5 = 0xffff;
123 #endif
124
125 ll_unitdata_req_p->seg_pos = 0xff;
126 ll_unitdata_req_p->attached_counter= 0x00;
127
128 GMM_RETURN;
129 }
130
131 /*
132 +------------------------------------------------------------------------------
133 | Function : tx_unitdata_req
134 +------------------------------------------------------------------------------
135 | Description : This procedure tx_unitdata_req() fills the primitive
136 | ll_unitdata_req with all necessary parameters.and sends
137 | the message to LLC
138 |
139 |
140 | Parameters : tlli_type - local, foreign or random
141 |
142 |
143 +------------------------------------------------------------------------------
144 */
145 GLOBAL void tx_unitdata_req ( T_TLLI_TYPE tlli_type, UBYTE msg_type )
146 {
147 U8 *payload;
148 #ifndef GMM_TCS4
149 U16 length;
150 #endif
151
152 GMM_TRACE_FUNCTION( "tx_unitdata_req" );
153 _decodedMsg[0] = msg_type;
154
155 /*
156 * send the message to LLC
157 */
158 {
159 USHORT bit_size = bit_size_message_table[msg_type] + LLC_SDU_OFFSET_BITS;
160 PALLOC_SDU ( ll_unitdata_req_p, LL_UNITDATA_REQ, bit_size );
161
162 ll_unitdata_req_p->sdu.o_buf = LLC_SDU_OFFSET_BITS;
163 /*
164 * l_buf has to be set to inform CCD how many bit must be reset
165 */
166 ll_unitdata_req_p->sdu.l_buf = bit_size_message_table[msg_type];
167
168 /*
169 * fills the primitive with all necessary data
170 */
171
172 if ( gmm_data->cipher )
173 {
174 switch ( _decodedMsg [0] )
175 {
176 case ATTACH_REQUEST:
177 case ATTACH_REJECT:
178 case AUTHENTICATION_AND_CIPHERING_REQUEST:
179 case AUTHENTICATION_AND_CIPHERING_RESPONSE:
180 case AUTHENTICATION_AND_CIPHERING_REJECT:
181 case IDENTITY_RESPONSE:
182 case ROUTING_AREA_UPDATE_REQUEST:
183 /*
184 * <R.GMM.CIPHMSG.M.001>
185 */
186 tx_fill_unitdata_req ( ll_unitdata_req_p,
187 tlli_type,
188 LL_CIPHER_OFF );
189
190 break;
191 default:
192 tx_fill_unitdata_req ( ll_unitdata_req_p,
193 tlli_type,
194 LL_CIPHER_ON );
195 break;
196 }
197 }
198 else
199 {
200 tx_fill_unitdata_req ( ll_unitdata_req_p,
201 tlli_type,
202 LL_CIPHER_OFF );
203
204 }
205
206 if ( ccd_codeMsg ( CCDENT_GMM,
207 UPLINK,
208 (T_MSGBUF *) &ll_unitdata_req_p->sdu,
209 _decodedMsg,
210 NOT_PRESENT_8BIT) != ccdOK
211 )
212 {
213
214 /*
215 * Error Handling
216 */
217 TRACE_ERROR( "CCD_ERROR: Error Handling for ccd-output not yet supported" ) ;
218 PFREE ( ll_unitdata_req_p );
219 }
220 else
221 {
222 /*
223 * Set the Protocol discriminator to PD_GMM, defined in GSM 4.0.8
224 * Set the Skip indicater to 0
225 */
226 ccd_codeByte (ll_unitdata_req_p->sdu.buf,
227 (USHORT)(ll_unitdata_req_p->sdu.o_buf - 8),
228 8,
229 PD_GMM);
230 ll_unitdata_req_p->sdu.l_buf += 8;
231 ll_unitdata_req_p->sdu.o_buf -= 8;
232
233 #ifndef NTRACE
234
235 payload = &(ll_unitdata_req_p->sdu.buf[0]); /* beginning of buffer */
236 payload += (ll_unitdata_req_p->sdu.o_buf) >> 3; /* plus offset (bytes) */
237 #ifndef GMM_TCS4
238 length = (ll_unitdata_req_p->sdu.l_buf) >> 3; /* length (bytes, bits / 8) */
239 #endif
240
241 switch ( _decodedMsg [0] )
242 {
243 case ATTACH_REQUEST:
244 TRACE_0_OUT_PARA ( "ATTACH_REQ" );
245 #ifndef GMM_TCS4
246 TRACE_BINDUMP( GMM_handle,
247 TC_USER4,
248 "ATTACH REQUEST",
249 payload,
250 length);
251 #endif
252 break;
253 case ATTACH_COMPLETE:
254 TRACE_0_OUT_PARA ( "ATTACH_COMPLETE" );
255 break;
256 case U_DETACH_REQUEST:
257 TRACE_0_OUT_PARA ( "DETACH_REQ" );
258 break;
259 case U_DETACH_ACCEPT:
260 TRACE_0_OUT_PARA ( "DETACH_ACC" );
261 break;
262 case ROUTING_AREA_UPDATE_REQUEST:
263 TRACE_0_OUT_PARA ( "RAU_REQ" );
264 #ifndef GMM_TCS4
265 TRACE_BINDUMP( GMM_handle,
266 TC_USER4,
267 "ROUTING AREA UPDATE REQUEST",
268 payload,
269 length);
270 #endif
271 break;
272 case ROUTING_AREA_UPDATE_COMPLETE:
273 TRACE_0_OUT_PARA ( "RAU_COMPLETE" );
274 break;
275 case P_TMSI_REALLOCATION_COMPLETE:
276 TRACE_0_OUT_PARA ( "PTMSI_REALLOC_COMPLETE" );
277 break;
278 case AUTHENTICATION_AND_CIPHERING_RESPONSE:
279 TRACE_0_OUT_PARA ( "A&C_RES" );
280 break;
281 case IDENTITY_RESPONSE:
282 TRACE_0_OUT_PARA ( "ID_RES");
283 break;
284 case GMM_STATUS:
285 TRACE_0_OUT_PARA ( "GMM_STATUS");
286 break;
287 /* wrong direction: */
288 case ATTACH_ACCEPT:
289 TRACE_ERROR ( "ATTACH_ACC not uplink direction");
290 break;
291 case ATTACH_REJECT:
292 TRACE_ERROR ( "ATTACH_REJECT not uplink direction");
293 break;
294 case ROUTING_AREA_UPDATE_ACCEPT:
295 TRACE_ERROR ( "ROUTING_AREA_UPDATE_ACCEPT not uplink direction");
296 break;
297 case ROUTING_AREA_UPDATE_REJECT:
298 TRACE_ERROR ( "ROUTING_AREA_UPDATE_REJECT not uplink direction");
299 break;
300 case P_TMSI_REALLOCATION_COMMAND:
301 TRACE_ERROR ( "PTMSI_REALLOC_CMD not uplink direction");
302 break;
303 case AUTHENTICATION_AND_CIPHERING_REQUEST:
304 TRACE_ERROR ( "A&C_REQ not uplink direction");
305 break;
306 case AUTHENTICATION_AND_CIPHERING_REJECT:
307 TRACE_ERROR ( "A&C_REJ not uplink direction");
308 break;
309 case IDENTITY_REQUEST:
310 TRACE_ERROR ( "ID_REQ not uplink direction");
311 break;
312 case GMM_INFORMATION:
313 TRACE_ERROR ( "GMM_INFO not uplink direction");
314 break;
315 default:
316 TRACE_ERROR ("Unknown GMM PDU");
317 break;
318 }
319 #endif /* _SIMULATION_ */
320
321 PSEND ( hCommLLC, ll_unitdata_req_p);
322
323 }
324 }
325 GMM_RETURN;
326 } /* tx_fill_unitdata_req() */
327
328