comparison gsm-fw/g23m-aci/aci/psa_sms.c @ 775:eedbf248bac0

gsm-fw/g23m-aci subtree: initial import from LoCosto source
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 12 Oct 2014 01:45:14 +0000
parents
children
comparison
equal deleted inserted replaced
774:40a721fd9854 775:eedbf248bac0
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 module defines the signalling functions of the
18 | protocol stack adapter for the registration part of
19 | GPRS session management.
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifdef GPRS
24
25 #ifndef PSA_SMS_C
26 #define PSA_SMS_C
27 #endif
28
29 #include "aci_all.h"
30 /*==== INCLUDES ===================================================*/
31 #include "dti.h" /* functionality of the dti library */
32 #include "aci_cmh.h"
33 #include "ati_cmd.h"
34 #include "aci_cmd.h"
35 #include "aci.h"
36 #include "psa.h"
37
38 #include "dti_conn_mng.h"
39 #include "dti_cntrl_mng.h"
40
41 #include "gaci_cmh.h"
42 #include "psa_gmm.h"
43 #include "psa_sm.h"
44 #include "cmh.h"
45 #include "gaci.h"
46 #include "gaci_cmh.h"
47 #include "cmh_sm.h"
48
49 /*==== CONSTANTS ==================================================*/
50
51
52 /*==== TYPES ======================================================*/
53
54
55 /*==== EXPORT =====================================================*/
56
57 /*==== VARIABLES ==================================================*/
58
59
60 /*==== FUNCTIONS ==================================================*/
61
62 /*
63 +-------------------------------------------------------------------+
64 | PROJECT : GPRS (8441) MODULE : PSA_SMS |
65 | STATE : finished ROUTINE : psaSM_ActivateReq |
66 +-------------------------------------------------------------------+
67
68 PURPOSE : MS initiates a primary PDP context activation
69
70 */
71 GLOBAL void psaSM_smreg_pdp_activate_req( U8 cid,
72 U8 hcomp,
73 U8 dcomp)
74 {
75
76 U8 no_of_tft_pf = 0;
77 USHORT PCO_length = 0;
78 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
79 T_TFT_INTERNAL *p_tft_pf_node = NULL;
80 UBYTE gprs_default_pco[] = {
81 0x80,0x80,0x21,0x10,0x01,0x01,0x00,0x10,0x81,0x06,
82 0x00,0x00,0x00,0x00,0x83,0x06,0x00,0x00,0x00,0x00
83 };
84
85
86 TRACE_FUNCTION ("psaSM_smreg_pdp_activate_req()");
87
88 p_pdp_context_node = pdp_context_find_node_from_cid( cid );
89 if( !p_pdp_context_node )
90 {
91 TRACE_ERROR( "ERROR: PDP context not found, invalid cid");
92 return;
93 }
94
95 /* As in the previous Berlin code the default user_pco.len is 160
96 * This is not present in Alborg code, but as we have to be consitant with our
97 * prious implementation we have to set the user_pco some default value
98 */
99 if( p_pdp_context_node->internal_data.user_pco.len EQ 0 )
100 {
101 p_pdp_context_node->internal_data.user_pco.len = sizeof (gprs_default_pco);
102 memcpy (p_pdp_context_node->internal_data.user_pco.pco, gprs_default_pco, sizeof (gprs_default_pco));
103 }
104
105 PCO_length = p_pdp_context_node->internal_data.user_pco.len << 3;
106 no_of_tft_pf = pdp_context_get_no_of_tft_pfs( p_pdp_context_node->cid );
107
108 /*
109 *-------------------------------------------------------------------
110 * create and send primitive for context activation
111 *-------------------------------------------------------------------
112 */
113
114 {
115 PALLOC_SDU( p_smreg_pdp_activate_req, SMREG_PDP_ACTIVATE_REQ, PCO_length );
116
117 p_smreg_pdp_activate_req -> comp_params.hcomp = hcomp;
118 p_smreg_pdp_activate_req -> comp_params.dcomp = dcomp;
119
120 p_smreg_pdp_activate_req -> pdp_type = cmhSM_Get_pdp_type();
121 p_smreg_pdp_activate_req -> nsapi = (U8)CID_TO_NSAPI( cid );
122 p_smreg_pdp_activate_req -> ti = gprs_call_table[current_gprs_ct_index].sm_ind.ti;
123
124 /* Set the control for the UNIONs sm_qos and sm_min_qos */
125
126 cmhSM_Get_QOS ( &p_smreg_pdp_activate_req -> qos );
127 cmhSM_Get_QOS_min ( &p_smreg_pdp_activate_req -> min_qos );
128 cmhSM_Get_pdp_address( &p_smreg_pdp_activate_req -> ip_address, &p_smreg_pdp_activate_req->ctrl_ip_address);
129 cmhSM_Get_smreg_apn ( &p_smreg_pdp_activate_req -> apn );
130
131
132 p_smreg_pdp_activate_req -> ctrl_qos = p_pdp_context_node->ctrl_qos;
133 p_smreg_pdp_activate_req -> ctrl_min_qos = p_pdp_context_node->ctrl_min_qos;
134
135 /*
136 * At this point the TFT should be added, waiting for a new frame release.
137 * remove the line below !!!!!!! "no_of_tft_pf = 0;"
138 */
139
140 /*no_of_tft_pf = 0;*/
141
142 if( no_of_tft_pf )
143 {
144 p_smreg_pdp_activate_req -> v_tft = TRUE;
145 p_smreg_pdp_activate_req -> tft.c_tft_pf = no_of_tft_pf;
146 p_smreg_pdp_activate_req -> tft.ptr_tft_pf = (T_NAS_tft_pf*) DRP_ALLOC( no_of_tft_pf * sizeof( T_NAS_tft_pf ), 0 );
147 }
148 else
149 {
150 p_smreg_pdp_activate_req -> v_tft = FALSE;
151 }
152
153 no_of_tft_pf = 0;
154
155 p_tft_pf_node = p_pdp_context_node -> p_tft_pf;
156 while( p_tft_pf_node AND p_smreg_pdp_activate_req -> v_tft )
157 {
158 memcpy( &p_smreg_pdp_activate_req->tft.ptr_tft_pf[no_of_tft_pf], &p_tft_pf_node->pf_attributes, sizeof( T_NAS_tft_pf ) );
159 no_of_tft_pf++;
160 p_tft_pf_node = p_tft_pf_node->p_next;
161 }
162 p_smreg_pdp_activate_req -> sdu.l_buf = PCO_length;
163 p_smreg_pdp_activate_req -> sdu.o_buf = 0;
164
165 if ( PCO_length )
166 {
167 memcpy( &p_smreg_pdp_activate_req -> sdu.buf,
168 &p_pdp_context_node->internal_data.user_pco.pco,
169 p_pdp_context_node->internal_data.user_pco.len );
170 }
171
172 psaGMM_NetworkRegistrationStatus( SMREG_PDP_ACTIVATE_REQ, p_smreg_pdp_activate_req );
173
174 PSEND( hCommSM, p_smreg_pdp_activate_req );
175 }
176 return;
177 }
178
179 /*
180 +--------------------------------------------------------------------------+
181 | PROJECT : UMTS MODULE : PSA_SMS |
182 | STATE : - ROUTINE : psaSM_smreg_pdp_activate_sec_req |
183 +--------------------------------------------------------------------------+
184
185 PURPOSE : MS initiates a secondary PDP context activation
186
187 */
188 #ifdef REL99
189 GLOBAL void psaSM_smreg_pdp_activate_sec_req( U8 cid )
190 /*,
191 U32 dti_linkid,
192 U8 dti_neighbor[NAS_SIZE_ENTITY_NAME],
193 U8 dti_direction )*/
194 {
195
196 T_PDP_CONTEXT_INTERNAL *p_pdp_context_prim_node = NULL;
197 T_PDP_CONTEXT_INTERNAL *p_pdp_context_sec_node = NULL;
198 T_TFT_INTERNAL *p_tft_pf_node = NULL;
199 T_SMREG_PDP_ACTIVATE_SEC_REQ *p_smreg_pdp_activate_sec_req = NULL;
200 U8 no_of_tft_pf = 0;
201
202 TRACE_FUNCTION( "psaSM_smreg_pdp_activate_sec_req()");
203
204
205 /* Find secondary PDP context */
206 p_pdp_context_sec_node = pdp_context_find_node_from_cid( cid );
207 if( !p_pdp_context_sec_node )
208 {
209 TRACE_ERROR( "ERROR: Secondary PDP context not found, invalid cid");
210 return;
211 }
212
213 /* Find primary PDP context */
214 p_pdp_context_prim_node = pdp_context_find_node_from_cid( p_pdp_context_sec_node->attributes.p_cid );
215 if( !p_pdp_context_prim_node )
216 {
217 TRACE_ERROR( "ERROR: Primary PDP context not found, invalid cid");
218 return;
219 }
220
221 no_of_tft_pf = pdp_context_get_no_of_tft_pfs( p_pdp_context_sec_node->cid );
222
223 p_smreg_pdp_activate_sec_req = DRPO_ALLOC( SMREG_PDP_ACTIVATE_SEC_REQ, (no_of_tft_pf * sizeof(T_NAS_tft_pf)) );
224
225 p_smreg_pdp_activate_sec_req->nsapi = (U8)CID_TO_NSAPI( cid );
226 p_smreg_pdp_activate_sec_req->pri_nsapi = (U8)CID_TO_NSAPI( p_pdp_context_prim_node->cid ); /* !!! From primary PDP context */
227 p_smreg_pdp_activate_sec_req->comp_params.dcomp = p_pdp_context_sec_node->attributes.d_comp;
228 p_smreg_pdp_activate_sec_req->comp_params.hcomp = p_pdp_context_sec_node->attributes.h_comp;
229 p_smreg_pdp_activate_sec_req->ti = p_pdp_context_sec_node->internal_data.smreg_ti;
230
231 p_smreg_pdp_activate_sec_req->ctrl_qos = p_pdp_context_sec_node->ctrl_qos;
232 p_smreg_pdp_activate_sec_req->qos = p_pdp_context_sec_node->qos;
233 p_smreg_pdp_activate_sec_req->ctrl_min_qos = p_pdp_context_sec_node->ctrl_min_qos;
234 p_smreg_pdp_activate_sec_req->min_qos = p_pdp_context_sec_node->min_qos;
235
236 if( no_of_tft_pf )
237 {
238 p_smreg_pdp_activate_sec_req -> v_tft = TRUE;
239 p_smreg_pdp_activate_sec_req -> tft.c_tft_pf = no_of_tft_pf;
240 p_smreg_pdp_activate_sec_req -> tft.ptr_tft_pf = (T_NAS_tft_pf*) DP_ALLOC( (no_of_tft_pf * sizeof( T_NAS_tft_pf )), p_smreg_pdp_activate_sec_req, 0 );
241
242 }
243 else
244 {
245 p_smreg_pdp_activate_sec_req->v_tft = FALSE;
246 }
247
248 no_of_tft_pf = 0;
249
250 p_tft_pf_node = p_pdp_context_sec_node->p_tft_pf;
251 while( p_tft_pf_node )
252 {
253 memcpy( &p_smreg_pdp_activate_sec_req->tft.ptr_tft_pf[no_of_tft_pf], &p_tft_pf_node->pf_attributes, sizeof( T_NAS_tft_pf ) );
254 no_of_tft_pf++;
255 p_tft_pf_node = p_tft_pf_node->p_next;
256 }
257
258 psaGMM_NetworkRegistrationStatus( SMREG_PDP_ACTIVATE_SEC_REQ, p_smreg_pdp_activate_sec_req );
259
260 PSEND( hCommSM, p_smreg_pdp_activate_sec_req );
261
262 }
263 #endif
264
265
266 /*
267 +-------------------------------------------------------------------+
268 | PROJECT : GPRS (8441) MODULE : PSA_SMS |
269 | STATE : finished ROUTINE : psaSM_PDP_Deactivate |
270 +-------------------------------------------------------------------+
271
272 PURPOSE : MS initiates a PDP context deactivation
273
274 */
275 GLOBAL void psaSM_PDP_Deactivate( USHORT nsapi_set, UBYTE smreg_local )
276 {
277
278 TRACE_FUNCTION ("psaSM_PDP_Deactivate()");
279
280 /*
281 *-------------------------------------------------------------------
282 * create and send primitive for context deactivation
283 *-------------------------------------------------------------------
284 */
285 {
286 PALLOC (smreg_pdp_deactivate_req, SMREG_PDP_DEACTIVATE_REQ);
287
288 smreg_pdp_deactivate_req -> nsapi_set = nsapi_set;
289 smreg_pdp_deactivate_req -> rel_ind = smreg_local;//PS_REL_IND_YES;
290
291 PSEND (hCommSM, smreg_pdp_deactivate_req);
292 }
293 }
294
295 /*
296 +-------------------------------------------------------------------+
297 | PROJECT : GPRS (8441) MODULE : PSA_SMS |
298 | STATE : finished ROUTINE : psaSM_PDP_No_activate |
299 +-------------------------------------------------------------------+
300
301 PURPOSE : GACI is not able to set up another context
302
303 */
304 GLOBAL void psaSM_PDP_No_activate ( UBYTE smreg_ti, USHORT smreg_cause )
305 {
306 TRACE_FUNCTION ("psaSM_PDP_No_activate()");
307
308 /*
309 *-------------------------------------------------------------------
310 * create and send primitive for rejection
311 * the network requested context activation
312 */
313 {
314 PALLOC (smreg_pdp_activate_rej_rsp, SMREG_PDP_ACTIVATE_REJ_RES);
315
316 /* fill in primitive parameter: registration mode */
317 smreg_pdp_activate_rej_rsp -> ti = smreg_ti;
318 smreg_pdp_activate_rej_rsp->ps_cause.ctrl_value = CAUSE_is_from_nwsm;
319 smreg_pdp_activate_rej_rsp->ps_cause.value.sm_cause = (unsigned char)smreg_cause;
320
321 PSEND (hCommSM, smreg_pdp_activate_rej_rsp);
322 }
323
324 }
325
326
327 /*
328 +-------------------------------------------------------------------+
329 | PROJECT : GPRS (8441) MODULE : PSA_SMS |
330 | STATE : finished ROUTINE : psaSM_PDP_Modify |
331 +-------------------------------------------------------------------+
332
333 PURPOSE : MS initiates a PDP context modification.
334
335 */
336 GLOBAL void psaSM_PDP_Modify( void )
337 {
338 T_SMREG_PDP_MODIFY_REQ *p_smreg_pdp_modify_req = NULL;
339 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
340 T_TFT_INTERNAL *p_tft_node = NULL;
341 U8 tft_pf_count = 0;
342
343
344 TRACE_FUNCTION ("psaSM_PDP_Modify()");
345
346 p_pdp_context_node = pdp_context_find_node_from_cid( work_cids[cid_pointer] );
347 if( ! p_pdp_context_node )
348 {
349 TRACE_ERROR( "ERROR: PDP context not found, in function psaSM_PDP_Modify" );
350 return;
351 }
352
353 /*
354 *-------------------------------------------------------------------
355 * send primitive for modify context
356 *-------------------------------------------------------------------
357 */
358
359 p_smreg_pdp_modify_req = DRPO_ALLOC( SMREG_PDP_MODIFY_REQ, 0 );
360
361 /* fill in primitive parameter: registration mode */
362 p_smreg_pdp_modify_req -> nsapi = (U8)CID_TO_NSAPI( work_cids[cid_pointer] );
363 p_smreg_pdp_modify_req -> ctrl_qos = p_pdp_context_node->ctrl_qos;
364 p_smreg_pdp_modify_req -> ctrl_min_qos = p_pdp_context_node->ctrl_min_qos;
365 p_smreg_pdp_modify_req -> v_tft = FALSE;
366 cmhSM_Get_QOS ( &p_smreg_pdp_modify_req -> qos );
367 cmhSM_Get_QOS_min( &p_smreg_pdp_modify_req -> min_qos );
368
369 if( p_pdp_context_node -> tft_changed )
370 {
371 // Set the tft_changed bool to false since we are modifying the pdp context now.
372 p_pdp_context_node -> tft_changed = FALSE;
373
374 p_tft_node = p_pdp_context_node -> p_tft_pf;
375
376 while( p_tft_node )
377 {
378 tft_pf_count ++;
379 p_tft_node = p_tft_node -> p_next;
380 }
381
382 if( tft_pf_count )
383 {
384 p_smreg_pdp_modify_req->v_tft = TRUE;
385 p_smreg_pdp_modify_req->tft.c_tft_pf = tft_pf_count;
386 p_smreg_pdp_modify_req->tft.ptr_tft_pf = (T_NAS_tft_pf*) DP_ALLOC( tft_pf_count * sizeof( T_NAS_tft_pf ), p_smreg_pdp_modify_req, 0 );
387 }
388
389 tft_pf_count = 0;
390
391 p_tft_node = p_pdp_context_node -> p_tft_pf;
392 while( p_tft_node )
393 {
394 memcpy( &p_smreg_pdp_modify_req->tft.ptr_tft_pf[tft_pf_count],
395 p_tft_node,
396 sizeof( T_TFT_INTERNAL ) );
397
398 p_tft_node = p_tft_node->p_next;
399 tft_pf_count++;
400
401 }
402 }
403
404 PSEND( hCommSM, p_smreg_pdp_modify_req );
405
406 return;
407 }
408
409
410
411 #endif /* GPRS */
412 /*==== EOF ========================================================*/
413